mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-31 17:12:53 +00:00
Don't ICE when auto trait has assoc ty in old solver
This commit is contained in:
parent
2ccafed862
commit
0919d0714e
@ -1202,6 +1202,12 @@ fn assemble_candidates_from_impls<'cx, 'tcx>(
|
|||||||
false
|
false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if tcx.trait_is_auto(trait_ref.def_id) {
|
||||||
|
tcx.dcx().span_delayed_bug(
|
||||||
|
tcx.def_span(obligation.predicate.def_id),
|
||||||
|
"associated types not allowed on auto traits",
|
||||||
|
);
|
||||||
|
false
|
||||||
} else {
|
} else {
|
||||||
bug!("unexpected builtin trait with associated type: {trait_ref:?}")
|
bug!("unexpected builtin trait with associated type: {trait_ref:?}")
|
||||||
}
|
}
|
||||||
|
@ -1,14 +0,0 @@
|
|||||||
//@ known-bug: #117829
|
|
||||||
#![feature(auto_traits)]
|
|
||||||
|
|
||||||
trait B {}
|
|
||||||
|
|
||||||
auto trait Z<T>
|
|
||||||
where
|
|
||||||
T: Z<u16>,
|
|
||||||
<T as Z<u16>>::W: B,
|
|
||||||
{
|
|
||||||
type W;
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {}
|
|
@ -1,9 +0,0 @@
|
|||||||
//@ known-bug: #117829
|
|
||||||
auto trait Z<'a, T: ?Sized>
|
|
||||||
where
|
|
||||||
T: Z<'a, u16>,
|
|
||||||
|
|
||||||
for<'b> <T as Z<'b, u16>>::W: Clone,
|
|
||||||
{
|
|
||||||
type W: ?Sized;
|
|
||||||
}
|
|
40
tests/ui/auto-traits/assoc-ty.current.stderr
Normal file
40
tests/ui/auto-traits/assoc-ty.current.stderr
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
error[E0380]: auto traits cannot have associated items
|
||||||
|
--> $DIR/assoc-ty.rs:10:10
|
||||||
|
|
|
||||||
|
LL | auto trait Trait {
|
||||||
|
| ----- auto traits cannot have associated items
|
||||||
|
LL |
|
||||||
|
LL | type Output;
|
||||||
|
| -----^^^^^^- help: remove these associated items
|
||||||
|
|
||||||
|
error[E0658]: auto traits are experimental and possibly buggy
|
||||||
|
--> $DIR/assoc-ty.rs:8:1
|
||||||
|
|
|
||||||
|
LL | / auto trait Trait {
|
||||||
|
LL | |
|
||||||
|
LL | | type Output;
|
||||||
|
LL | |
|
||||||
|
LL | | }
|
||||||
|
| |_^
|
||||||
|
|
|
||||||
|
= note: see issue #13231 <https://github.com/rust-lang/rust/issues/13231> for more information
|
||||||
|
= help: add `#![feature(auto_traits)]` to the crate attributes to enable
|
||||||
|
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||||
|
|
||||||
|
error[E0308]: mismatched types
|
||||||
|
--> $DIR/assoc-ty.rs:15:36
|
||||||
|
|
|
||||||
|
LL | let _: <() as Trait>::Output = ();
|
||||||
|
| --------------------- ^^ expected associated type, found `()`
|
||||||
|
| |
|
||||||
|
| expected due to this
|
||||||
|
|
|
||||||
|
= note: expected associated type `<() as Trait>::Output`
|
||||||
|
found unit type `()`
|
||||||
|
= help: consider constraining the associated type `<() as Trait>::Output` to `()` or calling a method that returns `<() as Trait>::Output`
|
||||||
|
= note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
|
||||||
|
|
||||||
|
error: aborting due to 3 previous errors
|
||||||
|
|
||||||
|
Some errors have detailed explanations: E0308, E0380, E0658.
|
||||||
|
For more information about an error, try `rustc --explain E0308`.
|
40
tests/ui/auto-traits/assoc-ty.next.stderr
Normal file
40
tests/ui/auto-traits/assoc-ty.next.stderr
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
error[E0380]: auto traits cannot have associated items
|
||||||
|
--> $DIR/assoc-ty.rs:10:10
|
||||||
|
|
|
||||||
|
LL | auto trait Trait {
|
||||||
|
| ----- auto traits cannot have associated items
|
||||||
|
LL |
|
||||||
|
LL | type Output;
|
||||||
|
| -----^^^^^^- help: remove these associated items
|
||||||
|
|
||||||
|
error[E0658]: auto traits are experimental and possibly buggy
|
||||||
|
--> $DIR/assoc-ty.rs:8:1
|
||||||
|
|
|
||||||
|
LL | / auto trait Trait {
|
||||||
|
LL | |
|
||||||
|
LL | | type Output;
|
||||||
|
LL | |
|
||||||
|
LL | | }
|
||||||
|
| |_^
|
||||||
|
|
|
||||||
|
= note: see issue #13231 <https://github.com/rust-lang/rust/issues/13231> for more information
|
||||||
|
= help: add `#![feature(auto_traits)]` to the crate attributes to enable
|
||||||
|
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||||
|
|
||||||
|
error[E0308]: mismatched types
|
||||||
|
--> $DIR/assoc-ty.rs:15:36
|
||||||
|
|
|
||||||
|
LL | let _: <() as Trait>::Output = ();
|
||||||
|
| --------------------- ^^ types differ
|
||||||
|
| |
|
||||||
|
| expected due to this
|
||||||
|
|
|
||||||
|
= note: expected associated type `<() as Trait>::Output`
|
||||||
|
found unit type `()`
|
||||||
|
= help: consider constraining the associated type `<() as Trait>::Output` to `()` or calling a method that returns `<() as Trait>::Output`
|
||||||
|
= note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
|
||||||
|
|
||||||
|
error: aborting due to 3 previous errors
|
||||||
|
|
||||||
|
Some errors have detailed explanations: E0308, E0380, E0658.
|
||||||
|
For more information about an error, try `rustc --explain E0308`.
|
17
tests/ui/auto-traits/assoc-ty.rs
Normal file
17
tests/ui/auto-traits/assoc-ty.rs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
//@ revisions: current next
|
||||||
|
//@[next] compile-flags: -Znext-solver
|
||||||
|
//@ ignore-compare-mode-next-solver (explicit revisions)
|
||||||
|
|
||||||
|
// Tests that projection doesn't explode if we accidentally
|
||||||
|
// put an associated type on an auto trait.
|
||||||
|
|
||||||
|
auto trait Trait {
|
||||||
|
//~^ ERROR auto traits are experimental and possibly buggy
|
||||||
|
type Output;
|
||||||
|
//~^ ERROR auto traits cannot have associated items
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let _: <() as Trait>::Output = ();
|
||||||
|
//~^ ERROR mismatched types
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user