提交 837856d1 编写于 作者: F Felix S. Klock II

Test illustrating that the nested_impl_trait lint should only catch shallow cases.

上级 c9930335
// 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() { }
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`.
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册