10000 Detect object safety errors when assoc type is missing by estebank · Pull Request #116405 · rust-lang/rust · GitHub
[go: up one dir, main page]

Skip to content

Detect object safety errors when assoc type is missing #116405

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Sort errors
  • Loading branch information
estebank committed Oct 30, 2023
commit b8a8ba9c919b76ef1e51ee42f1c7182fd1ac20cd
10 changes: 6 additions & 4 deletions compiler/rustc_hir_analysis/src/astconv/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,9 +585,10 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
}
}

let names = names
let mut names = names
.into_iter()
.map(|(trait_, assocs)| {
.map(|(trait_, mut assocs)| {
assocs.sort();
format!(
"{} in `{trait_}`",
match &assocs[..] {
Expand All @@ -600,8 +601,9 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
}
)
})
.collect::<Vec<String>>()
.join(", ");
.collect::<Vec<String>>();
names.sort();
let names = names.join(", ");

trait_bound_spans.sort();
let mut err = struct_span_err!(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error[E0191]: the value of the associated types `Item`, `IntoIter`, `Item` and `IntoIter` in `IntoIterator` must be specified
error[E0191]: the value of the associated types `Item`, `Item`, `Into 10000 Iter` and `IntoIter` in `IntoIterator` must be specified
--> $DIR/overlaping-bound-suggestion.rs:7:13
|
LL | inner: <IntoIterator<Item: IntoIterator<Item: >>::IntoIterator as Item>::Core,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ LL | fn dent_object<COLOR>(c: dyn BoxCar<Color=COLOR>) {
T: Vehicle::Color = COLOR,
T: Box::Color = COLOR

error[E0191]: the value of the associated types `Color` in `Vehicle`, `Color` in `Box` must be specified
error[E0191]: the value of the associated types `Color` in `Box`, `Color` in `Vehicle` must be specified
--> $DIR/associated-type-projection-from-multiple-supertraits.rs:23:30
|
LL | type Color;
Expand Down Expand Up @@ -80,7 +80,7 @@ help: use fully-qualified syntax to disambiguate
LL | fn paint<C:BoxCar>(c: C, d: <C as Box>::Color) {
| ~~~~~~~~~~~~

error[E0191]: the value of the associated types `Color` in `Vehicle`, `Color` in `Box` must be specified
error[E0191]: the value of the associated types `Color` in `Box`, `Color` in `Vehicle` must be specified
--> $DIR/associated-type-projection-from-multiple-supertraits.rs:32:32
|
LL | type Color;
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/associated-types/issue-22560.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ LL | type Test = dyn Add + Sub;
= help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: Add + Sub {}`
= note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>

error[E0191]: the value of the associated types `Output` in `Sub`, `Output` in `Add` must be specified
error[E0191]: the value of the associated types `Output` in `Add`, `Output` in `Sub` must be specified
--> $DIR/issue-22560.rs:9:17
|
LL | type Output;
Expand Down
8 changes: 4 additions & 4 deletions tests/ui/associated-types/missing-associated-types.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ LL | type Foo<Rhs> = dyn Add<Rhs> + Sub<Rhs> + X<Rhs> + Y<Rhs>;
= help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: Add<Rhs> + Sub<Rhs> + X<Rhs> + Y<Rhs> {}`
= note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>

error[E0191]: the value of the associated types `A` in `Y`, `Output` in `Sub`, `Output` in `Mul`, `Output` in `Add` must be specified
error[E0191]: the value of the associated types `A` in `Y`, `Output` in `Add`, `Output` in `Mul`, `Output` in `Sub` must be specified
--> $DIR/missing-associated-types.rs:12:21
|
LL | type A;
Expand Down Expand Up @@ -38,7 +38,7 @@ LL | type Bar<Rhs> = dyn Add<Rhs> + Sub<Rhs> + X<Rhs> + Z<Rhs>;
= help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: Add<Rhs> + Sub<Rhs> + X<Rhs> + Z<Rhs> {}`
= note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>

error[E0191]: the value of the associated types `Output` and `Output` in `Div`, `Output` in `Add`, `Output` in `Sub`, `Output` in `Mul`, `A` and `B` in `Z` must be specified
error[E0191]: the value of the associated types `A` and `B` in `Z`, `Output` and `Output` in `Div`, `Output` in `Add`, `Output` in `Mul`, `Output` in `Sub` must be specified
--> $DIR/missing-associated-types.rs:15:21
|
LL | type A;
Expand Down Expand Up @@ -74,7 +74,7 @@ LL | type Baz<Rhs> = dyn Add<Rhs> + Sub<Rhs> + Y<Rhs>;
= help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: Add<Rhs> + Sub<Rhs> + Y<Rhs> {}`
= note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>

error[E0191]: the value of the associated types `Output` in `Sub`, `A` in `Y`, `Output` in `Add` must be specified
error[E0191]: the value of the associated types `A` in `Y`, `Output` in `Add`, `Output` in `Sub` must be specified
--> $DIR/missing-associated-types.rs:18:21
|
LL | type A;
Expand Down Expand Up @@ -102,7 +102,7 @@ LL | type Bat<Rhs> = dyn Add<Rhs> + Sub<Rhs> + Fine<Rhs>;
= help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: Add<Rhs> + Sub<Rhs> + Fine<Rhs> {}`
= note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>

error[E0191]: the value of the associated types `Output` in `Sub`, `Output` in `Add` must be specified
error[E0191]: the value of the associated types `Output` in `Add`, `Output` in `Sub` must be specified
--> $DIR/missing-associated-types.rs:21:21
|
LL | type Bat<Rhs> = dyn Add<Rhs> + Sub<Rhs> + Fine<Rhs>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ help: replace the generic bounds with the associated types
LL | i: Box<dyn T<usize, usize, A = usize, C = usize, B=usize>>,
| +++ +++

error[E0191]: the value of the associated types `A` and `C` in `T` must be specified
error[E0191]: the value of the associated types `C` and `A` in `T` must be specified
--> $DIR/use-type-argument-instead-of-assoc-type.rs:7:16
|
LL | type A;
Expand Down
0