forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add tests for ICE: 'broken MIR: bad assignment: NoSolution' on trait …
…with default method and no impls Fixes rust-lang#109869
- Loading branch information
1 parent
e800b99
commit e4d816e
Showing
6 changed files
with
103 additions
and
0 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
tests/ui/traits/ice-trait-with-default-method-but-no-impl-broken-mir-109869-1.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,21 @@ | ||
// ICE 'broken MIR: bad assignment: NoSolution' | ||
// on trait with default method and no impls | ||
// issue: rust-lang/rust#109869 | ||
|
||
type Spanned<T> = (T, ()); | ||
|
||
trait Span<T> {} | ||
|
||
impl<T> Span<T> for (T, ()) {} | ||
|
||
impl<F, T: From<F>> From<Spanned<F>> for dyn Span<T> | ||
where | ||
Self: Sized | ||
{ | ||
fn from((from, ()): Spanned<F>) -> Self { | ||
(T::from(from), ()) | ||
//~^ ERROR mismatched types | ||
} | ||
} | ||
|
||
pub fn main() {} |
19 changes: 19 additions & 0 deletions
19
tests/ui/traits/ice-trait-with-default-method-but-no-impl-broken-mir-109869-1.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,19 @@ | ||
error[E0308]: mismatched types | ||
--> $DIR/ice-trait-with-default-method-but-no-impl-broken-mir-109869-1.rs:16:9 | ||
| | ||
LL | fn from((from, ()): Spanned<F>) -> Self { | ||
| ---- expected `(dyn Span<T> + 'static)` because of return type | ||
LL | (T::from(from), ()) | ||
| ^^^^^^^^^^^^^^^^^^^ expected `dyn Span`, found `(T, ())` | ||
| | ||
= note: expected trait object `(dyn Span<T> + 'static)` | ||
found tuple `(T, ())` | ||
= help: `(T, ())` implements `Span` so you could box the found value and coerce it to the trait object `Box<dyn Span>`, you will have to change the expected type as well | ||
help: call `Into::into` on this expression to convert `(T, ())` into `(dyn Span<T> + 'static)` | ||
| | ||
LL | (T::from(from), ()).into() | ||
| +++++++ | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0308`. |
17 changes: 17 additions & 0 deletions
17
tests/ui/traits/ice-trait-with-default-method-but-no-impl-broken-mir-109869-2.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,17 @@ | ||
// ICE 'broken MIR: bad assignment: NoSolution' | ||
// on trait with default method and no impls | ||
// issue: rust-lang/rust#109869 | ||
|
||
trait Empty<T> {} | ||
|
||
impl<T> Default for dyn Empty<T> | ||
where | ||
Self: Sized, | ||
{ | ||
fn default() -> Self { | ||
() | ||
//~^ ERROR mismatched types | ||
} | ||
} | ||
|
||
pub fn main() {} |
14 changes: 14 additions & 0 deletions
14
tests/ui/traits/ice-trait-with-default-method-but-no-impl-broken-mir-109869-2.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,14 @@ | ||
error[E0308]: mismatched types | ||
--> $DIR/ice-trait-with-default-method-but-no-impl-broken-mir-109869-2.rs:12:9 | ||
| | ||
LL | fn default() -> Self { | ||
| ---- expected `(dyn Empty<T> + 'static)` because of return type | ||
LL | () | ||
| ^^ expected `dyn Empty`, found `()` | ||
| | ||
= note: expected trait object `(dyn Empty<T> + 'static)` | ||
found unit type `()` | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0308`. |
18 changes: 18 additions & 0 deletions
18
...s/ui/traits/ice-trait-with-default-method-but-no-impl-broken-mir-109869-trivial-bounds.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,18 @@ | ||
// ICE 'broken MIR: bad assignment: NoSolution' | ||
// on trait with default method and no impls | ||
// issue: rust-lang/rust#109869 | ||
|
||
#![feature(trivial_bounds)] | ||
trait Empty {} | ||
|
||
impl Default for dyn Empty | ||
where | ||
Self: Sized, | ||
{ | ||
fn default() -> Self { | ||
() | ||
//~^ ERROR mismatched types | ||
} | ||
} | ||
|
||
pub fn main() {} |
14 changes: 14 additions & 0 deletions
14
.../traits/ice-trait-with-default-method-but-no-impl-broken-mir-109869-trivial-bounds.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,14 @@ | ||
error[E0308]: mismatched types | ||
--> $DIR/ice-trait-with-default-method-but-no-impl-broken-mir-109869-trivial-bounds.rs:13:9 | ||
| | ||
LL | fn default() -> Self { | ||
| ---- expected `(dyn Empty + 'static)` because of return type | ||
LL | () | ||
| ^^ expected `dyn Empty`, found `()` | ||
| | ||
= note: expected trait object `(dyn Empty + 'static)` | ||
found unit type `()` | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0308`. |