diff options
| author | bors <bors@rust-lang.org> | 2022-02-08 22:33:05 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-02-08 22:33:05 +0000 |
| commit | cc38176793e9e13bb7b70dde4b951d9371017662 (patch) | |
| tree | cdec181da68a6a6849e1b1e3edb98e6a24035143 /src/test | |
| parent | 0c292c9667f1b202a9150d58bdd2e89e3e803996 (diff) | |
| parent | 239f1e716dcb1e145b5df5f9439524c817d123b2 (diff) | |
| download | rust-cc38176793e9e13bb7b70dde4b951d9371017662.tar.gz rust-cc38176793e9e13bb7b70dde4b951d9371017662.zip | |
Auto merge of #93783 - oli-obk:lazy_tait_regression_fix, r=jackh726
Fix regression from lazy opaque types The breakage was found in https://github.com/rust-lang/rust/pull/92007#issuecomment-1032203011 and has not hit nightly yet.
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/ui/impl-trait/hidden-type-is-opaque-2.rs | 34 | ||||
| -rw-r--r-- | src/test/ui/impl-trait/hidden-type-is-opaque-2.stderr | 11 | ||||
| -rw-r--r-- | src/test/ui/impl-trait/hidden-type-is-opaque.rs | 32 | ||||
| -rw-r--r-- | src/test/ui/impl-trait/issues/issue-70877.rs | 2 | ||||
| -rw-r--r-- | src/test/ui/impl-trait/issues/issue-70877.stderr | 17 |
5 files changed, 94 insertions, 2 deletions
diff --git a/src/test/ui/impl-trait/hidden-type-is-opaque-2.rs b/src/test/ui/impl-trait/hidden-type-is-opaque-2.rs new file mode 100644 index 00000000000..1b65685a6c0 --- /dev/null +++ b/src/test/ui/impl-trait/hidden-type-is-opaque-2.rs @@ -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() {} diff --git a/src/test/ui/impl-trait/hidden-type-is-opaque-2.stderr b/src/test/ui/impl-trait/hidden-type-is-opaque-2.stderr new file mode 100644 index 00000000000..e538aaeb4c5 --- /dev/null +++ b/src/test/ui/impl-trait/hidden-type-is-opaque-2.stderr @@ -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`. diff --git a/src/test/ui/impl-trait/hidden-type-is-opaque.rs b/src/test/ui/impl-trait/hidden-type-is-opaque.rs new file mode 100644 index 00000000000..b302ae36ef4 --- /dev/null +++ b/src/test/ui/impl-trait/hidden-type-is-opaque.rs @@ -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() {} diff --git a/src/test/ui/impl-trait/issues/issue-70877.rs b/src/test/ui/impl-trait/issues/issue-70877.rs index 8169cfafac7..1a86fa00ed1 100644 --- a/src/test/ui/impl-trait/issues/issue-70877.rs +++ b/src/test/ui/impl-trait/issues/issue-70877.rs @@ -13,7 +13,7 @@ impl Iterator for Bar { type Item = FooItem; fn next(&mut self) -> Option<Self::Item> { - Some(Box::new(quux)) + Some(Box::new(quux)) //~ ERROR mismatched types } } diff --git a/src/test/ui/impl-trait/issues/issue-70877.stderr b/src/test/ui/impl-trait/issues/issue-70877.stderr index 8813bff3c35..7cbd58bdabf 100644 --- a/src/test/ui/impl-trait/issues/issue-70877.stderr +++ b/src/test/ui/impl-trait/issues/issue-70877.stderr @@ -1,3 +1,17 @@ +error[E0308]: mismatched types + --> $DIR/issue-70877.rs:16:9 + | +LL | type FooRet = impl std::fmt::Debug; + | -------------------- the expected opaque type +... +LL | fn next(&mut self) -> Option<Self::Item> { + | ------------------ expected `Option<Box<(dyn for<'r> Fn(&'r (dyn ToString + 'r)) -> FooRet + 'static)>>` because of return type +LL | Some(Box::new(quux)) + | ^^^^^^^^^^^^^^^^^^^^ expected trait object `dyn Fn`, found fn item + | + = note: expected enum `Option<Box<(dyn for<'r> Fn(&'r (dyn ToString + 'r)) -> FooRet + 'static)>>` + found enum `Option<Box<for<'r> fn(&'r (dyn ToString + 'r)) -> FooRet {quux}>>` + error: opaque type's hidden type cannot be another opaque type from the same scope --> $DIR/issue-70877.rs:31:12 | @@ -15,5 +29,6 @@ note: opaque type being used as hidden type LL | type FooRet = impl std::fmt::Debug; | ^^^^^^^^^^^^^^^^^^^^ -error: aborting due to previous error +error: aborting due to 2 previous errors +For more information about this error, try `rustc --explain E0308`. |
