Skip to content

Commit e6d43ed

Browse files
authored
Unrolled build for #147269
Rollup merge of #147269 - reddevilmidzy:ice-fix, r=petrochenkov Add regression test for 123953 close: #123953
2 parents 7950f24 + fab9906 commit e6d43ed

File tree

2 files changed

+80
-0
lines changed

2 files changed

+80
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Regression test for the projection bug in <https://github.com/rust-lang/rust/issues/123953>
2+
//
3+
//@ compile-flags: -Zincremental-verify-ich=yes
4+
//@ incremental
5+
6+
pub trait A {}
7+
pub trait B: A {}
8+
9+
pub trait Mirror {
10+
type Assoc: ?Sized;
11+
}
12+
13+
impl<T: ?Sized> Mirror for A {
14+
//~^ ERROR the type parameter `T` is not constrained by the impl trait, self type, or predicates [E0207]
15+
//~| WARN trait objects without an explicit `dyn` are deprecated [bare_trait_objects]
16+
//~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
17+
type Assoc = T;
18+
}
19+
20+
pub fn foo<'a>(
21+
x: &'a <dyn A + 'static as Mirror>::Assoc
22+
) -> &'a <dyn B + 'static as Mirror>::Assoc {
23+
//~^ ERROR the trait bound `(dyn B + 'static): Mirror` is not satisfied [E0277]
24+
//~| ERROR the trait bound `(dyn B + 'static): Mirror` is not satisfied [E0277]
25+
static
26+
} //~ ERROR expected identifier, found `}`
27+
28+
pub fn main() {}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
error: expected identifier, found `}`
2+
--> $DIR/projection-dyn-associated-type.rs:26:1
3+
|
4+
LL | }
5+
| ^ expected identifier
6+
7+
warning: trait objects without an explicit `dyn` are deprecated
8+
--> $DIR/projection-dyn-associated-type.rs:13:28
9+
|
10+
LL | impl<T: ?Sized> Mirror for A {
11+
| ^
12+
|
13+
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
14+
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2021/warnings-promoted-to-error.html>
15+
= note: `#[warn(bare_trait_objects)]` (part of `#[warn(rust_2021_compatibility)]`) on by default
16+
help: if this is a dyn-compatible trait, use `dyn`
17+
|
18+
LL | impl<T: ?Sized> Mirror for dyn A {
19+
| +++
20+
help: alternatively use a blanket implementation to implement `Mirror` for all types that also implement `A`
21+
|
22+
LL - impl<T: ?Sized> Mirror for A {
23+
LL + impl<T: ?Sized, U: A> Mirror for U {
24+
|
25+
26+
error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates
27+
--> $DIR/projection-dyn-associated-type.rs:13:6
28+
|
29+
LL | impl<T: ?Sized> Mirror for A {
30+
| ^ unconstrained type parameter
31+
32+
error[E0277]: the trait bound `(dyn B + 'static): Mirror` is not satisfied
33+
--> $DIR/projection-dyn-associated-type.rs:22:6
34+
|
35+
LL | ) -> &'a <dyn B + 'static as Mirror>::Assoc {
36+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Mirror` is not implemented for `(dyn B + 'static)`
37+
|
38+
= help: the trait `Mirror` is implemented for `dyn A`
39+
40+
error[E0277]: the trait bound `(dyn B + 'static): Mirror` is not satisfied
41+
--> $DIR/projection-dyn-associated-type.rs:22:6
42+
|
43+
LL | ) -> &'a <dyn B + 'static as Mirror>::Assoc {
44+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Mirror` is not implemented for `(dyn B + 'static)`
45+
|
46+
= help: the trait `Mirror` is implemented for `dyn A`
47+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
48+
49+
error: aborting due to 4 previous errors; 1 warning emitted
50+
51+
Some errors have detailed explanations: E0207, E0277.
52+
For more information about an error, try `rustc --explain E0207`.

0 commit comments

Comments
 (0)