Skip to content

Commit 5b54286

Browse files
committed
Remove detail from label/note that is already available in other note
Remove the "which is required by `{root_obligation}`" post-script in "the trait `X` is not implemented for `Y`" explanation in E0277. This information is already conveyed in the notes explaining requirements, making it redundant while making the text (particularly in labels) harder to read. ``` error[E0277]: the trait bound `NotCopy: Copy` is not satisfied --> $DIR/wf-static-type.rs:10:13 | LL | static FOO: IsCopy<Option<NotCopy>> = IsCopy { t: None }; | ^^^^^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `NotCopy` | = note: required for `Option<NotCopy>` to implement `Copy` note: required by a bound in `IsCopy` --> $DIR/wf-static-type.rs:7:17 | LL | struct IsCopy<T:Copy> { t: T } | ^^^^ required by this bound in `IsCopy` ``` vs the prior ``` error[E0277]: the trait bound `NotCopy: Copy` is not satisfied --> $DIR/wf-static-type.rs:10:13 | LL | static FOO: IsCopy<Option<NotCopy>> = IsCopy { t: None }; | ^^^^^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `NotCopy`, which is required by `Option<NotCopy>: Copy` | = note: required for `Option<NotCopy>` to implement `Copy` note: required by a bound in `IsCopy` --> $DIR/wf-static-type.rs:7:17 | LL | struct IsCopy<T:Copy> { t: T } | ^^^^ required by this bound in `IsCopy` ```
1 parent 2dece5b commit 5b54286

File tree

223 files changed

+407
-418
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

223 files changed

+407
-418
lines changed

compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5105,32 +5105,21 @@ pub(super) fn get_explanation_based_on_obligation<'tcx>(
51055105
_ => None,
51065106
};
51075107

5108-
let pred = obligation.predicate;
5109-
let (_, base) = obligation.cause.code().peel_derives_with_predicate();
5110-
let post = if let ty::PredicateKind::Clause(clause) = pred.kind().skip_binder()
5111-
&& let ty::ClauseKind::Trait(pred) = clause
5112-
&& let Some(base) = base
5113-
&& base.skip_binder() != pred
5114-
{
5115-
format!(", which is required by `{base}`")
5116-
} else {
5117-
String::new()
5118-
};
51195108
let desc = match ty_desc {
51205109
Some(desc) => format!(" {desc}"),
51215110
None => String::new(),
51225111
};
51235112
if let ty::PredicatePolarity::Positive = trait_predicate.polarity() {
51245113
format!(
5125-
"{pre_message}the trait `{}` is not implemented for{desc} `{}`{post}",
5114+
"{pre_message}the trait `{}` is not implemented for{desc} `{}`",
51265115
trait_predicate.print_modifiers_and_trait_path(),
51275116
tcx.short_ty_string(trait_predicate.self_ty().skip_binder(), &mut None),
51285117
)
51295118
} else {
51305119
// "the trait bound `T: !Send` is not satisfied" reads better than "`!Send` is
51315120
// not implemented for `T`".
51325121
// FIXME: add note explaining explicit negative trait bounds.
5133-
format!("{pre_message}the trait bound `{trait_predicate}` is not satisfied{post}")
5122+
format!("{pre_message}the trait bound `{trait_predicate}` is not satisfied")
51345123
}
51355124
}
51365125
}

