Skip to content
/ rust Public
forked from rust-lang/rust

Commit cdf5b8d

Browse files
committed
Change how anonymous associated types are printed.
Give them their own symbol `anon_assoc`, as is done for all the other anonymous `DefPathData` variants.
1 parent 9eca59a commit cdf5b8d

File tree

9 files changed

+16
-15
lines changed

9 files changed

+16
-15
lines changed

compiler/rustc_hir/src/definitions.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ impl DefPathData {
446446
Ctor => DefPathDataName::Anon { namespace: sym::constructor },
447447
AnonConst => DefPathDataName::Anon { namespace: sym::constant },
448448
OpaqueTy => DefPathDataName::Anon { namespace: sym::opaque },
449-
AnonAssocTy => DefPathDataName::Anon { namespace: sym::synthetic },
449+
AnonAssocTy => DefPathDataName::Anon { namespace: sym::anon_assoc },
450450
SyntheticCoroutineBody => DefPathDataName::Anon { namespace: sym::synthetic },
451451
}
452452
}

compiler/rustc_span/src/symbol.rs

+1
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,7 @@ symbols! {
454454
and_then,
455455
anon,
456456
anon_adt,
457+
anon_assoc,
457458
anonymous_lifetime_in_impl_trait,
458459
any,
459460
append_const_msg,

tests/ui-fulldeps/stable-mir/check_assoc_items.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ fn test_assoc_items() -> ControlFlow<()> {
5151
check_items(
5252
&trait_assoc_item_defs,
5353
&[
54-
"ATrait::{synthetic#0}",
54+
"ATrait::{anon_assoc#0}",
5555
"ATrait::rpitit",
5656
"ATrait::Assoc",
5757
"ATrait::assoc_fn_no_self",
@@ -64,7 +64,7 @@ fn test_assoc_items() -> ControlFlow<()> {
6464
check_items(
6565
&impl_assoc_item_defs,
6666
&[
67-
"<AStruct as ATrait>::{synthetic#0}",
67+
"<AStruct as ATrait>::{anon_assoc#0}",
6868
"<AStruct as ATrait>::rpitit",
6969
"<AStruct as ATrait>::Assoc",
7070
"<AStruct as ATrait>::assoc_fn_no_self",

tests/ui/delegation/unsupported.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0391]: cycle detected when computing type of `opaque::<impl at $DIR/unsupported.rs:21:5: 21:24>::{synthetic#0}`
1+
error[E0391]: cycle detected when computing type of `opaque::<impl at $DIR/unsupported.rs:21:5: 21:24>::{anon_assoc#0}`
22
--> $DIR/unsupported.rs:22:25
33
|
44
LL | reuse to_reuse::opaque_ret;
@@ -9,15 +9,15 @@ note: ...which requires comparing an impl and trait method signature, inferring
99
|
1010
LL | reuse to_reuse::opaque_ret;
1111
| ^^^^^^^^^^
12-
= note: ...which again requires computing type of `opaque::<impl at $DIR/unsupported.rs:21:5: 21:24>::{synthetic#0}`, completing the cycle
12+
= note: ...which again requires computing type of `opaque::<impl at $DIR/unsupported.rs:21:5: 21:24>::{anon_assoc#0}`, completing the cycle
1313
note: cycle used when checking that `opaque::<impl at $DIR/unsupported.rs:21:5: 21:24>` is well-formed
1414
--> $DIR/unsupported.rs:21:5
1515
|
1616
LL | impl ToReuse for u8 {
1717
| ^^^^^^^^^^^^^^^^^^^
1818
= 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
1919

20-
error[E0391]: cycle detected when computing type of `opaque::<impl at $DIR/unsupported.rs:24:5: 24:25>::{synthetic#0}`
20+
error[E0391]: cycle detected when computing type of `opaque::<impl at $DIR/unsupported.rs:24:5: 24:25>::{anon_assoc#0}`
2121
--> $DIR/unsupported.rs:25:24
2222
|
2323
LL | reuse ToReuse::opaque_ret;
@@ -28,7 +28,7 @@ note: ...which requires comparing an impl and trait method signature, inferring
2828
|
2929
LL | reuse ToReuse::opaque_ret;
3030
| ^^^^^^^^^^
31-
= note: ...which again requires computing type of `opaque::<impl at $DIR/unsupported.rs:24:5: 24:25>::{synthetic#0}`, completing the cycle
31+
= note: ...which again requires computing type of `opaque::<impl at $DIR/unsupported.rs:24:5: 24:25>::{anon_assoc#0}`, completing the cycle
3232
note: cycle used when checking that `opaque::<impl at $DIR/unsupported.rs:24:5: 24:25>` is well-formed
3333
--> $DIR/unsupported.rs:24:5
3434
|

tests/ui/impl-trait/in-trait/doesnt-satisfy.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ LL | fn bar() -> () {}
66
|
77
= help: the trait `std::fmt::Display` is not implemented for `()`
88
= note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
9-
note: required by a bound in `Foo::{synthetic#0}`
9+
note: required by a bound in `Foo::{anon_assoc#0}`
1010
--> $DIR/doesnt-satisfy.rs:2:22
1111
|
1212
LL | fn bar() -> impl std::fmt::Display;
13-
| ^^^^^^^^^^^^^^^^^ required by this bound in `Foo::{synthetic#0}`
13+
| ^^^^^^^^^^^^^^^^^ required by this bound in `Foo::{anon_assoc#0}`
1414

1515
error: aborting due to 1 previous error
1616

tests/ui/impl-trait/in-trait/dump.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ trait Foo {
88
}
99

1010
fn hello<'s, T: Foo>(x: &'s T) -> impl Sized + use<'s, T> {
11-
//~^ ERROR <T as Foo>::{synthetic#0}<'s/#1>
11+
//~^ ERROR <T as Foo>::{anon_assoc#0}<'s/#1>
1212
x.hello()
1313
}
1414

tests/ui/impl-trait/in-trait/dump.stderr

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

tests/ui/impl-trait/in-trait/return-dont-satisfy-bounds.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ LL | fn foo<F2: Foo<u8>>(self) -> impl Foo<u8> {
1414
| ^^^^^^^^^^^^ the trait `Foo<char>` is not implemented for `impl Foo<u8>`
1515
|
1616
= help: the trait `Foo<char>` is implemented for `Bar`
17-
note: required by a bound in `Foo::{synthetic#0}`
17+
note: required by a bound in `Foo::{anon_assoc#0}`
1818
--> $DIR/return-dont-satisfy-bounds.rs:2:30
1919
|
2020
LL | fn foo<F2>(self) -> impl Foo<T>;
21-
| ^^^^^^ required by this bound in `Foo::{synthetic#0}`
21+
| ^^^^^^ required by this bound in `Foo::{anon_assoc#0}`
2222

2323
error[E0277]: the trait bound `Bar: Foo<u8>` is not satisfied
2424
--> $DIR/return-dont-satisfy-bounds.rs:8:34

tests/ui/rfcs/rfc-1937-termination-trait/issue-103052-2.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ error[E0277]: the trait bound `Something: Termination` is not satisfied
44
LL | fn main() -> Something {
55
| ^^^^^^^^^ the trait `Termination` is not implemented for `Something`
66
|
7-
note: required by a bound in `Main::{synthetic#0}`
7+
note: required by a bound in `Main::{anon_assoc#0}`
88
--> $DIR/issue-103052-2.rs:3:27
99
|
1010
LL | fn main() -> impl std::process::Termination;
11-
| ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Main::{synthetic#0}`
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Main::{anon_assoc#0}`
1212

1313
error: aborting due to 1 previous error
1414

0 commit comments

Comments
 (0)