-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix regression from lazy opaque types
- Loading branch information
Showing
7 changed files
with
126 additions
and
10 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
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,34 @@ | ||
// This doesn't work, because we don't flow information from opaque types | ||
// into function arguments via the function's generic parameters | ||
// FIXME(oli-obk): make `expected_inputs_for_expected_output` support this | ||
|
||
fn reify_as() -> Thunk<impl FnOnce(Continuation) -> Continuation> { | ||
Thunk::new(|mut cont| { //~ ERROR type annotations needed | ||
cont.reify_as(); | ||
cont | ||
}) | ||
} | ||
|
||
#[must_use] | ||
struct Thunk<F>(F); | ||
|
||
impl<F> Thunk<F> { | ||
fn new(f: F) -> Self | ||
where | ||
F: ContFn, | ||
{ | ||
Thunk(f) | ||
} | ||
} | ||
|
||
trait ContFn {} | ||
|
||
impl<F: FnOnce(Continuation) -> Continuation> ContFn for F {} | ||
|
||
struct Continuation; | ||
|
||
impl Continuation { | ||
fn reify_as(&mut self) {} | ||
} | ||
|
||
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,11 @@ | ||
error[E0282]: type annotations needed | ||
--> $DIR/hidden-type-is-opaque-2.rs:6:17 | ||
| | ||
LL | Thunk::new(|mut cont| { | ||
| ^^^^^^^^ consider giving this closure parameter a type | ||
| | ||
= note: type must be known at this point | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0282`. |
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,32 @@ | ||
// check-pass | ||
|
||
fn reify_as() -> Thunk<impl ContFn> { | ||
Thunk::new(|mut cont| { | ||
cont.reify_as(); | ||
cont | ||
}) | ||
} | ||
|
||
#[must_use] | ||
struct Thunk<F>(F); | ||
|
||
impl<F> Thunk<F> { | ||
fn new(f: F) -> Self | ||
where | ||
F: FnOnce(Continuation) -> Continuation, | ||
{ | ||
Thunk(f) | ||
} | ||
} | ||
|
||
trait ContFn {} | ||
|
||
impl<F: FnOnce(Continuation) -> Continuation> ContFn for F {} | ||
|
||
struct Continuation; | ||
|
||
impl Continuation { | ||
fn reify_as(&mut self) {} | ||
} | ||
|
||
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
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