-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unit (and regression) tests for warning cycle code.
- Loading branch information
Showing
6 changed files
with
140 additions
and
59 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// rust-lang/rust#57979 : the initial support for `impl Trait` didn't | ||
// properly check syntax hidden behind an associated type projection. | ||
// Here we test behavior of occurrences of `impl Trait` within a path | ||
// component in that context. | ||
|
||
mod allowed { | ||
#![allow(nested_impl_trait)] | ||
|
||
pub trait Bar { } | ||
pub trait Quux<T> { type Assoc; } | ||
pub fn demo(_: impl Quux<(), Assoc=<() as Quux<impl Bar>>::Assoc>) { } | ||
impl<T> Quux<T> for () { type Assoc = u32; } | ||
} | ||
|
||
mod warned { | ||
#![warn(nested_impl_trait)] | ||
|
||
pub trait Bar { } | ||
pub trait Quux<T> { type Assoc; } | ||
pub fn demo(_: impl Quux<(), Assoc=<() as Quux<impl Bar>>::Assoc>) { } | ||
//~^ WARN `impl Trait` is not allowed in path parameters | ||
//~| WARN will become a hard error in a future release! | ||
impl<T> Quux<T> for () { type Assoc = u32; } | ||
} | ||
|
||
mod denied { | ||
#![deny(nested_impl_trait)] | ||
|
||
pub trait Bar { } | ||
pub trait Quux<T> { type Assoc; } | ||
pub fn demo(_: impl Quux<(), Assoc=<() as Quux<impl Bar>>::Assoc>) { } | ||
//~^ ERROR `impl Trait` is not allowed in path parameters | ||
//~| WARN will become a hard error in a future release! | ||
impl<T> Quux<T> for () { type Assoc = u32; } | ||
} | ||
|
||
fn main() { } |
30 changes: 30 additions & 0 deletions
30
src/test/ui/impl-trait/issue-57979-impl-trait-in-path.stderr
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,30 @@ | ||
warning: `impl Trait` is not allowed in path parameters | ||
--> $DIR/issue-57979-impl-trait-in-path.rs:20:52 | ||
| | ||
LL | pub fn demo(_: impl Quux<(), Assoc=<() as Quux<impl Bar>>::Assoc>) { } | ||
| ^^^^^^^^ | ||
| | ||
note: lint level defined here | ||
--> $DIR/issue-57979-impl-trait-in-path.rs:16:13 | ||
| | ||
LL | #![warn(nested_impl_trait)] | ||
| ^^^^^^^^^^^^^^^^^ | ||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | ||
= note: for more information, see issue #59014 <https://github.com/rust-lang/rust/issues/59014> | ||
|
||
error: `impl Trait` is not allowed in path parameters | ||
--> $DIR/issue-57979-impl-trait-in-path.rs:31:52 | ||
| | ||
LL | pub fn demo(_: impl Quux<(), Assoc=<() as Quux<impl Bar>>::Assoc>) { } | ||
| ^^^^^^^^ | ||
| | ||
note: lint level defined here | ||
--> $DIR/issue-57979-impl-trait-in-path.rs:27:13 | ||
| | ||
LL | #![deny(nested_impl_trait)] | ||
| ^^^^^^^^^^^^^^^^^ | ||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | ||
= note: for more information, see issue #59014 <https://github.com/rust-lang/rust/issues/59014> | ||
|
||
error: aborting due to previous error | ||
|
37 changes: 37 additions & 0 deletions
37
src/test/ui/impl-trait/issue-57979-nested-impl-trait-in-assoc-proj.rs
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,37 @@ | ||
// rust-lang/rust#57979 : the initial support for `impl Trait` didn't | ||
// properly check syntax hidden behind an associated type projection. | ||
// Here we test behavior of occurrences of `impl Trait` within an | ||
// `impl Trait` in that context. | ||
|
||
mod allowed { | ||
#![allow(nested_impl_trait)] | ||
|
||
pub trait Foo<T> { } | ||
pub trait Bar { } | ||
pub trait Quux { type Assoc; } | ||
pub fn demo(_: impl Quux<Assoc=impl Foo<impl Bar>>) { } | ||
} | ||
|
||
mod warned { | ||
#![warn(nested_impl_trait)] | ||
|
||
pub trait Foo<T> { } | ||
pub trait Bar { } | ||
pub trait Quux { type Assoc; } | ||
pub fn demo(_: impl Quux<Assoc=impl Foo<impl Bar>>) { } | ||
//~^ WARN nested `impl Trait` is not allowed | ||
//~| WARN will become a hard error in a future release! | ||
} | ||
|
||
mod denied { | ||
#![deny(nested_impl_trait)] | ||
|
||
pub trait Foo<T> { } | ||
pub trait Bar { } | ||
pub trait Quux { type Assoc; } | ||
pub fn demo(_: impl Quux<Assoc=impl Foo<impl Bar>>) { } | ||
//~^ ERROR nested `impl Trait` is not allowed | ||
//~| WARN will become a hard error in a future release! | ||
} | ||
|
||
fn main() { } |
36 changes: 36 additions & 0 deletions
36
src/test/ui/impl-trait/issue-57979-nested-impl-trait-in-assoc-proj.stderr
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,36 @@ | ||
warning: nested `impl Trait` is not allowed | ||
--> $DIR/issue-57979-nested-impl-trait-in-assoc-proj.rs:21:45 | ||
| | ||
LL | pub fn demo(_: impl Quux<Assoc=impl Foo<impl Bar>>) { } | ||
| ---------^^^^^^^^- | ||
| | | | ||
| | nested `impl Trait` here | ||
| outer `impl Trait` | ||
| | ||
note: lint level defined here | ||
--> $DIR/issue-57979-nested-impl-trait-in-assoc-proj.rs:16:13 | ||
| | ||
LL | #![warn(nested_impl_trait)] | ||
| ^^^^^^^^^^^^^^^^^ | ||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | ||
= note: for more information, see issue #59014 <https://github.com/rust-lang/rust/issues/59014> | ||
|
||
error: nested `impl Trait` is not allowed | ||
--> $DIR/issue-57979-nested-impl-trait-in-assoc-proj.rs:32:45 | ||
| | ||
LL | pub fn demo(_: impl Quux<Assoc=impl Foo<impl Bar>>) { } | ||
| ---------^^^^^^^^- | ||
| | | | ||
| | nested `impl Trait` here | ||
| outer `impl Trait` | ||
| | ||
note: lint level defined here | ||
--> $DIR/issue-57979-nested-impl-trait-in-assoc-proj.rs:27:13 | ||
| | ||
LL | #![deny(nested_impl_trait)] | ||
| ^^^^^^^^^^^^^^^^^ | ||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | ||
= note: for more information, see issue #59014 <https://github.com/rust-lang/rust/issues/59014> | ||
|
||
error: aborting due to previous error | ||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.