tests/ui/associated-consts/issue-58022.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ error[E0277]: the size for values of type `[u8]` cannot be known at compilation
1313
LL | fn new(slice: &[u8; Self::SIZE]) -> Self {
1414
| ^^^^ doesn't have a size known at compile-time
1515
|
16-
= help: within `Bar<[u8]>`, the trait `Sized` is not implemented for `[u8]`, which is required by `Bar<[u8]>: Sized`
16+
= help: within `Bar<[u8]>`, the trait `Sized` is not implemented for `[u8]`
1717
note: required because it appears within the type `Bar<[u8]>`
1818
--> $DIR/issue-58022.rs:8:12
1919
|

tests/ui/associated-type-bounds/return-type-notation/basic.without.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error: future cannot be sent between threads safely
44
LL | is_send(foo::<T>());
55
| ^^^^^^^^^^ future returned by `foo` is not `Send`
66
|
7-
= help: within `impl Future<Output = Result<(), ()>>`, the trait `Send` is not implemented for `impl Future<Output = Result<(), ()>> { <T as Foo>::method(..) }`, which is required by `impl Future<Output = Result<(), ()>>: Send`
7+
= help: within `impl Future<Output = Result<(), ()>>`, the trait `Send` is not implemented for `impl Future<Output = Result<(), ()>> { <T as Foo>::method(..) }`
88
note: future is not `Send` as it awaits another future which is not `Send`
99
--> $DIR/basic.rs:12:5
1010
|

tests/ui/associated-type-bounds/return-type-notation/path-unsatisfied.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ LL | fn method() -> impl Sized {
77
LL | test::<DoesntWork>();
88
| ^^^^^^^^^^ `*mut ()` cannot be sent between threads safely
99
|
10-
= help: within `impl Sized`, the trait `Send` is not implemented for `*mut ()`, which is required by `impl Sized: Send`
10+
= help: within `impl Sized`, the trait `Send` is not implemented for `*mut ()`
1111
note: required because it appears within the type `impl Sized`
1212
--> $DIR/path-unsatisfied.rs:9:20
1313
|

tests/ui/associated-types/defaults-suitability.current.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ error[E0277]: the trait bound `T: Clone` is not satisfied
3939
--> $DIR/defaults-suitability.rs:31:23
4040
|
4141
LL | type Bar: Clone = Vec<T>;
42-
| ^^^^^^ the trait `Clone` is not implemented for `T`, which is required by `Vec<T>: Clone`
42+
| ^^^^^^ the trait `Clone` is not implemented for `T`
4343
|
4444
= note: required for `Vec<T>` to implement `Clone`
4545
note: required by a bound in `Foo::Bar`
@@ -88,7 +88,7 @@ error[E0277]: the trait bound `<Self as Foo2<T>>::Baz: Clone` is not satisfied
8888
--> $DIR/defaults-suitability.rs:68:23
8989
|
9090
LL | type Bar: Clone = Vec<Self::Baz>;
91-
| ^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `<Self as Foo2<T>>::Baz`, which is required by `Vec<<Self as Foo2<T>>::Baz>: Clone`
91+
| ^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `<Self as Foo2<T>>::Baz`
9292
|
9393
= note: required for `Vec<<Self as Foo2<T>>::Baz>` to implement `Clone`
9494
note: required by a bound in `Foo2::Bar`
@@ -105,7 +105,7 @@ error[E0277]: the trait bound `<Self as Foo25<T>>::Baz: Clone` is not satisfied
105105
--> $DIR/defaults-suitability.rs:77:23
106106
|
107107
LL | type Bar: Clone = Vec<Self::Baz>;
108-
| ^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `<Self as Foo25<T>>::Baz`, which is required by `Vec<<Self as Foo25<T>>::Baz>: Clone`
108+
| ^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `<Self as Foo25<T>>::Baz`
109109
|
110110
= note: required for `Vec<<Self as Foo25<T>>::Baz>` to implement `Clone`
111111
note: required by a bound in `Foo25::Bar`

tests/ui/associated-types/defaults-suitability.next.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ error[E0277]: the trait bound `T: Clone` is not satisfied
3939
--> $DIR/defaults-suitability.rs:31:23
4040
|
4141
LL | type Bar: Clone = Vec<T>;
42-
| ^^^^^^ the trait `Clone` is not implemented for `T`, which is required by `Vec<T>: Clone`
42+
| ^^^^^^ the trait `Clone` is not implemented for `T`
4343
|
4444
= note: required for `Vec<T>` to implement `Clone`
4545
note: required by a bound in `Foo::Bar`
@@ -88,7 +88,7 @@ error[E0277]: the trait bound `<Self as Foo2<T>>::Baz: Clone` is not satisfied
8888
--> $DIR/defaults-suitability.rs:68:23
8989
|
9090
LL | type Bar: Clone = Vec<Self::Baz>;
91-
| ^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `<Self as Foo2<T>>::Baz`, which is required by `Vec<<Self as Foo2<T>>::Baz>: Clone`
91+
| ^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `<Self as Foo2<T>>::Baz`
9292
|
9393
= note: required for `Vec<<Self as Foo2<T>>::Baz>` to implement `Clone`
9494
note: required by a bound in `Foo2::Bar`
@@ -105,7 +105,7 @@ error[E0277]: the trait bound `<Self as Foo25<T>>::Baz: Clone` is not satisfied
105105
--> $DIR/defaults-suitability.rs:77:23
106106
|
107107
LL | type Bar: Clone = Vec<Self::Baz>;
108-
| ^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `<Self as Foo25<T>>::Baz`, which is required by `Vec<<Self as Foo25<T>>::Baz>: Clone`
108+
| ^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `<Self as Foo25<T>>::Baz`
109109
|
110110
= note: required for `Vec<<Self as Foo25<T>>::Baz>` to implement `Clone`
111111
note: required by a bound in `Foo25::Bar`

tests/ui/associated-types/hr-associated-type-bound-1.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0277]: the trait bound `str: Clone` is not satisfied
22
--> $DIR/hr-associated-type-bound-1.rs:12:14
33
|
44
LL | type U = str;
5-
| ^^^ the trait `Clone` is not implemented for `str`, which is required by `for<'b> <i32 as X<'b>>::U: Clone`
5+
| ^^^ the trait `Clone` is not implemented for `str`
66
|
77
= help: the trait `Clone` is implemented for `String`
88
note: required by a bound in `X`

tests/ui/associated-types/hr-associated-type-bound-param-1.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0277]: the trait bound `str: Clone` is not satisfied
22
--> $DIR/hr-associated-type-bound-param-1.rs:14:14
33
|
44
LL | type V = str;
5-
| ^^^ the trait `Clone` is not implemented for `str`, which is required by `for<'b> <u8 as Y<'b, u8>>::V: Clone`
5+
| ^^^ the trait `Clone` is not implemented for `str`
66
|
77
= help: the trait `Clone` is implemented for `String`
88
note: required by a bound in `Y`

tests/ui/associated-types/hr-associated-type-bound-param-2.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ error[E0277]: the trait bound `str: Clone` is not satisfied
1818
--> $DIR/hr-associated-type-bound-param-2.rs:17:14
1919
|
2020
LL | type W = str;
21-
| ^^^ the trait `Clone` is not implemented for `str`, which is required by `for<'b> <u16 as Z<'b, u16>>::W: Clone`
21+
| ^^^ the trait `Clone` is not implemented for `str`
2222
|
2323
= help: the trait `Clone` is implemented for `String`
2424
note: required by a bound in `Z`

tests/ui/associated-types/hr-associated-type-bound-param-3.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0277]: the trait bound `str: Clone` is not satisfied
22
--> $DIR/hr-associated-type-bound-param-3.rs:13:14
33
|
44
LL | type U = str;
5-
| ^^^ the trait `Clone` is not implemented for `str`, which is required by `for<'b> <(T,) as X<'b, (T,)>>::U: Clone`
5+
| ^^^ the trait `Clone` is not implemented for `str`
66
|
77
= help: the trait `Clone` is implemented for `String`
88
note: required by a bound in `X`

0 commit comments

Comments
 (0)