fix rustc_on_implemented _Self
paths
This commit is contained in:
parent
addc51a85f
commit
5ac917dbb2
7 changed files with 74 additions and 65 deletions
|
@ -163,61 +163,65 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||||
flags.push((sym::from_desugaring, None));
|
flags.push((sym::from_desugaring, None));
|
||||||
flags.push((sym::from_desugaring, Some(format!("{:?}", k))));
|
flags.push((sym::from_desugaring, Some(format!("{:?}", k))));
|
||||||
}
|
}
|
||||||
let generics = self.tcx.generics_of(def_id);
|
|
||||||
let self_ty = trait_ref.self_ty();
|
|
||||||
// This is also included through the generics list as `Self`,
|
|
||||||
// but the parser won't allow you to use it
|
|
||||||
flags.push((sym::_Self, Some(self_ty.to_string())));
|
|
||||||
if let Some(def) = self_ty.ty_adt_def() {
|
|
||||||
// We also want to be able to select self's original
|
|
||||||
// signature with no type arguments resolved
|
|
||||||
flags.push((sym::_Self, Some(self.tcx.type_of(def.did).to_string())));
|
|
||||||
}
|
|
||||||
|
|
||||||
for param in generics.params.iter() {
|
// Add all types without trimmed paths.
|
||||||
let value = match param.kind {
|
ty::print::with_no_trimmed_paths(|| {
|
||||||
GenericParamDefKind::Type { .. } | GenericParamDefKind::Const { .. } => {
|
let generics = self.tcx.generics_of(def_id);
|
||||||
trait_ref.substs[param.index as usize].to_string()
|
let self_ty = trait_ref.self_ty();
|
||||||
}
|
// This is also included through the generics list as `Self`,
|
||||||
GenericParamDefKind::Lifetime => continue,
|
// but the parser won't allow you to use it
|
||||||
};
|
flags.push((sym::_Self, Some(self_ty.to_string())));
|
||||||
let name = param.name;
|
if let Some(def) = self_ty.ty_adt_def() {
|
||||||
flags.push((name, Some(value)));
|
// We also want to be able to select self's original
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(true) = self_ty.ty_adt_def().map(|def| def.did.is_local()) {
|
|
||||||
flags.push((sym::crate_local, None));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Allow targeting all integers using `{integral}`, even if the exact type was resolved
|
|
||||||
if self_ty.is_integral() {
|
|
||||||
flags.push((sym::_Self, Some("{integral}".to_owned())));
|
|
||||||
}
|
|
||||||
|
|
||||||
if let ty::Array(aty, len) = self_ty.kind() {
|
|
||||||
flags.push((sym::_Self, Some("[]".to_owned())));
|
|
||||||
flags.push((sym::_Self, Some(format!("[{}]", aty))));
|
|
||||||
if let Some(def) = aty.ty_adt_def() {
|
|
||||||
// We also want to be able to select the array's type's original
|
|
||||||
// signature with no type arguments resolved
|
// signature with no type arguments resolved
|
||||||
let type_string = self.tcx.type_of(def.did).to_string();
|
flags.push((sym::_Self, Some(self.tcx.type_of(def.did).to_string())));
|
||||||
flags.push((sym::_Self, Some(format!("[{}]", type_string))));
|
|
||||||
|
|
||||||
let len = len.val.try_to_value().and_then(|v| v.try_to_machine_usize(self.tcx));
|
|
||||||
let string = match len {
|
|
||||||
Some(n) => format!("[{}; {}]", type_string, n),
|
|
||||||
None => format!("[{}; _]", type_string),
|
|
||||||
};
|
|
||||||
flags.push((sym::_Self, Some(string)));
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if let ty::Dynamic(traits, _) = self_ty.kind() {
|
for param in generics.params.iter() {
|
||||||
for t in traits.iter() {
|
let value = match param.kind {
|
||||||
if let ty::ExistentialPredicate::Trait(trait_ref) = t.skip_binder() {
|
GenericParamDefKind::Type { .. } | GenericParamDefKind::Const { .. } => {
|
||||||
flags.push((sym::_Self, Some(self.tcx.def_path_str(trait_ref.def_id))))
|
trait_ref.substs[param.index as usize].to_string()
|
||||||
|
}
|
||||||
|
GenericParamDefKind::Lifetime => continue,
|
||||||
|
};
|
||||||
|
let name = param.name;
|
||||||
|
flags.push((name, Some(value)));
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(true) = self_ty.ty_adt_def().map(|def| def.did.is_local()) {
|
||||||
|
flags.push((sym::crate_local, None));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Allow targeting all integers using `{integral}`, even if the exact type was resolved
|
||||||
|
if self_ty.is_integral() {
|
||||||
|
flags.push((sym::_Self, Some("{integral}".to_owned())));
|
||||||
|
}
|
||||||
|
|
||||||
|
if let ty::Array(aty, len) = self_ty.kind() {
|
||||||
|
flags.push((sym::_Self, Some("[]".to_owned())));
|
||||||
|
flags.push((sym::_Self, Some(format!("[{}]", aty))));
|
||||||
|
if let Some(def) = aty.ty_adt_def() {
|
||||||
|
// We also want to be able to select the array's type's original
|
||||||
|
// signature with no type arguments resolved
|
||||||
|
let type_string = self.tcx.type_of(def.did).to_string();
|
||||||
|
flags.push((sym::_Self, Some(format!("[{}]", type_string))));
|
||||||
|
|
||||||
|
let len = len.val.try_to_value().and_then(|v| v.try_to_machine_usize(self.tcx));
|
||||||
|
let string = match len {
|
||||||
|
Some(n) => format!("[{}; {}]", type_string, n),
|
||||||
|
None => format!("[{}; _]", type_string),
|
||||||
|
};
|
||||||
|
flags.push((sym::_Self, Some(string)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
if let ty::Dynamic(traits, _) = self_ty.kind() {
|
||||||
|
for t in traits.iter() {
|
||||||
|
if let ty::ExistentialPredicate::Trait(trait_ref) = t.skip_binder() {
|
||||||
|
flags.push((sym::_Self, Some(self.tcx.def_path_str(trait_ref.def_id))))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
if let Ok(Some(command)) =
|
if let Ok(Some(command)) =
|
||||||
OnUnimplementedDirective::of_item(self.tcx, trait_ref.def_id, def_id)
|
OnUnimplementedDirective::of_item(self.tcx, trait_ref.def_id, def_id)
|
||||||
|
|
|
@ -13,10 +13,10 @@ error[E0277]: `[RangeInclusive<{integer}>; 1]` is not an iterator
|
||||||
--> $DIR/array-of-ranges.rs:4:14
|
--> $DIR/array-of-ranges.rs:4:14
|
||||||
|
|
|
|
||||||
LL | for _ in [0..=1] {}
|
LL | for _ in [0..=1] {}
|
||||||
| ^^^^^^^ arrays do not yet implement `IntoIterator`; try using `std::array::IntoIter::new(arr)`
|
| ^^^^^^^ if you meant to iterate between two values, remove the square brackets
|
||||||
|
|
|
|
||||||
= help: the trait `Iterator` is not implemented for `[RangeInclusive<{integer}>; 1]`
|
= help: the trait `Iterator` is not implemented for `[RangeInclusive<{integer}>; 1]`
|
||||||
= note: see <https://github.com/rust-lang/rust/pull/65819> for more details
|
= note: `[start..=end]` is an array of one `RangeInclusive`; you might have meant to have a `RangeInclusive` without the brackets: `start..=end`
|
||||||
= note: required because of the requirements on the impl of `IntoIterator` for `[RangeInclusive<{integer}>; 1]`
|
= note: required because of the requirements on the impl of `IntoIterator` for `[RangeInclusive<{integer}>; 1]`
|
||||||
= note: required by `into_iter`
|
= note: required by `into_iter`
|
||||||
|
|
||||||
|
@ -24,10 +24,10 @@ error[E0277]: `[RangeFrom<{integer}>; 1]` is not an iterator
|
||||||
--> $DIR/array-of-ranges.rs:6:14
|
--> $DIR/array-of-ranges.rs:6:14
|
||||||
|
|
|
|
||||||
LL | for _ in [0..] {}
|
LL | for _ in [0..] {}
|
||||||
| ^^^^^ arrays do not yet implement `IntoIterator`; try using `std::array::IntoIter::new(arr)`
|
| ^^^^^ if you meant to iterate from a value onwards, remove the square brackets
|
||||||
|
|
|
|
||||||
= help: the trait `Iterator` is not implemented for `[RangeFrom<{integer}>; 1]`
|
= help: the trait `Iterator` is not implemented for `[RangeFrom<{integer}>; 1]`
|
||||||
= note: see <https://github.com/rust-lang/rust/pull/65819> for more details
|
= note: `[start..]` is an array of one `RangeFrom`; you might have meant to have a `RangeFrom` without the brackets: `start..`, keeping in mind that iterating over an unbounded iterator will run forever unless you `break` or `return` from within the loop
|
||||||
= note: required because of the requirements on the impl of `IntoIterator` for `[RangeFrom<{integer}>; 1]`
|
= note: required because of the requirements on the impl of `IntoIterator` for `[RangeFrom<{integer}>; 1]`
|
||||||
= note: required by `into_iter`
|
= note: required by `into_iter`
|
||||||
|
|
||||||
|
@ -35,10 +35,10 @@ error[E0277]: `[RangeTo<{integer}>; 1]` is not an iterator
|
||||||
--> $DIR/array-of-ranges.rs:8:14
|
--> $DIR/array-of-ranges.rs:8:14
|
||||||
|
|
|
|
||||||
LL | for _ in [..1] {}
|
LL | for _ in [..1] {}
|
||||||
| ^^^^^ arrays do not yet implement `IntoIterator`; try using `std::array::IntoIter::new(arr)`
|
| ^^^^^ if you meant to iterate until a value, remove the square brackets and add a starting value
|
||||||
|
|
|
|
||||||
= help: the trait `Iterator` is not implemented for `[RangeTo<{integer}>; 1]`
|
= help: the trait `Iterator` is not implemented for `[RangeTo<{integer}>; 1]`
|
||||||
= note: see <https://github.com/rust-lang/rust/pull/65819> for more details
|
= note: `[..end]` is an array of one `RangeTo`; you might have meant to have a bounded `Range` without the brackets: `0..end`
|
||||||
= note: required because of the requirements on the impl of `IntoIterator` for `[RangeTo<{integer}>; 1]`
|
= note: required because of the requirements on the impl of `IntoIterator` for `[RangeTo<{integer}>; 1]`
|
||||||
= note: required by `into_iter`
|
= note: required by `into_iter`
|
||||||
|
|
||||||
|
@ -46,10 +46,10 @@ error[E0277]: `[RangeToInclusive<{integer}>; 1]` is not an iterator
|
||||||
--> $DIR/array-of-ranges.rs:10:14
|
--> $DIR/array-of-ranges.rs:10:14
|
||||||
|
|
|
|
||||||
LL | for _ in [..=1] {}
|
LL | for _ in [..=1] {}
|
||||||
| ^^^^^^ arrays do not yet implement `IntoIterator`; try using `std::array::IntoIter::new(arr)`
|
| ^^^^^^ if you meant to iterate until a value (including it), remove the square brackets and add a starting value
|
||||||
|
|
|
|
||||||
= help: the trait `Iterator` is not implemented for `[RangeToInclusive<{integer}>; 1]`
|
= help: the trait `Iterator` is not implemented for `[RangeToInclusive<{integer}>; 1]`
|
||||||
= note: see <https://github.com/rust-lang/rust/pull/65819> for more details
|
= note: `[..=end]` is an array of one `RangeToInclusive`; you might have meant to have a bounded `RangeInclusive` without the brackets: `0..=end`
|
||||||
= note: required because of the requirements on the impl of `IntoIterator` for `[RangeToInclusive<{integer}>; 1]`
|
= note: required because of the requirements on the impl of `IntoIterator` for `[RangeToInclusive<{integer}>; 1]`
|
||||||
= note: required by `into_iter`
|
= note: required by `into_iter`
|
||||||
|
|
||||||
|
@ -90,10 +90,10 @@ error[E0277]: `[RangeInclusive<{integer}>; 1]` is not an iterator
|
||||||
--> $DIR/array-of-ranges.rs:21:14
|
--> $DIR/array-of-ranges.rs:21:14
|
||||||
|
|
|
|
||||||
LL | for _ in [0..=1] {}
|
LL | for _ in [0..=1] {}
|
||||||
| ^^^^^^^ arrays do not yet implement `IntoIterator`; try using `std::array::IntoIter::new(arr)`
|
| ^^^^^^^ if you meant to iterate between two values, remove the square brackets
|
||||||
|
|
|
|
||||||
= help: the trait `Iterator` is not implemented for `[RangeInclusive<{integer}>; 1]`
|
= help: the trait `Iterator` is not implemented for `[RangeInclusive<{integer}>; 1]`
|
||||||
= note: see <https://github.com/rust-lang/rust/pull/65819> for more details
|
= note: `[start..=end]` is an array of one `RangeInclusive`; you might have meant to have a `RangeInclusive` without the brackets: `start..=end`
|
||||||
= note: required because of the requirements on the impl of `IntoIterator` for `[RangeInclusive<{integer}>; 1]`
|
= note: required because of the requirements on the impl of `IntoIterator` for `[RangeInclusive<{integer}>; 1]`
|
||||||
= note: required by `into_iter`
|
= note: required by `into_iter`
|
||||||
|
|
||||||
|
|
|
@ -2,9 +2,10 @@ error[E0277]: `RangeTo<{integer}>` is not an iterator
|
||||||
--> $DIR/ranges.rs:2:14
|
--> $DIR/ranges.rs:2:14
|
||||||
|
|
|
|
||||||
LL | for _ in ..10 {}
|
LL | for _ in ..10 {}
|
||||||
| ^^^^ `RangeTo<{integer}>` is not an iterator
|
| ^^^^ if you meant to iterate until a value, add a starting value
|
||||||
|
|
|
|
||||||
= help: the trait `Iterator` is not implemented for `RangeTo<{integer}>`
|
= help: the trait `Iterator` is not implemented for `RangeTo<{integer}>`
|
||||||
|
= note: `..end` is a `RangeTo`, which cannot be iterated on; you might have meant to have a bounded `Range`: `0..end`
|
||||||
= note: required because of the requirements on the impl of `IntoIterator` for `RangeTo<{integer}>`
|
= note: required because of the requirements on the impl of `IntoIterator` for `RangeTo<{integer}>`
|
||||||
= note: required by `into_iter`
|
= note: required by `into_iter`
|
||||||
|
|
||||||
|
@ -12,9 +13,10 @@ error[E0277]: `RangeToInclusive<{integer}>` is not an iterator
|
||||||
--> $DIR/ranges.rs:4:14
|
--> $DIR/ranges.rs:4:14
|
||||||
|
|
|
|
||||||
LL | for _ in ..=10 {}
|
LL | for _ in ..=10 {}
|
||||||
| ^^^^^ `RangeToInclusive<{integer}>` is not an iterator
|
| ^^^^^ if you meant to iterate until a value (including it), add a starting value
|
||||||
|
|
|
|
||||||
= help: the trait `Iterator` is not implemented for `RangeToInclusive<{integer}>`
|
= help: the trait `Iterator` is not implemented for `RangeToInclusive<{integer}>`
|
||||||
|
= note: `..=end` is a `RangeToInclusive`, which cannot be iterated on; you might have meant to have a bounded `RangeInclusive`: `0..=end`
|
||||||
= note: required because of the requirements on the impl of `IntoIterator` for `RangeToInclusive<{integer}>`
|
= note: required because of the requirements on the impl of `IntoIterator` for `RangeToInclusive<{integer}>`
|
||||||
= note: required by `into_iter`
|
= note: required by `into_iter`
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ error[E0277]: `String` is not an iterator
|
||||||
--> $DIR/string.rs:2:14
|
--> $DIR/string.rs:2:14
|
||||||
|
|
|
|
||||||
LL | for _ in "".to_owned() {}
|
LL | for _ in "".to_owned() {}
|
||||||
| ^^^^^^^^^^^^^ `String` is not an iterator
|
| ^^^^^^^^^^^^^ `String` is not an iterator; try calling `.chars()` or `.bytes()`
|
||||||
|
|
|
|
||||||
= help: the trait `Iterator` is not implemented for `String`
|
= help: the trait `Iterator` is not implemented for `String`
|
||||||
= note: required because of the requirements on the impl of `IntoIterator` for `String`
|
= note: required because of the requirements on the impl of `IntoIterator` for `String`
|
||||||
|
|
|
@ -46,6 +46,7 @@ error[E0277]: `dyn Future<Output = i32> + Send` cannot be unpinned
|
||||||
LL | Pin::new(x)
|
LL | Pin::new(x)
|
||||||
| ^^^^^^^^ the trait `Unpin` is not implemented for `dyn Future<Output = i32> + Send`
|
| ^^^^^^^^ the trait `Unpin` is not implemented for `dyn Future<Output = i32> + Send`
|
||||||
|
|
|
|
||||||
|
= note: consider using `Box::pin`
|
||||||
= note: required by `Pin::<P>::new`
|
= note: required by `Pin::<P>::new`
|
||||||
|
|
||||||
error[E0277]: `dyn Future<Output = i32> + Send` cannot be unpinned
|
error[E0277]: `dyn Future<Output = i32> + Send` cannot be unpinned
|
||||||
|
@ -54,6 +55,7 @@ error[E0277]: `dyn Future<Output = i32> + Send` cannot be unpinned
|
||||||
LL | Pin::new(Box::new(x))
|
LL | Pin::new(Box::new(x))
|
||||||
| ^^^^^^^^ the trait `Unpin` is not implemented for `dyn Future<Output = i32> + Send`
|
| ^^^^^^^^ the trait `Unpin` is not implemented for `dyn Future<Output = i32> + Send`
|
||||||
|
|
|
|
||||||
|
= note: consider using `Box::pin`
|
||||||
= note: required by `Pin::<P>::new`
|
= note: required by `Pin::<P>::new`
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
|
|
|
@ -7,6 +7,7 @@ LL | fn foo<'a, T>(_t: T) where T: Into<&'a str> {}
|
||||||
LL | foo(String::new());
|
LL | foo(String::new());
|
||||||
| ^^^ the trait `From<String>` is not implemented for `&str`
|
| ^^^ the trait `From<String>` is not implemented for `&str`
|
||||||
|
|
|
|
||||||
|
= note: to coerce a `String` into a `&str`, use `&*` as a prefix
|
||||||
= note: required because of the requirements on the impl of `Into<&str>` for `String`
|
= note: required because of the requirements on the impl of `Into<&str>` for `String`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
|
@ -2,10 +2,10 @@ error[E0277]: `Path` doesn't implement `std::fmt::Display`
|
||||||
--> $DIR/path-display.rs:5:20
|
--> $DIR/path-display.rs:5:20
|
||||||
|
|
|
|
||||||
LL | println!("{}", path);
|
LL | println!("{}", path);
|
||||||
| ^^^^ `Path` cannot be formatted with the default formatter
|
| ^^^^ `Path` cannot be formatted with the default formatter; call `.display()` on it
|
||||||
|
|
|
|
||||||
= help: the trait `std::fmt::Display` is not implemented for `Path`
|
= help: the trait `std::fmt::Display` is not implemented for `Path`
|
||||||
= note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
|
= note: call `.display()` or `.to_string_lossy()` to safely print paths, as they may contain non-Unicode data
|
||||||
= note: required because of the requirements on the impl of `std::fmt::Display` for `&Path`
|
= note: required because of the requirements on the impl of `std::fmt::Display` for `&Path`
|
||||||
= note: required by `std::fmt::Display::fmt`
|
= note: required by `std::fmt::Display::fmt`
|
||||||
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue