diff options
| author | kadmin <julianknodt@gmail.com> | 2020-08-09 05:01:19 +0000 |
|---|---|---|
| committer | kadmin <julianknodt@gmail.com> | 2020-08-12 08:30:17 +0000 |
| commit | be650a7ecd57100b3f6348bed37fd9c6cc6b60bb (patch) | |
| tree | 6a373e2ab26fa6a6bc46c5bcea591040060b5068 | |
| parent | c94ed5ca91f1363b66970ce2cbd6e2773e3cb1d3 (diff) | |
| download | rust-be650a7ecd57100b3f6348bed37fd9c6cc6b60bb.tar.gz rust-be650a7ecd57100b3f6348bed37fd9c6cc6b60bb.zip | |
Add a bunch of revisions
This adds a bunch of revisions to const-generic tests
31 files changed, 305 insertions, 38 deletions
diff --git a/src/test/ui/const-generics/raw-ptr-const-param-deref.full.stderr b/src/test/ui/const-generics/raw-ptr-const-param-deref.full.stderr new file mode 100644 index 00000000000..ffaab51f766 --- /dev/null +++ b/src/test/ui/const-generics/raw-ptr-const-param-deref.full.stderr @@ -0,0 +1,14 @@ +error: using raw pointers as const generic parameters is forbidden + --> $DIR/raw-ptr-const-param-deref.rs:10:23 + | +LL | struct Const<const P: *const u32>; + | ^^^^^^^^^^ + +error: using raw pointers as const generic parameters is forbidden + --> $DIR/raw-ptr-const-param-deref.rs:12:15 + | +LL | impl<const P: *const u32> Const<P> { + | ^^^^^^^^^^ + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/const-generics/raw-ptr-const-param-deref.min.stderr b/src/test/ui/const-generics/raw-ptr-const-param-deref.min.stderr new file mode 100644 index 00000000000..dc4bb8b0f04 --- /dev/null +++ b/src/test/ui/const-generics/raw-ptr-const-param-deref.min.stderr @@ -0,0 +1,20 @@ +error: using raw pointers as const generic parameters is forbidden + --> $DIR/raw-ptr-const-param-deref.rs:10:23 + | +LL | struct Const<const P: *const u32>; + | ^^^^^^^^^^ + | + = note: the only supported types are integers, `bool` and `char` + = note: more complex types are supported with `#[feature(const_generics)]` + +error: using raw pointers as const generic parameters is forbidden + --> $DIR/raw-ptr-const-param-deref.rs:12:15 + | +LL | impl<const P: *const u32> Const<P> { + | ^^^^^^^^^^ + | + = note: the only supported types are integers, `bool` and `char` + = note: more complex types are supported with `#[feature(const_generics)]` + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/const-generics/raw-ptr-const-param-deref.rs b/src/test/ui/const-generics/raw-ptr-const-param-deref.rs index 97ca9d6a44c..a506153187b 100644 --- a/src/test/ui/const-generics/raw-ptr-const-param-deref.rs +++ b/src/test/ui/const-generics/raw-ptr-const-param-deref.rs @@ -1,5 +1,9 @@ -#![feature(const_generics)] -//~^ WARN the feature `const_generics` is incomplete +// Assert that cannot use const generics as ptrs and cannot deref them. +// revisions: full min + +#![cfg_attr(full, feature(const_generics))] +#![cfg_attr(full, allow(incomplete_features))] +#![cfg_attr(min, feature(min_const_generics))] const A: u32 = 3; diff --git a/src/test/ui/const-generics/raw-ptr-const-param.full.stderr b/src/test/ui/const-generics/raw-ptr-const-param.full.stderr new file mode 100644 index 00000000000..d317aa0f585 --- /dev/null +++ b/src/test/ui/const-generics/raw-ptr-const-param.full.stderr @@ -0,0 +1,8 @@ +error: using raw pointers as const generic parameters is forbidden + --> $DIR/raw-ptr-const-param.rs:7:23 + | +LL | struct Const<const P: *const u32>; + | ^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/const-generics/raw-ptr-const-param.min.stderr b/src/test/ui/const-generics/raw-ptr-const-param.min.stderr new file mode 100644 index 00000000000..f387974a21a --- /dev/null +++ b/src/test/ui/const-generics/raw-ptr-const-param.min.stderr @@ -0,0 +1,11 @@ +error: using raw pointers as const generic parameters is forbidden + --> $DIR/raw-ptr-const-param.rs:7:23 + | +LL | struct Const<const P: *const u32>; + | ^^^^^^^^^^ + | + = note: the only supported types are integers, `bool` and `char` + = note: more complex types are supported with `#[feature(const_generics)]` + +error: aborting due to previous error + diff --git a/src/test/ui/const-generics/raw-ptr-const-param.rs b/src/test/ui/const-generics/raw-ptr-const-param.rs index 237b410e073..36e593aa210 100644 --- a/src/test/ui/const-generics/raw-ptr-const-param.rs +++ b/src/test/ui/const-generics/raw-ptr-const-param.rs @@ -1,5 +1,8 @@ -#![feature(const_generics)] -//~^ WARN the feature `const_generics` is incomplete +// revisions: full min + +#![cfg_attr(full, feature(const_generics))] +#![cfg_attr(full, allow(incomplete_features))] +#![cfg_attr(min, feature(min_const_generics))] struct Const<const P: *const u32>; //~ ERROR: using raw pointers as const generic parameters diff --git a/src/test/ui/const-generics/slice-const-param-mismatch.rs b/src/test/ui/const-generics/slice-const-param-mismatch.rs index 4f321b02b82..17c374b82c7 100644 --- a/src/test/ui/const-generics/slice-const-param-mismatch.rs +++ b/src/test/ui/const-generics/slice-const-param-mismatch.rs @@ -1,5 +1,5 @@ #![feature(const_generics)] -//~^ WARN the feature `const_generics` is incomplete +#![allow(incomplete_features)] struct ConstString<const T: &'static str>; struct ConstBytes<const T: &'static [u8]>; diff --git a/src/test/ui/const-generics/slice-const-param-mismatch.stderr b/src/test/ui/const-generics/slice-const-param-mismatch.stderr index cc21f197e08..7016d78be73 100644 --- a/src/test/ui/const-generics/slice-const-param-mismatch.stderr +++ b/src/test/ui/const-generics/slice-const-param-mismatch.stderr @@ -1,12 +1,3 @@ -warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/slice-const-param-mismatch.rs:1:12 - | -LL | #![feature(const_generics)] - | ^^^^^^^^^^^^^^ - | - = note: `#[warn(incomplete_features)]` on by default - = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information - error[E0308]: mismatched types --> $DIR/slice-const-param-mismatch.rs:9:35 | @@ -40,6 +31,6 @@ LL | let _: ConstBytes<b"AAA"> = ConstBytes::<b"BBB">; = note: expected struct `ConstBytes<b"AAA">` found struct `ConstBytes<b"BBB">` -error: aborting due to 3 previous errors; 1 warning emitted +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/const-generics/slice-const-param.min.stderr b/src/test/ui/const-generics/slice-const-param.min.stderr new file mode 100644 index 00000000000..e2ffc67c357 --- /dev/null +++ b/src/test/ui/const-generics/slice-const-param.min.stderr @@ -0,0 +1,20 @@ +error: using `&'static str` as const generic parameters is forbidden + --> $DIR/slice-const-param.rs:8:40 + | +LL | pub fn function_with_str<const STRING: &'static str>() -> &'static str { + | ^^^^^^^^^^^^ + | + = note: the only supported types are integers, `bool` and `char` + = note: more complex types are supported with `#[feature(const_generics)]` + +error: using `&'static [u8]` as const generic parameters is forbidden + --> $DIR/slice-const-param.rs:13:41 + | +LL | pub fn function_with_bytes<const BYTES: &'static [u8]>() -> &'static [u8] { + | ^^^^^^^^^^^^^ + | + = note: the only supported types are integers, `bool` and `char` + = note: more complex types are supported with `#[feature(const_generics)]` + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/const-generics/slice-const-param.rs b/src/test/ui/const-generics/slice-const-param.rs index 9668f7ddabb..1b6d2f6216c 100644 --- a/src/test/ui/const-generics/slice-const-param.rs +++ b/src/test/ui/const-generics/slice-const-param.rs @@ -1,13 +1,17 @@ -// run-pass +//[full] run-pass +// revisions: min full -#![feature(const_generics)] -//~^ WARN the feature `const_generics` is incomplete +#![cfg_attr(full, feature(const_generics))] +#![cfg_attr(full, allow(incomplete_features))] +#![cfg_attr(min, feature(min_const_generics))] pub fn function_with_str<const STRING: &'static str>() -> &'static str { + //[min]~^ ERROR using `&'static str` as const STRING } pub fn function_with_bytes<const BYTES: &'static [u8]>() -> &'static [u8] { + //[min]~^ ERROR using `&'static [u8]` as const BYTES } diff --git a/src/test/ui/const-generics/struct-with-invalid-const-param.full.stderr b/src/test/ui/const-generics/struct-with-invalid-const-param.full.stderr new file mode 100644 index 00000000000..9734d2e41cb --- /dev/null +++ b/src/test/ui/const-generics/struct-with-invalid-const-param.full.stderr @@ -0,0 +1,12 @@ +error[E0573]: expected type, found const parameter `C` + --> $DIR/struct-with-invalid-const-param.rs:8:23 + | +LL | struct S<const C: u8>(C); + | ----------------------^-- + | | | + | | help: a struct with a similar name exists: `S` + | similarly named struct `S` defined here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0573`. diff --git a/src/test/ui/const-generics/struct-with-invalid-const-param.min.stderr b/src/test/ui/const-generics/struct-with-invalid-const-param.min.stderr new file mode 100644 index 00000000000..9734d2e41cb --- /dev/null +++ b/src/test/ui/const-generics/struct-with-invalid-const-param.min.stderr @@ -0,0 +1,12 @@ +error[E0573]: expected type, found const parameter `C` + --> $DIR/struct-with-invalid-const-param.rs:8:23 + | +LL | struct S<const C: u8>(C); + | ----------------------^-- + | | | + | | help: a struct with a similar name exists: `S` + | similarly named struct `S` defined here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0573`. diff --git a/src/test/ui/const-generics/struct-with-invalid-const-param.rs b/src/test/ui/const-generics/struct-with-invalid-const-param.rs index 0b00481d903..f0122ace3ae 100644 --- a/src/test/ui/const-generics/struct-with-invalid-const-param.rs +++ b/src/test/ui/const-generics/struct-with-invalid-const-param.rs @@ -1,5 +1,9 @@ -#![feature(const_generics)] -//~^ WARN the feature `const_generics` is incomplete +// Checks that a const param cannot be stored in a struct. +// revisions: full min + +#![cfg_attr(full, feature(const_generics))] +#![cfg_attr(full, allow(incomplete_features))] +#![cfg_attr(min, feature(min_const_generics))] struct S<const C: u8>(C); //~ ERROR expected type, found const parameter diff --git a/src/test/ui/const-generics/trait-const-args.rs b/src/test/ui/const-generics/trait-const-args.rs index b60d7e89651..b66d79845f9 100644 --- a/src/test/ui/const-generics/trait-const-args.rs +++ b/src/test/ui/const-generics/trait-const-args.rs @@ -1,6 +1,9 @@ // check-pass -#![allow(incomplete_features)] -#![feature(const_generics)] +// revisions: full min + +#![cfg_attr(full, feature(const_generics))] +#![cfg_attr(full, allow(incomplete_features))] +#![cfg_attr(min, feature(min_const_generics))] struct Const<const N: usize>; trait Foo<const N: usize> {} diff --git a/src/test/ui/const-generics/transparent-maybeunit-array-wrapper.rs b/src/test/ui/const-generics/transparent-maybeunit-array-wrapper.rs index 1aed9cfe927..e041e9709d0 100644 --- a/src/test/ui/const-generics/transparent-maybeunit-array-wrapper.rs +++ b/src/test/ui/const-generics/transparent-maybeunit-array-wrapper.rs @@ -1,7 +1,9 @@ // run-pass +// revisions: full min -#![feature(const_generics)] -//~^ WARN the feature `const_generics` is incomplete +#![cfg_attr(full, feature(const_generics))] +#![cfg_attr(full, allow(incomplete_features))] +#![cfg_attr(min, feature(min_const_generics))] use std::mem::MaybeUninit; diff --git a/src/test/ui/const-generics/type_of_anon_const.rs b/src/test/ui/const-generics/type_of_anon_const.rs index 588c7b9523a..f424fd03341 100644 --- a/src/test/ui/const-generics/type_of_anon_const.rs +++ b/src/test/ui/const-generics/type_of_anon_const.rs @@ -1,7 +1,9 @@ // run-pass +// revisions: full min -#![feature(const_generics)] -//~^ WARN the feature `const_generics` is incomplete +#![cfg_attr(full, feature(const_generics))] +#![cfg_attr(full, allow(incomplete_features))] +#![cfg_attr(min, feature(min_const_generics))] trait T<const A: usize> { fn l<const N: bool>() -> usize; diff --git a/src/test/ui/const-generics/uninferred-consts.full.stderr b/src/test/ui/const-generics/uninferred-consts.full.stderr new file mode 100644 index 00000000000..2c5af9e65f8 --- /dev/null +++ b/src/test/ui/const-generics/uninferred-consts.full.stderr @@ -0,0 +1,11 @@ +error[E0282]: type annotations needed + --> $DIR/uninferred-consts.rs:14:5 + | +LL | Foo.foo(); + | ^^^^^^^^^ + | + = note: unable to infer the value of a const parameter + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0282`. diff --git a/src/test/ui/const-generics/uninferred-consts.min.stderr b/src/test/ui/const-generics/uninferred-consts.min.stderr new file mode 100644 index 00000000000..2c5af9e65f8 --- /dev/null +++ b/src/test/ui/const-generics/uninferred-consts.min.stderr @@ -0,0 +1,11 @@ +error[E0282]: type annotations needed + --> $DIR/uninferred-consts.rs:14:5 + | +LL | Foo.foo(); + | ^^^^^^^^^ + | + = note: unable to infer the value of a const parameter + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0282`. diff --git a/src/test/ui/const-generics/uninferred-consts.rs b/src/test/ui/const-generics/uninferred-consts.rs index 3b2bb49197d..4d643721c8a 100644 --- a/src/test/ui/const-generics/uninferred-consts.rs +++ b/src/test/ui/const-generics/uninferred-consts.rs @@ -1,5 +1,9 @@ -#![feature(const_generics)] -//~^ WARN the feature `const_generics` is incomplete +// Test if emits error if cannot properly infer constant. +// revisions: full min + +#![cfg_attr(full, feature(const_generics))] +#![cfg_attr(full, allow(incomplete_features))] +#![cfg_attr(min, feature(min_const_generics))] // taken from https://github.com/rust-lang/rust/issues/70507#issuecomment-615268893 struct Foo; diff --git a/src/test/ui/const-generics/unknown_adt.full.stderr b/src/test/ui/const-generics/unknown_adt.full.stderr new file mode 100644 index 00000000000..983f46ce8e3 --- /dev/null +++ b/src/test/ui/const-generics/unknown_adt.full.stderr @@ -0,0 +1,9 @@ +error[E0412]: cannot find type `UnknownStruct` in this scope + --> $DIR/unknown_adt.rs:10:12 + | +LL | let _: UnknownStruct<7>; + | ^^^^^^^^^^^^^ not found in this scope + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0412`. diff --git a/src/test/ui/const-generics/unknown_adt.min.stderr b/src/test/ui/const-generics/unknown_adt.min.stderr new file mode 100644 index 00000000000..983f46ce8e3 --- /dev/null +++ b/src/test/ui/const-generics/unknown_adt.min.stderr @@ -0,0 +1,9 @@ +error[E0412]: cannot find type `UnknownStruct` in this scope + --> $DIR/unknown_adt.rs:10:12 + | +LL | let _: UnknownStruct<7>; + | ^^^^^^^^^^^^^ not found in this scope + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0412`. diff --git a/src/test/ui/const-generics/unknown_adt.rs b/src/test/ui/const-generics/unknown_adt.rs index 0ba9945b399..a803800dcbe 100644 --- a/src/test/ui/const-generics/unknown_adt.rs +++ b/src/test/ui/const-generics/unknown_adt.rs @@ -1,5 +1,10 @@ -#![feature(const_generics)] -#![allow(incomplete_features)] +// Checks errors when there is an abstract data type. +// revisions: full min + + +#![cfg_attr(full, feature(const_generics))] +#![cfg_attr(full, allow(incomplete_features))] +#![cfg_attr(min, feature(min_const_generics))] fn main() { let _: UnknownStruct<7>; diff --git a/src/test/ui/const-generics/unused-const-param.rs b/src/test/ui/const-generics/unused-const-param.rs index d9292efc21b..3c305167b4b 100644 --- a/src/test/ui/const-generics/unused-const-param.rs +++ b/src/test/ui/const-generics/unused-const-param.rs @@ -1,7 +1,9 @@ // check-pass +// revisions: full min -#![feature(const_generics)] -//~^ WARN the feature `const_generics` is incomplete +#![cfg_attr(full, feature(const_generics))] +#![cfg_attr(full, allow(incomplete_features))] +#![cfg_attr(min, feature(min_const_generics))] struct A<const N: usize>; // ok diff --git a/src/test/ui/const-generics/unused_braces.full.fixed b/src/test/ui/const-generics/unused_braces.full.fixed new file mode 100644 index 00000000000..cd3d9fda8b9 --- /dev/null +++ b/src/test/ui/const-generics/unused_braces.full.fixed @@ -0,0 +1,17 @@ +// check-pass +// run-rustfix +// revisions: full min + +#![cfg_attr(full, feature(const_generics))] +#![cfg_attr(full, allow(incomplete_features))] +#![cfg_attr(min, feature(min_const_generics))] +#![warn(unused_braces)] + + +struct A<const N: usize>; + +fn main() { + let _: A<7>; // ok + let _: A< 7 >; //~ WARN unnecessary braces + let _: A<{ 3 + 5 }>; // ok +} diff --git a/src/test/ui/const-generics/unused_braces.full.stderr b/src/test/ui/const-generics/unused_braces.full.stderr new file mode 100644 index 00000000000..1752779a60a --- /dev/null +++ b/src/test/ui/const-generics/unused_braces.full.stderr @@ -0,0 +1,14 @@ +warning: unnecessary braces around const expression + --> $DIR/unused_braces.rs:15:14 + | +LL | let _: A<{ 7 }>; + | ^^^^^ help: remove these braces + | +note: the lint level is defined here + --> $DIR/unused_braces.rs:8:9 + | +LL | #![warn(unused_braces)] + | ^^^^^^^^^^^^^ + +warning: 1 warning emitted + diff --git a/src/test/ui/const-generics/unused_braces.min.fixed b/src/test/ui/const-generics/unused_braces.min.fixed new file mode 100644 index 00000000000..cd3d9fda8b9 --- /dev/null +++ b/src/test/ui/const-generics/unused_braces.min.fixed @@ -0,0 +1,17 @@ +// check-pass +// run-rustfix +// revisions: full min + +#![cfg_attr(full, feature(const_generics))] +#![cfg_attr(full, allow(incomplete_features))] +#![cfg_attr(min, feature(min_const_generics))] +#![warn(unused_braces)] + + +struct A<const N: usize>; + +fn main() { + let _: A<7>; // ok + let _: A< 7 >; //~ WARN unnecessary braces + let _: A<{ 3 + 5 }>; // ok +} diff --git a/src/test/ui/const-generics/unused_braces.min.stderr b/src/test/ui/const-generics/unused_braces.min.stderr new file mode 100644 index 00000000000..1752779a60a --- /dev/null +++ b/src/test/ui/const-generics/unused_braces.min.stderr @@ -0,0 +1,14 @@ +warning: unnecessary braces around const expression + --> $DIR/unused_braces.rs:15:14 + | +LL | let _: A<{ 7 }>; + | ^^^^^ help: remove these braces + | +note: the lint level is defined here + --> $DIR/unused_braces.rs:8:9 + | +LL | #![warn(unused_braces)] + | ^^^^^^^^^^^^^ + +warning: 1 warning emitted + diff --git a/src/test/ui/const-generics/unused_braces.rs b/src/test/ui/const-generics/unused_braces.rs index c3e02b45ed5..31c4caf7ab8 100644 --- a/src/test/ui/const-generics/unused_braces.rs +++ b/src/test/ui/const-generics/unused_braces.rs @@ -1,10 +1,12 @@ // check-pass // run-rustfix +// revisions: full min -#![allow(incomplete_features)] +#![cfg_attr(full, feature(const_generics))] +#![cfg_attr(full, allow(incomplete_features))] +#![cfg_attr(min, feature(min_const_generics))] #![warn(unused_braces)] -#![feature(const_generics)] struct A<const N: usize>; diff --git a/src/test/ui/const-generics/wf-misc.full.stderr b/src/test/ui/const-generics/wf-misc.full.stderr new file mode 100644 index 00000000000..4af48fa1590 --- /dev/null +++ b/src/test/ui/const-generics/wf-misc.full.stderr @@ -0,0 +1,18 @@ +error: constant expression depends on a generic parameter + --> $DIR/wf-misc.rs:9:12 + | +LL | let _: [u8; N + 1]; + | ^^^^^^^^^^^ + | + = note: this may fail depending on what value the parameter takes + +error: constant expression depends on a generic parameter + --> $DIR/wf-misc.rs:17:12 + | +LL | let _: Const::<{N + 1}>; + | ^^^^^^^^^^^^^^^^ + | + = note: this may fail depending on what value the parameter takes + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/const-generics/wf-misc.min.stderr b/src/test/ui/const-generics/wf-misc.min.stderr new file mode 100644 index 00000000000..f2acb8fc06e --- /dev/null +++ b/src/test/ui/const-generics/wf-misc.min.stderr @@ -0,0 +1,18 @@ +error: generic parameters must not be used inside of non trivial constant values + --> $DIR/wf-misc.rs:9:17 + | +LL | let _: [u8; N + 1]; + | ^ non-trivial anonymous constants must not depend on the parameter `N` + | + = help: it is currently only allowed to use either `N` or `{ N }` as generic constants + +error: generic parameters must not be used inside of non trivial constant values + --> $DIR/wf-misc.rs:17:21 + | +LL | let _: Const::<{N + 1}>; + | ^ non-trivial anonymous constants must not depend on the parameter `N` + | + = help: it is currently only allowed to use either `N` or `{ N }` as generic constants + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/const-generics/wf-misc.rs b/src/test/ui/const-generics/wf-misc.rs index 4ff1b9e2da5..e6f7a9963e8 100644 --- a/src/test/ui/const-generics/wf-misc.rs +++ b/src/test/ui/const-generics/wf-misc.rs @@ -1,16 +1,22 @@ -#![feature(const_generics)] -//~^ WARN the feature `const_generics` is incomplete +// Tests miscellaneous well-formedness examples. +// revisions: full min + +#![cfg_attr(full, feature(const_generics))] +#![cfg_attr(full, allow(incomplete_features))] +#![cfg_attr(min, feature(min_const_generics))] pub fn arr_len<const N: usize>() { let _: [u8; N + 1]; - //~^ ERROR constant expression depends on a generic parameter + //[full]~^ ERROR constant expression depends on a generic parameter + //[min]~^^ ERROR generic parameters must not be used inside of non trivial } struct Const<const N: usize>; pub fn func_call<const N: usize>() { let _: Const::<{N + 1}>; - //~^ ERROR constant expression depends on a generic parameter + //[full]~^ ERROR constant expression depends on a generic parameter + //[min]~^^ ERROR generic parameters must not be used inside of non trivial } fn main() {} |
