diff options
| author | Felix S. Klock II <pnkfelix@pnkfx.org> | 2019-03-11 16:30:40 +0100 |
|---|---|---|
| committer | Felix S. Klock II <pnkfelix@pnkfx.org> | 2019-03-11 16:30:40 +0100 |
| commit | 837856d120ec3350f1e9d194801a6a89e5d71630 (patch) | |
| tree | 968ea3b1a58e612779b17cb0d04d0e16c56dc4a5 /src/test/ui/impl-trait | |
| parent | c99303351dd67df8657d9f11ca00d65dcceb8438 (diff) | |
| download | rust-837856d120ec3350f1e9d194801a6a89e5d71630.tar.gz rust-837856d120ec3350f1e9d194801a6a89e5d71630.zip | |
Test illustrating that the nested_impl_trait lint should only catch shallow cases.
Diffstat (limited to 'src/test/ui/impl-trait')
| -rw-r--r-- | src/test/ui/impl-trait/issue-57979-deeply-nested-impl-trait-in-assoc-proj.rs | 42 | ||||
| -rw-r--r-- | src/test/ui/impl-trait/issue-57979-deeply-nested-impl-trait-in-assoc-proj.stderr | 30 |
2 files changed, 72 insertions, 0 deletions
diff --git a/src/test/ui/impl-trait/issue-57979-deeply-nested-impl-trait-in-assoc-proj.rs b/src/test/ui/impl-trait/issue-57979-deeply-nested-impl-trait-in-assoc-proj.rs new file mode 100644 index 00000000000..5eef6a39325 --- /dev/null +++ b/src/test/ui/impl-trait/issue-57979-deeply-nested-impl-trait-in-assoc-proj.rs @@ -0,0 +1,42 @@ +// rust-lang/rust#57979 : the initial support for `impl Trait` didn't +// properly check syntax hidden behind an associated type projection, +// but it did catch *some cases*. This is checking that we continue to +// properly emit errors for those, even with the new +// future-incompatibility warnings. +// +// issue-57979-nested-impl-trait-in-assoc-proj.rs shows the main case +// that we were previously failing to catch. + +struct Deeper<T>(T); + +mod allowed { + #![allow(nested_impl_trait)] + + pub trait Foo<T> { } + pub trait Bar { } + pub trait Quux { type Assoc; } + pub fn demo(_: impl Quux<Assoc=super::Deeper<impl Foo<impl Bar>>>) { } + //~^ ERROR nested `impl Trait` is not allowed +} + +mod warned { + #![warn(nested_impl_trait)] + + pub trait Foo<T> { } + pub trait Bar { } + pub trait Quux { type Assoc; } + pub fn demo(_: impl Quux<Assoc=super::Deeper<impl Foo<impl Bar>>>) { } + //~^ ERROR nested `impl Trait` is not allowed +} + +mod denied { + #![deny(nested_impl_trait)] + + pub trait Foo<T> { } + pub trait Bar { } + pub trait Quux { type Assoc; } + pub fn demo(_: impl Quux<Assoc=super::Deeper<impl Foo<impl Bar>>>) { } + //~^ ERROR nested `impl Trait` is not allowed +} + +fn main() { } diff --git a/src/test/ui/impl-trait/issue-57979-deeply-nested-impl-trait-in-assoc-proj.stderr b/src/test/ui/impl-trait/issue-57979-deeply-nested-impl-trait-in-assoc-proj.stderr new file mode 100644 index 00000000000..2b6f15e6d3e --- /dev/null +++ b/src/test/ui/impl-trait/issue-57979-deeply-nested-impl-trait-in-assoc-proj.stderr @@ -0,0 +1,30 @@ +error[E0666]: nested `impl Trait` is not allowed + --> $DIR/issue-57979-deeply-nested-impl-trait-in-assoc-proj.rs:18:59 + | +LL | pub fn demo(_: impl Quux<Assoc=super::Deeper<impl Foo<impl Bar>>>) { } + | ---------^^^^^^^^- + | | | + | | nested `impl Trait` here + | outer `impl Trait` + +error[E0666]: nested `impl Trait` is not allowed + --> $DIR/issue-57979-deeply-nested-impl-trait-in-assoc-proj.rs:28:59 + | +LL | pub fn demo(_: impl Quux<Assoc=super::Deeper<impl Foo<impl Bar>>>) { } + | ---------^^^^^^^^- + | | | + | | nested `impl Trait` here + | outer `impl Trait` + +error[E0666]: nested `impl Trait` is not allowed + --> $DIR/issue-57979-deeply-nested-impl-trait-in-assoc-proj.rs:38:59 + | +LL | pub fn demo(_: impl Quux<Assoc=super::Deeper<impl Foo<impl Bar>>>) { } + | ---------^^^^^^^^- + | | | + | | nested `impl Trait` here + | outer `impl Trait` + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0666`. |
