diff options
| author | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2022-02-07 15:50:42 +0000 |
|---|---|---|
| committer | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2022-02-07 15:50:42 +0000 |
| commit | c93f571c2a040a29525b077e557b3d592072fcf2 (patch) | |
| tree | fca9f71e0581cae7493106f6de5fff2eb21dd232 | |
| parent | 75461633350a24c3c23d387155c200ae31ccc870 (diff) | |
| download | rust-c93f571c2a040a29525b077e557b3d592072fcf2.tar.gz rust-c93f571c2a040a29525b077e557b3d592072fcf2.zip | |
Print opaque types from type aliases via their path
44 files changed, 153 insertions, 77 deletions
diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index 11a3ee53629..6521957ec94 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -644,18 +644,23 @@ pub trait PrettyPrinter<'tcx>: return Ok(self); } - let def_key = self.tcx().def_key(def_id); - if let Some(name) = def_key.disambiguated_data.data.get_opt_name() { - p!(write("{}", name)); - // FIXME(eddyb) print this with `print_def_path`. - if !substs.is_empty() { - p!("::"); - p!(generic_delimiters(|cx| cx.comma_sep(substs.iter()))); + let parent = self.tcx().parent(def_id).expect("opaque types always have a parent"); + match self.tcx().def_kind(parent) { + DefKind::TyAlias | DefKind::AssocTy => { + if let ty::Opaque(d, _) = *self.tcx().type_of(parent).kind() { + if d == def_id { + // If the type alias directly starts with the `impl` of the + // opaque type we're printing, then skip the `::{opaque#1}`. + p!(print_def_path(parent, substs)); + return Ok(self); + } + } + // Complex opaque type, e.g. `type Foo = (i32, impl Debug);` + p!(print_def_path(def_id, substs)); + return Ok(self); } - return Ok(self); + _ => return self.pretty_print_opaque_impl_type(def_id, substs), } - - return self.pretty_print_opaque_impl_type(def_id, substs); } ty::Str => p!("str"), ty::Generator(did, substs, movability) => { @@ -898,15 +903,6 @@ pub trait PrettyPrinter<'tcx>: if !first { p!(", "); } - if let GenericArgKind::Type(ty) = ty.unpack() { - if let ty::Opaque(d, substs) = *ty.kind() { - if d == def_id { - p!(print_def_path(d, substs)); - first = false; - continue; - } - } - } p!(print(trait_ref.rebind(*ty))); first = false; } diff --git a/src/test/ui/associated-type-bounds/assoc-type-eq-with-dyn-atb-fail.stderr b/src/test/ui/associated-type-bounds/assoc-type-eq-with-dyn-atb-fail.stderr index be4bfa6272b..f1dcd34066d 100644 --- a/src/test/ui/associated-type-bounds/assoc-type-eq-with-dyn-atb-fail.stderr +++ b/src/test/ui/associated-type-bounds/assoc-type-eq-with-dyn-atb-fail.stderr @@ -4,7 +4,7 @@ error[E0277]: the trait bound `String: Copy` is not satisfied LL | Box::new(AssocNoCopy) | ^^^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String` | - = note: required for the cast to the object type `dyn Bar<Assoc = impl Copy>` + = note: required for the cast to the object type `dyn Bar<Assoc = <AssocNoCopy as Thing>::Out::{opaque#0}>` error: aborting due to previous error diff --git a/src/test/ui/impl-trait/auto-trait.rs b/src/test/ui/impl-trait/auto-trait.rs index cf2773f4ef5..35994e4a5ba 100644 --- a/src/test/ui/impl-trait/auto-trait.rs +++ b/src/test/ui/impl-trait/auto-trait.rs @@ -19,7 +19,7 @@ impl<T: Send> AnotherTrait for T {} // (We treat opaque types as "foreign types" that could grow more impls // in the future.) impl AnotherTrait for D<OpaqueType> { - //~^ ERROR conflicting implementations of trait `AnotherTrait` for type `D<impl OpaqueTrait>` + //~^ ERROR conflicting implementations of trait `AnotherTrait` for type `D<OpaqueType>` } fn main() {} diff --git a/src/test/ui/impl-trait/auto-trait.stderr b/src/test/ui/impl-trait/auto-trait.stderr index 26cd8fb6a9b..81009413c9a 100644 --- a/src/test/ui/impl-trait/auto-trait.stderr +++ b/src/test/ui/impl-trait/auto-trait.stderr @@ -1,11 +1,11 @@ -error[E0119]: conflicting implementations of trait `AnotherTrait` for type `D<impl OpaqueTrait>` +error[E0119]: conflicting implementations of trait `AnotherTrait` for type `D<OpaqueType>` --> $DIR/auto-trait.rs:21:1 | LL | impl<T: Send> AnotherTrait for T {} | -------------------------------- first implementation here ... LL | impl AnotherTrait for D<OpaqueType> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `D<impl OpaqueTrait>` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `D<OpaqueType>` error: aborting due to previous error diff --git a/src/test/ui/impl-trait/negative-reasoning.rs b/src/test/ui/impl-trait/negative-reasoning.rs index d173fe83fb7..70e24a3a9d0 100644 --- a/src/test/ui/impl-trait/negative-reasoning.rs +++ b/src/test/ui/impl-trait/negative-reasoning.rs @@ -17,7 +17,7 @@ impl<T: std::fmt::Debug> AnotherTrait for T {} // This is in error, because we cannot assume that `OpaqueType: !Debug` impl AnotherTrait for D<OpaqueType> { - //~^ ERROR conflicting implementations of trait `AnotherTrait` for type `D<impl OpaqueTrait>` + //~^ ERROR conflicting implementations of trait `AnotherTrait` for type `D<OpaqueType>` } fn main() {} diff --git a/src/test/ui/impl-trait/negative-reasoning.stderr b/src/test/ui/impl-trait/negative-reasoning.stderr index e39a8e53f79..6b8cc9e7374 100644 --- a/src/test/ui/impl-trait/negative-reasoning.stderr +++ b/src/test/ui/impl-trait/negative-reasoning.stderr @@ -1,13 +1,13 @@ -error[E0119]: conflicting implementations of trait `AnotherTrait` for type `D<impl OpaqueTrait>` +error[E0119]: conflicting implementations of trait `AnotherTrait` for type `D<OpaqueType>` --> $DIR/negative-reasoning.rs:19:1 | LL | impl<T: std::fmt::Debug> AnotherTrait for T {} | ------------------------------------------- first implementation here ... LL | impl AnotherTrait for D<OpaqueType> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `D<impl OpaqueTrait>` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `D<OpaqueType>` | - = note: upstream crates may add a new impl of trait `std::fmt::Debug` for type `impl OpaqueTrait` in future versions + = note: upstream crates may add a new impl of trait `std::fmt::Debug` for type `OpaqueType` in future versions error: aborting due to previous error diff --git a/src/test/ui/lint/lint-ctypes-73249-2.rs b/src/test/ui/lint/lint-ctypes-73249-2.rs index fe578f51b63..691047c8a40 100644 --- a/src/test/ui/lint/lint-ctypes-73249-2.rs +++ b/src/test/ui/lint/lint-ctypes-73249-2.rs @@ -23,7 +23,7 @@ pub struct A<T: Foo> { } extern "C" { - pub fn lint_me() -> A<()>; //~ ERROR: uses type `impl Baz` + pub fn lint_me() -> A<()>; //~ ERROR: uses type `Qux` } fn main() {} diff --git a/src/test/ui/lint/lint-ctypes-73249-2.stderr b/src/test/ui/lint/lint-ctypes-73249-2.stderr index 36dbe3217d7..7c85e9fa85c 100644 --- a/src/test/ui/lint/lint-ctypes-73249-2.stderr +++ b/src/test/ui/lint/lint-ctypes-73249-2.stderr @@ -1,4 +1,4 @@ -error: `extern` block uses type `impl Baz`, which is not FFI-safe +error: `extern` block uses type `Qux`, which is not FFI-safe --> $DIR/lint-ctypes-73249-2.rs:26:25 | LL | pub fn lint_me() -> A<()>; diff --git a/src/test/ui/lint/lint-ctypes-73249-3.rs b/src/test/ui/lint/lint-ctypes-73249-3.rs index ec12de00739..ef8ab7e03d2 100644 --- a/src/test/ui/lint/lint-ctypes-73249-3.rs +++ b/src/test/ui/lint/lint-ctypes-73249-3.rs @@ -17,7 +17,7 @@ pub struct A { } extern "C" { - pub fn lint_me() -> A; //~ ERROR: uses type `impl Baz` + pub fn lint_me() -> A; //~ ERROR: uses type `Qux` } fn main() {} diff --git a/src/test/ui/lint/lint-ctypes-73249-3.stderr b/src/test/ui/lint/lint-ctypes-73249-3.stderr index e987ec90228..83e2a233c43 100644 --- a/src/test/ui/lint/lint-ctypes-73249-3.stderr +++ b/src/test/ui/lint/lint-ctypes-73249-3.stderr @@ -1,4 +1,4 @@ -error: `extern` block uses type `impl Baz`, which is not FFI-safe +error: `extern` block uses type `Qux`, which is not FFI-safe --> $DIR/lint-ctypes-73249-3.rs:20:25 | LL | pub fn lint_me() -> A; diff --git a/src/test/ui/lint/lint-ctypes-73249-5.rs b/src/test/ui/lint/lint-ctypes-73249-5.rs index 58c2d7a501a..083fb6c5fb1 100644 --- a/src/test/ui/lint/lint-ctypes-73249-5.rs +++ b/src/test/ui/lint/lint-ctypes-73249-5.rs @@ -17,7 +17,7 @@ pub struct A { } extern "C" { - pub fn lint_me() -> A; //~ ERROR: uses type `impl Baz` + pub fn lint_me() -> A; //~ ERROR: uses type `Qux` } fn main() {} diff --git a/src/test/ui/lint/lint-ctypes-73249-5.stderr b/src/test/ui/lint/lint-ctypes-73249-5.stderr index 749714c7df8..37781d78cf2 100644 --- a/src/test/ui/lint/lint-ctypes-73249-5.stderr +++ b/src/test/ui/lint/lint-ctypes-73249-5.stderr @@ -1,4 +1,4 @@ -error: `extern` block uses type `impl Baz`, which is not FFI-safe +error: `extern` block uses type `Qux`, which is not FFI-safe --> $DIR/lint-ctypes-73249-5.rs:20:25 | LL | pub fn lint_me() -> A; diff --git a/src/test/ui/lint/lint-ctypes-73251-1.rs b/src/test/ui/lint/lint-ctypes-73251-1.rs index dc4c7efd7ef..145ba784f7c 100644 --- a/src/test/ui/lint/lint-ctypes-73251-1.rs +++ b/src/test/ui/lint/lint-ctypes-73251-1.rs @@ -20,7 +20,7 @@ fn assign() -> Qux { } extern "C" { - pub fn lint_me() -> <u32 as Foo>::Assoc; //~ ERROR: uses type `impl Baz` + pub fn lint_me() -> <u32 as Foo>::Assoc; //~ ERROR: uses type `Qux` } fn main() {} diff --git a/src/test/ui/lint/lint-ctypes-73251-1.stderr b/src/test/ui/lint/lint-ctypes-73251-1.stderr index 505ccd5a930..76b19d37e21 100644 --- a/src/test/ui/lint/lint-ctypes-73251-1.stderr +++ b/src/test/ui/lint/lint-ctypes-73251-1.stderr @@ -1,4 +1,4 @@ -error: `extern` block uses type `impl Baz`, which is not FFI-safe +error: `extern` block uses type `Qux`, which is not FFI-safe --> $DIR/lint-ctypes-73251-1.rs:23:25 | LL | pub fn lint_me() -> <u32 as Foo>::Assoc; diff --git a/src/test/ui/lint/lint-ctypes-73251-2.rs b/src/test/ui/lint/lint-ctypes-73251-2.rs index 717ca4986f7..df71a945796 100644 --- a/src/test/ui/lint/lint-ctypes-73251-2.rs +++ b/src/test/ui/lint/lint-ctypes-73251-2.rs @@ -33,7 +33,7 @@ fn use_of_b() -> AliasB { } extern "C" { - pub fn lint_me() -> <AliasB as TraitB>::Assoc; //~ ERROR: uses type `impl TraitA<Assoc = u32>` + pub fn lint_me() -> <AliasB as TraitB>::Assoc; //~ ERROR: uses type `AliasA` } fn main() {} diff --git a/src/test/ui/lint/lint-ctypes-73251-2.stderr b/src/test/ui/lint/lint-ctypes-73251-2.stderr index d7e10db441e..64f0fb2d892 100644 --- a/src/test/ui/lint/lint-ctypes-73251-2.stderr +++ b/src/test/ui/lint/lint-ctypes-73251-2.stderr @@ -1,4 +1,4 @@ -error: `extern` block uses type `impl TraitA<Assoc = u32>`, which is not FFI-safe +error: `extern` block uses type `AliasA`, which is not FFI-safe --> $DIR/lint-ctypes-73251-2.rs:36:25 | LL | pub fn lint_me() -> <AliasB as TraitB>::Assoc; diff --git a/src/test/ui/lint/opaque-ty-ffi-unsafe.rs b/src/test/ui/lint/opaque-ty-ffi-unsafe.rs index 3a62b6a21a5..b7cc38e99fc 100644 --- a/src/test/ui/lint/opaque-ty-ffi-unsafe.rs +++ b/src/test/ui/lint/opaque-ty-ffi-unsafe.rs @@ -9,7 +9,7 @@ pub fn ret_closure() -> A { extern "C" { pub fn a(_: A); - //~^ ERROR `extern` block uses type `impl Fn()`, which is not FFI-safe [improper_ctypes] + //~^ ERROR `extern` block uses type `A`, which is not FFI-safe [improper_ctypes] } fn main() {} diff --git a/src/test/ui/lint/opaque-ty-ffi-unsafe.stderr b/src/test/ui/lint/opaque-ty-ffi-unsafe.stderr index 5afbef778b3..62d00fd6835 100644 --- a/src/test/ui/lint/opaque-ty-ffi-unsafe.stderr +++ b/src/test/ui/lint/opaque-ty-ffi-unsafe.stderr @@ -1,4 +1,4 @@ -error: `extern` block uses type `impl Fn()`, which is not FFI-safe +error: `extern` block uses type `A`, which is not FFI-safe --> $DIR/opaque-ty-ffi-unsafe.rs:11:17 | LL | pub fn a(_: A); diff --git a/src/test/ui/traits/alias/issue-83613.rs b/src/test/ui/traits/alias/issue-83613.rs index 0013d5d66f1..04320e72076 100644 --- a/src/test/ui/traits/alias/issue-83613.rs +++ b/src/test/ui/traits/alias/issue-83613.rs @@ -8,6 +8,6 @@ fn mk_opaque() -> OpaqueType { trait AnotherTrait {} impl<T: Send> AnotherTrait for T {} impl AnotherTrait for OpaqueType {} -//~^ ERROR conflicting implementations of trait `AnotherTrait` for type `impl OpaqueTrait` +//~^ ERROR conflicting implementations of trait `AnotherTrait` for type `OpaqueType` //~| ERROR cannot implement trait on type alias impl trait fn main() {} diff --git a/src/test/ui/traits/alias/issue-83613.stderr b/src/test/ui/traits/alias/issue-83613.stderr index 6a3498a3893..4f19e6607c8 100644 --- a/src/test/ui/traits/alias/issue-83613.stderr +++ b/src/test/ui/traits/alias/issue-83613.stderr @@ -10,13 +10,13 @@ note: type alias impl trait defined here LL | type OpaqueType = impl OpaqueTrait; | ^^^^^^^^^^^^^^^^ -error[E0119]: conflicting implementations of trait `AnotherTrait` for type `impl OpaqueTrait` +error[E0119]: conflicting implementations of trait `AnotherTrait` for type `OpaqueType` --> $DIR/issue-83613.rs:10:1 | LL | impl<T: Send> AnotherTrait for T {} | -------------------------------- first implementation here LL | impl AnotherTrait for OpaqueType {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `impl OpaqueTrait` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `OpaqueType` error: aborting due to 2 previous errors diff --git a/src/test/ui/type-alias-impl-trait/auto-trait-leakage2.stderr b/src/test/ui/type-alias-impl-trait/auto-trait-leakage2.stderr index 4a49d6e4ab8..0664275b2ad 100644 --- a/src/test/ui/type-alias-impl-trait/auto-trait-leakage2.stderr +++ b/src/test/ui/type-alias-impl-trait/auto-trait-leakage2.stderr @@ -2,15 +2,15 @@ error[E0277]: `Rc<u32>` cannot be sent between threads safely --> $DIR/auto-trait-leakage2.rs:17:13 | LL | type Foo = impl std::fmt::Debug; - | -------------------- within this `impl Debug` + | -------------------- within this `Foo` ... LL | is_send(m::foo()); | ------- ^^^^^^^^ `Rc<u32>` cannot be sent between threads safely | | | required by a bound introduced by this call | - = help: within `impl Debug`, the trait `Send` is not implemented for `Rc<u32>` - = note: required because it appears within the type `impl Debug` + = help: within `Foo`, the trait `Send` is not implemented for `Rc<u32>` + = note: required because it appears within the type `Foo` note: required by a bound in `is_send` --> $DIR/auto-trait-leakage2.rs:14:15 | diff --git a/src/test/ui/type-alias-impl-trait/declared_but_not_defined_in_scope.stderr b/src/test/ui/type-alias-impl-trait/declared_but_not_defined_in_scope.stderr index d61561d3ea9..26308c6ff6b 100644 --- a/src/test/ui/type-alias-impl-trait/declared_but_not_defined_in_scope.stderr +++ b/src/test/ui/type-alias-impl-trait/declared_but_not_defined_in_scope.stderr @@ -15,7 +15,7 @@ LL | pub type Boo = impl ::std::fmt::Debug; LL | "" | ^^ expected opaque type, found `&str` | - = note: expected opaque type `impl Debug` + = note: expected opaque type `Boo` found reference `&str` error: aborting due to 2 previous errors diff --git a/src/test/ui/type-alias-impl-trait/issue-63279.stderr b/src/test/ui/type-alias-impl-trait/issue-63279.stderr index 950d9bbf245..4b7dbbd6a56 100644 --- a/src/test/ui/type-alias-impl-trait/issue-63279.stderr +++ b/src/test/ui/type-alias-impl-trait/issue-63279.stderr @@ -25,7 +25,7 @@ LL | type Closure = impl FnOnce(); LL | || -> Closure { || () } | ^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found closure | - = note: expected opaque type `impl FnOnce()` + = note: expected opaque type `Closure` found closure `[closure@$DIR/issue-63279.rs:8:5: 8:28]` error: aborting due to 3 previous errors diff --git a/src/test/ui/type-alias-impl-trait/issue-74280.stderr b/src/test/ui/type-alias-impl-trait/issue-74280.stderr index c11585db077..38591e37f53 100644 --- a/src/test/ui/type-alias-impl-trait/issue-74280.stderr +++ b/src/test/ui/type-alias-impl-trait/issue-74280.stderr @@ -7,7 +7,7 @@ LL | type Test = impl Copy; LL | 7 | ^ expected `()`, found integer | - = note: expected opaque type `impl Copy` + = note: expected opaque type `Test` found type `{integer}` error: aborting due to previous error diff --git a/src/test/ui/type-alias-impl-trait/issue-77179.stderr b/src/test/ui/type-alias-impl-trait/issue-77179.stderr index 9e742a25500..053546e4b92 100644 --- a/src/test/ui/type-alias-impl-trait/issue-77179.stderr +++ b/src/test/ui/type-alias-impl-trait/issue-77179.stderr @@ -5,7 +5,7 @@ LL | fn test() -> Pointer<_> { | --------^- | | | | | not allowed in type signatures - | help: replace with the correct return type: `impl Deref<Target = i32>` + | help: replace with the correct return type: `Pointer<i32>` error: aborting due to previous error diff --git a/src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn3.stderr b/src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn3.stderr index 20da37ec9a1..db4b60461ef 100644 --- a/src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn3.stderr +++ b/src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn3.stderr @@ -11,7 +11,7 @@ LL | fn g<A: ToString + Clone, B: ToString + Clone>(a: A, b: B) -> (X<A, B>, X<A LL | (a, b) | ^ expected type parameter `A`, found type parameter `B` | - = note: expected opaque type `impl ToString` + = note: expected opaque type `X<A, B>` found type parameter `B` = note: a type parameter was expected, but a different one was found; you might be missing a type parameter or trait bound = note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters diff --git a/src/test/ui/type-alias-impl-trait/nested-tait-inference.rs b/src/test/ui/type-alias-impl-trait/nested-tait-inference.rs index d51c4185fbc..784a6c75886 100644 --- a/src/test/ui/type-alias-impl-trait/nested-tait-inference.rs +++ b/src/test/ui/type-alias-impl-trait/nested-tait-inference.rs @@ -12,7 +12,7 @@ impl Foo<()> for () { } fn foo() -> impl Foo<FooX> { // FIXME(type-alias-impl-trait): We could probably make this work. () - //~^ ERROR: the trait bound `(): Foo<impl Debug>` is not satisfied + //~^ ERROR: the trait bound `(): Foo<FooX>` is not satisfied } fn main() { } diff --git a/src/test/ui/type-alias-impl-trait/nested-tait-inference.stderr b/src/test/ui/type-alias-impl-trait/nested-tait-inference.stderr index 630328afc52..9472cac6355 100644 --- a/src/test/ui/type-alias-impl-trait/nested-tait-inference.stderr +++ b/src/test/ui/type-alias-impl-trait/nested-tait-inference.stderr @@ -1,8 +1,8 @@ -error[E0277]: the trait bound `(): Foo<impl Debug>` is not satisfied +error[E0277]: the trait bound `(): Foo<FooX>` is not satisfied --> $DIR/nested-tait-inference.rs:14:5 | LL | () - | ^^ the trait `Foo<impl Debug>` is not implemented for `()` + | ^^ the trait `Foo<FooX>` is not implemented for `()` | = help: the following implementations were found: <() as Foo<()>> diff --git a/src/test/ui/type-alias-impl-trait/nested-tait-inference2.rs b/src/test/ui/type-alias-impl-trait/nested-tait-inference2.rs index 00d835d3ca7..00bd44c493c 100644 --- a/src/test/ui/type-alias-impl-trait/nested-tait-inference2.rs +++ b/src/test/ui/type-alias-impl-trait/nested-tait-inference2.rs @@ -12,7 +12,7 @@ impl Foo<u32> for () {} fn foo() -> impl Foo<FooX> { () - //~^ ERROR: the trait bound `(): Foo<impl Debug>` is not satisfied + //~^ ERROR: the trait bound `(): Foo<FooX>` is not satisfied } fn main() {} diff --git a/src/test/ui/type-alias-impl-trait/nested-tait-inference2.stderr b/src/test/ui/type-alias-impl-trait/nested-tait-inference2.stderr index 1b04ea2bf16..ec1b4642d08 100644 --- a/src/test/ui/type-alias-impl-trait/nested-tait-inference2.stderr +++ b/src/test/ui/type-alias-impl-trait/nested-tait-inference2.stderr @@ -1,8 +1,8 @@ -error[E0277]: the trait bound `(): Foo<impl Debug>` is not satisfied +error[E0277]: the trait bound `(): Foo<FooX>` is not satisfied --> $DIR/nested-tait-inference2.rs:14:5 | LL | () - | ^^ the trait `Foo<impl Debug>` is not implemented for `()` + | ^^ the trait `Foo<FooX>` is not implemented for `()` | = help: the following implementations were found: <() as Foo<()>> diff --git a/src/test/ui/type-alias-impl-trait/nested.rs b/src/test/ui/type-alias-impl-trait/nested.rs index e55fe3a3aaf..6b866be7d17 100644 --- a/src/test/ui/type-alias-impl-trait/nested.rs +++ b/src/test/ui/type-alias-impl-trait/nested.rs @@ -13,5 +13,5 @@ fn bar() -> Bar { fn main() { println!("{:?}", bar()); - //~^ ERROR `impl Trait<impl Debug>` doesn't implement `Debug` + //~^ ERROR `Bar` doesn't implement `Debug` } diff --git a/src/test/ui/type-alias-impl-trait/nested.stderr b/src/test/ui/type-alias-impl-trait/nested.stderr index eff56e3b76d..cf4d23656e0 100644 --- a/src/test/ui/type-alias-impl-trait/nested.stderr +++ b/src/test/ui/type-alias-impl-trait/nested.stderr @@ -1,10 +1,10 @@ -error[E0277]: `impl Trait<impl Debug>` doesn't implement `Debug` +error[E0277]: `Bar` doesn't implement `Debug` --> $DIR/nested.rs:15:22 | LL | println!("{:?}", bar()); - | ^^^^^ `impl Trait<impl Debug>` cannot be formatted using `{:?}` because it doesn't implement `Debug` + | ^^^^^ `Bar` cannot be formatted using `{:?}` because it doesn't implement `Debug` | - = help: the trait `Debug` is not implemented for `impl Trait<impl Debug>` + = help: the trait `Debug` is not implemented for `Bar` = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/type-alias-impl-trait/no_revealing_outside_defining_module.stderr b/src/test/ui/type-alias-impl-trait/no_revealing_outside_defining_module.stderr index d12160a9793..e691d8781c0 100644 --- a/src/test/ui/type-alias-impl-trait/no_revealing_outside_defining_module.stderr +++ b/src/test/ui/type-alias-impl-trait/no_revealing_outside_defining_module.stderr @@ -8,7 +8,7 @@ LL | let _: &str = bomp(); | ^^^^^^ expected `&str`, found opaque type | = note: expected reference `&str` - found opaque type `impl Debug` + found opaque type `Boo` error[E0308]: mismatched types --> $DIR/no_revealing_outside_defining_module.rs:19:5 @@ -19,7 +19,7 @@ LL | pub type Boo = impl ::std::fmt::Debug; LL | "" | ^^ expected opaque type, found `&str` | - = note: expected opaque type `impl Debug` + = note: expected opaque type `Boo` found reference `&str` error: aborting due to 2 previous errors diff --git a/src/test/ui/type-alias-impl-trait/self-referential-2.rs b/src/test/ui/type-alias-impl-trait/self-referential-2.rs index e9ace992c8b..dc7054da5ec 100644 --- a/src/test/ui/type-alias-impl-trait/self-referential-2.rs +++ b/src/test/ui/type-alias-impl-trait/self-referential-2.rs @@ -4,7 +4,7 @@ type Foo = impl std::fmt::Debug; type Bar = impl PartialEq<Foo>; fn bar() -> Bar { - 42_i32 //~ ERROR can't compare `i32` with `impl Debug` + 42_i32 //~ ERROR can't compare `i32` with `Foo` } fn main() {} diff --git a/src/test/ui/type-alias-impl-trait/self-referential-2.stderr b/src/test/ui/type-alias-impl-trait/self-referential-2.stderr index 2c3630dc394..6997676260d 100644 --- a/src/test/ui/type-alias-impl-trait/self-referential-2.stderr +++ b/src/test/ui/type-alias-impl-trait/self-referential-2.stderr @@ -1,10 +1,10 @@ -error[E0277]: can't compare `i32` with `impl Debug` +error[E0277]: can't compare `i32` with `Foo` --> $DIR/self-referential-2.rs:7:5 | LL | 42_i32 - | ^^^^^^ no implementation for `i32 == impl Debug` + | ^^^^^^ no implementation for `i32 == Foo` | - = help: the trait `PartialEq<impl Debug>` is not implemented for `i32` + = help: the trait `PartialEq<Foo>` is not implemented for `i32` error: aborting due to previous error diff --git a/src/test/ui/type-alias-impl-trait/self-referential-4.rs b/src/test/ui/type-alias-impl-trait/self-referential-4.rs new file mode 100644 index 00000000000..697ec56825a --- /dev/null +++ b/src/test/ui/type-alias-impl-trait/self-referential-4.rs @@ -0,0 +1,25 @@ +#![feature(type_alias_impl_trait)] + +type Bar<'a, 'b> = impl PartialEq<Bar<'b, 'static>> + std::fmt::Debug; + +fn bar<'a, 'b>(i: &'a i32) -> Bar<'a, 'b> { + i //~ ERROR can't compare `&i32` with `Bar<'b, 'static>` +} + +type Foo<'a, 'b> = impl PartialEq<Foo<'static, 'b>> + std::fmt::Debug; + +fn foo<'a, 'b>(i: &'a i32) -> Foo<'a, 'b> { + i //~ ERROR can't compare `&i32` with `Foo<'static, 'b>` +} + +type Moo<'a, 'b> = impl PartialEq<Moo<'static, 'a>> + std::fmt::Debug; + +fn moo<'a, 'b>(i: &'a i32) -> Moo<'a, 'b> { + i //~ ERROR can't compare `&i32` with `Moo<'static, 'a>` +} + +fn main() { + let meh = 42; + let muh = 69; + assert_eq!(bar(&meh), bar(&meh)); +} diff --git a/src/test/ui/type-alias-impl-trait/self-referential-4.stderr b/src/test/ui/type-alias-impl-trait/self-referential-4.stderr new file mode 100644 index 00000000000..4a6ee2f9279 --- /dev/null +++ b/src/test/ui/type-alias-impl-trait/self-referential-4.stderr @@ -0,0 +1,27 @@ +error[E0277]: can't compare `&i32` with `Bar<'b, 'static>` + --> $DIR/self-referential-4.rs:6:5 + | +LL | i + | ^ no implementation for `&i32 == Bar<'b, 'static>` + | + = help: the trait `PartialEq<Bar<'b, 'static>>` is not implemented for `&i32` + +error[E0277]: can't compare `&i32` with `Foo<'static, 'b>` + --> $DIR/self-referential-4.rs:12:5 + | +LL | i + | ^ no implementation for `&i32 == Foo<'static, 'b>` + | + = help: the trait `PartialEq<Foo<'static, 'b>>` is not implemented for `&i32` + +error[E0277]: can't compare `&i32` with `Moo<'static, 'a>` + --> $DIR/self-referential-4.rs:18:5 + | +LL | i + | ^ no implementation for `&i32 == Moo<'static, 'a>` + | + = help: the trait `PartialEq<Moo<'static, 'a>>` is not implemented for `&i32` + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/type-alias-impl-trait/self-referential.rs b/src/test/ui/type-alias-impl-trait/self-referential.rs index 46468bc98b9..4974ac72dad 100644 --- a/src/test/ui/type-alias-impl-trait/self-referential.rs +++ b/src/test/ui/type-alias-impl-trait/self-referential.rs @@ -3,7 +3,19 @@ type Bar<'a, 'b> = impl PartialEq<Bar<'b, 'a>> + std::fmt::Debug; fn bar<'a, 'b>(i: &'a i32) -> Bar<'a, 'b> { - i //~ ERROR can't compare `&i32` with `impl PartialEq<Bar<'a, 'b> + i //~ ERROR can't compare `&i32` with `Bar<'b, 'a>` +} + +type Foo<'a, 'b> = (i32, impl PartialEq<Foo<'a, 'b>> + std::fmt::Debug); + +fn foo<'a, 'b>(i: &'a i32) -> Foo<'a, 'b> { + (42, i) //~ ERROR can't compare `&i32` with `(i32, &i32)` +} + +type Moo<'a, 'b> = (i32, impl PartialEq<Moo<'b, 'a>> + std::fmt::Debug); + +fn moo<'a, 'b>(i: &'a i32) -> Moo<'a, 'b> { + (42, i) //~ ERROR can't compare `&i32` with `(i32, Moo<'b, 'a>::{opaque#0})` } fn main() { diff --git a/src/test/ui/type-alias-impl-trait/self-referential.stderr b/src/test/ui/type-alias-impl-trait/self-referential.stderr index 29f1e0bec08..0626e6be0d5 100644 --- a/src/test/ui/type-alias-impl-trait/self-referential.stderr +++ b/src/test/ui/type-alias-impl-trait/self-referential.stderr @@ -1,11 +1,27 @@ -error[E0277]: can't compare `&i32` with `impl PartialEq<Bar<'a, 'b>::{opaque#0}> + Debug` +error[E0277]: can't compare `&i32` with `Bar<'b, 'a>` --> $DIR/self-referential.rs:6:5 | LL | i - | ^ no implementation for `&i32 == impl PartialEq<Bar<'a, 'b>::{opaque#0}> + Debug` + | ^ no implementation for `&i32 == Bar<'b, 'a>` | - = help: the trait `PartialEq<impl PartialEq<Bar<'a, 'b>::{opaque#0}> + Debug>` is not implemented for `&i32` + = help: the trait `PartialEq<Bar<'b, 'a>>` is not implemented for `&i32` -error: aborting due to previous error +error[E0277]: can't compare `&i32` with `(i32, &i32)` + --> $DIR/self-referential.rs:12:10 + | +LL | (42, i) + | ^ no implementation for `&i32 == (i32, &i32)` + | + = help: the trait `PartialEq<(i32, &i32)>` is not implemented for `&i32` + +error[E0277]: can't compare `&i32` with `(i32, Moo<'b, 'a>::{opaque#0})` + --> $DIR/self-referential.rs:18:10 + | +LL | (42, i) + | ^ no implementation for `&i32 == (i32, Moo<'b, 'a>::{opaque#0})` + | + = help: the trait `PartialEq<(i32, Moo<'b, 'a>::{opaque#0})>` is not implemented for `&i32` + +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/type-alias-impl-trait/structural-match-no-leak.rs b/src/test/ui/type-alias-impl-trait/structural-match-no-leak.rs index e0d24146179..cab742d23f5 100644 --- a/src/test/ui/type-alias-impl-trait/structural-match-no-leak.rs +++ b/src/test/ui/type-alias-impl-trait/structural-match-no-leak.rs @@ -13,7 +13,7 @@ const LEAK_FREE: Bar = leak_free(); fn leak_free_test() { match LEAK_FREE { LEAK_FREE => (), - //~^ `impl Send` cannot be used in patterns + //~^ `Bar` cannot be used in patterns _ => (), } } diff --git a/src/test/ui/type-alias-impl-trait/structural-match-no-leak.stderr b/src/test/ui/type-alias-impl-trait/structural-match-no-leak.stderr index 7e41b374452..aacc0cc7aa6 100644 --- a/src/test/ui/type-alias-impl-trait/structural-match-no-leak.stderr +++ b/src/test/ui/type-alias-impl-trait/structural-match-no-leak.stderr @@ -1,4 +1,4 @@ -error: `impl Send` cannot be used in patterns +error: `Bar` cannot be used in patterns --> $DIR/structural-match-no-leak.rs:15:9 | LL | LEAK_FREE => (), diff --git a/src/test/ui/type-alias-impl-trait/structural-match.rs b/src/test/ui/type-alias-impl-trait/structural-match.rs index 1a2c373bac1..c8825c68e33 100644 --- a/src/test/ui/type-alias-impl-trait/structural-match.rs +++ b/src/test/ui/type-alias-impl-trait/structural-match.rs @@ -14,7 +14,7 @@ const VALUE: Foo = value(); fn test() { match VALUE { VALUE => (), - //~^ `impl Send` cannot be used in patterns + //~^ `Foo` cannot be used in patterns _ => (), } } diff --git a/src/test/ui/type-alias-impl-trait/structural-match.stderr b/src/test/ui/type-alias-impl-trait/structural-match.stderr index b43f2148dea..28ae9c212d9 100644 --- a/src/test/ui/type-alias-impl-trait/structural-match.stderr +++ b/src/test/ui/type-alias-impl-trait/structural-match.stderr @@ -1,4 +1,4 @@ -error: `impl Send` cannot be used in patterns +error: `Foo` cannot be used in patterns --> $DIR/structural-match.rs:16:9 | LL | VALUE => (), diff --git a/src/test/ui/type-alias-impl-trait/type_of_a_let.stderr b/src/test/ui/type-alias-impl-trait/type_of_a_let.stderr index eccd3f9048f..1dabe4586c5 100644 --- a/src/test/ui/type-alias-impl-trait/type_of_a_let.stderr +++ b/src/test/ui/type-alias-impl-trait/type_of_a_let.stderr @@ -2,7 +2,7 @@ error[E0382]: use of moved value: `x` --> $DIR/type_of_a_let.rs:16:16 | LL | let x: Foo = 22_u32; - | - move occurs because `x` has type `impl Debug`, which does not implement the `Copy` trait + | - move occurs because `x` has type `Foo`, which does not implement the `Copy` trait LL | let y: Foo = x; | - value moved here LL | same_type((x, y)); @@ -12,7 +12,7 @@ error[E0382]: use of moved value: `y` --> $DIR/type_of_a_let.rs:17:5 | LL | let y: Foo = x; - | - move occurs because `y` has type `impl Debug`, which does not implement the `Copy` trait + | - move occurs because `y` has type `Foo`, which does not implement the `Copy` trait LL | same_type((x, y)); | - value moved here LL | y |
