-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
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,9 @@ | ||
error[E0271]: type mismatch resolving `impl Trait <: dyn Trait` | ||
--> $DIR/unsized_coercion.rs:14:17 | ||
| | ||
LL | let x = hello(); | ||
| ^^^^^^^ types differ | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0271`. |
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 @@ | ||
//! This test checks that opaque types get unsized instead of | ||
//! constraining their hidden type to a trait object. | ||
//@ revisions: next old | ||
//@[next] compile-flags: -Znext-solver | ||
//@[old] check-pass | ||
|
||
trait Trait {} | ||
|
||
impl Trait for u32 {} | ||
|
||
fn hello() -> Box<impl Trait> { | ||
if true { | ||
let x = hello(); | ||
//[next]~^ ERROR: type mismatch resolving `impl Trait <: dyn Trait` | ||
let y: Box<dyn Trait> = x; | ||
} | ||
Box::new(1u32) | ||
} | ||
|
||
fn main() {} |
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,12 @@ | ||
error[E0277]: the size for values of type `impl Trait + ?Sized` cannot be known at compilation time | ||
--> $DIR/unsized_coercion2.rs:15:33 | ||
| | ||
LL | let y: Box<dyn Trait> = x; | ||
| ^ doesn't have a size known at compile-time | ||
| | ||
= help: the trait `Sized` is not implemented for `impl Trait + ?Sized` | ||
= note: required for the cast from `Box<impl Trait + ?Sized>` to `Box<dyn Trait>` | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0277`. |
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 @@ | ||
//! This test checks that opaque types get unsized instead of | ||
//! constraining their hidden type to a trait object. | ||
//@ revisions: next old | ||
//@[next] compile-flags: -Znext-solver | ||
//@[next] check-pass | ||
|
||
trait Trait {} | ||
|
||
impl Trait for u32 {} | ||
|
||
fn hello() -> Box<impl Trait + ?Sized> { | ||
if true { | ||
let x = hello(); | ||
let y: Box<dyn Trait> = x; | ||
//[old]~^ ERROR: the size for values of type `impl Trait + ?Sized` cannot be know | ||
} | ||
Box::new(1u32) | ||
} | ||
|
||
fn main() {} |