forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add variation of the rust-lang#135246 unsoundness
- Loading branch information
Showing
3 changed files
with
124 additions
and
0 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
.../ui/traits/next-solver/cycles/coinduction/item-bound-via-impl-where-clause.current.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
error[E0275]: overflow evaluating the requirement `<Vec<u8> as Trait<String>>::Proof == _` | ||
--> $DIR/item-bound-via-impl-where-clause.rs:24:21 | ||
| | ||
LL | let s: String = transmute::<_, String>(vec![65_u8, 66, 67]); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
note: required for `Vec<u8>` to implement `Trait<String>` | ||
--> $DIR/item-bound-via-impl-where-clause.rs:14:12 | ||
| | ||
LL | impl<L, R> Trait<R> for L | ||
| ^^^^^^^^ ^ | ||
... | ||
LL | R: Trait<R, Proof = <L::Proof as Trait<R>>::Proof> | ||
| ------------------------------------- unsatisfied trait bound introduced here | ||
= note: 1 redundant requirement hidden | ||
= note: required for `Vec<u8>` to implement `Trait<String>` | ||
note: required by a bound in `transmute` | ||
--> $DIR/item-bound-via-impl-where-clause.rs:22:17 | ||
| | ||
LL | fn transmute<L: Trait<R>, R>(r: L) -> <L::Proof as Trait<R>>::Proof { r } | ||
| ^^^^^^^^ required by this bound in `transmute` | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0275`. |
69 changes: 69 additions & 0 deletions
69
tests/ui/traits/next-solver/cycles/coinduction/item-bound-via-impl-where-clause.next.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
error[E0271]: type mismatch resolving `<String as Trait<String>>::Proof normalizes-to String` | ||
--> $DIR/item-bound-via-impl-where-clause.rs:24:33 | ||
| | ||
LL | let s: String = transmute::<_, String>(vec![65_u8, 66, 67]); | ||
| ^ types differ | ||
| | ||
note: required for `String` to implement `Trait<String>` | ||
--> $DIR/item-bound-via-impl-where-clause.rs:14:12 | ||
| | ||
LL | impl<L, R> Trait<R> for L | ||
| ^^^^^^^^ ^ | ||
... | ||
LL | R: Trait<R, Proof = <L::Proof as Trait<R>>::Proof> | ||
| ------------------------------------- unsatisfied trait bound introduced here | ||
= note: 2 redundant requirements hidden | ||
= note: required for `Vec<u8>` to implement `Trait<String>` | ||
note: required by a bound in `transmute` | ||
--> $DIR/item-bound-via-impl-where-clause.rs:22:17 | ||
| | ||
LL | fn transmute<L: Trait<R>, R>(r: L) -> <L::Proof as Trait<R>>::Proof { r } | ||
| ^^^^^^^^ required by this bound in `transmute` | ||
|
||
error[E0271]: type mismatch resolving `<String as Trait<String>>::Proof normalizes-to String` | ||
--> $DIR/item-bound-via-impl-where-clause.rs:24:21 | ||
| | ||
LL | let s: String = transmute::<_, String>(vec![65_u8, 66, 67]); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ types differ | ||
| | ||
note: required for `String` to implement `Trait<String>` | ||
--> $DIR/item-bound-via-impl-where-clause.rs:14:12 | ||
| | ||
LL | impl<L, R> Trait<R> for L | ||
| ^^^^^^^^ ^ | ||
... | ||
LL | R: Trait<R, Proof = <L::Proof as Trait<R>>::Proof> | ||
| ------------------------------------- unsatisfied trait bound introduced here | ||
= note: 1 redundant requirement hidden | ||
= note: required for `Vec<u8>` to implement `Trait<String>` | ||
note: required by a bound in `Trait` | ||
--> $DIR/item-bound-via-impl-where-clause.rs:11:17 | ||
| | ||
LL | trait Trait<R>: Sized { | ||
| ^^^^^ required by this bound in `Trait` | ||
|
||
error[E0271]: type mismatch resolving `<String as Trait<String>>::Proof == _` | ||
--> $DIR/item-bound-via-impl-where-clause.rs:24:21 | ||
| | ||
LL | let s: String = transmute::<_, String>(vec![65_u8, 66, 67]); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type mismatch resolving `<String as Trait<String>>::Proof == _` | ||
| | ||
note: types differ | ||
--> $DIR/item-bound-via-impl-where-clause.rs:20:11 | ||
| | ||
LL | = R; | ||
| ^ | ||
note: required for `String` to implement `Trait<String>` | ||
--> $DIR/item-bound-via-impl-where-clause.rs:14:12 | ||
| | ||
LL | impl<L, R> Trait<R> for L | ||
| ^^^^^^^^ ^ | ||
... | ||
LL | R: Trait<R, Proof = <L::Proof as Trait<R>>::Proof> | ||
| ------------------------------------- unsatisfied trait bound introduced here | ||
= note: 2 redundant requirements hidden | ||
= note: required for `Vec<u8>` to implement `Trait<String>` | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0271`. |
30 changes: 30 additions & 0 deletions
30
tests/ui/traits/next-solver/cycles/coinduction/item-bound-via-impl-where-clause.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
//@ revisions: current next | ||
//@ ignore-compare-mode-next-solver (explicit revisions) | ||
//@[next] compile-flags: -Znext-solver | ||
|
||
// A variation of #135246 where the cyclic bounds are part of | ||
// the impl instead of the impl associated item. | ||
// | ||
// This has never been an unsound and fails with a non-productive | ||
// cycle when normalizing the expected term of the projection goal. | ||
|
||
trait Trait<R>: Sized { | ||
type Proof: Trait<R, Proof = Self>; | ||
} | ||
impl<L, R> Trait<R> for L | ||
where | ||
L: Trait<R>, | ||
R: Trait<R, Proof = <L::Proof as Trait<R>>::Proof> | ||
{ | ||
type Proof | ||
= R; | ||
} | ||
fn transmute<L: Trait<R>, R>(r: L) -> <L::Proof as Trait<R>>::Proof { r } | ||
fn main() { | ||
let s: String = transmute::<_, String>(vec![65_u8, 66, 67]); | ||
//[current]~^ ERROR overflow evaluating the requirement | ||
//[next]~^^ ERROR type mismatch resolving `<String as Trait<String>>::Proof normalizes-to String` | ||
//[next]~| ERROR type mismatch resolving `<String as Trait<String>>::Proof normalizes-to String` | ||
//[next]~| ERROR type mismatch resolving `<String as Trait<String>>::Proof == _` | ||
println!("{}", s); | ||
} |