Skip to content

Commit c2066cf

Browse files
committed
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.
1 parent 638980a commit c2066cf

14 files changed

+28
-142
lines changed

compiler/rustc_infer/src/infer/error_reporting/nice_region_error/placeholder_error.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,10 +207,6 @@ impl NiceRegionError<'me, 'tcx> {
207207
self.tcx().def_path_str(trait_def_id),
208208
);
209209
let mut err = self.tcx().sess.struct_span_err(span, &msg);
210-
err.span_label(
211-
self.tcx().def_span(trait_def_id),
212-
format!("trait `{}` defined here", self.tcx().def_path_str(trait_def_id)),
213-
);
214210

215211
let leading_ellipsis = if let ObligationCauseCode::ItemObligation(def_id) = cause.code {
216212
err.span_label(span, "doesn't satisfy where-clause");

src/test/ui/associated-types/associated-types-eq-hr.stderr

Lines changed: 10 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -31,79 +31,44 @@ LL | bar::<IntStruct>();
3131
error: implementation of `TheTrait` is not general enough
3232
--> $DIR/associated-types-eq-hr.rs:96:5
3333
|
34-
LL | / pub trait TheTrait<T> {
35-
LL | | type A;
36-
LL | |
37-
LL | | fn get(&self, t: T) -> Self::A;
38-
LL | | }
39-
| |_- trait `TheTrait` defined here
40-
...
41-
LL | tuple_one::<Tuple>();
42-
| ^^^^^^^^^^^^^^^^^^ implementation of `TheTrait` is not general enough
34+
LL | tuple_one::<Tuple>();
35+
| ^^^^^^^^^^^^^^^^^^ implementation of `TheTrait` is not general enough
4336
|
4437
= note: `Tuple` must implement `TheTrait<(&'0 isize, &'1 isize)>`, for any two lifetimes `'0` and `'1`...
4538
= note: ...but `Tuple` actually implements `TheTrait<(&'2 isize, &'2 isize)>`, for some specific lifetime `'2`
4639

4740
error: implementation of `TheTrait` is not general enough
4841
--> $DIR/associated-types-eq-hr.rs:96:5
4942
|
50-
LL | / pub trait TheTrait<T> {
51-
LL | | type A;
52-
LL | |
53-
LL | | fn get(&self, t: T) -> Self::A;
54-
LL | | }
55-
| |_- trait `TheTrait` defined here
56-
...
57-
LL | tuple_one::<Tuple>();
58-
| ^^^^^^^^^^^^^^^^^^ implementation of `TheTrait` is not general enough
43+
LL | tuple_one::<Tuple>();
44+
| ^^^^^^^^^^^^^^^^^^ implementation of `TheTrait` is not general enough
5945
|
6046
= note: `Tuple` must implement `TheTrait<(&'0 isize, &'1 isize)>`, for any two lifetimes `'0` and `'1`...
6147
= note: ...but `Tuple` actually implements `TheTrait<(&'2 isize, &'2 isize)>`, for some specific lifetime `'2`
6248

6349
error: implementation of `TheTrait` is not general enough
6450
--> $DIR/associated-types-eq-hr.rs:102:5
6551
|
66-
LL | / pub trait TheTrait<T> {
67-
LL | | type A;
68-
LL | |
69-
LL | | fn get(&self, t: T) -> Self::A;
70-
LL | | }
71-
| |_- trait `TheTrait` defined here
72-
...
73-
LL | tuple_two::<Tuple>();
74-
| ^^^^^^^^^^^^^^^^^^ implementation of `TheTrait` is not general enough
52+
LL | tuple_two::<Tuple>();
53+
| ^^^^^^^^^^^^^^^^^^ implementation of `TheTrait` is not general enough
7554
|
7655
= note: `Tuple` must implement `TheTrait<(&'0 isize, &'1 isize)>`, for any two lifetimes `'0` and `'1`...
7756
= note: ...but `Tuple` actually implements `TheTrait<(&'2 isize, &'2 isize)>`, for some specific lifetime `'2`
7857

7958
error: implementation of `TheTrait` is not general enough
8059
--> $DIR/associated-types-eq-hr.rs:102:5
8160
|
82-
LL | / pub trait TheTrait<T> {
83-
LL | | type A;
84-
LL | |
85-
LL | | fn get(&self, t: T) -> Self::A;
86-
LL | | }
87-
| |_- trait `TheTrait` defined here
88-
...
89-
LL | tuple_two::<Tuple>();
90-
| ^^^^^^^^^^^^^^^^^^ implementation of `TheTrait` is not general enough
61+
LL | tuple_two::<Tuple>();
62+
| ^^^^^^^^^^^^^^^^^^ implementation of `TheTrait` is not general enough
9163
|
9264
= note: `Tuple` must implement `TheTrait<(&'0 isize, &'1 isize)>`, for any two lifetimes `'0` and `'1`...
9365
= note: ...but `Tuple` actually implements `TheTrait<(&'2 isize, &'2 isize)>`, for some specific lifetime `'2`
9466

9567
error: implementation of `TheTrait` is not general enough
9668
--> $DIR/associated-types-eq-hr.rs:112:5
9769
|
98-
LL | / pub trait TheTrait<T> {
99-
LL | | type A;
100-
LL | |
101-
LL | | fn get(&self, t: T) -> Self::A;
102-
LL | | }
103-
| |_- trait `TheTrait` defined here
104-
...
105-
LL | tuple_four::<Tuple>();
106-
| ^^^^^^^^^^^^^^^^^^^ implementation of `TheTrait` is not general enough
70+
LL | tuple_four::<Tuple>();
71+
| ^^^^^^^^^^^^^^^^^^^ implementation of `TheTrait` is not general enough
10772
|
10873
= note: `Tuple` must implement `TheTrait<(&'0 isize, &'1 isize)>`, for any two lifetimes `'0` and `'1`...
10974
= note: ...but `Tuple` actually implements `TheTrait<(&'2 isize, &'2 isize)>`, for some specific lifetime `'2`

src/test/ui/generator/auto-trait-regions.stderr

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
error: implementation of `Foo` is not general enough
22
--> $DIR/auto-trait-regions.rs:31:5
33
|
4-
LL | auto trait Foo {}
5-
| ----------------- trait `Foo` defined here
6-
...
74
LL | assert_foo(gen);
85
| ^^^^^^^^^^ implementation of `Foo` is not general enough
96
|
@@ -13,9 +10,6 @@ LL | assert_foo(gen);
1310
error: implementation of `Foo` is not general enough
1411
--> $DIR/auto-trait-regions.rs:31:5
1512
|
16-
LL | auto trait Foo {}
17-
| ----------------- trait `Foo` defined here
18-
...
1913
LL | assert_foo(gen);
2014
| ^^^^^^^^^^ implementation of `Foo` is not general enough
2115
|
@@ -25,9 +19,6 @@ LL | assert_foo(gen);
2519
error: implementation of `Foo` is not general enough
2620
--> $DIR/auto-trait-regions.rs:50:5
2721
|
28-
LL | auto trait Foo {}
29-
| ----------------- trait `Foo` defined here
30-
...
3122
LL | assert_foo(gen);
3223
| ^^^^^^^^^^ implementation of `Foo` is not general enough
3324
|
@@ -37,9 +28,6 @@ LL | assert_foo(gen);
3728
error: implementation of `Foo` is not general enough
3829
--> $DIR/auto-trait-regions.rs:50:5
3930
|
40-
LL | auto trait Foo {}
41-
| ----------------- trait `Foo` defined here
42-
...
4331
LL | assert_foo(gen);
4432
| ^^^^^^^^^^ implementation of `Foo` is not general enough
4533
|

src/test/ui/hrtb/due-to-where-clause.stderr

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@ error: implementation of `Foo` is not general enough
33
|
44
LL | test::<FooS>(&mut 42);
55
| ^^^^^^^^^^^^ implementation of `Foo` is not general enough
6-
...
7-
LL | trait Foo<'a> {}
8-
| ---------------- trait `Foo` defined here
96
|
107
= note: `FooS<'_>` must implement `Foo<'0>`, for any lifetime `'0`...
118
= note: ...but `FooS<'_>` actually implements `Foo<'1>`, for some specific lifetime `'1`

src/test/ui/hrtb/hrtb-cache-issue-54302.stderr

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
error: implementation of `Deserialize` is not general enough
22
--> $DIR/hrtb-cache-issue-54302.rs:19:5
33
|
4-
LL | trait Deserialize<'de> {}
5-
| ------------------------- trait `Deserialize` defined here
6-
...
74
LL | assert_deserialize_owned::<&'static str>();
85
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Deserialize` is not general enough
96
|

src/test/ui/hrtb/hrtb-conflate-regions.stderr

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
error: implementation of `Foo` is not general enough
22
--> $DIR/hrtb-conflate-regions.rs:27:10
33
|
4-
LL | / trait Foo<X> {
5-
LL | | fn foo(&self, x: X) { }
6-
LL | | }
7-
| |_- trait `Foo` defined here
8-
...
9-
LL | fn b() { want_foo2::<SomeStruct>(); }
10-
| ^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough
4+
LL | fn b() { want_foo2::<SomeStruct>(); }
5+
| ^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough
116
|
127
= note: `SomeStruct` must implement `Foo<(&'0 isize, &'1 isize)>`, for any two lifetimes `'0` and `'1`...
138
= note: ...but `SomeStruct` actually implements `Foo<(&'2 isize, &'2 isize)>`, for some specific lifetime `'2`

src/test/ui/hrtb/hrtb-exists-forall-trait-contravariant.stderr

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
error: implementation of `Trait` is not general enough
22
--> $DIR/hrtb-exists-forall-trait-contravariant.rs:34:5
33
|
4-
LL | trait Trait<T> {}
5-
| ----------------- trait `Trait` defined here
6-
...
74
LL | foo::<()>();
85
| ^^^^^^^^^ implementation of `Trait` is not general enough
96
|

src/test/ui/hrtb/hrtb-exists-forall-trait-invariant.stderr

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
error: implementation of `Trait` is not general enough
22
--> $DIR/hrtb-exists-forall-trait-invariant.rs:28:5
33
|
4-
LL | trait Trait<T> {}
5-
| ----------------- trait `Trait` defined here
6-
...
74
LL | foo::<()>();
85
| ^^^^^^^^^ implementation of `Trait` is not general enough
96
|

src/test/ui/hrtb/hrtb-just-for-static.stderr

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,17 @@
11
error: implementation of `Foo` is not general enough
22
--> $DIR/hrtb-just-for-static.rs:24:5
33
|
4-
LL | / trait Foo<X> {
5-
LL | | fn foo(&self, x: X) { }
6-
LL | | }
7-
| |_- trait `Foo` defined here
8-
...
9-
LL | want_hrtb::<StaticInt>()
10-
| ^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough
4+
LL | want_hrtb::<StaticInt>()
5+
| ^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough
116
|
127
= note: `StaticInt` must implement `Foo<&'0 isize>`, for any lifetime `'0`...
138
= note: ...but `StaticInt` actually implements `Foo<&'1 isize>`, for some specific lifetime `'1`
149

1510
error: implementation of `Foo` is not general enough
1611
--> $DIR/hrtb-just-for-static.rs:30:5
1712
|
18-
LL | / trait Foo<X> {
19-
LL | | fn foo(&self, x: X) { }
20-
LL | | }
21-
| |_- trait `Foo` defined here
22-
...
23-
LL | want_hrtb::<&'a u32>()
24-
| ^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough
13+
LL | want_hrtb::<&'a u32>()
14+
| ^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough
2515
|
2616
= note: `Foo<&'0 isize>` would have to be implemented for the type `&'a u32`, for any lifetime `'0`...
2717
= note: ...but `Foo<&'1 isize>` is actually implemented for the type `&'1 u32`, for some specific lifetime `'1`

src/test/ui/hrtb/issue-46989.stderr

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
error: implementation of `Foo` is not general enough
22
--> $DIR/issue-46989.rs:38:5
33
|
4-
LL | trait Foo {}
5-
| ------------ trait `Foo` defined here
6-
...
74
LL | assert_foo::<fn(&i32)>();
85
| ^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough
96
|

src/test/ui/issues/issue-54302-cases.stderr

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,35 @@
11
error: implementation of `Foo` is not general enough
22
--> $DIR/issue-54302-cases.rs:63:5
33
|
4-
LL | / trait Foo<'x, T> {
5-
LL | | fn foo(self) -> &'x T;
6-
LL | | }
7-
| |_- trait `Foo` defined here
8-
...
9-
LL | <u32 as RefFoo<u32>>::ref_foo(a)
10-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough
4+
LL | <u32 as RefFoo<u32>>::ref_foo(a)
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough
116
|
127
= note: `Foo<'static, u32>` would have to be implemented for the type `&'0 u32`, for any lifetime `'0`...
138
= note: ...but `Foo<'_, u32>` is actually implemented for the type `&'1 u32`, for some specific lifetime `'1`
149

