From 03cf0d737f075aa8839dd7cc5b1047910ec00ddf Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Thu, 7 Nov 2019 20:12:34 +0100 Subject: [PATCH] TAIT: adjust tests --- .../feature-gate-type_alias_impl_trait.rs | 36 ++++- .../feature-gate-type_alias_impl_trait.stderr | 149 +++++++++++++++++- src/test/ui/impl-trait/where-allowed.rs | 1 + src/test/ui/impl-trait/where-allowed.stderr | 41 +++-- .../type-alias-impl-trait/issue-60371.stderr | 4 +- 5 files changed, 202 insertions(+), 29 deletions(-) diff --git a/src/test/ui/feature-gates/feature-gate-type_alias_impl_trait.rs b/src/test/ui/feature-gates/feature-gate-type_alias_impl_trait.rs index 4a0c8c52c4ed7..6088331cded77 100644 --- a/src/test/ui/feature-gates/feature-gate-type_alias_impl_trait.rs +++ b/src/test/ui/feature-gates/feature-gate-type_alias_impl_trait.rs @@ -1,15 +1,45 @@ -type Foo = impl std::fmt::Debug; //~ ERROR `impl Trait` in type aliases is unstable +use std::fmt::Debug; + +type Foo = impl Debug; //~ ERROR `impl Trait` in type aliases is unstable trait Bar { - type Baa: std::fmt::Debug; + type Baa: Debug; fn define() -> Self::Baa; } impl Bar for () { - type Baa = impl std::fmt::Debug; //~ ERROR `impl Trait` in type aliases is unstable + type Baa = impl Debug; //~ ERROR `impl Trait` in type aliases is unstable fn define() -> Self::Baa { 0 } } fn define() -> Foo { 0 } +trait TraitWithDefault { + type Assoc = impl Debug; + //~^ ERROR associated type defaults are unstable + //~| ERROR `impl Trait` not allowed outside of function + //~| ERROR `impl Trait` in type aliases is unstable +} + +type NestedFree = (Vec, impl Debug, impl Iterator); +//~^ ERROR `impl Trait` in type aliases is unstable +//~| ERROR `impl Trait` in type aliases is unstable +//~| ERROR `impl Trait` in type aliases is unstable +//~| ERROR `impl Trait` in type aliases is unstable +//~| ERROR `impl Trait` not allowed outside of function +//~| ERROR `impl Trait` not allowed outside of function +//~| ERROR `impl Trait` not allowed outside of function + +impl Bar for u8 { + type Baa = (Vec, impl Debug, impl Iterator); + //~^ ERROR `impl Trait` in type aliases is unstable + //~| ERROR `impl Trait` in type aliases is unstable + //~| ERROR `impl Trait` in type aliases is unstable + //~| ERROR `impl Trait` in type aliases is unstable + //~| ERROR `impl Trait` not allowed outside of function + //~| ERROR `impl Trait` not allowed outside of function + //~| ERROR `impl Trait` not allowed outside of function + fn define() -> Self::Baa { (vec![true], 0u8, 0i32..1) } +} + fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-type_alias_impl_trait.stderr b/src/test/ui/feature-gates/feature-gate-type_alias_impl_trait.stderr index 2d0710ea37cf6..d9ebcdecb9bfd 100644 --- a/src/test/ui/feature-gates/feature-gate-type_alias_impl_trait.stderr +++ b/src/test/ui/feature-gates/feature-gate-type_alias_impl_trait.stderr @@ -1,21 +1,154 @@ error[E0658]: `impl Trait` in type aliases is unstable - --> $DIR/feature-gate-type_alias_impl_trait.rs:1:1 + --> $DIR/feature-gate-type_alias_impl_trait.rs:3:12 | -LL | type Foo = impl std::fmt::Debug; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | type Foo = impl Debug; + | ^^^^^^^^^^ | = note: for more information, see https://github.com/rust-lang/rust/issues/63063 = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable error[E0658]: `impl Trait` in type aliases is unstable - --> $DIR/feature-gate-type_alias_impl_trait.rs:9:5 + --> $DIR/feature-gate-type_alias_impl_trait.rs:11:16 | -LL | type Baa = impl std::fmt::Debug; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | type Baa = impl Debug; + | ^^^^^^^^^^ | = note: for more information, see https://github.com/rust-lang/rust/issues/63063 = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable -error: aborting due to 2 previous errors +error[E0658]: `impl Trait` in type aliases is unstable + --> $DIR/feature-gate-type_alias_impl_trait.rs:18:18 + | +LL | type Assoc = impl Debug; + | ^^^^^^^^^^ + | + = note: for more information, see https://github.com/rust-lang/rust/issues/63063 + = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable + +error[E0658]: associated type defaults are unstable + --> $DIR/feature-gate-type_alias_impl_trait.rs:18:5 + | +LL | type Assoc = impl Debug; + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: for more information, see https://github.com/rust-lang/rust/issues/29661 + = help: add `#![feature(associated_type_defaults)]` to the crate attributes to enable + +error[E0658]: `impl Trait` in type aliases is unstable + --> $DIR/feature-gate-type_alias_impl_trait.rs:24:24 + | +LL | type NestedFree = (Vec, impl Debug, impl Iterator); + | ^^^^^^^^^^ + | + = note: for more information, see https://github.com/rust-lang/rust/issues/63063 + = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable + +error[E0658]: `impl Trait` in type aliases is unstable + --> $DIR/feature-gate-type_alias_impl_trait.rs:24:37 + | +LL | type NestedFree = (Vec, impl Debug, impl Iterator); + | ^^^^^^^^^^ + | + = note: for more information, see https://github.com/rust-lang/rust/issues/63063 + = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable + +error[E0658]: `impl Trait` in type aliases is unstable + --> $DIR/feature-gate-type_alias_impl_trait.rs:24:49 + | +LL | type NestedFree = (Vec, impl Debug, impl Iterator); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: for more information, see https://github.com/rust-lang/rust/issues/63063 + = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable + +error[E0658]: `impl Trait` in type aliases is unstable + --> $DIR/feature-gate-type_alias_impl_trait.rs:24:70 + | +LL | type NestedFree = (Vec, impl Debug, impl Iterator); + | ^^^^^^^^^^ + | + = note: for more information, see https://github.com/rust-lang/rust/issues/63063 + = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable + +error[E0658]: `impl Trait` in type aliases is unstable + --> $DIR/feature-gate-type_alias_impl_trait.rs:34:21 + | +LL | type Baa = (Vec, impl Debug, impl Iterator); + | ^^^^^^^^^^ + | + = note: for more information, see https://github.com/rust-lang/rust/issues/63063 + = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable + +error[E0658]: `impl Trait` in type aliases is unstable + --> $DIR/feature-gate-type_alias_impl_trait.rs:34:34 + | +LL | type Baa = (Vec, impl Debug, impl Iterator); + | ^^^^^^^^^^ + | + = note: for more information, see https://github.com/rust-lang/rust/issues/63063 + = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable + +error[E0658]: `impl Trait` in type aliases is unstable + --> $DIR/feature-gate-type_alias_impl_trait.rs:34:46 + | +LL | type Baa = (Vec, impl Debug, impl Iterator); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: for more information, see https://github.com/rust-lang/rust/issues/63063 + = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable + +error[E0658]: `impl Trait` in type aliases is unstable + --> $DIR/feature-gate-type_alias_impl_trait.rs:34:67 + | +LL | type Baa = (Vec, impl Debug, impl Iterator); + | ^^^^^^^^^^ + | + = note: for more information, see https://github.com/rust-lang/rust/issues/63063 + = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable + +error[E0562]: `impl Trait` not allowed outside of function and inherent method return types + --> $DIR/feature-gate-type_alias_impl_trait.rs:18:18 + | +LL | type Assoc = impl Debug; + | ^^^^^^^^^^ + +error[E0562]: `impl Trait` not allowed outside of function and inherent method return types + --> $DIR/feature-gate-type_alias_impl_trait.rs:24:24 + | +LL | type NestedFree = (Vec, impl Debug, impl Iterator); + | ^^^^^^^^^^ + +error[E0562]: `impl Trait` not allowed outside of function and inherent method return types + --> $DIR/feature-gate-type_alias_impl_trait.rs:24:37 + | +LL | type NestedFree = (Vec, impl Debug, impl Iterator); + | ^^^^^^^^^^ + +error[E0562]: `impl Trait` not allowed outside of function and inherent method return types + --> $DIR/feature-gate-type_alias_impl_trait.rs:24:49 + | +LL | type NestedFree = (Vec, impl Debug, impl Iterator); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0562]: `impl Trait` not allowed outside of function and inherent method return types + --> $DIR/feature-gate-type_alias_impl_trait.rs:34:21 + | +LL | type Baa = (Vec, impl Debug, impl Iterator); + | ^^^^^^^^^^ + +error[E0562]: `impl Trait` not allowed outside of function and inherent method return types + --> $DIR/feature-gate-type_alias_impl_trait.rs:34:34 + | +LL | type Baa = (Vec, impl Debug, impl Iterator); + | ^^^^^^^^^^ + +error[E0562]: `impl Trait` not allowed outside of function and inherent method return types + --> $DIR/feature-gate-type_alias_impl_trait.rs:34:46 + | +LL | type Baa = (Vec, impl Debug, impl Iterator); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 19 previous errors -For more information about this error, try `rustc --explain E0658`. +Some errors have detailed explanations: E0562, E0658. +For more information about an error, try `rustc --explain E0562`. diff --git a/src/test/ui/impl-trait/where-allowed.rs b/src/test/ui/impl-trait/where-allowed.rs index 65c4b78bf6a40..5ab74e02e0e40 100644 --- a/src/test/ui/impl-trait/where-allowed.rs +++ b/src/test/ui/impl-trait/where-allowed.rs @@ -163,6 +163,7 @@ type InTypeAlias = impl Debug; type InReturnInTypeAlias = fn() -> impl Debug; //~^ ERROR `impl Trait` not allowed outside of function and inherent method return types +//~| ERROR `impl Trait` in type aliases is unstable // Disallowed in impl headers impl PartialEq for () { diff --git a/src/test/ui/impl-trait/where-allowed.stderr b/src/test/ui/impl-trait/where-allowed.stderr index b01095f15a978..fcd4c357afdbe 100644 --- a/src/test/ui/impl-trait/where-allowed.stderr +++ b/src/test/ui/impl-trait/where-allowed.stderr @@ -17,19 +17,28 @@ LL | fn in_impl_Fn_parameter_in_return() -> &'static impl Fn(impl Debug) { panic | outer `impl Trait` error[E0658]: `impl Trait` in type aliases is unstable - --> $DIR/where-allowed.rs:124:5 + --> $DIR/where-allowed.rs:124:16 | LL | type Out = impl Debug; - | ^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^ | = note: for more information, see https://github.com/rust-lang/rust/issues/63063 = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable error[E0658]: `impl Trait` in type aliases is unstable - --> $DIR/where-allowed.rs:160:1 + --> $DIR/where-allowed.rs:160:23 | LL | type InTypeAlias = impl Debug; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^ + | + = note: for more information, see https://github.com/rust-lang/rust/issues/63063 + = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable + +error[E0658]: `impl Trait` in type aliases is unstable + --> $DIR/where-allowed.rs:164:39 + | +LL | type InReturnInTypeAlias = fn() -> impl Debug; + | ^^^^^^^^^^ | = note: for more information, see https://github.com/rust-lang/rust/issues/63063 = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable @@ -179,61 +188,61 @@ LL | type InReturnInTypeAlias = fn() -> impl Debug; | ^^^^^^^^^^ error[E0562]: `impl Trait` not allowed outside of function and inherent method return types - --> $DIR/where-allowed.rs:168:16 + --> $DIR/where-allowed.rs:169:16 | LL | impl PartialEq for () { | ^^^^^^^^^^ error[E0562]: `impl Trait` not allowed outside of function and inherent method return types - --> $DIR/where-allowed.rs:173:24 + --> $DIR/where-allowed.rs:174:24 | LL | impl PartialEq<()> for impl Debug { | ^^^^^^^^^^ error[E0562]: `impl Trait` not allowed outside of function and inherent method return types - --> $DIR/where-allowed.rs:178:6 + --> $DIR/where-allowed.rs:179:6 | LL | impl impl Debug { | ^^^^^^^^^^ error[E0562]: `impl Trait` not allowed outside of function and inherent method return types - --> $DIR/where-allowed.rs:184:24 + --> $DIR/where-allowed.rs:185:24 | LL | impl InInherentImplAdt { | ^^^^^^^^^^ error[E0562]: `impl Trait` not allowed outside of function and inherent method return types - --> $DIR/where-allowed.rs:190:11 + --> $DIR/where-allowed.rs:191:11 | LL | where impl Debug: Debug | ^^^^^^^^^^ error[E0562]: `impl Trait` not allowed outside of function and inherent method return types - --> $DIR/where-allowed.rs:197:15 + --> $DIR/where-allowed.rs:198:15 | LL | where Vec: Debug | ^^^^^^^^^^ error[E0562]: `impl Trait` not allowed outside of function and inherent method return types - --> $DIR/where-allowed.rs:204:24 + --> $DIR/where-allowed.rs:205:24 | LL | where T: PartialEq | ^^^^^^^^^^ error[E0562]: `impl Trait` not allowed outside of function and inherent method return types - --> $DIR/where-allowed.rs:211:17 + --> $DIR/where-allowed.rs:212:17 | LL | where T: Fn(impl Debug) | ^^^^^^^^^^ error[E0562]: `impl Trait` not allowed outside of function and inherent method return types - --> $DIR/where-allowed.rs:218:22 + --> $DIR/where-allowed.rs:219:22 | LL | where T: Fn() -> impl Debug | ^^^^^^^^^^ error[E0562]: `impl Trait` not allowed outside of function and inherent method return types - --> $DIR/where-allowed.rs:224:29 + --> $DIR/where-allowed.rs:225:29 | LL | let _in_local_variable: impl Fn() = || {}; | ^^^^^^^^^ @@ -241,7 +250,7 @@ LL | let _in_local_variable: impl Fn() = || {}; = help: add `#![feature(impl_trait_in_bindings)]` to the crate attributes to enable error[E0562]: `impl Trait` not allowed outside of function and inherent method return types - --> $DIR/where-allowed.rs:226:46 + --> $DIR/where-allowed.rs:227:46 | LL | let _in_return_in_local_variable = || -> impl Fn() { || {} }; | ^^^^^^^^^ @@ -270,7 +279,7 @@ error: could not find defining uses LL | type Out = impl Debug; | ^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 43 previous errors +error: aborting due to 44 previous errors Some errors have detailed explanations: E0282, E0562, E0658, E0666. For more information about an error, try `rustc --explain E0282`. diff --git a/src/test/ui/type-alias-impl-trait/issue-60371.stderr b/src/test/ui/type-alias-impl-trait/issue-60371.stderr index 1e9b12ebc39aa..cb35706a51e09 100644 --- a/src/test/ui/type-alias-impl-trait/issue-60371.stderr +++ b/src/test/ui/type-alias-impl-trait/issue-60371.stderr @@ -1,8 +1,8 @@ error[E0658]: `impl Trait` in type aliases is unstable - --> $DIR/issue-60371.rs:8:5 + --> $DIR/issue-60371.rs:8:17 | LL | type Item = impl Bug; - | ^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^ | = note: for more information, see https://github.com/rust-lang/rust/issues/63063 = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable