Skip to content

Commit

Permalink
Revert "sort suggestions for object diagnostic"
Browse files Browse the repository at this point in the history
This reverts commit 540be28.
  • Loading branch information
compiler-errors committed Feb 11, 2024
1 parent 88baa23 commit a4ef7c4
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
3 changes: 1 addition & 2 deletions compiler/rustc_infer/src/traits/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,12 @@ pub fn report_object_safety_error<'tcx>(
)));
}
impls => {
let mut types = impls
let types = impls
.iter()
.map(|t| {
with_no_trimmed_paths!(format!(" {}", tcx.type_of(*t).instantiate_identity(),))
})
.collect::<Vec<_>>();
types.sort();
err.help(format!(
"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 \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ LL | type A<'a> where Self: 'a;
| ^ ...because it contains the generic associated type `A`
= 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:
Fooer<T>
Fooy
Fooer<T>

error: aborting due to 1 previous error

Expand Down
4 changes: 2 additions & 2 deletions tests/ui/generic-associated-types/issue-79422.base.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ LL | type VRefCont<'a>: RefCont<'a, V> where Self: 'a;
| ^^^^^^^^ ...because it contains the generic associated type `VRefCont`
= 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:
Source
std::collections::BTreeMap<K, V>
Source

error[E0038]: the trait `MapLike` cannot be made into an object
--> $DIR/issue-79422.rs:44:13
Expand All @@ -47,8 +47,8 @@ LL | type VRefCont<'a>: RefCont<'a, V> where Self: 'a;
| ^^^^^^^^ ...because it contains the generic associated type `VRefCont`
= 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:
Source
std::collections::BTreeMap<K, V>
Source
= 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
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/wf/wf-unsafe-trait-obj-match.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ LL | trait Trait: Sized {}
| |
| 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:
R
S
R
= note: required for the cast from `&S` to `&dyn Trait`

error[E0038]: the trait `Trait` cannot be made into an object
Expand All @@ -52,8 +52,8 @@ LL | trait Trait: Sized {}
| |
| 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:
R
S
R
= note: required for the cast from `&R` to `&dyn Trait`

error: aborting due to 3 previous errors
Expand Down

0 comments on commit a4ef7c4

Please sign in to comment.