1
Fork 0

Change how anonymous associated types are printed.

Give them their own symbol `anon_assoc`, as is done for all the other
anonymous `DefPathData` variants.
This commit is contained in:
Nicholas Nethercote 2025-04-11 15:28:09 +10:00
parent 9eca59a940
commit cdf5b8d4e7
9 changed files with 16 additions and 15 deletions

View file

@ -446,7 +446,7 @@ impl DefPathData {
Ctor => DefPathDataName::Anon { namespace: sym::constructor },
AnonConst => DefPathDataName::Anon { namespace: sym::constant },
OpaqueTy => DefPathDataName::Anon { namespace: sym::opaque },
AnonAssocTy => DefPathDataName::Anon { namespace: sym::synthetic },
AnonAssocTy => DefPathDataName::Anon { namespace: sym::anon_assoc },
SyntheticCoroutineBody => DefPathDataName::Anon { namespace: sym::synthetic },
}
}

View file

@ -454,6 +454,7 @@ symbols! {
and_then,
anon,
anon_adt,
anon_assoc,
anonymous_lifetime_in_impl_trait,
any,
append_const_msg,

View file

@ -51,7 +51,7 @@ fn test_assoc_items() -> ControlFlow<()> {
check_items(
&trait_assoc_item_defs,
&[
"ATrait::{synthetic#0}",
"ATrait::{anon_assoc#0}",
"ATrait::rpitit",
"ATrait::Assoc",
"ATrait::assoc_fn_no_self",
@ -64,7 +64,7 @@ fn test_assoc_items() -> ControlFlow<()> {
check_items(
&impl_assoc_item_defs,
&[
"<AStruct as ATrait>::{synthetic#0}",
"<AStruct as ATrait>::{anon_assoc#0}",
"<AStruct as ATrait>::rpitit",
"<AStruct as ATrait>::Assoc",
"<AStruct as ATrait>::assoc_fn_no_self",

View file

@ -1,4 +1,4 @@
error[E0391]: cycle detected when computing type of `opaque::<impl at $DIR/unsupported.rs:21:5: 21:24>::{synthetic#0}`
error[E0391]: cycle detected when computing type of `opaque::<impl at $DIR/unsupported.rs:21:5: 21:24>::{anon_assoc#0}`
--> $DIR/unsupported.rs:22:25
|
LL | reuse to_reuse::opaque_ret;
@ -9,7 +9,7 @@ note: ...which requires comparing an impl and trait method signature, inferring
|
LL | reuse to_reuse::opaque_ret;
| ^^^^^^^^^^
= note: ...which again requires computing type of `opaque::<impl at $DIR/unsupported.rs:21:5: 21:24>::{synthetic#0}`, completing the cycle
= note: ...which again requires computing type of `opaque::<impl at $DIR/unsupported.rs:21:5: 21:24>::{anon_assoc#0}`, completing the cycle
note: cycle used when checking that `opaque::<impl at $DIR/unsupported.rs:21:5: 21:24>` is well-formed
--> $DIR/unsupported.rs:21:5
|
@ -17,7 +17,7 @@ LL | impl ToReuse for u8 {
| ^^^^^^^^^^^^^^^^^^^
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
error[E0391]: cycle detected when computing type of `opaque::<impl at $DIR/unsupported.rs:24:5: 24:25>::{synthetic#0}`
error[E0391]: cycle detected when computing type of `opaque::<impl at $DIR/unsupported.rs:24:5: 24:25>::{anon_assoc#0}`
--> $DIR/unsupported.rs:25:24
|
LL | reuse ToReuse::opaque_ret;
@ -28,7 +28,7 @@ note: ...which requires comparing an impl and trait method signature, inferring
|
LL | reuse ToReuse::opaque_ret;
| ^^^^^^^^^^
= note: ...which again requires computing type of `opaque::<impl at $DIR/unsupported.rs:24:5: 24:25>::{synthetic#0}`, completing the cycle
= note: ...which again requires computing type of `opaque::<impl at $DIR/unsupported.rs:24:5: 24:25>::{anon_assoc#0}`, completing the cycle
note: cycle used when checking that `opaque::<impl at $DIR/unsupported.rs:24:5: 24:25>` is well-formed
--> $DIR/unsupported.rs:24:5
|

View file

@ -6,11 +6,11 @@ LL | fn bar() -> () {}
|
= help: the trait `std::fmt::Display` is not implemented for `()`
= note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
note: required by a bound in `Foo::{synthetic#0}`
note: required by a bound in `Foo::{anon_assoc#0}`
--> $DIR/doesnt-satisfy.rs:2:22
|
LL | fn bar() -> impl std::fmt::Display;
| ^^^^^^^^^^^^^^^^^ required by this bound in `Foo::{synthetic#0}`
| ^^^^^^^^^^^^^^^^^ required by this bound in `Foo::{anon_assoc#0}`
error: aborting due to 1 previous error

View file

@ -8,7 +8,7 @@ trait Foo {
}
fn hello<'s, T: Foo>(x: &'s T) -> impl Sized + use<'s, T> {
//~^ ERROR <T as Foo>::{synthetic#0}<'s/#1>
//~^ ERROR <T as Foo>::{anon_assoc#0}<'s/#1>
x.hello()
}

View file

@ -1,4 +1,4 @@
error: <T as Foo>::{synthetic#0}<'s/#1>
error: <T as Foo>::{anon_assoc#0}<'s/#1>
--> $DIR/dump.rs:10:35
|
LL | fn hello<'s, T: Foo>(x: &'s T) -> impl Sized + use<'s, T> {

View file

@ -14,11 +14,11 @@ LL | fn foo<F2: Foo<u8>>(self) -> impl Foo<u8> {
| ^^^^^^^^^^^^ the trait `Foo<char>` is not implemented for `impl Foo<u8>`
|
= help: the trait `Foo<char>` is implemented for `Bar`
note: required by a bound in `Foo::{synthetic#0}`
note: required by a bound in `Foo::{anon_assoc#0}`
--> $DIR/return-dont-satisfy-bounds.rs:2:30
|
LL | fn foo<F2>(self) -> impl Foo<T>;
| ^^^^^^ required by this bound in `Foo::{synthetic#0}`
| ^^^^^^ required by this bound in `Foo::{anon_assoc#0}`
error[E0277]: the trait bound `Bar: Foo<u8>` is not satisfied
--> $DIR/return-dont-satisfy-bounds.rs:8:34

View file

@ -4,11 +4,11 @@ error[E0277]: the trait bound `Something: Termination` is not satisfied
LL | fn main() -> Something {
| ^^^^^^^^^ the trait `Termination` is not implemented for `Something`
|
note: required by a bound in `Main::{synthetic#0}`
note: required by a bound in `Main::{anon_assoc#0}`
--> $DIR/issue-103052-2.rs:3:27
|
LL | fn main() -> impl std::process::Termination;
| ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Main::{synthetic#0}`
| ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Main::{anon_assoc#0}`
error: aborting due to 1 previous error