-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pessimistically treat all function items as containing an opaque type
- Loading branch information
Showing
7 changed files
with
63 additions
and
4 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
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
4 changes: 1 addition & 3 deletions
4
src/test/ui/type-alias-impl-trait/issue-53398-cyclic-types.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
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,13 @@ | ||
// edition:2018 | ||
|
||
type AsyncFnPtr = Box< | ||
dyn Fn() -> std::pin::Pin<Box<dyn std::future::Future<Output = ()>>>, | ||
>; | ||
|
||
async fn test() {} | ||
|
||
#[allow(unused_must_use)] | ||
fn main() { | ||
Box::new(test) as AsyncFnPtr; | ||
//~^ ERROR type mismatch | ||
} |
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 @@ | ||
error[E0271]: type mismatch resolving `<fn() -> impl Future<Output = ()> {test} as FnOnce<()>>::Output == Pin<Box<(dyn Future<Output = ()> + 'static)>>` | ||
--> $DIR/issue-98604.rs:11:5 | ||
| | ||
LL | Box::new(test) as AsyncFnPtr; | ||
| ^^^^^^^^^^^^^^ expected struct `Pin`, found opaque type | ||
| | ||
note: while checking the return type of the `async fn` | ||
--> $DIR/issue-98604.rs:7:17 | ||
| | ||
LL | async fn test() {} | ||
| ^ checked the `Output` of this `async fn`, found opaque type | ||
= note: expected struct `Pin<Box<(dyn Future<Output = ()> + 'static)>>` | ||
found opaque type `impl Future<Output = ()>` | ||
= note: required for the cast from `fn() -> impl Future<Output = ()> {test}` to the object type `dyn Fn() -> Pin<Box<(dyn Future<Output = ()> + 'static)>>` | ||
|
||
error: aborting due to 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,9 @@ | ||
fn hi() -> impl Sized { std::ptr::null::<u8>() } | ||
|
||
fn main() { | ||
let b: Box<dyn Fn() -> Box<u8>> = Box::new(hi); | ||
//~^ ERROR type mismatch resolving `<fn() -> impl Sized {hi} as FnOnce<()>>::Output == Box<u8>` | ||
let boxed = b(); | ||
let null = *boxed; | ||
println!("{null:?}"); | ||
} |
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,16 @@ | ||
error[E0271]: type mismatch resolving `<fn() -> impl Sized {hi} as FnOnce<()>>::Output == Box<u8>` | ||
--> $DIR/issue-98608.rs:4:39 | ||
| | ||
LL | fn hi() -> impl Sized { std::ptr::null::<u8>() } | ||
| ---------- the found opaque type | ||
... | ||
LL | let b: Box<dyn Fn() -> Box<u8>> = Box::new(hi); | ||
| ^^^^^^^^^^^^ expected struct `Box`, found opaque type | ||
| | ||
= note: expected struct `Box<u8>` | ||
found opaque type `impl Sized` | ||
= note: required for the cast from `fn() -> impl Sized {hi}` to the object type `dyn Fn() -> Box<u8>` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0271`. |