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

+6-1
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

-4
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

-4
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

-1
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

-1
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

-1
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

-1
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

-6
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

-2
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

-1
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
|

src/test/ui/builtin-superkinds/builtin-superkinds-typaram-not-send.stderr

-1
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: the trait `std::marker::Send` is not implemented for `T`
1110
help: consider further restricting this bound
1211
|
1312
LL | impl <T: Sync+'static + std::marker::Send> Foo for T { }

src/test/ui/closures/closure-bounds-cant-promote-superkind-in-struct.stderr

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ LL | struct X<F> where F: FnOnce() + 'static + Send {
77
LL | fn foo<F>(blk: F) -> X<F> where F: FnOnce() + 'static {
88
| ^^^^ `F` cannot be sent between threads safely
99
|
10-
= help: the trait `std::marker::Send` is not implemented for `F`
1110
help: consider further restricting this bound
1211
|
1312
LL | fn foo<F>(blk: F) -> X<F> where F: FnOnce() + 'static + std::marker::Send {

src/test/ui/closures/closure-bounds-subtype.stderr

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ LL | fn take_const_owned<F>(_: F) where F: FnOnce() + Sync + Send {
77
LL | take_const_owned(f);
88
| ^ `F` cannot be shared between threads safely
99
|
10-
= help: the trait `std::marker::Sync` is not implemented for `F`
1110
help: consider further restricting this bound
1211
|
1312
LL | fn give_owned<F>(f: F) where F: FnOnce() + Send + std::marker::Sync {

src/test/ui/dst/dst-object-from-unsized-type.stderr

-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ LL | fn test1<T: ?Sized + Foo>(t: &T) {
66
LL | let u: &dyn Foo = t;
77
| ^ doesn't have a size known at compile-time
88
|
9-
= help: the trait `std::marker::Sized` is not implemented for `T`
109
= note: required for the cast to the object type `dyn Foo`
1110

1211
error[E0277]: the size for values of type `T` cannot be known at compilation time
@@ -17,7 +16,6 @@ LL | fn test2<T: ?Sized + Foo>(t: &T) {
1716
LL | let v: &dyn Foo = t as &dyn Foo;
1817
| ^ doesn't have a size known at compile-time
1918
|
20-
= help: the trait `std::marker::Sized` is not implemented for `T`
2119
= note: required for the cast to the object type `dyn Foo`
2220

2321
error[E0277]: the size for values of type `str` cannot be known at compilation time

src/test/ui/generic-associated-types/issue-68642-broken-llvm-ir.stderr

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ LL | type F<'a>: Fn() -> u32;
1616
LL | type F<'a> = Self;
1717
| ^^^^^^^^^^^^^^^^^^ expected an `Fn<()>` closure, found `T`
1818
|
19-
= help: the trait `std::ops::Fn<()>` is not implemented for `T`
2019
= note: wrap the `T` in a closure with no arguments: `|| { /* code */ }
2120
help: consider restricting type parameter `T`
2221
|

src/test/ui/generic-associated-types/issue-68643-broken-mir.stderr

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ LL | type F<'a>: Fn() -> u32;
1616
LL | type F<'a> = Self;
1717
| ^^^^^^^^^^^^^^^^^^ expected an `Fn<()>` closure, found `T`
1818
|
19-
= help: the trait `std::ops::Fn<()>` is not implemented for `T`
2019
= note: wrap the `T` in a closure with no arguments: `|| { /* code */ }
2120
help: consider restricting type parameter `T`
2221
|

src/test/ui/generic-associated-types/issue-68644-codegen-selection.stderr

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ LL | type F<'a>: Fn() -> u32;
1616
LL | type F<'a> = Self;
1717
| ^^^^^^^^^^^^^^^^^^ expected an `Fn<()>` closure, found `T`
1818
|
19-
= help: the trait `std::ops::Fn<()>` is not implemented for `T`
2019
= note: wrap the `T` in a closure with no arguments: `|| { /* code */ }
2120
help: consider restricting type parameter `T`
2221
|

src/test/ui/generic-associated-types/issue-68645-codegen-fulfillment.stderr

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ LL | type F<'a>: Fn() -> u32;
1616
LL | type F<'a> = Self;
1717
| ^^^^^^^^^^^^^^^^^^ expected an `Fn<()>` closure, found `T`
1818
|
19-
= help: the trait `std::ops::Fn<()>` is not implemented for `T`
2019
= note: wrap the `T` in a closure with no arguments: `|| { /* code */ }
2120
help: consider restricting type parameter `T`
2221
|

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

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ LL | trait From<Src> {
77
LL | ) -> <Dst as From<Self>>::Result where Dst: From<Self> {
88
| ^^^^^^^^^^ doesn't have a size known at compile-time
99
|
10-
= help: the trait `std::marker::Sized` is not implemented for `Self`
1110
help: consider further restricting `Self`
1211
|
1312
LL | ) -> <Dst as From<Self>>::Result where Dst: From<Self>, Self: std::marker::Sized {

src/test/ui/issues/issue-27060-2.stderr

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ LL | pub struct Bad<T: ?Sized> {
66
LL | data: T,
77
| ^ doesn't have a size known at compile-time
88
|
9-
= help: the trait `std::marker::Sized` is not implemented for `T`
109
= note: the last field of a packed struct may only have a dynamically sized type if it does not need drop to be run
1110
= help: change the field's type to have a statically known size
1211
help: borrowed types always have a statically known size

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

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ error[E0277]: the size for values of type `Self` cannot be known at compilation
44
LL | fn foo(self) -> &'static i32 {
55
| ^^^^ doesn't have a size known at compile-time
66
|
7-
= help: the trait `std::marker::Sized` is not implemented for `Self`
87
= help: unsized locals are gated as an unstable feature
98
help: consider further restricting `Self`
109
|

src/test/ui/kindck/kindck-impl-type-params.stderr

-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ error[E0277]: `T` cannot be sent between threads safely
44
LL | let a = &t as &dyn Gettable<T>;
55
| ^^ `T` cannot be sent between threads safely
66
|
7-
= help: the trait `std::marker::Send` is not implemented for `T`
87
= note: required because of the requirements on the impl of `Gettable<T>` for `S<T>`
98
= note: required for the cast to the object type `dyn Gettable<T>`
109
help: consider restricting type parameter `T`
@@ -31,7 +30,6 @@ error[E0277]: `T` cannot be sent between threads safely
3130
LL | let a: &dyn Gettable<T> = &t;
3231
| ^^ `T` cannot be sent between threads safely
3332
|
34-
= help: the trait `std::marker::Send` is not implemented for `T`
3533
= note: required because of the requirements on the impl of `Gettable<T>` for `S<T>`
3634
= note: required for the cast to the object type `dyn Gettable<T>`
3735
help: consider restricting type parameter `T`

src/test/ui/lazy_normalization_consts/feature-gate-lazy_normalization_consts.stderr

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ LL | fn test<T>() {
99
LL | let _: [u8; sof::<T>()];
1010
| ^ doesn't have a size known at compile-time
1111
|
12-
= help: the trait `std::marker::Sized` is not implemented for `T`
1312
help: consider relaxing the implicit `Sized` restriction
1413
|
1514
LL | pub const fn sof<T: ?Sized>() -> usize {

src/test/ui/phantom-oibit.stderr

-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ LL | fn is_zen<T: Zen>(_: T) {}
77
LL | is_zen(x)
88
| ^ `T` cannot be shared between threads safely
99
|
10-
= help: the trait `std::marker::Sync` is not implemented for `T`
1110
= note: required because of the requirements on the impl of `Zen` for `&T`
1211
= note: required because it appears within the type `std::marker::PhantomData<&T>`
1312
= note: required because it appears within the type `Guard<'_, T>`
@@ -25,7 +24,6 @@ LL | fn is_zen<T: Zen>(_: T) {}
2524
LL | is_zen(x)
2625
| ^ `T` cannot be shared between threads safely
2726
|
28-
= help: the trait `std::marker::Sync` is not implemented for `T`
2927
= note: required because of the requirements on the impl of `Zen` for `&T`
3028
= note: required because it appears within the type `std::marker::PhantomData<&T>`
3129
= note: required because it appears within the type `Guard<'_, T>`

src/test/ui/specialization/deafult-generic-associated-type-bound.stderr

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ LL | type U<'a>: PartialEq<&'a Self>;
2424
LL | default type U<'a> = &'a T;
2525
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `T == T`
2626
|
27-
= help: the trait `std::cmp::PartialEq` is not implemented for `T`
2827
= note: required because of the requirements on the impl of `std::cmp::PartialEq` for `&'a T`
2928
help: consider further restricting this bound
3029
|

src/test/ui/suggestions/adt-param-with-implicit-sized-bound.stderr

-5
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ LL | struct Struct5<T: ?Sized>{
99
LL | _t: X<T>,
1010
| ^^^^ doesn't have a size known at compile-time
1111
|
12-
= help: the trait `std::marker::Sized` is not implemented for `T`
1312
help: you could relax the implicit `Sized` bound on `T` if it were used through indirection like `&T` or `Box<T>`
1413
--> $DIR/adt-param-with-implicit-sized-bound.rs:18:10
1514
|
@@ -27,7 +26,6 @@ LL | fn func1() -> Struct1<Self>;
2726
LL | struct Struct1<T>{
2827
| - required by this bound in `Struct1`
2928
|
30-
= help: the trait `std::marker::Sized` is not implemented for `Self`
3129
help: consider further restricting `Self`
3230
|
3331
LL | fn func1() -> Struct1<Self> where Self: std::marker::Sized;
@@ -46,7 +44,6 @@ LL | fn func2<'a>() -> Struct2<'a, Self>;
4644
LL | struct Struct2<'a, T>{
4745
| - required by this bound in `Struct2`
4846
|
49-
= help: the trait `std::marker::Sized` is not implemented for `Self`
5047
help: consider further restricting `Self`
5148
|
5249
LL | fn func2<'a>() -> Struct2<'a, Self> where Self: std::marker::Sized;
@@ -65,7 +62,6 @@ LL | fn func3() -> Struct3<Self>;
6562
LL | struct Struct3<T>{
6663
| - required by this bound in `Struct3`
6764
|
68-
= help: the trait `std::marker::Sized` is not implemented for `Self`
6965
help: you could relax the implicit `Sized` bound on `T` if it were used through indirection like `&T` or `Box<T>`
7066
--> $DIR/adt-param-with-implicit-sized-bound.rs:14:16
7167
|
@@ -87,7 +83,6 @@ LL | fn func4() -> Struct4<Self>;
8783
LL | struct Struct4<T>{
8884
| - required by this bound in `Struct4`
8985
|
90-
= help: the trait `std::marker::Sized` is not implemented for `Self`
9186
help: consider further restricting `Self`
9287
|
9388
LL | fn func4() -> Struct4<Self> where Self: std::marker::Sized;

0 commit comments

Comments
 (0)