regression: tagged-box macro fails on :ty pattern when a later pattern would match (original) (raw)
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 => <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">(</mo></mrow><annotation encoding="application/x-tex">(</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">(</span></span></span></span>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