Skip to content

regression: tagged-box macro fails on :ty pattern when a later pattern would match #146417

Closed

Description

@cuviper

Found in 1.90-beta crater run #145758, e.g. https://crater-reports.s3.amazonaws.com/beta-1.90-3/beta-2025-08-22/reg/caro-0.7.1/log.txt

[INFO] [stdout] error: expected `;` or `]`, found `:`
[INFO] [stdout]    --> /opt/rustwide/cargo-home/registry/src/index.crates.io-1949cf8c6b5b557f/tagged-box-0.1.1/src/tagged_box.rs:484:17
[INFO] [stdout]     |
[INFO] [stdout] 484 | impl_fmt!(impl[T: TaggableInner] TaggedBox<T> => LowerHex, UpperHex, Binary, Octal);
[INFO] [stdout]     |                 ^ expected `;` or `]`
[INFO] [stdout]     |
[INFO] [stdout]    ::: /opt/rustwide/cargo-home/registry/src/index.crates.io-1949cf8c6b5b557f/tagged-box-0.1.1/src/lib.rs:213:6
[INFO] [stdout]     |
[INFO] [stdout] 213 |     ($ty:ty => $($fmt:ident),+) => {
[INFO] [stdout]     |      ------ while parsing argument for this `ty` macro fragment
[INFO] [stdout]     |
[INFO] [stdout]     = note: you might have meant to write a slice or array type

Code

Here's an isolated reproducer (playground):

macro_rules! foo {
    ($ty:ty) => { dbg!("ty") };
    (impl [foo] $ty:ty) => { "foo" };
    (impl [T: Foo] $ty:ty) => { "T: Foo" };
}

fn main() {
    dbg!(foo!(i32));
    dbg!(foo!(impl [foo] i32));
    dbg!(foo!(impl [T: Foo] i32));
}

I expected to see this happen: builds and prints the 3 different strings

Instead, this happened:

error: expected a trait, found type
 --> src/main.rs:9:20
  |
2 |     ($ty:ty) => { dbg!("ty") };
  |      ------ while parsing argument for this `ty` macro fragment
...
9 |     dbg!(foo!(impl [foo] i32));
  |                    ^^^^^

error: expected `;` or `]`, found `:`
  --> src/main.rs:10:22
   |
 2 |     ($ty:ty) => { dbg!("ty") };
   |      ------ while parsing argument for this `ty` macro fragment
...
10 |     dbg!(foo!(impl [T: Foo] i32));
   |                      ^ expected `;` or `]`
   |
   = note: you might have meant to write a slice or array type

Version it worked on

It most recently worked on: 1.89

Version with regression

rustc --version --verbose:

rustc 1.90.0-beta.7 (fb918cec0 2025-08-29)
binary: rustc
commit-hash: fb918cec013920472f6975b2009b0339d9e8cc9c
commit-date: 2025-08-29
host: x86_64-unknown-linux-gnu
release: 1.90.0-beta.7
LLVM version: 20.1.8

Bisecting identified d41e12f, of which I suspect the [const] Trait #139858, i.e. trying to parse the :ty as an impl [const] Trait here.

@rustbot modify labels: +regression-from-stable-to-beta -regression-untriaged

Activity

  1. added
    C-bugCategory: This is a bug.
    regression-untriagedUntriaged performance or correctness regression.
    on Sep 10, 2025
  2. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    and removed
    regression-untriagedUntriaged performance or correctness regression.
    on Sep 10, 2025
  3. cuviper commented on Sep 10, 2025

    @cuviper
    MemberAuthor

    cc @oli-obk -- and sorry that I didn't pick this out of the crater results sooner!

  4. added this to the 1.90.0 milestone on Sep 10, 2025
  5. added
    A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)
    T-langRelevant to the language team
    on Sep 10, 2025
  6. added
    S-has-bisectionStatus: A bisection has been found for this issue
    S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issue
    and removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Sep 10, 2025
  7. removed
    S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issue
    on Sep 10, 2025
  8. 3 remaining items

  9. added
    S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issue
    S-has-bisectionStatus: A bisection has been found for this issue
    and removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Sep 10, 2025
  10. self-assigned this
    on Sep 10, 2025
  11. fmease commented on Sep 10, 2025

    @fmease
    Member

    PR #146422 addresses the regression (after beta backport).

  12. added and removed
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    on Sep 11, 2025
  13. added a commit that references this issue on Sep 11, 2025
  14. added a commit that references this issue on Sep 11, 2025
  15. fmease commented on Sep 11, 2025

    @fmease
    Member

    Fix: #146422
    Backport: #146443

  16. added a commit that references this issue on Mar 9, 2026
  17. added 2 commits that reference this issue on Mar 9, 2026
  18. added a commit that references this issue on Mar 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)C-bugCategory: This is a bug.P-criticalCritical priorityS-has-bisectionStatus: A bisection has been found for this issueS-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language teamregression-from-stable-to-betaPerformance or correctness regression from stable to beta.

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions