From c2066cf0694c304c0fc43f17bebefb518b066619 Mon Sep 17 00:00:00 2001 From: Matthew Jasper Date: Tue, 9 Feb 2021 21:16:00 +0000 Subject: [PATCH] Remove unnecessary note on errors Seeing the trait definition doesn't help with implementation not general enough errors, so don't make the error message larger to show it. --- .../nice_region_error/placeholder_error.rs | 4 -- .../associated-types-eq-hr.stderr | 55 ++++--------------- .../ui/generator/auto-trait-regions.stderr | 12 ---- src/test/ui/hrtb/due-to-where-clause.stderr | 3 - .../ui/hrtb/hrtb-cache-issue-54302.stderr | 3 - src/test/ui/hrtb/hrtb-conflate-regions.stderr | 9 +-- ...b-exists-forall-trait-contravariant.stderr | 3 - .../hrtb-exists-forall-trait-invariant.stderr | 3 - src/test/ui/hrtb/hrtb-just-for-static.stderr | 18 ++---- src/test/ui/hrtb/issue-46989.stderr | 3 - src/test/ui/issues/issue-54302-cases.stderr | 36 +++--------- src/test/ui/issues/issue-54302.stderr | 3 - src/test/ui/issues/issue-55731.stderr | 9 +-- .../ui/where-clauses/where-for-self-2.stderr | 9 +-- 14 files changed, 28 insertions(+), 142 deletions(-) diff --git a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/placeholder_error.rs b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/placeholder_error.rs index 8c933df8ca0..d99e79005fb 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/placeholder_error.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/placeholder_error.rs @@ -207,10 +207,6 @@ impl NiceRegionError<'me, 'tcx> { self.tcx().def_path_str(trait_def_id), ); let mut err = self.tcx().sess.struct_span_err(span, &msg); - err.span_label( - self.tcx().def_span(trait_def_id), - format!("trait `{}` defined here", self.tcx().def_path_str(trait_def_id)), - ); let leading_ellipsis = if let ObligationCauseCode::ItemObligation(def_id) = cause.code { err.span_label(span, "doesn't satisfy where-clause"); diff --git a/src/test/ui/associated-types/associated-types-eq-hr.stderr b/src/test/ui/associated-types/associated-types-eq-hr.stderr index 127ab867355..6188d9ca979 100644 --- a/src/test/ui/associated-types/associated-types-eq-hr.stderr +++ b/src/test/ui/associated-types/associated-types-eq-hr.stderr @@ -31,15 +31,8 @@ LL | bar::(); error: implementation of `TheTrait` is not general enough --> $DIR/associated-types-eq-hr.rs:96:5 | -LL | / pub trait TheTrait { -LL | | type A; -LL | | -LL | | fn get(&self, t: T) -> Self::A; -LL | | } - | |_- trait `TheTrait` defined here -... -LL | tuple_one::(); - | ^^^^^^^^^^^^^^^^^^ implementation of `TheTrait` is not general enough +LL | tuple_one::(); + | ^^^^^^^^^^^^^^^^^^ implementation of `TheTrait` is not general enough | = note: `Tuple` must implement `TheTrait<(&'0 isize, &'1 isize)>`, for any two lifetimes `'0` and `'1`... = note: ...but `Tuple` actually implements `TheTrait<(&'2 isize, &'2 isize)>`, for some specific lifetime `'2` @@ -47,15 +40,8 @@ LL | tuple_one::(); error: implementation of `TheTrait` is not general enough --> $DIR/associated-types-eq-hr.rs:96:5 | -LL | / pub trait TheTrait { -LL | | type A; -LL | | -LL | | fn get(&self, t: T) -> Self::A; -LL | | } - | |_- trait `TheTrait` defined here -... -LL | tuple_one::(); - | ^^^^^^^^^^^^^^^^^^ implementation of `TheTrait` is not general enough +LL | tuple_one::(); + | ^^^^^^^^^^^^^^^^^^ implementation of `TheTrait` is not general enough | = note: `Tuple` must implement `TheTrait<(&'0 isize, &'1 isize)>`, for any two lifetimes `'0` and `'1`... = note: ...but `Tuple` actually implements `TheTrait<(&'2 isize, &'2 isize)>`, for some specific lifetime `'2` @@ -63,15 +49,8 @@ LL | tuple_one::(); error: implementation of `TheTrait` is not general enough --> $DIR/associated-types-eq-hr.rs:102:5 | -LL | / pub trait TheTrait { -LL | | type A; -LL | | -LL | | fn get(&self, t: T) -> Self::A; -LL | | } - | |_- trait `TheTrait` defined here -... -LL | tuple_two::(); - | ^^^^^^^^^^^^^^^^^^ implementation of `TheTrait` is not general enough +LL | tuple_two::(); + | ^^^^^^^^^^^^^^^^^^ implementation of `TheTrait` is not general enough | = note: `Tuple` must implement `TheTrait<(&'0 isize, &'1 isize)>`, for any two lifetimes `'0` and `'1`... = note: ...but `Tuple` actually implements `TheTrait<(&'2 isize, &'2 isize)>`, for some specific lifetime `'2` @@ -79,15 +58,8 @@ LL | tuple_two::(); error: implementation of `TheTrait` is not general enough --> $DIR/associated-types-eq-hr.rs:102:5 | -LL | / pub trait TheTrait { -LL | | type A; -LL | | -LL | | fn get(&self, t: T) -> Self::A; -LL | | } - | |_- trait `TheTrait` defined here -... -LL | tuple_two::(); - | ^^^^^^^^^^^^^^^^^^ implementation of `TheTrait` is not general enough +LL | tuple_two::(); + | ^^^^^^^^^^^^^^^^^^ implementation of `TheTrait` is not general enough | = note: `Tuple` must implement `TheTrait<(&'0 isize, &'1 isize)>`, for any two lifetimes `'0` and `'1`... = note: ...but `Tuple` actually implements `TheTrait<(&'2 isize, &'2 isize)>`, for some specific lifetime `'2` @@ -95,15 +67,8 @@ LL | tuple_two::(); error: implementation of `TheTrait` is not general enough --> $DIR/associated-types-eq-hr.rs:112:5 | -LL | / pub trait TheTrait { -LL | | type A; -LL | | -LL | | fn get(&self, t: T) -> Self::A; -LL | | } - | |_- trait `TheTrait` defined here -... -LL | tuple_four::(); - | ^^^^^^^^^^^^^^^^^^^ implementation of `TheTrait` is not general enough +LL | tuple_four::(); + | ^^^^^^^^^^^^^^^^^^^ implementation of `TheTrait` is not general enough | = note: `Tuple` must implement `TheTrait<(&'0 isize, &'1 isize)>`, for any two lifetimes `'0` and `'1`... = note: ...but `Tuple` actually implements `TheTrait<(&'2 isize, &'2 isize)>`, for some specific lifetime `'2` diff --git a/src/test/ui/generator/auto-trait-regions.stderr b/src/test/ui/generator/auto-trait-regions.stderr index 5ec462e1046..5fe4193905c 100644 --- a/src/test/ui/generator/auto-trait-regions.stderr +++ b/src/test/ui/generator/auto-trait-regions.stderr @@ -1,9 +1,6 @@ error: implementation of `Foo` is not general enough --> $DIR/auto-trait-regions.rs:31:5 | -LL | auto trait Foo {} - | ----------------- trait `Foo` defined here -... LL | assert_foo(gen); | ^^^^^^^^^^ implementation of `Foo` is not general enough | @@ -13,9 +10,6 @@ LL | assert_foo(gen); error: implementation of `Foo` is not general enough --> $DIR/auto-trait-regions.rs:31:5 | -LL | auto trait Foo {} - | ----------------- trait `Foo` defined here -... LL | assert_foo(gen); | ^^^^^^^^^^ implementation of `Foo` is not general enough | @@ -25,9 +19,6 @@ LL | assert_foo(gen); error: implementation of `Foo` is not general enough --> $DIR/auto-trait-regions.rs:50:5 | -LL | auto trait Foo {} - | ----------------- trait `Foo` defined here -... LL | assert_foo(gen); | ^^^^^^^^^^ implementation of `Foo` is not general enough | @@ -37,9 +28,6 @@ LL | assert_foo(gen); error: implementation of `Foo` is not general enough --> $DIR/auto-trait-regions.rs:50:5 | -LL | auto trait Foo {} - | ----------------- trait `Foo` defined here -... LL | assert_foo(gen); | ^^^^^^^^^^ implementation of `Foo` is not general enough | diff --git a/src/test/ui/hrtb/due-to-where-clause.stderr b/src/test/ui/hrtb/due-to-where-clause.stderr index e4096ec059a..520938a6335 100644 --- a/src/test/ui/hrtb/due-to-where-clause.stderr +++ b/src/test/ui/hrtb/due-to-where-clause.stderr @@ -3,9 +3,6 @@ error: implementation of `Foo` is not general enough | LL | test::(&mut 42); | ^^^^^^^^^^^^ implementation of `Foo` is not general enough -... -LL | trait Foo<'a> {} - | ---------------- trait `Foo` defined here | = note: `FooS<'_>` must implement `Foo<'0>`, for any lifetime `'0`... = note: ...but `FooS<'_>` actually implements `Foo<'1>`, for some specific lifetime `'1` diff --git a/src/test/ui/hrtb/hrtb-cache-issue-54302.stderr b/src/test/ui/hrtb/hrtb-cache-issue-54302.stderr index 003f3265935..f014eab8601 100644 --- a/src/test/ui/hrtb/hrtb-cache-issue-54302.stderr +++ b/src/test/ui/hrtb/hrtb-cache-issue-54302.stderr @@ -1,9 +1,6 @@ error: implementation of `Deserialize` is not general enough --> $DIR/hrtb-cache-issue-54302.rs:19:5 | -LL | trait Deserialize<'de> {} - | ------------------------- trait `Deserialize` defined here -... LL | assert_deserialize_owned::<&'static str>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Deserialize` is not general enough | diff --git a/src/test/ui/hrtb/hrtb-conflate-regions.stderr b/src/test/ui/hrtb/hrtb-conflate-regions.stderr index 45573814d13..7a0ede5af20 100644 --- a/src/test/ui/hrtb/hrtb-conflate-regions.stderr +++ b/src/test/ui/hrtb/hrtb-conflate-regions.stderr @@ -1,13 +1,8 @@ error: implementation of `Foo` is not general enough --> $DIR/hrtb-conflate-regions.rs:27:10 | -LL | / trait Foo { -LL | | fn foo(&self, x: X) { } -LL | | } - | |_- trait `Foo` defined here -... -LL | fn b() { want_foo2::(); } - | ^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough +LL | fn b() { want_foo2::(); } + | ^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough | = note: `SomeStruct` must implement `Foo<(&'0 isize, &'1 isize)>`, for any two lifetimes `'0` and `'1`... = note: ...but `SomeStruct` actually implements `Foo<(&'2 isize, &'2 isize)>`, for some specific lifetime `'2` diff --git a/src/test/ui/hrtb/hrtb-exists-forall-trait-contravariant.stderr b/src/test/ui/hrtb/hrtb-exists-forall-trait-contravariant.stderr index fe8209d054c..2f946c7d9bf 100644 --- a/src/test/ui/hrtb/hrtb-exists-forall-trait-contravariant.stderr +++ b/src/test/ui/hrtb/hrtb-exists-forall-trait-contravariant.stderr @@ -1,9 +1,6 @@ error: implementation of `Trait` is not general enough --> $DIR/hrtb-exists-forall-trait-contravariant.rs:34:5 | -LL | trait Trait {} - | ----------------- trait `Trait` defined here -... LL | foo::<()>(); | ^^^^^^^^^ implementation of `Trait` is not general enough | diff --git a/src/test/ui/hrtb/hrtb-exists-forall-trait-invariant.stderr b/src/test/ui/hrtb/hrtb-exists-forall-trait-invariant.stderr index 8bd23aa9018..ba244e0f2eb 100644 --- a/src/test/ui/hrtb/hrtb-exists-forall-trait-invariant.stderr +++ b/src/test/ui/hrtb/hrtb-exists-forall-trait-invariant.stderr @@ -1,9 +1,6 @@ error: implementation of `Trait` is not general enough --> $DIR/hrtb-exists-forall-trait-invariant.rs:28:5 | -LL | trait Trait {} - | ----------------- trait `Trait` defined here -... LL | foo::<()>(); | ^^^^^^^^^ implementation of `Trait` is not general enough | diff --git a/src/test/ui/hrtb/hrtb-just-for-static.stderr b/src/test/ui/hrtb/hrtb-just-for-static.stderr index 5e3014317f5..0d46a130e09 100644 --- a/src/test/ui/hrtb/hrtb-just-for-static.stderr +++ b/src/test/ui/hrtb/hrtb-just-for-static.stderr @@ -1,13 +1,8 @@ error: implementation of `Foo` is not general enough --> $DIR/hrtb-just-for-static.rs:24:5 | -LL | / trait Foo { -LL | | fn foo(&self, x: X) { } -LL | | } - | |_- trait `Foo` defined here -... -LL | want_hrtb::() - | ^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough +LL | want_hrtb::() + | ^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough | = note: `StaticInt` must implement `Foo<&'0 isize>`, for any lifetime `'0`... = note: ...but `StaticInt` actually implements `Foo<&'1 isize>`, for some specific lifetime `'1` @@ -15,13 +10,8 @@ LL | want_hrtb::() error: implementation of `Foo` is not general enough --> $DIR/hrtb-just-for-static.rs:30:5 | -LL | / trait Foo { -LL | | fn foo(&self, x: X) { } -LL | | } - | |_- trait `Foo` defined here -... -LL | want_hrtb::<&'a u32>() - | ^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough +LL | want_hrtb::<&'a u32>() + | ^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough | = note: `Foo<&'0 isize>` would have to be implemented for the type `&'a u32`, for any lifetime `'0`... = note: ...but `Foo<&'1 isize>` is actually implemented for the type `&'1 u32`, for some specific lifetime `'1` diff --git a/src/test/ui/hrtb/issue-46989.stderr b/src/test/ui/hrtb/issue-46989.stderr index c85c37ff923..f3d906cae4c 100644 --- a/src/test/ui/hrtb/issue-46989.stderr +++ b/src/test/ui/hrtb/issue-46989.stderr @@ -1,9 +1,6 @@ error: implementation of `Foo` is not general enough --> $DIR/issue-46989.rs:38:5 | -LL | trait Foo {} - | ------------ trait `Foo` defined here -... LL | assert_foo::(); | ^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough | diff --git a/src/test/ui/issues/issue-54302-cases.stderr b/src/test/ui/issues/issue-54302-cases.stderr index 3ed27791643..baa75f28d37 100644 --- a/src/test/ui/issues/issue-54302-cases.stderr +++ b/src/test/ui/issues/issue-54302-cases.stderr @@ -1,13 +1,8 @@ error: implementation of `Foo` is not general enough --> $DIR/issue-54302-cases.rs:63:5 | -LL | / trait Foo<'x, T> { -LL | | fn foo(self) -> &'x T; -LL | | } - | |_- trait `Foo` defined here -... -LL | >::ref_foo(a) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough +LL | >::ref_foo(a) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough | = note: `Foo<'static, u32>` would have to be implemented for the type `&'0 u32`, for any lifetime `'0`... = note: ...but `Foo<'_, u32>` is actually implemented for the type `&'1 u32`, for some specific lifetime `'1` @@ -15,13 +10,8 @@ LL | >::ref_foo(a) error: implementation of `Foo` is not general enough --> $DIR/issue-54302-cases.rs:69:5 | -LL | / trait Foo<'x, T> { -LL | | fn foo(self) -> &'x T; -LL | | } - | |_- trait `Foo` defined here -... -LL | >::ref_foo(a) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough +LL | >::ref_foo(a) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough | = note: `Foo<'static, i32>` would have to be implemented for the type `&'0 i32`, for any lifetime `'0`... = note: ...but `Foo<'_, i32>` is actually implemented for the type `&'1 i32`, for some specific lifetime `'1` @@ -29,13 +19,8 @@ LL | >::ref_foo(a) error: implementation of `Foo` is not general enough --> $DIR/issue-54302-cases.rs:75:5 | -LL | / trait Foo<'x, T> { -LL | | fn foo(self) -> &'x T; -LL | | } - | |_- trait `Foo` defined here -... -LL | >::ref_foo(a) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough +LL | >::ref_foo(a) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough | = note: `Foo<'static, u64>` would have to be implemented for the type `&'0 u64`, for any lifetime `'0`... = note: ...but `Foo<'_, u64>` is actually implemented for the type `&'1 u64`, for some specific lifetime `'1` @@ -43,13 +28,8 @@ LL | >::ref_foo(a) error: implementation of `Foo` is not general enough --> $DIR/issue-54302-cases.rs:81:5 | -LL | / trait Foo<'x, T> { -LL | | fn foo(self) -> &'x T; -LL | | } - | |_- trait `Foo` defined here -... -LL | >::ref_foo(a) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough +LL | >::ref_foo(a) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough | = note: `Foo<'static, i64>` would have to be implemented for the type `&'0 i64`, for any lifetime `'0`... = note: ...but `Foo<'_, i64>` is actually implemented for the type `&'1 i64`, for some specific lifetime `'1` diff --git a/src/test/ui/issues/issue-54302.stderr b/src/test/ui/issues/issue-54302.stderr index 1b3f57ba188..26c46571f9c 100644 --- a/src/test/ui/issues/issue-54302.stderr +++ b/src/test/ui/issues/issue-54302.stderr @@ -1,9 +1,6 @@ error: implementation of `Deserialize` is not general enough --> $DIR/issue-54302.rs:13:5 | -LL | trait Deserialize<'de> {} - | ------------------------- trait `Deserialize` defined here -... LL | assert_deserialize_owned::<&'static str>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Deserialize` is not general enough | diff --git a/src/test/ui/issues/issue-55731.stderr b/src/test/ui/issues/issue-55731.stderr index f44c842187c..de327cd3cc2 100644 --- a/src/test/ui/issues/issue-55731.stderr +++ b/src/test/ui/issues/issue-55731.stderr @@ -1,13 +1,8 @@ error: implementation of `DistributedIteratorMulti` is not general enough --> $DIR/issue-55731.rs:48:5 | -LL | / trait DistributedIteratorMulti { -LL | | type Item; -LL | | } - | |_- trait `DistributedIteratorMulti` defined here -... -LL | multi(Map { - | ^^^^^ implementation of `DistributedIteratorMulti` is not general enough +LL | multi(Map { + | ^^^^^ implementation of `DistributedIteratorMulti` is not general enough | = note: `DistributedIteratorMulti<&'0 ()>` would have to be implemented for the type `Cloned<&()>`, for any lifetime `'0`... = note: ...but `DistributedIteratorMulti<&'1 ()>` is actually implemented for the type `Cloned<&'1 ()>`, for some specific lifetime `'1` diff --git a/src/test/ui/where-clauses/where-for-self-2.stderr b/src/test/ui/where-clauses/where-for-self-2.stderr index 30eb78b2da4..4f8b19291db 100644 --- a/src/test/ui/where-clauses/where-for-self-2.stderr +++ b/src/test/ui/where-clauses/where-for-self-2.stderr @@ -1,13 +1,8 @@ error: implementation of `Bar` is not general enough --> $DIR/where-for-self-2.rs:23:5 | -LL | / trait Bar { -LL | | fn bar(&self); -LL | | } - | |_- trait `Bar` defined here -... -LL | foo(&X); - | ^^^ implementation of `Bar` is not general enough +LL | foo(&X); + | ^^^ implementation of `Bar` is not general enough | = note: `Bar` would have to be implemented for the type `&'0 u32`, for any lifetime `'0`... = note: ...but `Bar` is actually implemented for the type `&'1 u32`, for some specific lifetime `'1`