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 }, Ctor => DefPathDataName::Anon { namespace: sym::constructor },
AnonConst => DefPathDataName::Anon { namespace: sym::constant }, AnonConst => DefPathDataName::Anon { namespace: sym::constant },
OpaqueTy => DefPathDataName::Anon { namespace: sym::opaque }, 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 }, SyntheticCoroutineBody => DefPathDataName::Anon { namespace: sym::synthetic },
} }
} }

View file

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

View file

@ -51,7 +51,7 @@ fn test_assoc_items() -> ControlFlow<()> {
check_items( check_items(
&trait_assoc_item_defs, &trait_assoc_item_defs,
&[ &[
"ATrait::{synthetic#0}", "ATrait::{anon_assoc#0}",
"ATrait::rpitit", "ATrait::rpitit",
"ATrait::Assoc", "ATrait::Assoc",
"ATrait::assoc_fn_no_self", "ATrait::assoc_fn_no_self",
@ -64,7 +64,7 @@ fn test_assoc_items() -> ControlFlow<()> {
check_items( check_items(
&impl_assoc_item_defs, &impl_assoc_item_defs,
&[ &[
"<AStruct as ATrait>::{synthetic#0}", "<AStruct as ATrait>::{anon_assoc#0}",
"<AStruct as ATrait>::rpitit", "<AStruct as ATrait>::rpitit",
"<AStruct as ATrait>::Assoc", "<AStruct as ATrait>::Assoc",
"<AStruct as ATrait>::assoc_fn_no_self", "<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 --> $DIR/unsupported.rs:22:25
| |
LL | reuse to_reuse::opaque_ret; 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; 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 note: cycle used when checking that `opaque::<impl at $DIR/unsupported.rs:21:5: 21:24>` is well-formed
--> $DIR/unsupported.rs:21:5 --> $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 = 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 --> $DIR/unsupported.rs:25:24
| |
LL | reuse ToReuse::opaque_ret; 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; 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 note: cycle used when checking that `opaque::<impl at $DIR/unsupported.rs:24:5: 24:25>` is well-formed
--> $DIR/unsupported.rs:24:5 --> $DIR/unsupported.rs:24:5
| |

View file

@ -6,11 +6,11 @@ LL | fn bar() -> () {}
| |
= help: the trait `std::fmt::Display` is not implemented for `()` = 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: 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 --> $DIR/doesnt-satisfy.rs:2:22
| |
LL | fn bar() -> impl std::fmt::Display; 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 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> { 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() 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 --> $DIR/dump.rs:10:35
| |
LL | fn hello<'s, T: Foo>(x: &'s T) -> impl Sized + use<'s, T> { 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>` | ^^^^^^^^^^^^ the trait `Foo<char>` is not implemented for `impl Foo<u8>`
| |
= help: the trait `Foo<char>` is implemented for `Bar` = 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 --> $DIR/return-dont-satisfy-bounds.rs:2:30
| |
LL | fn foo<F2>(self) -> impl Foo<T>; 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 error[E0277]: the trait bound `Bar: Foo<u8>` is not satisfied
--> $DIR/return-dont-satisfy-bounds.rs:8:34 --> $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 { LL | fn main() -> Something {
| ^^^^^^^^^ the trait `Termination` is not implemented for `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 --> $DIR/issue-103052-2.rs:3:27
| |
LL | fn main() -> impl std::process::Termination; 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 error: aborting due to 1 previous error