From: Oliver Schneider Date: Mon, 16 Jul 2018 15:17:01 +0000 (+0200) Subject: Split monster tests into smaller ones X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=0f05b4be82ae9e48b2c604b97f5436b1d43a194d;p=rust.git Split monster tests into smaller ones --- diff --git a/src/test/ui/existential_types/declared_but_never_defined.rs b/src/test/ui/existential_types/declared_but_never_defined.rs new file mode 100644 index 00000000000..c0f08fe057f --- /dev/null +++ b/src/test/ui/existential_types/declared_but_never_defined.rs @@ -0,0 +1,17 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +#![feature(existential_type)] + +fn main() {} + +// declared but never defined +existential type Bar: std::fmt::Debug; //~ ERROR could not find defining uses diff --git a/src/test/ui/existential_types/declared_but_never_defined.stderr b/src/test/ui/existential_types/declared_but_never_defined.stderr new file mode 100644 index 00000000000..29ae10c1c48 --- /dev/null +++ b/src/test/ui/existential_types/declared_but_never_defined.stderr @@ -0,0 +1,8 @@ +error: could not find defining uses + --> $DIR/declared_but_never_defined.rs:17:1 + | +LL | existential type Bar: std::fmt::Debug; //~ ERROR could not find defining uses + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/existential_types/declared_but_not_defined_in_scope.rs b/src/test/ui/existential_types/declared_but_not_defined_in_scope.rs new file mode 100644 index 00000000000..6d0a9b80a3f --- /dev/null +++ b/src/test/ui/existential_types/declared_but_not_defined_in_scope.rs @@ -0,0 +1,23 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +#![feature(existential_type)] + +fn main() {} + +mod boo { + // declared in module but not defined inside of it + pub existential type Boo: ::std::fmt::Debug; //~ ERROR could not find defining uses +} + +fn bomp() -> boo::Boo { + "" +} diff --git a/src/test/ui/existential_types/declared_but_not_defined_in_scope.stderr b/src/test/ui/existential_types/declared_but_not_defined_in_scope.stderr new file mode 100644 index 00000000000..fcd8e2a7f84 --- /dev/null +++ b/src/test/ui/existential_types/declared_but_not_defined_in_scope.stderr @@ -0,0 +1,8 @@ +error: could not find defining uses + --> $DIR/declared_but_not_defined_in_scope.rs:18:5 + | +LL | pub existential type Boo: ::std::fmt::Debug; //~ ERROR could not find defining uses + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/existential_types/different_defining_uses.rs b/src/test/ui/existential_types/different_defining_uses.rs new file mode 100644 index 00000000000..c58ca3f6210 --- /dev/null +++ b/src/test/ui/existential_types/different_defining_uses.rs @@ -0,0 +1,25 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +#![feature(existential_type)] + +fn main() {} + +// two definitions with different types +existential type Foo: std::fmt::Debug; + +fn foo() -> Foo { + "" +} + +fn bar() -> Foo { //~ ERROR defining existential type use differs from previous + 42i32 +} diff --git a/src/test/ui/existential_types/different_defining_uses.stderr b/src/test/ui/existential_types/different_defining_uses.stderr new file mode 100644 index 00000000000..63177e8a123 --- /dev/null +++ b/src/test/ui/existential_types/different_defining_uses.stderr @@ -0,0 +1,18 @@ +error: defining existential type use differs from previous + --> $DIR/different_defining_uses.rs:23:1 + | +LL | / fn bar() -> Foo { //~ ERROR defining existential type use differs from previous +LL | | 42i32 +LL | | } + | |_^ + | +note: previous use here + --> $DIR/different_defining_uses.rs:19:1 + | +LL | / fn foo() -> Foo { +LL | | "" +LL | | } + | |_^ + +error: aborting due to previous error + diff --git a/src/test/ui/existential_types/different_defining_uses_never_type.rs b/src/test/ui/existential_types/different_defining_uses_never_type.rs new file mode 100644 index 00000000000..5bf46ef91bf --- /dev/null +++ b/src/test/ui/existential_types/different_defining_uses_never_type.rs @@ -0,0 +1,29 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +#![feature(existential_type)] + +fn main() {} + +// two definitions with different types +existential type Foo: std::fmt::Debug; + +fn foo() -> Foo { + "" +} + +fn bar() -> Foo { //~ ERROR defining existential type use differs from previous + panic!() +} + +fn boo() -> Foo { //~ ERROR defining existential type use differs from previous + loop {} +} diff --git a/src/test/ui/existential_types/different_defining_uses_never_type.stderr b/src/test/ui/existential_types/different_defining_uses_never_type.stderr new file mode 100644 index 00000000000..f0e9f505f6e --- /dev/null +++ b/src/test/ui/existential_types/different_defining_uses_never_type.stderr @@ -0,0 +1,34 @@ +error: defining existential type use differs from previous + --> $DIR/different_defining_uses_never_type.rs:23:1 + | +LL | / fn bar() -> Foo { //~ ERROR defining existential type use differs from previous +LL | | panic!() +LL | | } + | |_^ + | +note: previous use here + --> $DIR/different_defining_uses_never_type.rs:19:1 + | +LL | / fn foo() -> Foo { +LL | | "" +LL | | } + | |_^ + +error: defining existential type use differs from previous + --> $DIR/different_defining_uses_never_type.rs:27:1 + | +LL | / fn boo() -> Foo { //~ ERROR defining existential type use differs from previous +LL | | loop {} +LL | | } + | |_^ + | +note: previous use here + --> $DIR/different_defining_uses_never_type.rs:19:1 + | +LL | / fn foo() -> Foo { +LL | | "" +LL | | } + | |_^ + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/existential_types/different_defining_uses_never_type2.rs b/src/test/ui/existential_types/different_defining_uses_never_type2.rs new file mode 100644 index 00000000000..0e40221d829 --- /dev/null +++ b/src/test/ui/existential_types/different_defining_uses_never_type2.rs @@ -0,0 +1,54 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass + +#![feature(existential_type)] + +fn main() {} + +// two definitions with different types +existential type Foo: std::fmt::Debug; + +fn foo() -> Foo { + "" +} + +fn bar(arg: bool) -> Foo { + if arg { + panic!() + } else { + "bar" + } +} + +fn boo(arg: bool) -> Foo { + if arg { + loop {} + } else { + "boo" + } +} + +fn bar2(arg: bool) -> Foo { + if arg { + "bar2" + } else { + panic!() + } +} + +fn boo2(arg: bool) -> Foo { + if arg { + "boo2" + } else { + loop {} + } +} diff --git a/src/test/ui/existential_types/existential_type.nll.stderr b/src/test/ui/existential_types/existential_type.nll.stderr deleted file mode 100644 index 90840bf205c..00000000000 --- a/src/test/ui/existential_types/existential_type.nll.stderr +++ /dev/null @@ -1,111 +0,0 @@ -error: defining existential type use differs from previous - --> $DIR/existential_type.rs:23:1 - | -LL | / fn bar() -> Foo { //~ ERROR defining existential type use differs from previous -LL | | 42i32 -LL | | } - | |_^ - | -note: previous use here - --> $DIR/existential_type.rs:19:1 - | -LL | / fn foo() -> Foo { -LL | | "" -LL | | } - | |_^ - -error[E0308]: mismatched types - --> $DIR/existential_type.rs:36:5 - | -LL | fn bomp() -> boo::Boo { - | -------- expected `Boo` because of return type -LL | "" //~ ERROR mismatched types - | ^^ expected anonymized type, found reference - | - = note: expected type `Boo` - found type `&'static str` - -error[E0308]: mismatched types - --> $DIR/existential_type.rs:50:23 - | -LL | let _: &str = bomp(); //~ ERROR mismatched types - | ^^^^^^ expected &str, found anonymized type - | - = note: expected type `&str` - found type `Boo` - -error[E0308]: mismatched types - --> $DIR/existential_type.rs:54:9 - | -LL | fn bomp() -> boo::Boo { - | -------- expected `Boo` because of return type -LL | "" //~ ERROR mismatched types - | ^^ expected anonymized type, found reference - | - = note: expected type `Boo` - found type `&'static str` - -error[E0277]: the trait bound `T: Trait` is not satisfied - --> $DIR/existential_type.rs:61:1 - | -LL | existential type Underconstrained: 'static; //~ ERROR the trait bound `T: Trait` - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `T` - | - = help: consider adding a `where T: Trait` bound - = note: the return type of a function must have a statically known size - -warning: not reporting region error due to nll - --> $DIR/existential_type.rs:78:1 - | -LL | existential type WrongGeneric: 'static; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0308]: mismatched types - --> $DIR/existential_type.rs:93:27 - | -LL | let _: &'static str = x; //~ mismatched types - | ^ expected reference, found anonymized type - | - = note: expected type `&'static str` - found type `NoReveal` - -error[E0605]: non-primitive cast: `NoReveal` as `&'static str` - --> $DIR/existential_type.rs:94:13 - | -LL | let _ = x as &'static str; //~ non-primitive cast - | ^^^^^^^^^^^^^^^^^ - | - = note: an `as` expression can only be used to convert between primitive types. Consider using the `From` trait - -error: could not find defining uses - --> $DIR/existential_type.rs:28:1 - | -LL | existential type Bar: std::fmt::Debug; //~ ERROR could not find defining uses - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: could not find defining uses - --> $DIR/existential_type.rs:32:5 - | -LL | pub existential type Boo: ::std::fmt::Debug; //~ ERROR could not find defining uses - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: defining existential type use differs from previous - --> $DIR/existential_type.rs:74:1 - | -LL | / fn my_iter2(t: T) -> MyIter { //~ ERROR defining existential type use differs from previous -LL | | Some(t).into_iter() -LL | | } - | |_^ - | -note: previous use here - --> $DIR/existential_type.rs:70:1 - | -LL | / fn my_iter(t: T) -> MyIter { -LL | | std::iter::once(t) -LL | | } - | |_^ - -error: aborting due to 10 previous errors - -Some errors occurred: E0277, E0308, E0605. -For more information about an error, try `rustc --explain E0277`. diff --git a/src/test/ui/existential_types/existential_type.rs b/src/test/ui/existential_types/existential_type.rs deleted file mode 100644 index 6824d362049..00000000000 --- a/src/test/ui/existential_types/existential_type.rs +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -#![feature(existential_type)] - -fn main() {} - -// two definitions with different types -existential type Foo: std::fmt::Debug; - -fn foo() -> Foo { - "" -} - -fn bar() -> Foo { //~ ERROR defining existential type use differs from previous - 42i32 -} - -// declared but never defined -existential type Bar: std::fmt::Debug; //~ ERROR could not find defining uses - -mod boo { - // declared in module but not defined inside of it - pub existential type Boo: ::std::fmt::Debug; //~ ERROR could not find defining uses -} - -fn bomp() -> boo::Boo { - "" //~ ERROR mismatched types -} - -mod boo2 { - mod boo { - pub existential type Boo: ::std::fmt::Debug; - fn bomp() -> Boo { - "" - } - } - - // don't actually know the type here - - fn bomp2() { - let _: &str = bomp(); //~ ERROR mismatched types - } - - fn bomp() -> boo::Boo { - "" //~ ERROR mismatched types - } -} - -// generics - -trait Trait {} -existential type Underconstrained: 'static; //~ ERROR the trait bound `T: Trait` - -// no `Trait` bound -fn underconstrain(_: T) -> Underconstrained { - unimplemented!() -} - -existential type MyIter: Iterator; - -fn my_iter(t: T) -> MyIter { - std::iter::once(t) -} - -fn my_iter2(t: T) -> MyIter { //~ ERROR defining existential type use differs from previous - Some(t).into_iter() -} - -existential type WrongGeneric: 'static; -//~^ ERROR the parameter type `T` may not live long enough - -fn wrong_generic(t: T) -> WrongGeneric { - t -} - -// don't reveal the concrete type -existential type NoReveal: std::fmt::Debug; - -fn define_no_reveal() -> NoReveal { - "" -} - -fn no_reveal(x: NoReveal) { - let _: &'static str = x; //~ mismatched types - let _ = x as &'static str; //~ non-primitive cast -} diff --git a/src/test/ui/existential_types/existential_type.stderr b/src/test/ui/existential_types/existential_type.stderr deleted file mode 100644 index 3e7476448bf..00000000000 --- a/src/test/ui/existential_types/existential_type.stderr +++ /dev/null @@ -1,120 +0,0 @@ -error: defining existential type use differs from previous - --> $DIR/existential_type.rs:23:1 - | -LL | / fn bar() -> Foo { //~ ERROR defining existential type use differs from previous -LL | | 42i32 -LL | | } - | |_^ - | -note: previous use here - --> $DIR/existential_type.rs:19:1 - | -LL | / fn foo() -> Foo { -LL | | "" -LL | | } - | |_^ - -error[E0308]: mismatched types - --> $DIR/existential_type.rs:36:5 - | -LL | fn bomp() -> boo::Boo { - | -------- expected `Boo` because of return type -LL | "" //~ ERROR mismatched types - | ^^ expected anonymized type, found reference - | - = note: expected type `Boo` - found type `&'static str` - -error[E0308]: mismatched types - --> $DIR/existential_type.rs:50:23 - | -LL | let _: &str = bomp(); //~ ERROR mismatched types - | ^^^^^^ expected &str, found anonymized type - | - = note: expected type `&str` - found type `Boo` - -error[E0308]: mismatched types - --> $DIR/existential_type.rs:54:9 - | -LL | fn bomp() -> boo::Boo { - | -------- expected `Boo` because of return type -LL | "" //~ ERROR mismatched types - | ^^ expected anonymized type, found reference - | - = note: expected type `Boo` - found type `&'static str` - -error[E0277]: the trait bound `T: Trait` is not satisfied - --> $DIR/existential_type.rs:61:1 - | -LL | existential type Underconstrained: 'static; //~ ERROR the trait bound `T: Trait` - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `T` - | - = help: consider adding a `where T: Trait` bound - = note: the return type of a function must have a statically known size - -error[E0310]: the parameter type `T` may not live long enough - --> $DIR/existential_type.rs:78:1 - | -LL | existential type WrongGeneric: 'static; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -... -LL | fn wrong_generic(t: T) -> WrongGeneric { - | - help: consider adding an explicit lifetime bound `T: 'static`... - | -note: ...so that the type `T` will meet its required lifetime bounds - --> $DIR/existential_type.rs:78:1 - | -LL | existential type WrongGeneric: 'static; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0308]: mismatched types - --> $DIR/existential_type.rs:93:27 - | -LL | let _: &'static str = x; //~ mismatched types - | ^ expected reference, found anonymized type - | - = note: expected type `&'static str` - found type `NoReveal` - -error[E0605]: non-primitive cast: `NoReveal` as `&'static str` - --> $DIR/existential_type.rs:94:13 - | -LL | let _ = x as &'static str; //~ non-primitive cast - | ^^^^^^^^^^^^^^^^^ - | - = note: an `as` expression can only be used to convert between primitive types. Consider using the `From` trait - -error: could not find defining uses - --> $DIR/existential_type.rs:28:1 - | -LL | existential type Bar: std::fmt::Debug; //~ ERROR could not find defining uses - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: could not find defining uses - --> $DIR/existential_type.rs:32:5 - | -LL | pub existential type Boo: ::std::fmt::Debug; //~ ERROR could not find defining uses - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: defining existential type use differs from previous - --> $DIR/existential_type.rs:74:1 - | -LL | / fn my_iter2(t: T) -> MyIter { //~ ERROR defining existential type use differs from previous -LL | | Some(t).into_iter() -LL | | } - | |_^ - | -note: previous use here - --> $DIR/existential_type.rs:70:1 - | -LL | / fn my_iter(t: T) -> MyIter { -LL | | std::iter::once(t) -LL | | } - | |_^ - -error: aborting due to 11 previous errors - -Some errors occurred: E0277, E0308, E0310, E0605. -For more information about an error, try `rustc --explain E0277`. diff --git a/src/test/ui/existential_types/existential_type2.rs b/src/test/ui/existential_types/existential_type2.rs deleted file mode 100644 index bffb6b5ee10..00000000000 --- a/src/test/ui/existential_types/existential_type2.rs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -#![feature(existential_type)] - -fn main() {} - -existential type Underconstrained: 'static; -//~^ ERROR `U` doesn't implement `std::fmt::Debug` - -// not a defining use, because it doesn't define *all* possible generics -fn underconstrained(_: U) -> Underconstrained { - 5u32 -} - -existential type Underconstrained2: 'static; -//~^ ERROR `V` doesn't implement `std::fmt::Debug` - -// not a defining use, because it doesn't define *all* possible generics -fn underconstrained2(_: U, _: V) -> Underconstrained2 { - 5u32 -} diff --git a/src/test/ui/existential_types/existential_type2.stderr b/src/test/ui/existential_types/existential_type2.stderr deleted file mode 100644 index 53003a4f05d..00000000000 --- a/src/test/ui/existential_types/existential_type2.stderr +++ /dev/null @@ -1,23 +0,0 @@ -error[E0277]: `U` doesn't implement `std::fmt::Debug` - --> $DIR/existential_type2.rs:16:1 - | -LL | existential type Underconstrained: 'static; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `U` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug` - | - = help: the trait `std::fmt::Debug` is not implemented for `U` - = help: consider adding a `where U: std::fmt::Debug` bound - = note: the return type of a function must have a statically known size - -error[E0277]: `V` doesn't implement `std::fmt::Debug` - --> $DIR/existential_type2.rs:24:1 - | -LL | existential type Underconstrained2: 'static; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `V` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug` - | - = help: the trait `std::fmt::Debug` is not implemented for `V` - = help: consider adding a `where V: std::fmt::Debug` bound - = note: the return type of a function must have a statically known size - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/existential_types/existential_type3.rs b/src/test/ui/existential_types/existential_type3.rs deleted file mode 100644 index b090cf26b87..00000000000 --- a/src/test/ui/existential_types/existential_type3.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -#![feature(existential_type)] - -fn main() {} - -existential type WrongGeneric: 'static; - -fn wrong_generic(_: U, v: V) -> WrongGeneric { -//~^ ERROR type parameter `V` is part of concrete type but not used in parameter list - v -} diff --git a/src/test/ui/existential_types/existential_type3.stderr b/src/test/ui/existential_types/existential_type3.stderr deleted file mode 100644 index 90800728d7c..00000000000 --- a/src/test/ui/existential_types/existential_type3.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error: type parameter `V` is part of concrete type but not used in parameter list for existential type - --> $DIR/existential_type3.rs:18:73 - | -LL | fn wrong_generic(_: U, v: V) -> WrongGeneric { - | _________________________________________________________________________^ -LL | | //~^ ERROR type parameter `V` is part of concrete type but not used in parameter list -LL | | v -LL | | } - | |_^ - -error: aborting due to previous error - diff --git a/src/test/ui/existential_types/existential_type4.rs b/src/test/ui/existential_types/existential_type4.rs deleted file mode 100644 index a4b74d6751b..00000000000 --- a/src/test/ui/existential_types/existential_type4.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -#![feature(existential_type)] - -fn main() {} - -existential type Cmp: 'static; - -// not a defining use, because it doesn't define *all* possible generics -fn cmp() -> Cmp { //~ ERROR non-defining existential type use in defining scope - 5u32 -} diff --git a/src/test/ui/existential_types/existential_type4.stderr b/src/test/ui/existential_types/existential_type4.stderr deleted file mode 100644 index b11988746ea..00000000000 --- a/src/test/ui/existential_types/existential_type4.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error: non-defining existential type use in defining scope - --> $DIR/existential_type4.rs:19:1 - | -LL | / fn cmp() -> Cmp { //~ ERROR non-defining existential type use in defining scope -LL | | 5u32 -LL | | } - | |_^ - | -note: used non-generic type u32 for generic parameter - --> $DIR/existential_type4.rs:16:22 - | -LL | existential type Cmp: 'static; - | ^ - -error: aborting due to previous error - diff --git a/src/test/ui/existential_types/generic_different_defining_uses.rs b/src/test/ui/existential_types/generic_different_defining_uses.rs new file mode 100644 index 00000000000..109f1cd9132 --- /dev/null +++ b/src/test/ui/existential_types/generic_different_defining_uses.rs @@ -0,0 +1,24 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +#![feature(existential_type)] + +fn main() {} + +existential type MyIter: Iterator; + +fn my_iter(t: T) -> MyIter { + std::iter::once(t) +} + +fn my_iter2(t: T) -> MyIter { //~ ERROR defining existential type use differs from previous + Some(t).into_iter() +} diff --git a/src/test/ui/existential_types/generic_different_defining_uses.stderr b/src/test/ui/existential_types/generic_different_defining_uses.stderr new file mode 100644 index 00000000000..bc71af4c9af --- /dev/null +++ b/src/test/ui/existential_types/generic_different_defining_uses.stderr @@ -0,0 +1,18 @@ +error: defining existential type use differs from previous + --> $DIR/generic_different_defining_uses.rs:22:1 + | +LL | / fn my_iter2(t: T) -> MyIter { //~ ERROR defining existential type use differs from previous +LL | | Some(t).into_iter() +LL | | } + | |_^ + | +note: previous use here + --> $DIR/generic_different_defining_uses.rs:18:1 + | +LL | / fn my_iter(t: T) -> MyIter { +LL | | std::iter::once(t) +LL | | } + | |_^ + +error: aborting due to previous error + diff --git a/src/test/ui/existential_types/generic_nondefining_use.rs b/src/test/ui/existential_types/generic_nondefining_use.rs new file mode 100644 index 00000000000..a4b74d6751b --- /dev/null +++ b/src/test/ui/existential_types/generic_nondefining_use.rs @@ -0,0 +1,21 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +#![feature(existential_type)] + +fn main() {} + +existential type Cmp: 'static; + +// not a defining use, because it doesn't define *all* possible generics +fn cmp() -> Cmp { //~ ERROR non-defining existential type use in defining scope + 5u32 +} diff --git a/src/test/ui/existential_types/generic_nondefining_use.stderr b/src/test/ui/existential_types/generic_nondefining_use.stderr new file mode 100644 index 00000000000..3c826708649 --- /dev/null +++ b/src/test/ui/existential_types/generic_nondefining_use.stderr @@ -0,0 +1,16 @@ +error: non-defining existential type use in defining scope + --> $DIR/generic_nondefining_use.rs:19:1 + | +LL | / fn cmp() -> Cmp { //~ ERROR non-defining existential type use in defining scope +LL | | 5u32 +LL | | } + | |_^ + | +note: used non-generic type u32 for generic parameter + --> $DIR/generic_nondefining_use.rs:16:22 + | +LL | existential type Cmp: 'static; + | ^ + +error: aborting due to previous error + diff --git a/src/test/ui/existential_types/generic_not_used.rs b/src/test/ui/existential_types/generic_not_used.rs new file mode 100644 index 00000000000..b090cf26b87 --- /dev/null +++ b/src/test/ui/existential_types/generic_not_used.rs @@ -0,0 +1,21 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +#![feature(existential_type)] + +fn main() {} + +existential type WrongGeneric: 'static; + +fn wrong_generic(_: U, v: V) -> WrongGeneric { +//~^ ERROR type parameter `V` is part of concrete type but not used in parameter list + v +} diff --git a/src/test/ui/existential_types/generic_not_used.stderr b/src/test/ui/existential_types/generic_not_used.stderr new file mode 100644 index 00000000000..34d82c0ddb0 --- /dev/null +++ b/src/test/ui/existential_types/generic_not_used.stderr @@ -0,0 +1,12 @@ +error: type parameter `V` is part of concrete type but not used in parameter list for existential type + --> $DIR/generic_not_used.rs:18:73 + | +LL | fn wrong_generic(_: U, v: V) -> WrongGeneric { + | _________________________________________________________________________^ +LL | | //~^ ERROR type parameter `V` is part of concrete type but not used in parameter list +LL | | v +LL | | } + | |_^ + +error: aborting due to previous error + diff --git a/src/test/ui/existential_types/generic_type_does_not_live_long_enough.nll.stderr b/src/test/ui/existential_types/generic_type_does_not_live_long_enough.nll.stderr new file mode 100644 index 00000000000..8a6cae08ce0 --- /dev/null +++ b/src/test/ui/existential_types/generic_type_does_not_live_long_enough.nll.stderr @@ -0,0 +1,17 @@ +warning: not reporting region error due to nll + --> $DIR/generic_type_does_not_live_long_enough.rs:16:1 + | +LL | existential type WrongGeneric: 'static; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0310]: the parameter type `T` may not live long enough + --> $DIR/generic_type_does_not_live_long_enough.rs:20:5 + | +LL | t + | ^ + | + = help: consider adding an explicit lifetime bound `T: 'static`... + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0310`. diff --git a/src/test/ui/existential_types/generic_type_does_not_live_long_enough.rs b/src/test/ui/existential_types/generic_type_does_not_live_long_enough.rs new file mode 100644 index 00000000000..092aa1eda16 --- /dev/null +++ b/src/test/ui/existential_types/generic_type_does_not_live_long_enough.rs @@ -0,0 +1,21 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +#![feature(existential_type)] + +fn main() {} + +existential type WrongGeneric: 'static; +//~^ ERROR the parameter type `T` may not live long enough + +fn wrong_generic(t: T) -> WrongGeneric { + t +} diff --git a/src/test/ui/existential_types/generic_type_does_not_live_long_enough.stderr b/src/test/ui/existential_types/generic_type_does_not_live_long_enough.stderr new file mode 100644 index 00000000000..cbf994defc8 --- /dev/null +++ b/src/test/ui/existential_types/generic_type_does_not_live_long_enough.stderr @@ -0,0 +1,18 @@ +error[E0310]: the parameter type `T` may not live long enough + --> $DIR/generic_type_does_not_live_long_enough.rs:16:1 + | +LL | existential type WrongGeneric: 'static; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | fn wrong_generic(t: T) -> WrongGeneric { + | - help: consider adding an explicit lifetime bound `T: 'static`... + | +note: ...so that the type `T` will meet its required lifetime bounds + --> $DIR/generic_type_does_not_live_long_enough.rs:16:1 + | +LL | existential type WrongGeneric: 'static; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0310`. diff --git a/src/test/ui/existential_types/generic_underconstrained.rs b/src/test/ui/existential_types/generic_underconstrained.rs new file mode 100644 index 00000000000..fdc7a7935a2 --- /dev/null +++ b/src/test/ui/existential_types/generic_underconstrained.rs @@ -0,0 +1,22 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +#![feature(existential_type)] + +fn main() {} + +trait Trait {} +existential type Underconstrained: 'static; //~ ERROR the trait bound `T: Trait` + +// no `Trait` bound +fn underconstrain(_: T) -> Underconstrained { + unimplemented!() +} diff --git a/src/test/ui/existential_types/generic_underconstrained.stderr b/src/test/ui/existential_types/generic_underconstrained.stderr new file mode 100644 index 00000000000..1454ba575b1 --- /dev/null +++ b/src/test/ui/existential_types/generic_underconstrained.stderr @@ -0,0 +1,12 @@ +error[E0277]: the trait bound `T: Trait` is not satisfied + --> $DIR/generic_underconstrained.rs:17:1 + | +LL | existential type Underconstrained: 'static; //~ ERROR the trait bound `T: Trait` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `T` + | + = help: consider adding a `where T: Trait` bound + = note: the return type of a function must have a statically known size + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/existential_types/generic_underconstrained2.rs b/src/test/ui/existential_types/generic_underconstrained2.rs new file mode 100644 index 00000000000..bffb6b5ee10 --- /dev/null +++ b/src/test/ui/existential_types/generic_underconstrained2.rs @@ -0,0 +1,30 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +#![feature(existential_type)] + +fn main() {} + +existential type Underconstrained: 'static; +//~^ ERROR `U` doesn't implement `std::fmt::Debug` + +// not a defining use, because it doesn't define *all* possible generics +fn underconstrained(_: U) -> Underconstrained { + 5u32 +} + +existential type Underconstrained2: 'static; +//~^ ERROR `V` doesn't implement `std::fmt::Debug` + +// not a defining use, because it doesn't define *all* possible generics +fn underconstrained2(_: U, _: V) -> Underconstrained2 { + 5u32 +} diff --git a/src/test/ui/existential_types/generic_underconstrained2.stderr b/src/test/ui/existential_types/generic_underconstrained2.stderr new file mode 100644 index 00000000000..78e79e7fc86 --- /dev/null +++ b/src/test/ui/existential_types/generic_underconstrained2.stderr @@ -0,0 +1,23 @@ +error[E0277]: `U` doesn't implement `std::fmt::Debug` + --> $DIR/generic_underconstrained2.rs:16:1 + | +LL | existential type Underconstrained: 'static; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `U` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug` + | + = help: the trait `std::fmt::Debug` is not implemented for `U` + = help: consider adding a `where U: std::fmt::Debug` bound + = note: the return type of a function must have a statically known size + +error[E0277]: `V` doesn't implement `std::fmt::Debug` + --> $DIR/generic_underconstrained2.rs:24:1 + | +LL | existential type Underconstrained2: 'static; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `V` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug` + | + = help: the trait `std::fmt::Debug` is not implemented for `V` + = help: consider adding a `where V: std::fmt::Debug` bound + = note: the return type of a function must have a statically known size + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/existential_types/never_reveal_concrete_type.rs b/src/test/ui/existential_types/never_reveal_concrete_type.rs new file mode 100644 index 00000000000..4517eca60ed --- /dev/null +++ b/src/test/ui/existential_types/never_reveal_concrete_type.rs @@ -0,0 +1,26 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +#![feature(existential_type)] + +fn main() {} + +// don't reveal the concrete type +existential type NoReveal: std::fmt::Debug; + +fn define_no_reveal() -> NoReveal { + "" +} + +fn no_reveal(x: NoReveal) { + let _: &'static str = x; //~ mismatched types + let _ = x as &'static str; //~ non-primitive cast +} diff --git a/src/test/ui/existential_types/never_reveal_concrete_type.stderr b/src/test/ui/existential_types/never_reveal_concrete_type.stderr new file mode 100644 index 00000000000..449799c91b7 --- /dev/null +++ b/src/test/ui/existential_types/never_reveal_concrete_type.stderr @@ -0,0 +1,21 @@ +error[E0308]: mismatched types + --> $DIR/never_reveal_concrete_type.rs:24:27 + | +LL | let _: &'static str = x; //~ mismatched types + | ^ expected reference, found anonymized type + | + = note: expected type `&'static str` + found type `NoReveal` + +error[E0605]: non-primitive cast: `NoReveal` as `&'static str` + --> $DIR/never_reveal_concrete_type.rs:25:13 + | +LL | let _ = x as &'static str; //~ non-primitive cast + | ^^^^^^^^^^^^^^^^^ + | + = note: an `as` expression can only be used to convert between primitive types. Consider using the `From` trait + +error: aborting due to 2 previous errors + +Some errors occurred: E0308, E0605. +For more information about an error, try `rustc --explain E0308`. diff --git a/src/test/ui/existential_types/no_revealing_outside_defining_module.rs b/src/test/ui/existential_types/no_revealing_outside_defining_module.rs new file mode 100644 index 00000000000..086df13ba70 --- /dev/null +++ b/src/test/ui/existential_types/no_revealing_outside_defining_module.rs @@ -0,0 +1,33 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +#![feature(existential_type)] + +fn main() {} + +mod boo2 { + mod boo { + pub existential type Boo: ::std::fmt::Debug; + fn bomp() -> Boo { + "" + } + } + + // don't actually know the type here + + fn bomp2() { + let _: &str = bomp(); //~ ERROR mismatched types + } + + fn bomp() -> boo::Boo { + "" //~ ERROR mismatched types + } +} diff --git a/src/test/ui/existential_types/no_revealing_outside_defining_module.stderr b/src/test/ui/existential_types/no_revealing_outside_defining_module.stderr new file mode 100644 index 00000000000..eebd3295489 --- /dev/null +++ b/src/test/ui/existential_types/no_revealing_outside_defining_module.stderr @@ -0,0 +1,23 @@ +error[E0308]: mismatched types + --> $DIR/no_revealing_outside_defining_module.rs:27:23 + | +LL | let _: &str = bomp(); //~ ERROR mismatched types + | ^^^^^^ expected &str, found anonymized type + | + = note: expected type `&str` + found type `Boo` + +error[E0308]: mismatched types + --> $DIR/no_revealing_outside_defining_module.rs:31:9 + | +LL | fn bomp() -> boo::Boo { + | -------- expected `Boo` because of return type +LL | "" //~ ERROR mismatched types + | ^^ expected anonymized type, found reference + | + = note: expected type `Boo` + found type `&'static str` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`.