Skip to content

Commit

Permalink
give full path of constraint in suggest_constraining_type_param
Browse files Browse the repository at this point in the history
revert file

bless with nll mode
  • Loading branch information
Rustin170506 committed Mar 31, 2021
1 parent 74874a6 commit 8f77356
Show file tree
Hide file tree
Showing 90 changed files with 249 additions and 247 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ use std::fmt;

use super::InferCtxtPrivExt;
use crate::traits::query::evaluate_obligation::InferCtxtExt as _;
use rustc_middle::ty::print::with_no_trimmed_paths;

#[derive(Debug)]
pub enum GeneratorInteriorOrUpvar {
Expand Down Expand Up @@ -440,7 +441,8 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
{
// Missing generic type parameter bound.
let param_name = self_ty.to_string();
let constraint = trait_ref.print_only_trait_path().to_string();
let constraint =
with_no_trimmed_paths(|| trait_ref.print_only_trait_path().to_string());
if suggest_constraining_type_param(
self.tcx,
generics,
Expand Down
8 changes: 4 additions & 4 deletions src/test/ui/associated-types/defaults-suitability.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ LL | type Bar: Clone = Vec<T>;
= note: required because of the requirements on the impl of `Clone` for `Vec<T>`
help: consider restricting type parameter `T`
|
LL | trait Foo<T: Clone> {
| ^^^^^^^
LL | trait Foo<T: std::clone::Clone> {
| ^^^^^^^^^^^^^^^^^^^

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

error: aborting due to 8 previous errors

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ LL | copy::<dyn Setup<From=T>>(t)
|
help: consider restricting type parameter `T`
|
LL | pub fn copy_any<T: Copy>(t: &T) -> T {
| ^^^^^^
LL | pub fn copy_any<T: std::marker::Copy>(t: &T) -> T {
| ^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ LL | type Assoc = T;
|
help: consider restricting type parameter `T`
|
LL | impl<T: Copy> Complete for T {
| ^^^^^^
LL | impl<T: std::marker::Copy> Complete for T {
| ^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error

Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/async-await/issue-70818.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ LL | async { (ty, ty1) }
| ^^^ has type `U` which is not `Send`
help: consider restricting type parameter `U`
|
LL | fn foo<T: Send, U: Send>(ty: T, ty1: U) -> impl Future<Output = (T, U)> + Send {
| ^^^^^^
LL | fn foo<T: Send, U: std::marker::Send>(ty: T, ty1: U) -> impl Future<Output = (T, U)> + Send {
| ^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error

4 changes: 2 additions & 2 deletions src/test/ui/bad/bad-method-typaram-kind.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ LL | 1.bar::<T>();
|
help: consider further restricting this bound
|
LL | fn foo<T:'static + Send>() {
| ^^^^^^
LL | fn foo<T:'static + std::marker::Send>() {
| ^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error

Expand Down
12 changes: 6 additions & 6 deletions src/test/ui/bound-suggestions.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,37 @@ use std::fmt::Debug;
// Rustfix should add this, or use `std::fmt::Debug` instead.

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

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

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

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

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

#[allow(dead_code)]
fn test_many_bounds_where<X>(x: X) where X: Sized, X: Sized, X: Debug {
fn test_many_bounds_where<X>(x: X) where X: Sized, X: Sized, X: std::fmt::Debug {
println!("{:?}", x);
//~^ ERROR doesn't implement
}
Expand Down
24 changes: 12 additions & 12 deletions src/test/ui/bound-suggestions.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ LL | println!("{:?}", t);
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider further restricting this bound
|
LL | fn test_impl(t: impl Sized + Debug) {
| ^^^^^^^
LL | fn test_impl(t: impl Sized + std::fmt::Debug) {
| ^^^^^^^^^^^^^^^^^

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

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

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

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

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

error[E0277]: the size for values of type `Self` cannot be known at compilation time
--> $DIR/bound-suggestions.rs:44:46
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ LL | impl <T: Sync+'static> Foo for (T,) { }
= note: required because it appears within the type `(T,)`
help: consider further restricting this bound
|
LL | impl <T: Sync+'static + Send> Foo for (T,) { }
| ^^^^^^
LL | impl <T: Sync+'static + std::marker::Send> Foo for (T,) { }
| ^^^^^^^^^^^^^^^^^^^

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

error: aborting due to 2 previous errors

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ LL | pub trait RequiresRequiresShareAndSend : RequiresShare + Send { }
= note: required because it appears within the type `X<T>`
help: consider further restricting this bound
|
LL | impl <T:Sync+'static + Send> RequiresRequiresShareAndSend for X<T> { }
| ^^^^^^
LL | impl <T:Sync+'static + std::marker::Send> RequiresRequiresShareAndSend for X<T> { }
| ^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ LL | impl <T: Sync+'static> Foo for T { }
|
help: consider further restricting this bound
|
LL | impl <T: Sync+'static + Send> Foo for T { }
| ^^^^^^
LL | impl <T: Sync+'static + std::marker::Send> Foo for T { }
| ^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ LL | fn foo<F>(blk: F) -> X<F> where F: FnOnce() + 'static {
|
help: consider further restricting this bound
|
LL | fn foo<F>(blk: F) -> X<F> where F: FnOnce() + 'static + Send {
| ^^^^^^
LL | fn foo<F>(blk: F) -> X<F> where F: FnOnce() + 'static + std::marker::Send {
| ^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error

Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/closures/closure-bounds-subtype.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ LL | take_const_owned(f);
|
help: consider further restricting this bound
|
LL | fn give_owned<F>(f: F) where F: FnOnce() + Send + Sync {
| ^^^^^^
LL | fn give_owned<F>(f: F) where F: FnOnce() + Send + std::marker::Sync {
| ^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim
--> $DIR/const-argument-if-length.rs:7:28
|
LL | pub const fn is_zst<T: ?Sized>() -> usize {
| - this type parameter needs to be `Sized`
| - this type parameter needs to be `std::marker::Sized`
LL | if std::mem::size_of::<T>() == 0 {
| ^ doesn't have a size known at compile-time
|
Expand All @@ -15,7 +15,7 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim
--> $DIR/const-argument-if-length.rs:16:12
|
LL | pub struct AtLeastByte<T: ?Sized> {
| - this type parameter needs to be `Sized`
| - this type parameter needs to be `std::marker::Sized`
LL | value: T,
| ^ doesn't have a size known at compile-time
|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim
--> $DIR/const-argument-if-length.rs:16:12
|
LL | pub struct AtLeastByte<T: ?Sized> {
| - this type parameter needs to be `Sized`
| - this type parameter needs to be `std::marker::Sized`
LL | value: T,
| ^ doesn't have a size known at compile-time
|
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/const-generics/issues/issue-61336-2.full.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ LL | [x; { N }]
= note: the `Copy` trait is required because the repeated element will be copied
help: consider restricting type parameter `T`
|
LL | fn g<T: Copy, const N: usize>(x: T) -> [T; N] {
| ^^^^^^
LL | fn g<T: std::marker::Copy, const N: usize>(x: T) -> [T; N] {
| ^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error; 1 warning emitted

Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/const-generics/issues/issue-61336-2.min.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ LL | [x; { N }]
= note: the `Copy` trait is required because the repeated element will be copied
help: consider restricting type parameter `T`
|
LL | fn g<T: Copy, const N: usize>(x: T) -> [T; N] {
| ^^^^^^
LL | fn g<T: std::marker::Copy, const N: usize>(x: T) -> [T; N] {
| ^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error

Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/const-generics/issues/issue-61336.full.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ LL | [x; N]
= note: the `Copy` trait is required because the repeated element will be copied
help: consider restricting type parameter `T`
|
LL | fn g<T: Copy, const N: usize>(x: T) -> [T; N] {
| ^^^^^^
LL | fn g<T: std::marker::Copy, const N: usize>(x: T) -> [T; N] {
| ^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error; 1 warning emitted

Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/const-generics/issues/issue-61336.min.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ LL | [x; N]
= note: the `Copy` trait is required because the repeated element will be copied
help: consider restricting type parameter `T`
|
LL | fn g<T: Copy, const N: usize>(x: T) -> [T; N] {
| ^^^^^^
LL | fn g<T: std::marker::Copy, const N: usize>(x: T) -> [T; N] {
| ^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error

Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/dst/dst-object-from-unsized-type.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim
--> $DIR/dst-object-from-unsized-type.rs:8:23
|
LL | fn test1<T: ?Sized + Foo>(t: &T) {
| - this type parameter needs to be `Sized`
| - this type parameter needs to be `std::marker::Sized`
LL | let u: &dyn Foo = t;
| ^ doesn't have a size known at compile-time
|
Expand All @@ -12,7 +12,7 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim
--> $DIR/dst-object-from-unsized-type.rs:13:23
|
LL | fn test2<T: ?Sized + Foo>(t: &T) {
| - this type parameter needs to be `Sized`
| - this type parameter needs to be `std::marker::Sized`
LL | let v: &dyn Foo = t as &dyn Foo;
| ^ doesn't have a size known at compile-time
|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ LL | type Pointer2<U32> = Box<U32>;
|
help: consider restricting type parameter `U32`
|
LL | type Pointer2<U32: Clone> = Box<U32>;
| ^^^^^^^
LL | type Pointer2<U32: std::clone::Clone> = Box<U32>;
| ^^^^^^^^^^^^^^^^^^^

error: aborting due to 8 previous errors

Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/generic-associated-types/impl_bounds.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ LL | type C where Self: Copy = String;
= note: the requirement `Fooy<T>: Copy` appears on the associated impl type but not on the corresponding associated trait type
help: consider restricting type parameter `T`
|
LL | impl<T: Copy> Foo for Fooy<T> {
| ^^^^^^
LL | impl<T: std::marker::Copy> Foo for Fooy<T> {
| ^^^^^^^^^^^^^^^^^^^

error: aborting due to 4 previous errors

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ LL | type Item<'a> = T;
|
help: consider restricting type parameter `T`
|
LL | impl<T: Copy> UnsafeCopy for T {
| ^^^^^^
LL | impl<T: std::marker::Copy> UnsafeCopy for T {
| ^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error; 1 warning emitted

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ LL | type F<'a> = Self;
= note: wrap the `T` in a closure with no arguments: `|| { /* code */ }`
help: consider restricting type parameter `T`
|
LL | impl<T: Fn<()>> Fun for T {
| ^^^^^^^^
LL | impl<T: std::ops::Fn<()>> Fun for T {
| ^^^^^^^^^^^^^^^^^^

error: aborting due to previous error; 1 warning emitted

Expand Down
Loading

0 comments on commit 8f77356

Please sign in to comment.