Skip to content

Commit 918166e

Browse files
authored
Rollup merge of rust-lang#83673 - hi-rustin:rustin-patch-suggestion, r=estebank
give full path of constraint in suggest_constraining_type_param close rust-lang#83513
2 parents 952ed03 + 8f77356 commit 918166e

File tree

90 files changed

+249
-247
lines changed

Some content is hidden

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

90 files changed

+249
-247
lines changed

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ use std::fmt;
2828

2929
use super::InferCtxtPrivExt;
3030
use crate::traits::query::evaluate_obligation::InferCtxtExt as _;
31+
use rustc_middle::ty::print::with_no_trimmed_paths;
3132

3233
#[derive(Debug)]
3334
pub enum GeneratorInteriorOrUpvar {
@@ -440,7 +441,8 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
440441
{
441442
// Missing generic type parameter bound.
442443
let param_name = self_ty.to_string();
443-
let constraint = trait_ref.print_only_trait_path().to_string();
444+
let constraint =
445+
with_no_trimmed_paths(|| trait_ref.print_only_trait_path().to_string());
444446
if suggest_constraining_type_param(
445447
self.tcx,
446448
generics,

src/test/ui/associated-types/defaults-suitability.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ LL | type Bar: Clone = Vec<T>;
3131
= note: required because of the requirements on the impl of `Clone` for `Vec<T>`
3232
help: consider restricting type parameter `T`
3333
|
34-
LL | trait Foo<T: Clone> {
35-
| ^^^^^^^
34+
LL | trait Foo<T: std::clone::Clone> {
35+
| ^^^^^^^^^^^^^^^^^^^
3636

3737
error[E0277]: the trait bound `(): Foo<Self>` is not satisfied
3838
--> $DIR/defaults-suitability.rs:34:5
@@ -99,8 +99,8 @@ LL | type Baz = T;
9999
|
100100
help: consider further restricting type parameter `T`
101101
|
102-
LL | Self::Baz: Clone, T: Clone
103-
| ^^^^^^^^^^
102+
LL | Self::Baz: Clone, T: std::clone::Clone
103+
| ^^^^^^^^^^^^^^^^^^^^^^
104104

105105
error: aborting due to 8 previous errors
106106

src/test/ui/associated-types/issue-27675-unchecked-bounds.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ LL | copy::<dyn Setup<From=T>>(t)
99
|
1010
help: consider restricting type parameter `T`
1111
|
12-
LL | pub fn copy_any<T: Copy>(t: &T) -> T {
13-
| ^^^^^^
12+
LL | pub fn copy_any<T: std::marker::Copy>(t: &T) -> T {
13+
| ^^^^^^^^^^^^^^^^^^^
1414

1515
error: aborting due to previous error
1616

src/test/ui/associated-types/issue-43784-associated-type.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ LL | type Assoc = T;
99
|
1010
help: consider restricting type parameter `T`
1111
|
12-
LL | impl<T: Copy> Complete for T {
13-
| ^^^^^^
12+
LL | impl<T: std::marker::Copy> Complete for T {
13+
| ^^^^^^^^^^^^^^^^^^^
1414

1515
error: aborting due to previous error
1616

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ LL | async { (ty, ty1) }
1111
| ^^^ has type `U` which is not `Send`
1212
help: consider restricting type parameter `U`
1313
|
14-
LL | fn foo<T: Send, U: Send>(ty: T, ty1: U) -> impl Future<Output = (T, U)> + Send {
15-
| ^^^^^^
14+
LL | fn foo<T: Send, U: std::marker::Send>(ty: T, ty1: U) -> impl Future<Output = (T, U)> + Send {
15+
| ^^^^^^^^^^^^^^^^^^^
1616

1717
error: aborting due to previous error
1818

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ LL | 1.bar::<T>();
66
|
77
help: consider further restricting this bound
88
|
9-
LL | fn foo<T:'static + Send>() {
10-
| ^^^^^^
9+
LL | fn foo<T:'static + std::marker::Send>() {
10+
| ^^^^^^^^^^^^^^^^^^^
1111

1212
error: aborting due to previous error
1313

src/test/ui/bound-suggestions.fixed

+6-6
Original file line numberDiff line numberDiff line change
@@ -5,37 +5,37 @@ use std::fmt::Debug;
55
// Rustfix should add this, or use `std::fmt::Debug` instead.
66

77
#[allow(dead_code)]
8-
fn test_impl(t: impl Sized + Debug) {
8+
fn test_impl(t: impl Sized + std::fmt::Debug) {
99
println!("{:?}", t);
1010
//~^ ERROR doesn't implement
1111
}
1212

1313
#[allow(dead_code)]
14-
fn test_no_bounds<T: Debug>(t: T) {
14+
fn test_no_bounds<T: std::fmt::Debug>(t: T) {
1515
println!("{:?}", t);
1616
//~^ ERROR doesn't implement
1717
}
1818

1919
#[allow(dead_code)]
20-
fn test_one_bound<T: Sized + Debug>(t: T) {
20+
fn test_one_bound<T: Sized + std::fmt::Debug>(t: T) {
2121
println!("{:?}", t);
2222
//~^ ERROR doesn't implement
2323
}
2424

2525
#[allow(dead_code)]
26-
fn test_no_bounds_where<X, Y>(x: X, y: Y) where X: std::fmt::Debug, Y: Debug {
26+
fn test_no_bounds_where<X, Y>(x: X, y: Y) where X: std::fmt::Debug, Y: std::fmt::Debug {
2727
println!("{:?} {:?}", x, y);
2828
//~^ ERROR doesn't implement
2929
}
3030

3131
#[allow(dead_code)]
32-
fn test_one_bound_where<X>(x: X) where X: Sized + Debug {
32+
fn test_one_bound_where<X>(x: X) where X: Sized + std::fmt::Debug {
3333
println!("{:?}", x);
3434
//~^ ERROR doesn't implement
3535
}
3636

3737
#[allow(dead_code)]
38-
fn test_many_bounds_where<X>(x: X) where X: Sized, X: Sized, X: Debug {
38+
fn test_many_bounds_where<X>(x: X) where X: Sized, X: Sized, X: std::fmt::Debug {
3939
println!("{:?}", x);
4040
//~^ ERROR doesn't implement
4141
}

src/test/ui/bound-suggestions.stderr

+12-12
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ LL | println!("{:?}", t);
88
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
99
help: consider further restricting this bound
1010
|
11-
LL | fn test_impl(t: impl Sized + Debug) {
12-
| ^^^^^^^
11+
LL | fn test_impl(t: impl Sized + std::fmt::Debug) {
12+
| ^^^^^^^^^^^^^^^^^
1313

1414
error[E0277]: `T` doesn't implement `Debug`
1515
--> $DIR/bound-suggestions.rs:15:22
@@ -21,8 +21,8 @@ LL | println!("{:?}", t);
2121
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
2222
help: consider restricting type parameter `T`
2323
|
24-
LL | fn test_no_bounds<T: Debug>(t: T) {
25-
| ^^^^^^^
24+
LL | fn test_no_bounds<T: std::fmt::Debug>(t: T) {
25+
| ^^^^^^^^^^^^^^^^^
2626

2727
error[E0277]: `T` doesn't implement `Debug`
2828
--> $DIR/bound-suggestions.rs:21:22
@@ -34,8 +34,8 @@ LL | println!("{:?}", t);
3434
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
3535
help: consider further restricting this bound
3636
|
37-
LL | fn test_one_bound<T: Sized + Debug>(t: T) {
38-
| ^^^^^^^
37+
LL | fn test_one_bound<T: Sized + std::fmt::Debug>(t: T) {
38+
| ^^^^^^^^^^^^^^^^^
3939

4040
error[E0277]: `Y` doesn't implement `Debug`
4141
--> $DIR/bound-suggestions.rs:27:30
@@ -47,8 +47,8 @@ LL | println!("{:?} {:?}", x, y);
4747
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
4848
help: consider further restricting type parameter `Y`
4949
|
50-
LL | fn test_no_bounds_where<X, Y>(x: X, y: Y) where X: std::fmt::Debug, Y: Debug {
51-
| ^^^^^^^^^^
50+
LL | fn test_no_bounds_where<X, Y>(x: X, y: Y) where X: std::fmt::Debug, Y: std::fmt::Debug {
51+
| ^^^^^^^^^^^^^^^^^^^^
5252

5353
error[E0277]: `X` doesn't implement `Debug`
5454
--> $DIR/bound-suggestions.rs:33:22
@@ -60,8 +60,8 @@ LL | println!("{:?}", x);
6060
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
6161
help: consider further restricting this bound
6262
|
63-
LL | fn test_one_bound_where<X>(x: X) where X: Sized + Debug {
64-
| ^^^^^^^
63+
LL | fn test_one_bound_where<X>(x: X) where X: Sized + std::fmt::Debug {
64+
| ^^^^^^^^^^^^^^^^^
6565

6666
error[E0277]: `X` doesn't implement `Debug`
6767
--> $DIR/bound-suggestions.rs:39:22
@@ -73,8 +73,8 @@ LL | println!("{:?}", x);
7373
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
7474
help: consider further restricting type parameter `X`
7575
|
76-
LL | fn test_many_bounds_where<X>(x: X) where X: Sized, X: Sized, X: Debug {
77-
| ^^^^^^^^^^
76+
LL | fn test_many_bounds_where<X>(x: X) where X: Sized, X: Sized, X: std::fmt::Debug {
77+
| ^^^^^^^^^^^^^^^^^^^^
7878

7979
error[E0277]: the size for values of type `Self` cannot be known at compilation time
8080
--> $DIR/bound-suggestions.rs:44:46

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ LL | impl <T: Sync+'static> Foo for (T,) { }
1010
= note: required because it appears within the type `(T,)`
1111
help: consider further restricting this bound
1212
|
13-
LL | impl <T: Sync+'static + Send> Foo for (T,) { }
14-
| ^^^^^^
13+
LL | impl <T: Sync+'static + std::marker::Send> Foo for (T,) { }
14+
| ^^^^^^^^^^^^^^^^^^^
1515

1616
error[E0277]: `T` cannot be shared between threads safely
1717
--> $DIR/builtin-superkinds-double-superkind.rs:9:16
@@ -25,8 +25,8 @@ LL | impl <T: Send> Foo for (T,T) { }
2525
= note: required because it appears within the type `(T, T)`
2626
help: consider further restricting this bound
2727
|
28-
LL | impl <T: Send + Sync> Foo for (T,T) { }
29-
| ^^^^^^
28+
LL | impl <T: Send + std::marker::Sync> Foo for (T,T) { }
29+
| ^^^^^^^^^^^^^^^^^^^
3030

3131
error: aborting due to 2 previous errors
3232

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ LL | pub trait RequiresRequiresShareAndSend : RequiresShare + Send { }
1212
= note: required because it appears within the type `X<T>`
1313
help: consider further restricting this bound
1414
|
15-
LL | impl <T:Sync+'static + Send> RequiresRequiresShareAndSend for X<T> { }
16-
| ^^^^^^
15+
LL | impl <T:Sync+'static + std::marker::Send> RequiresRequiresShareAndSend for X<T> { }
16+
| ^^^^^^^^^^^^^^^^^^^
1717

1818
error: aborting due to previous error
1919

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ LL | impl <T: Sync+'static> Foo for T { }
99
|
1010
help: consider further restricting this bound
1111
|
12-
LL | impl <T: Sync+'static + Send> Foo for T { }
13-
| ^^^^^^
12+
LL | impl <T: Sync+'static + std::marker::Send> Foo for T { }
13+
| ^^^^^^^^^^^^^^^^^^^
1414

1515
error: aborting due to previous error
1616

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ LL | fn foo<F>(blk: F) -> X<F> where F: FnOnce() + 'static {
99
|
1010
help: consider further restricting this bound
1111
|
12-
LL | fn foo<F>(blk: F) -> X<F> where F: FnOnce() + 'static + Send {
13-
| ^^^^^^
12+
LL | fn foo<F>(blk: F) -> X<F> where F: FnOnce() + 'static + std::marker::Send {
13+
| ^^^^^^^^^^^^^^^^^^^
1414

1515
error: aborting due to previous error
1616

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ LL | take_const_owned(f);
99
|
1010
help: consider further restricting this bound
1111
|
12-
LL | fn give_owned<F>(f: F) where F: FnOnce() + Send + Sync {
13-
| ^^^^^^
12+
LL | fn give_owned<F>(f: F) where F: FnOnce() + Send + std::marker::Sync {
13+
| ^^^^^^^^^^^^^^^^^^^
1414

1515
error: aborting due to previous error
1616

src/test/ui/const-generics/const-argument-if-length.full.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim
22
--> $DIR/const-argument-if-length.rs:7:28
33
|
44
LL | pub const fn is_zst<T: ?Sized>() -> usize {
5-
| - this type parameter needs to be `Sized`
5+
| - this type parameter needs to be `std::marker::Sized`
66
LL | if std::mem::size_of::<T>() == 0 {
77
| ^ doesn't have a size known at compile-time
88
|
@@ -15,7 +15,7 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim
1515
--> $DIR/const-argument-if-length.rs:16:12
1616
|
1717
LL | pub struct AtLeastByte<T: ?Sized> {
18-
| - this type parameter needs to be `Sized`
18+
| - this type parameter needs to be `std::marker::Sized`
1919
LL | value: T,
2020
| ^ doesn't have a size known at compile-time
2121
|

src/test/ui/const-generics/const-argument-if-length.min.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim
1111
--> $DIR/const-argument-if-length.rs:16:12
1212
|
1313
LL | pub struct AtLeastByte<T: ?Sized> {
14-
| - this type parameter needs to be `Sized`
14+
| - this type parameter needs to be `std::marker::Sized`
1515
LL | value: T,
1616
| ^ doesn't have a size known at compile-time
1717
|

src/test/ui/const-generics/issues/issue-61336-2.full.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ LL | [x; { N }]
1616
= note: the `Copy` trait is required because the repeated element will be copied
1717
help: consider restricting type parameter `T`
1818
|
19-
LL | fn g<T: Copy, const N: usize>(x: T) -> [T; N] {
20-
| ^^^^^^
19+
LL | fn g<T: std::marker::Copy, const N: usize>(x: T) -> [T; N] {
20+
| ^^^^^^^^^^^^^^^^^^^
2121

2222
error: aborting due to previous error; 1 warning emitted
2323

src/test/ui/const-generics/issues/issue-61336-2.min.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ LL | [x; { N }]
77
= note: the `Copy` trait is required because the repeated element will be copied
88
help: consider restricting type parameter `T`
99
|
10-
LL | fn g<T: Copy, const N: usize>(x: T) -> [T; N] {
11-
| ^^^^^^
10+
LL | fn g<T: std::marker::Copy, const N: usize>(x: T) -> [T; N] {
11+
| ^^^^^^^^^^^^^^^^^^^
1212

1313
error: aborting due to previous error
1414

src/test/ui/const-generics/issues/issue-61336.full.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ LL | [x; N]
1616
= note: the `Copy` trait is required because the repeated element will be copied
1717
help: consider restricting type parameter `T`
1818
|
19-
LL | fn g<T: Copy, const N: usize>(x: T) -> [T; N] {
20-
| ^^^^^^
19+
LL | fn g<T: std::marker::Copy, const N: usize>(x: T) -> [T; N] {
20+
| ^^^^^^^^^^^^^^^^^^^
2121

2222
error: aborting due to previous error; 1 warning emitted
2323

src/test/ui/const-generics/issues/issue-61336.min.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ LL | [x; N]
77
= note: the `Copy` trait is required because the repeated element will be copied
88
help: consider restricting type parameter `T`
99
|
10-
LL | fn g<T: Copy, const N: usize>(x: T) -> [T; N] {
11-
| ^^^^^^
10+
LL | fn g<T: std::marker::Copy, const N: usize>(x: T) -> [T; N] {
11+
| ^^^^^^^^^^^^^^^^^^^
1212

1313
error: aborting due to previous error
1414

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim
22
--> $DIR/dst-object-from-unsized-type.rs:8:23
33
|
44
LL | fn test1<T: ?Sized + Foo>(t: &T) {
5-
| - this type parameter needs to be `Sized`
5+
| - this type parameter needs to be `std::marker::Sized`
66
LL | let u: &dyn Foo = t;
77
| ^ doesn't have a size known at compile-time
88
|
@@ -12,7 +12,7 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim
1212
--> $DIR/dst-object-from-unsized-type.rs:13:23
1313
|
1414
LL | fn test2<T: ?Sized + Foo>(t: &T) {
15-
| - this type parameter needs to be `Sized`
15+
| - this type parameter needs to be `std::marker::Sized`
1616
LL | let v: &dyn Foo = t as &dyn Foo;
1717
| ^ doesn't have a size known at compile-time
1818
|

src/test/ui/feature-gates/feature-gate-generic_associated_types.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ LL | type Pointer2<U32> = Box<U32>;
6969
|
7070
help: consider restricting type parameter `U32`
7171
|
72-
LL | type Pointer2<U32: Clone> = Box<U32>;
73-
| ^^^^^^^
72+
LL | type Pointer2<U32: std::clone::Clone> = Box<U32>;
73+
| ^^^^^^^^^^^^^^^^^^^
7474

7575
error: aborting due to 8 previous errors
7676

src/test/ui/generic-associated-types/impl_bounds.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ LL | type C where Self: Copy = String;
5151
= note: the requirement `Fooy<T>: Copy` appears on the associated impl type but not on the corresponding associated trait type
5252
help: consider restricting type parameter `T`
5353
|
54-
LL | impl<T: Copy> Foo for Fooy<T> {
55-
| ^^^^^^
54+
LL | impl<T: std::marker::Copy> Foo for Fooy<T> {
55+
| ^^^^^^^^^^^^^^^^^^^
5656

5757
error: aborting due to 4 previous errors
5858

src/test/ui/generic-associated-types/issue-68641-check-gat-bounds.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ LL | type Item<'a> = T;
1818
|
1919
help: consider restricting type parameter `T`
2020
|
21-
LL | impl<T: Copy> UnsafeCopy for T {
22-
| ^^^^^^
21+
LL | impl<T: std::marker::Copy> UnsafeCopy for T {
22+
| ^^^^^^^^^^^^^^^^^^^
2323

2424
error: aborting due to previous error; 1 warning emitted
2525

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ LL | type F<'a> = Self;
1919
= note: wrap the `T` in a closure with no arguments: `|| { /* code */ }`
2020
help: consider restricting type parameter `T`
2121
|
22-
LL | impl<T: Fn<()>> Fun for T {
23-
| ^^^^^^^^
22+
LL | impl<T: std::ops::Fn<()>> Fun for T {
23+
| ^^^^^^^^^^^^^^^^^^
2424

2525
error: aborting due to previous error; 1 warning emitted
2626

0 commit comments

Comments
 (0)