Don't give APITs names with macro expansion placeholder fragments in it

This commit is contained in:
Michael Goulet 2025-06-18 17:57:22 +00:00
parent 2801f9aaf9
commit 8cd3fa04e2
9 changed files with 77 additions and 18 deletions

View file

@ -1,9 +0,0 @@
//@ known-bug: #140333
fn a() -> impl b<
[c; {
struct d {
#[a]
bar: e,
}
}],
>;

View file

@ -0,0 +1,12 @@
trait Foo<T> {}
macro_rules! bar {
() => { () }
}
fn foo(x: impl Foo<bar!()>) {
let () = x;
//~^ ERROR mismatched types
}
fn main() {}

View file

@ -0,0 +1,16 @@
error[E0308]: mismatched types
--> $DIR/name-mentioning-macro.rs:8:9
|
LL | fn foo(x: impl Foo<bar!()>) {
| ---------------- expected this type parameter
LL | let () = x;
| ^^ - this expression has type `impl Foo<bar!()>`
| |
| expected type parameter `impl Foo<bar!()>`, found `()`
|
= note: expected type parameter `impl Foo<bar!()>`
found unit type `()`
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0308`.

View file

@ -0,0 +1,16 @@
//@ check-pass
trait Trait<T> {}
fn a(_: impl Trait<
[(); {
struct D {
#[rustfmt::skip]
bar: (),
}
0
}],
>) {
}
fn main() {}