Skip to content

Commit

Permalink
Remove unnecessary note on errors
Browse files Browse the repository at this point in the history
Seeing the trait definition doesn't help with implementation not general
enough errors, so don't make the error message larger to show it.
  • Loading branch information
matthewjasper committed Feb 9, 2021
1 parent 638980a commit c2066cf
Show file tree
Hide file tree
Showing 14 changed files with 28 additions and 142 deletions.
Expand Up @@ -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");
Expand Down
55 changes: 10 additions & 45 deletions src/test/ui/associated-types/associated-types-eq-hr.stderr
Expand Up @@ -31,79 +31,44 @@ LL | bar::<IntStruct>();
error: implementation of `TheTrait` is not general enough
--> $DIR/associated-types-eq-hr.rs:96:5
|
LL | / pub trait TheTrait<T> {
LL | | type A;
LL | |
LL | | fn get(&self, t: T) -> Self::A;
LL | | }
| |_- trait `TheTrait` defined here
...
LL | tuple_one::<Tuple>();
| ^^^^^^^^^^^^^^^^^^ implementation of `TheTrait` is not general enough
LL | tuple_one::<Tuple>();
| ^^^^^^^^^^^^^^^^^^ 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`

error: implementation of `TheTrait` is not general enough
--> $DIR/associated-types-eq-hr.rs:96:5
|
LL | / pub trait TheTrait<T> {
LL | | type A;
LL | |
LL | | fn get(&self, t: T) -> Self::A;
LL | | }
| |_- trait `TheTrait` defined here
...
LL | tuple_one::<Tuple>();
| ^^^^^^^^^^^^^^^^^^ implementation of `TheTrait` is not general enough
LL | tuple_one::<Tuple>();
| ^^^^^^^^^^^^^^^^^^ 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`

error: implementation of `TheTrait` is not general enough
--> $DIR/associated-types-eq-hr.rs:102:5
|
LL | / pub trait TheTrait<T> {
LL | | type A;
LL | |
LL | | fn get(&self, t: T) -> Self::A;
LL | | }
| |_- trait `TheTrait` defined here
...
LL | tuple_two::<Tuple>();
| ^^^^^^^^^^^^^^^^^^ implementation of `TheTrait` is not general enough
LL | tuple_two::<Tuple>();
| ^^^^^^^^^^^^^^^^^^ 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`

error: implementation of `TheTrait` is not general enough
--> $DIR/associated-types-eq-hr.rs:102:5
|
LL | / pub trait TheTrait<T> {
LL | | type A;
LL | |
LL | | fn get(&self, t: T) -> Self::A;
LL | | }
| |_- trait `TheTrait` defined here
...
LL | tuple_two::<Tuple>();
| ^^^^^^^^^^^^^^^^^^ implementation of `TheTrait` is not general enough
LL | tuple_two::<Tuple>();
| ^^^^^^^^^^^^^^^^^^ 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`

error: implementation of `TheTrait` is not general enough
--> $DIR/associated-types-eq-hr.rs:112:5
|
LL | / pub trait TheTrait<T> {
LL | | type A;
LL | |
LL | | fn get(&self, t: T) -> Self::A;
LL | | }
| |_- trait `TheTrait` defined here
...
LL | tuple_four::<Tuple>();
| ^^^^^^^^^^^^^^^^^^^ implementation of `TheTrait` is not general enough
LL | tuple_four::<Tuple>();
| ^^^^^^^^^^^^^^^^^^^ 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`
Expand Down
12 changes: 0 additions & 12 deletions 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
|
Expand All @@ -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
|
Expand All @@ -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
|
Expand All @@ -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
|
Expand Down
3 changes: 0 additions & 3 deletions src/test/ui/hrtb/due-to-where-clause.stderr
Expand Up @@ -3,9 +3,6 @@ error: implementation of `Foo` is not general enough
|
LL | test::<FooS>(&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`
Expand Down
3 changes: 0 additions & 3 deletions 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
|
Expand Down
9 changes: 2 additions & 7 deletions 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<X> {
LL | | fn foo(&self, x: X) { }
LL | | }
| |_- trait `Foo` defined here
...
LL | fn b() { want_foo2::<SomeStruct>(); }
| ^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough
LL | fn b() { want_foo2::<SomeStruct>(); }
| ^^^^^^^^^^^^^^^^^^^^^^^ 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`
Expand Down
@@ -1,9 +1,6 @@
error: implementation of `Trait` is not general enough
--> $DIR/hrtb-exists-forall-trait-contravariant.rs:34:5
|
LL | trait Trait<T> {}
| ----------------- trait `Trait` defined here
...
LL | foo::<()>();
| ^^^^^^^^^ implementation of `Trait` is not general enough
|
Expand Down
3 changes: 0 additions & 3 deletions 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<T> {}
| ----------------- trait `Trait` defined here
...
LL | foo::<()>();
| ^^^^^^^^^ implementation of `Trait` is not general enough
|
Expand Down
18 changes: 4 additions & 14 deletions src/test/ui/hrtb/hrtb-just-for-static.stderr
@@ -1,27 +1,17 @@
error: implementation of `Foo` is not general enough
--> $DIR/hrtb-just-for-static.rs:24:5
|
LL | / trait Foo<X> {
LL | | fn foo(&self, x: X) { }
LL | | }
| |_- trait `Foo` defined here
...
LL | want_hrtb::<StaticInt>()
| ^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough
LL | want_hrtb::<StaticInt>()
| ^^^^^^^^^^^^^^^^^^^^^^ 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`

error: implementation of `Foo` is not general enough
--> $DIR/hrtb-just-for-static.rs:30:5
|
LL | / trait Foo<X> {
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`
Expand Down
3 changes: 0 additions & 3 deletions 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::<fn(&i32)>();
| ^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough
|
Expand Down
36 changes: 8 additions & 28 deletions src/test/ui/issues/issue-54302-cases.stderr
@@ -1,55 +1,35 @@
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 | <u32 as RefFoo<u32>>::ref_foo(a)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough
LL | <u32 as RefFoo<u32>>::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`

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 | <i32 as RefFoo<i32>>::ref_foo(a)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough
LL | <i32 as RefFoo<i32>>::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`

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 | <u64 as RefFoo<u64>>::ref_foo(a)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough
LL | <u64 as RefFoo<u64>>::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`

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 | <i64 as RefFoo<i64>>::ref_foo(a)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough
LL | <i64 as RefFoo<i64>>::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`
Expand Down
3 changes: 0 additions & 3 deletions 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
|
Expand Down
9 changes: 2 additions & 7 deletions 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<Source> {
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`
Expand Down
9 changes: 2 additions & 7 deletions 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`
Expand Down

0 comments on commit c2066cf

Please sign in to comment.