Skip to content

Commit

Permalink
Unit (and regression) tests for warning cycle code.
Browse files Browse the repository at this point in the history
  • Loading branch information
pnkfelix committed Mar 8, 2019
1 parent 98e4017 commit d6cee67
Show file tree
Hide file tree
Showing 6 changed files with 140 additions and 59 deletions.
37 changes: 37 additions & 0 deletions src/test/ui/impl-trait/issue-57979-impl-trait-in-path.rs
@@ -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 src/test/ui/impl-trait/issue-57979-impl-trait-in-path.stderr
@@ -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

@@ -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() { }
@@ -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

42 changes: 0 additions & 42 deletions src/test/ui/issues/issue-57979.rs

This file was deleted.

17 changes: 0 additions & 17 deletions src/test/ui/issues/issue-57979.stderr

This file was deleted.

0 comments on commit d6cee67

Please sign in to comment.