1510
error: implementation of `Foo` is not general enough
1611
--> $DIR/issue-54302-cases.rs:69:5
1712
|
18-
LL | / trait Foo<'x, T> {
19-
LL | | fn foo(self) -> &'x T;
20-
LL | | }
21-
| |_- trait `Foo` defined here
22-
...
23-
LL | <i32 as RefFoo<i32>>::ref_foo(a)
24-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough
13+
LL | <i32 as RefFoo<i32>>::ref_foo(a)
14+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough
2515
|
2616
= note: `Foo<'static, i32>` would have to be implemented for the type `&'0 i32`, for any lifetime `'0`...
2717
= note: ...but `Foo<'_, i32>` is actually implemented for the type `&'1 i32`, for some specific lifetime `'1`
2818

2919
error: implementation of `Foo` is not general enough
3020
--> $DIR/issue-54302-cases.rs:75:5
3121
|
32-
LL | / trait Foo<'x, T> {
33-
LL | | fn foo(self) -> &'x T;
34-
LL | | }
35-
| |_- trait `Foo` defined here
36-
...
37-
LL | <u64 as RefFoo<u64>>::ref_foo(a)
38-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough
22+
LL | <u64 as RefFoo<u64>>::ref_foo(a)
23+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough
3924
|
4025
= note: `Foo<'static, u64>` would have to be implemented for the type `&'0 u64`, for any lifetime `'0`...
4126
= note: ...but `Foo<'_, u64>` is actually implemented for the type `&'1 u64`, for some specific lifetime `'1`
4227

