Skip to content

Commit 2d0f3eb

Browse files
committed
Remove redundant explanatory note for type parameters
1 parent 424902a commit 2d0f3eb

File tree

42 files changed

+6
-96
lines changed

Some content is hidden

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

42 files changed

+6
-96
lines changed

src/librustc_trait_selection/traits/error_reporting/mod.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,12 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
376376
// If it has a custom `#[rustc_on_unimplemented]`
377377
// error message, let's display it as the label!
378378
err.span_label(span, s.as_str());
379-
err.help(&explanation);
379+
if !matches!(trait_ref.skip_binder().self_ty().kind, ty::Param(_)) {
380+
// When the self type is a type param We don't need to "the trait
381+
// `std::marker::Sized` is not implemented for `T`" as we will point
382+
// at the type param with a label to suggest constraining it.
383+
err.help(&explanation);
384+
}
380385
} else {
381386
err.span_label(span, explanation);
382387
}

src/test/ui/associated-types/defaults-unsound-62211-1.stderr

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ LL | trait UncheckedCopy: Sized {
2121
LL | + AddAssign<&'static str>
2222
| ^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `Self += &'static str`
2323
|
24-
= help: the trait `std::ops::AddAssign<&'static str>` is not implemented for `Self`
2524
help: consider further restricting `Self`
2625
|
2726
LL | trait UncheckedCopy: Sized + std::ops::AddAssign<&'static str> {
@@ -50,7 +49,6 @@ LL | trait UncheckedCopy: Sized {
5049
LL | + Display = Self;
5150
| ^^^^^^^ `Self` cannot be formatted with the default formatter
5251
|
53-
= help: the trait `std::fmt::Display` is not implemented for `Self`
5452
= note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
5553
help: consider further restricting `Self`
5654
|
@@ -69,7 +67,6 @@ LL | + Display = Self;
6967
LL | impl<T> UncheckedCopy for T {}
7068
| ^^^^^^^^^^^^^ `T` cannot be formatted with the default formatter
7169
|
72-
= help: the trait `std::fmt::Display` is not implemented for `T`
7370
= note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
7471
help: consider restricting type parameter `T`
7572
|
@@ -105,7 +102,6 @@ LL | + AddAssign<&'static str>
105102
LL | impl<T> UncheckedCopy for T {}
106103
| ^^^^^^^^^^^^^ no implementation for `T += &'static str`
107104
|
108-
= help: the trait `std::ops::AddAssign<&'static str>` is not implemented for `T`
109105
help: consider restricting type parameter `T`
110106
|
111107
LL | impl<T: std::ops::AddAssign<&'static str>> UncheckedCopy for T {}

src/test/ui/associated-types/defaults-unsound-62211-2.stderr

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ LL | trait UncheckedCopy: Sized {
2121
LL | + AddAssign<&'static str>
2222
| ^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `Self += &'static str`
2323
|
24-
= help: the trait `std::ops::AddAssign<&'static str>` is not implemented for `Self`
2524
help: consider further restricting `Self`
2625
|
2726
LL | trait UncheckedCopy: Sized + std::ops::AddAssign<&'static str> {
@@ -50,7 +49,6 @@ LL | trait UncheckedCopy: Sized {
5049
LL | + Display = Self;
5150
| ^^^^^^^ `Self` cannot be formatted with the default formatter
5251
|
53-
= help: the trait `std::fmt::Display` is not implemented for `Self`
5452
= note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
5553
help: consider further restricting `Self`
5654
|
@@ -69,7 +67,6 @@ LL | + Display = Self;
6967
LL | impl<T> UncheckedCopy for T {}
7068
| ^^^^^^^^^^^^^ `T` cannot be formatted with the default formatter
7169
|
72-
= help: the trait `std::fmt::Display` is not implemented for `T`
7370
= note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
7471
help: consider restricting type parameter `T`
7572
|
@@ -105,7 +102,6 @@ LL | + AddAssign<&'static str>
105102
LL | impl<T> UncheckedCopy for T {}
106103
| ^^^^^^^^^^^^^ no implementation for `T += &'static str`
107104
|
108-
= help: the trait `std::ops::AddAssign<&'static str>` is not implemented for `T`
109105
help: consider restricting type parameter `T`
110106
|
111107
LL | impl<T: std::ops::AddAssign<&'static str>> UncheckedCopy for T {}

src/test/ui/associated-types/issue-63593.stderr

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ LL | trait MyTrait {
66
LL | type This = Self;
77
| ^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
88
|
9-
= help: the trait `std::marker::Sized` is not implemented for `Self`
109
help: consider further restricting `Self`
1110
|
1211
LL | trait MyTrait: std::marker::Sized {

src/test/ui/associated-types/trait-with-supertraits-needing-sized-self.stderr

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ LL | trait ArithmeticOps: Add<Output=Self> + Sub<Output=Self> + Mul<Output=Self>
99
LL | pub trait Add<Rhs = Self> {
1010
| --- required by this bound in `std::ops::Add`
1111
|
12-
= help: the trait `std::marker::Sized` is not implemented for `Self`
1312
help: consider further restricting `Self`
1413
|
1514
LL | trait ArithmeticOps: Add<Output=Self> + Sub<Output=Self> + Mul<Output=Self> + Div<Output=Self> + std::marker::Sized {}

src/test/ui/async-await/issue-70818.stderr

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ LL |
77
LL | async { (ty, ty1) }
88
| ------------------- this returned value is of type `impl std::future::Future`
99
|
10-
= help: within `impl std::future::Future`, the trait `std::marker::Send` is not implemented for `U`
1110
note: captured value is not `Send`
1211
--> $DIR/issue-70818.rs:6:18
1312
|

src/test/ui/bad/bad-method-typaram-kind.stderr

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ error[E0277]: `T` cannot be sent between threads safely
44
LL | 1.bar::<T>();
55
| ^^^ `T` cannot be sent between threads safely
66
|
7-
= help: the trait `std::marker::Send` is not implemented for `T`
87
help: consider further restricting this bound
98
|
109
LL | fn foo<T:'static + std::marker::Send>() {

src/test/ui/bound-suggestions.stderr

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ error[E0277]: `impl Sized` doesn't implement `std::fmt::Debug`
44
LL | println!("{:?}", t);
55
| ^ `impl Sized` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug`
66
|
7-
= help: the trait `std::fmt::Debug` is not implemented for `impl Sized`
87
= note: required by `std::fmt::Debug::fmt`
98
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
109
help: consider further restricting this bound
@@ -18,7 +17,6 @@ error[E0277]: `T` doesn't implement `std::fmt::Debug`
1817
LL | println!("{:?}", t);
1918
| ^ `T` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug`
2019
|
21-
= help: the trait `std::fmt::Debug` is not implemented for `T`
2220
= note: required by `std::fmt::Debug::fmt`
2321
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
2422
help: consider restricting type parameter `T`
@@ -32,7 +30,6 @@ error[E0277]: `T` doesn't implement `std::fmt::Debug`
3230
LL | println!("{:?}", t);
3331
| ^ `T` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug`
3432
|
35-
= help: the trait `std::fmt::Debug` is not implemented for `T`
3633
= note: required by `std::fmt::Debug::fmt`
3734
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
3835
help: consider further restricting this bound
@@ -46,7 +43,6 @@ error[E0277]: `Y` doesn't implement `std::fmt::Debug`
4643
LL | println!("{:?} {:?}", x, y);
4744
| ^ `Y` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug`
4845
|
49-
= help: the trait `std::fmt::Debug` is not implemented for `Y`
5046
= note: required by `std::fmt::Debug::fmt`
5147
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
5248
help: consider further restricting type parameter `Y`
@@ -60,7 +56,6 @@ error[E0277]: `X` doesn't implement `std::fmt::Debug`
6056
LL | println!("{:?}", x);
6157
| ^ `X` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug`
6258
|
63-
= help: the trait `std::fmt::Debug` is not implemented for `X`
6459
= note: required by `std::fmt::Debug::fmt`
6560
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
6661
help: consider further restricting this bound
@@ -74,7 +69,6 @@ error[E0277]: `X` doesn't implement `std::fmt::Debug`
7469
LL | println!("{:?}", x);
7570
| ^ `X` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug`
7671
|
77-
= help: the trait `std::fmt::Debug` is not implemented for `X`
7872
= note: required by `std::fmt::Debug::fmt`
7973
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
8074
help: consider further restricting type parameter `X`

src/test/ui/builtin-superkinds/builtin-superkinds-double-superkind.stderr

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ LL |
77
LL | impl <T: Sync+'static> Foo for (T,) { }
88
| ^^^ `T` cannot be sent between threads safely
99
|
10-
= help: within `(T,)`, the trait `std::marker::Send` is not implemented for `T`
1110
= note: required because it appears within the type `(T,)`
1211
help: consider further restricting this bound
1312
|
@@ -23,7 +22,6 @@ LL | trait Foo : Send+Sync { }
2322
LL | impl <T: Send> Foo for (T,T) { }
2423
| ^^^ `T` cannot be shared between threads safely
2524
|
26-
= help: within `(T, T)`, the trait `std::marker::Sync` is not implemented for `T`
2725
= note: required because it appears within the type `(T, T)`
2826
help: consider further restricting this bound
2927
|

src/test/ui/builtin-superkinds/builtin-superkinds-in-metadata.stderr

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ LL | impl <T:Sync+'static> RequiresRequiresShareAndSend for X<T> { }
99
LL | pub trait RequiresRequiresShareAndSend : RequiresShare + Send { }
1010
| ---- required by this bound in `trait_superkinds_in_metadata::RequiresRequiresShareAndSend`
1111
|
12-
= help: within `X<T>`, the trait `std::marker::Send` is not implemented for `T`
1312
= note: required because it appears within the type `X<T>`
1413
help: consider further restricting this bound
1514
|

0 commit comments

Comments
 (0)