Skip to content

Commit 5886437

Browse files
authored
Unrolled build for rust-lang#121686
Rollup merge of rust-lang#121686 - compiler-errors:rpitit-printing, r=lcnr Adjust printing for RPITITs 1. Call RPITITs `{synthetic#N}` instead of `{opaque#N}`. 2. Fall back to printing the RPITIT like an opaque even when printed as an `AliasTy`, just like we do for `ty::Alias`. You could argue that (2.) is misleading, but I believe it's more consistent than naming `{synthetic#N}`, which I assume approximately nobody knows where that def path name comes from. r? lcnr
2 parents d377991 + b57ddfe commit 5886437

File tree

10 files changed

+28
-21
lines changed

10 files changed

+28
-21
lines changed

compiler/rustc_hir/src/definitions.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,9 @@ impl DefPathData {
420420
pub fn name(&self) -> DefPathDataName {
421421
use self::DefPathData::*;
422422
match *self {
423-
TypeNs(name) if name == kw::Empty => DefPathDataName::Anon { namespace: sym::opaque },
423+
TypeNs(name) if name == kw::Empty => {
424+
DefPathDataName::Anon { namespace: sym::synthetic }
425+
}
424426
TypeNs(name) | ValueNs(name) | MacroNs(name) | LifetimeNs(name) => {
425427
DefPathDataName::Named(name)
426428
}

compiler/rustc_middle/src/ty/print/pretty.rs

+12-8
Original file line numberDiff line numberDiff line change
@@ -715,13 +715,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
715715
p!(print_def_path(def_id, &[]));
716716
}
717717
ty::Alias(ty::Projection | ty::Inherent | ty::Weak, ref data) => {
718-
if !(self.should_print_verbose() || with_no_queries())
719-
&& self.tcx().is_impl_trait_in_trait(data.def_id)
720-
{
721-
return self.pretty_print_opaque_impl_type(data.def_id, data.args);
722-
} else {
723-
p!(print(data))
724-
}
718+
p!(print(data))
725719
}
726720
ty::Placeholder(placeholder) => match placeholder.bound.kind {
727721
ty::BoundTyKind::Anon => p!(write("{placeholder:?}")),
@@ -3053,7 +3047,17 @@ define_print_and_forward_display! {
30533047
if let DefKind::Impl { of_trait: false } = cx.tcx().def_kind(cx.tcx().parent(self.def_id)) {
30543048
p!(pretty_print_inherent_projection(self))
30553049
} else {
3056-
p!(print_def_path(self.def_id, self.args));
3050+
// If we're printing verbosely, or don't want to invoke queries
3051+
// (`is_impl_trait_in_trait`), then fall back to printing the def path.
3052+
// This is likely what you want if you're debugging the compiler anyways.
3053+
if !(cx.should_print_verbose() || with_no_queries())
3054+
&& cx.tcx().is_impl_trait_in_trait(self.def_id)
3055+
{
3056+
return cx.pretty_print_opaque_impl_type(self.def_id, self.args);
3057+
} else {
3058+
p!(print_def_path(self.def_id, self.args));
3059+
}
3060+
30573061
}
30583062
}
30593063

compiler/rustc_span/src/symbol.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1690,6 +1690,7 @@ symbols! {
16901690
suggestion,
16911691
sym,
16921692
sync,
1693+
synthetic,
16931694
t32,
16941695
target,
16951696
target_abi,

tests/ui/impl-trait/in-trait/async-and-ret-ref.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ trait T {}
55

66
trait MyTrait {
77
async fn foo() -> &'static impl T;
8-
//~^ ERROR the associated type `<Self as MyTrait>::{opaque#0}` may not live long enough
8+
//~^ ERROR the associated type `impl T` may not live long enough
99
}
1010

1111
fn main() {}

tests/ui/impl-trait/in-trait/async-and-ret-ref.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
error[E0310]: the associated type `<Self as MyTrait>::{opaque#0}` may not live long enough
1+
error[E0310]: the associated type `impl T` may not live long enough
22
--> $DIR/async-and-ret-ref.rs:7:5
33
|
44
LL | async fn foo() -> &'static impl T;
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
| |
7-
| the associated type `<Self as MyTrait>::{opaque#0}` must be valid for the static lifetime...
7+
| the associated type `impl T` must be valid for the static lifetime...
88
| ...so that the reference type `&'static impl T` does not outlive the data it points at
99

1010
error: aborting due to 1 previous error

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::{opaque#0}`
9+
note: required by a bound in `Foo::{synthetic#0}`
1010
--> $DIR/doesnt-satisfy.rs:2:22
1111
|
1212
LL | fn bar() -> impl std::fmt::Display;
13-
| ^^^^^^^^^^^^^^^^^ required by this bound in `Foo::{opaque#0}`
13+
| ^^^^^^^^^^^^^^^^^ required by this bound in `Foo::{synthetic#0}`
1414

1515
error: aborting due to 1 previous error
1616

tests/ui/impl-trait/in-trait/missing-static-bound-from-impl.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ trait Erased {
99
impl<T: Original> Erased for T {
1010
fn f(&self) -> Box<dyn Fn()> {
1111
Box::new(<T as Original>::f())
12-
//~^ ERROR the associated type `<T as Original>::{opaque#0}` may not live long enough
12+
//~^ ERROR the associated type `impl Fn()` may not live long enough
1313
}
1414
}
1515

tests/ui/impl-trait/in-trait/missing-static-bound-from-impl.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
error[E0310]: the associated type `<T as Original>::{opaque#0}` may not live long enough
1+
error[E0310]: the associated type `impl Fn()` may not live long enough
22
--> $DIR/missing-static-bound-from-impl.rs:11:9
33
|
44
LL | Box::new(<T as Original>::f())
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
| |
7-
| the associated type `<T as Original>::{opaque#0}` must be valid for the static lifetime...
7+
| the associated type `impl Fn()` must be valid for the static lifetime...
88
| ...so that the type `impl Fn()` will meet its required lifetime bounds
99

1010
error: aborting due to 1 previous error

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ LL | fn foo<F2: Foo<u8>>(self) -> impl Foo<u8> {
55
| ^^^^^^^^^^^^ the trait `Foo<char>` is not implemented for `impl Foo<u8>`
66
|
77
= help: the trait `Foo<char>` is implemented for `Bar`
8-
note: required by a bound in `Foo::{opaque#0}`
8+
note: required by a bound in `Foo::{synthetic#0}`
99
--> $DIR/return-dont-satisfy-bounds.rs:2:30
1010
|
1111
LL | fn foo<F2>(self) -> impl Foo<T>;
12-
| ^^^^^^ required by this bound in `Foo::{opaque#0}`
12+
| ^^^^^^ required by this bound in `Foo::{synthetic#0}`
1313

1414
error[E0276]: impl has stricter requirements than trait
1515
--> $DIR/return-dont-satisfy-bounds.rs:8:16

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::{opaque#0}`
7+
note: required by a bound in `Main::{synthetic#0}`
88
--> $DIR/issue-103052-2.rs:5:27
99
|
1010
LL | fn main() -> impl std::process::Termination;
11-
| ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Main::{opaque#0}`
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Main::{synthetic#0}`
1212

1313
error: aborting due to 1 previous error
1414

0 commit comments

Comments
 (0)