4328
error: implementation of `Foo` is not general enough
4429
--> $DIR/issue-54302-cases.rs:81:5
4530
|
46-
LL | / trait Foo<'x, T> {
47-
LL | | fn foo(self) -> &'x T;
48-
LL | | }
49-
| |_- trait `Foo` defined here
50-
...
51-
LL | <i64 as RefFoo<i64>>::ref_foo(a)
52-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough
31+
LL | <i64 as RefFoo<i64>>::ref_foo(a)
32+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough
5333
|
5434
= note: `Foo<'static, i64>` would have to be implemented for the type `&'0 i64`, for any lifetime `'0`...
5535
= note: ...but `Foo<'_, i64>` is actually implemented for the type `&'1 i64`, for some specific lifetime `'1`

src/test/ui/issues/issue-54302.stderr

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
error: implementation of `Deserialize` is not general enough
22
--> $DIR/issue-54302.rs:13:5
33
|
4-
LL | trait Deserialize<'de> {}
5-
| ------------------------- trait `Deserialize` defined here
6-
...
74
LL | assert_deserialize_owned::<&'static str>();
85
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Deserialize` is not general enough
96
|

src/test/ui/issues/issue-55731.stderr

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
error: implementation of `DistributedIteratorMulti` is not general enough
22
--> $DIR/issue-55731.rs:48:5
33
|
4-
LL | / trait DistributedIteratorMulti<Source> {
5-
LL | | type Item;
6-
LL | | }
7-
| |_- trait `DistributedIteratorMulti` defined here
8-
...
9-
LL | multi(Map {
10-
| ^^^^^ implementation of `DistributedIteratorMulti` is not general enough
4+
LL | multi(Map {
5+
| ^^^^^ implementation of `DistributedIteratorMulti` is not general enough
116
|
127
= note: `DistributedIteratorMulti<&'0 ()>` would have to be implemented for the type `Cloned<&()>`, for any lifetime `'0`...
138
= note: ...but `DistributedIteratorMulti<&'1 ()>` is actually implemented for the type `Cloned<&'1 ()>`, for some specific lifetime `'1`

src/test/ui/where-clauses/where-for-self-2.stderr

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
error: implementation of `Bar` is not general enough
22
--> $DIR/where-for-self-2.rs:23:5
33
|
4-
LL | / trait Bar {
5-
LL | | fn bar(&self);
6-
LL | | }
7-
| |_- trait `Bar` defined here
8-
...
9-
LL | foo(&X);
10-
| ^^^ implementation of `Bar` is not general enough
4+
LL | foo(&X);
5+
| ^^^ implementation of `Bar` is not general enough
116
|
127
= note: `Bar` would have to be implemented for the type `&'0 u32`, for any lifetime `'0`...
138
= note: ...but `Bar` is actually implemented for the type `&'1 u32`, for some specific lifetime `'1`

0 commit comments

Comments
 (0)