sort suggestions for object diagnostic
This commit is contained in:
parent
9322882ade
commit
540be28f6c
4 changed files with 7 additions and 6 deletions
|
@ -178,12 +178,13 @@ pub fn report_object_safety_error<'tcx>(
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
impls => {
|
impls => {
|
||||||
let types = impls
|
let mut types = impls
|
||||||
.iter()
|
.iter()
|
||||||
.map(|t| {
|
.map(|t| {
|
||||||
with_no_trimmed_paths!(format!(" {}", tcx.type_of(*t).instantiate_identity(),))
|
with_no_trimmed_paths!(format!(" {}", tcx.type_of(*t).instantiate_identity(),))
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
types.sort();
|
||||||
err.help(format!(
|
err.help(format!(
|
||||||
"the following types implement the trait, consider defining an enum where each \
|
"the following types implement the trait, consider defining an enum where each \
|
||||||
variant holds one of these types, implementing `{}` for this new enum and using \
|
variant holds one of these types, implementing `{}` for this new enum and using \
|
||||||
|
|
|
@ -13,8 +13,8 @@ LL | type A<'a> where Self: 'a;
|
||||||
| ^ ...because it contains the generic associated type `A`
|
| ^ ...because it contains the generic associated type `A`
|
||||||
= help: consider moving `A` to another trait
|
= help: consider moving `A` to another trait
|
||||||
= help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `Foo` for this new enum and using it instead:
|
= help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `Foo` for this new enum and using it instead:
|
||||||
Fooy
|
|
||||||
Fooer<T>
|
Fooer<T>
|
||||||
|
Fooy
|
||||||
|
|
||||||
error: aborting due to 1 previous error
|
error: aborting due to 1 previous error
|
||||||
|
|
||||||
|
|
|
@ -29,8 +29,8 @@ LL | type VRefCont<'a>: RefCont<'a, V> where Self: 'a;
|
||||||
| ^^^^^^^^ ...because it contains the generic associated type `VRefCont`
|
| ^^^^^^^^ ...because it contains the generic associated type `VRefCont`
|
||||||
= help: consider moving `VRefCont` to another trait
|
= help: consider moving `VRefCont` to another trait
|
||||||
= help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `MapLike` for this new enum and using it instead:
|
= help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `MapLike` for this new enum and using it instead:
|
||||||
std::collections::BTreeMap<K, V>
|
|
||||||
Source
|
Source
|
||||||
|
std::collections::BTreeMap<K, V>
|
||||||
|
|
||||||
error[E0038]: the trait `MapLike` cannot be made into an object
|
error[E0038]: the trait `MapLike` cannot be made into an object
|
||||||
--> $DIR/issue-79422.rs:44:13
|
--> $DIR/issue-79422.rs:44:13
|
||||||
|
@ -47,8 +47,8 @@ LL | type VRefCont<'a>: RefCont<'a, V> where Self: 'a;
|
||||||
| ^^^^^^^^ ...because it contains the generic associated type `VRefCont`
|
| ^^^^^^^^ ...because it contains the generic associated type `VRefCont`
|
||||||
= help: consider moving `VRefCont` to another trait
|
= help: consider moving `VRefCont` to another trait
|
||||||
= help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `MapLike` for this new enum and using it instead:
|
= help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `MapLike` for this new enum and using it instead:
|
||||||
std::collections::BTreeMap<K, V>
|
|
||||||
Source
|
Source
|
||||||
|
std::collections::BTreeMap<K, V>
|
||||||
= note: required for the cast from `Box<BTreeMap<u8, u8>>` to `Box<dyn MapLike<u8, u8, VRefCont = (dyn RefCont<'_, u8> + 'static)>>`
|
= note: required for the cast from `Box<BTreeMap<u8, u8>>` to `Box<dyn MapLike<u8, u8, VRefCont = (dyn RefCont<'_, u8> + 'static)>>`
|
||||||
|
|
||||||
error: aborting due to 3 previous errors
|
error: aborting due to 3 previous errors
|
||||||
|
|
|
@ -30,8 +30,8 @@ LL | trait Trait: Sized {}
|
||||||
| |
|
| |
|
||||||
| this trait cannot be made into an object...
|
| this trait cannot be made into an object...
|
||||||
= help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `Trait` for this new enum and using it instead:
|
= help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `Trait` for this new enum and using it instead:
|
||||||
S
|
|
||||||
R
|
R
|
||||||
|
S
|
||||||
= note: required for the cast from `&S` to `&dyn Trait`
|
= note: required for the cast from `&S` to `&dyn Trait`
|
||||||
|
|
||||||
error[E0038]: the trait `Trait` cannot be made into an object
|
error[E0038]: the trait `Trait` cannot be made into an object
|
||||||
|
@ -52,8 +52,8 @@ LL | trait Trait: Sized {}
|
||||||
| |
|
| |
|
||||||
| this trait cannot be made into an object...
|
| this trait cannot be made into an object...
|
||||||
= help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `Trait` for this new enum and using it instead:
|
= help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `Trait` for this new enum and using it instead:
|
||||||
S
|
|
||||||
R
|
R
|
||||||
|
S
|
||||||
= note: required for the cast from `&R` to `&dyn Trait`
|
= note: required for the cast from `&R` to `&dyn Trait`
|
||||||
|
|
||||||
error: aborting due to 3 previous errors
|
error: aborting due to 3 previous errors
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue