diff options
| author | Michael Goulet <michael@errs.io> | 2022-08-03 03:16:31 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2022-08-10 03:27:41 +0000 |
| commit | 28b6373b1d4f6fd58f3435da2551021034c4a9d4 (patch) | |
| tree | 54a364db3965d69f2ddf228625ea434b9488da6b /src/test | |
| parent | 34a6cae28e7013ff0e640026a8e46f315426829d (diff) | |
| download | rust-28b6373b1d4f6fd58f3435da2551021034c4a9d4.tar.gz rust-28b6373b1d4f6fd58f3435da2551021034c4a9d4.zip | |
Fall back when relating two opaques by substs in MIR typeck
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/ui/impl-trait/issue-100075-2.rs | 8 | ||||
| -rw-r--r-- | src/test/ui/impl-trait/issue-100075-2.stderr | 24 | ||||
| -rw-r--r-- | src/test/ui/impl-trait/issue-100075.rs | 21 | ||||
| -rw-r--r-- | src/test/ui/impl-trait/issue-100075.stderr | 12 |
4 files changed, 65 insertions, 0 deletions
diff --git a/src/test/ui/impl-trait/issue-100075-2.rs b/src/test/ui/impl-trait/issue-100075-2.rs new file mode 100644 index 00000000000..cf059af1925 --- /dev/null +++ b/src/test/ui/impl-trait/issue-100075-2.rs @@ -0,0 +1,8 @@ +fn opaque<T>(t: T) -> impl Sized { + //~^ ERROR cannot resolve opaque type + //~| WARNING function cannot return without recursing + opaque(Some(t)) +} + +#[allow(dead_code)] +fn main() {} diff --git a/src/test/ui/impl-trait/issue-100075-2.stderr b/src/test/ui/impl-trait/issue-100075-2.stderr new file mode 100644 index 00000000000..5a1f1a97d04 --- /dev/null +++ b/src/test/ui/impl-trait/issue-100075-2.stderr @@ -0,0 +1,24 @@ +warning: function cannot return without recursing + --> $DIR/issue-100075-2.rs:1:1 + | +LL | fn opaque<T>(t: T) -> impl Sized { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot return without recursing +... +LL | opaque(Some(t)) + | --------------- recursive call site + | + = note: `#[warn(unconditional_recursion)]` on by default + = help: a `loop` may express intention better if this is on purpose + +error[E0720]: cannot resolve opaque type + --> $DIR/issue-100075-2.rs:1:23 + | +LL | fn opaque<T>(t: T) -> impl Sized { + | ^^^^^^^^^^ recursive opaque type +... +LL | opaque(Some(t)) + | --------------- returning here with type `impl Sized` + +error: aborting due to previous error; 1 warning emitted + +For more information about this error, try `rustc --explain E0720`. diff --git a/src/test/ui/impl-trait/issue-100075.rs b/src/test/ui/impl-trait/issue-100075.rs new file mode 100644 index 00000000000..ea30abb4855 --- /dev/null +++ b/src/test/ui/impl-trait/issue-100075.rs @@ -0,0 +1,21 @@ +trait Marker {} +impl<T> Marker for T {} + +fn maybe<T>( + _t: T, +) -> Option< + //removing the line below makes it compile + &'static T, +> { + None +} + +fn _g<T>(t: &'static T) -> &'static impl Marker { + //~^ ERROR cannot resolve opaque type + if let Some(t) = maybe(t) { + return _g(t); + } + todo!() +} + +fn main() {} diff --git a/src/test/ui/impl-trait/issue-100075.stderr b/src/test/ui/impl-trait/issue-100075.stderr new file mode 100644 index 00000000000..267ecfdaed1 --- /dev/null +++ b/src/test/ui/impl-trait/issue-100075.stderr @@ -0,0 +1,12 @@ +error[E0720]: cannot resolve opaque type + --> $DIR/issue-100075.rs:13:37 + | +LL | fn _g<T>(t: &'static T) -> &'static impl Marker { + | ^^^^^^^^^^^ recursive opaque type +... +LL | return _g(t); + | ----- returning here with type `&impl Marker` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0720`. |
