From d39cc45cf251be63f3066c6002d409274aa9d2a4 Mon Sep 17 00:00:00 2001 From: Amjad Alsharafi Date: Wed, 26 Aug 2020 18:22:55 +0800 Subject: [PATCH 1/9] Added a lot of min_const_generics revisions --- ...rder.stderr => argument_order.full.stderr} | 4 +- .../const-generics/argument_order.min.stderr | 30 ++++++++++ src/test/ui/const-generics/argument_order.rs | 14 +++-- .../array-wrapper-struct-ctor.rs | 7 ++- .../array-wrapper-struct-ctor.stderr | 11 ---- .../cannot-infer-type-for-const-param.rs | 6 +- .../cannot-infer-type-for-const-param.stderr | 11 ---- ...const-arg-type-arg-misordered.full.stderr} | 2 +- .../const-arg-type-arg-misordered.min.stderr | 12 ++++ .../const-arg-type-arg-misordered.rs | 10 +++- ...nst-param-before-other-params.full.stderr} | 2 +- ...const-param-before-other-params.min.stderr | 32 +++++++++++ .../const-param-before-other-params.rs | 12 +++- ...e-71381.stderr => issue-71381.full.stderr} | 8 +-- .../issues/issue-71381.min.stderr | 27 +++++++++ .../ui/const-generics/issues/issue-71381.rs | 18 ++++-- ...e-71382.stderr => issue-71382.full.stderr} | 2 +- .../issues/issue-71382.min.stderr | 8 +++ .../ui/const-generics/issues/issue-71382.rs | 9 ++- ...e-71611.stderr => issue-71611.full.stderr} | 4 +- .../issues/issue-71611.min.stderr | 15 +++++ .../ui/const-generics/issues/issue-71611.rs | 12 ++-- ...e-72352.stderr => issue-72352.full.stderr} | 2 +- .../issues/issue-72352.min.stderr | 8 +++ .../ui/const-generics/issues/issue-72352.rs | 9 ++- .../issues/issue-73491.min.stderr | 11 ++++ .../ui/const-generics/issues/issue-73491.rs | 9 ++- .../issues/issue-73508.full.stderr | 8 +++ .../issues/issue-73508.min.stderr | 8 +++ .../ui/const-generics/issues/issue-73508.rs | 8 ++- .../const-generics/issues/issue-73508.stderr | 17 ------ .../issues/issue-74101.min.stderr | 20 +++++++ .../ui/const-generics/issues/issue-74101.rs | 10 +++- .../issues/issue-74255.min.stderr | 11 ++++ .../ui/const-generics/issues/issue-74255.rs | 9 ++- .../issues/issue-75047.min.stderr | 11 ++++ .../ui/const-generics/issues/issue-75047.rs | 9 ++- .../issues/issue70273-assoc-fn.rs | 7 ++- .../issues/issue70273-assoc-fn.stderr | 11 ---- .../std/const-generics-range.min.stderr | 56 +++++++++++++++++++ .../std/const-generics-range.rs | 14 ++++- .../type-after-const-ok.min.stderr | 8 +++ .../ui/const-generics/type-after-const-ok.rs | 10 ++-- .../type-dependent/issue-61936.rs | 6 +- .../type-dependent/issue-63695.rs | 6 +- .../type-dependent/issue-67144-1.rs | 6 +- .../type-dependent/issue-67144-2.rs | 6 +- .../type-dependent/issue-69816.rs | 6 +- .../type-dependent/issue-70217.rs | 7 ++- .../type-dependent/issue-70507.rs | 6 +- .../type-dependent/issue-70586.rs | 6 +- .../type-dependent/issue-71348.min.stderr | 20 +++++++ .../type-dependent/issue-71348.rs | 10 +++- .../type-dependent/issue-71382.full.stderr | 8 +++ .../type-dependent/issue-71382.min.stderr | 8 +++ .../type-dependent/issue-71382.rs | 9 ++- .../type-dependent/issue-71382.stderr | 17 ------ .../type-dependent/issue-71805.rs | 6 +- .../type-dependent/issue-73730.rs | 6 +- .../type-dependent/non-local.rs | 6 +- .../ui/const-generics/type-dependent/qpath.rs | 6 +- .../const-generics/type-dependent/simple.rs | 6 +- .../type-dependent/type-mismatch.full.stderr | 14 +++++ .../type-dependent/type-mismatch.min.stderr | 14 +++++ .../type-dependent/type-mismatch.rs | 9 ++- .../type-dependent/type-mismatch.stderr | 23 -------- ... => types-mismatch-const-args.full.stderr} | 15 +---- .../types-mismatch-const-args.min.stderr | 25 +++++++++ .../types-mismatch-const-args.rs | 12 ++-- .../uninferred-consts-during-codegen-1.rs | 7 ++- .../uninferred-consts-during-codegen-1.stderr | 11 ---- .../uninferred-consts-during-codegen-2.rs | 7 ++- .../uninferred-consts-during-codegen-2.stderr | 11 ---- 73 files changed, 575 insertions(+), 236 deletions(-) rename src/test/ui/const-generics/{argument_order.stderr => argument_order.full.stderr} (91%) create mode 100644 src/test/ui/const-generics/argument_order.min.stderr delete mode 100644 src/test/ui/const-generics/array-wrapper-struct-ctor.stderr delete mode 100644 src/test/ui/const-generics/cannot-infer-type-for-const-param.stderr rename src/test/ui/const-generics/{const-arg-type-arg-misordered.stderr => const-arg-type-arg-misordered.full.stderr} (84%) create mode 100644 src/test/ui/const-generics/const-arg-type-arg-misordered.min.stderr rename src/test/ui/const-generics/{const-param-before-other-params.stderr => const-param-before-other-params.full.stderr} (84%) create mode 100644 src/test/ui/const-generics/const-param-before-other-params.min.stderr rename src/test/ui/const-generics/issues/{issue-71381.stderr => issue-71381.full.stderr} (89%) create mode 100644 src/test/ui/const-generics/issues/issue-71381.min.stderr rename src/test/ui/const-generics/issues/{issue-71382.stderr => issue-71382.full.stderr} (85%) create mode 100644 src/test/ui/const-generics/issues/issue-71382.min.stderr rename src/test/ui/const-generics/issues/{issue-71611.stderr => issue-71611.full.stderr} (89%) create mode 100644 src/test/ui/const-generics/issues/issue-71611.min.stderr rename src/test/ui/const-generics/issues/{issue-72352.stderr => issue-72352.full.stderr} (89%) create mode 100644 src/test/ui/const-generics/issues/issue-72352.min.stderr create mode 100644 src/test/ui/const-generics/issues/issue-73491.min.stderr create mode 100644 src/test/ui/const-generics/issues/issue-73508.full.stderr create mode 100644 src/test/ui/const-generics/issues/issue-73508.min.stderr delete mode 100644 src/test/ui/const-generics/issues/issue-73508.stderr create mode 100644 src/test/ui/const-generics/issues/issue-74101.min.stderr create mode 100644 src/test/ui/const-generics/issues/issue-74255.min.stderr create mode 100644 src/test/ui/const-generics/issues/issue-75047.min.stderr delete mode 100644 src/test/ui/const-generics/issues/issue70273-assoc-fn.stderr create mode 100644 src/test/ui/const-generics/std/const-generics-range.min.stderr create mode 100644 src/test/ui/const-generics/type-after-const-ok.min.stderr create mode 100644 src/test/ui/const-generics/type-dependent/issue-71348.min.stderr create mode 100644 src/test/ui/const-generics/type-dependent/issue-71382.full.stderr create mode 100644 src/test/ui/const-generics/type-dependent/issue-71382.min.stderr delete mode 100644 src/test/ui/const-generics/type-dependent/issue-71382.stderr create mode 100644 src/test/ui/const-generics/type-dependent/type-mismatch.full.stderr create mode 100644 src/test/ui/const-generics/type-dependent/type-mismatch.min.stderr delete mode 100644 src/test/ui/const-generics/type-dependent/type-mismatch.stderr rename src/test/ui/const-generics/{types-mismatch-const-args.stderr => types-mismatch-const-args.full.stderr} (64%) create mode 100644 src/test/ui/const-generics/types-mismatch-const-args.min.stderr delete mode 100644 src/test/ui/const-generics/uninferred-consts-during-codegen-1.stderr delete mode 100644 src/test/ui/const-generics/uninferred-consts-during-codegen-2.stderr diff --git a/src/test/ui/const-generics/argument_order.stderr b/src/test/ui/const-generics/argument_order.full.stderr similarity index 91% rename from src/test/ui/const-generics/argument_order.stderr rename to src/test/ui/const-generics/argument_order.full.stderr index d6546a768d23..5068fd6d7343 100644 --- a/src/test/ui/const-generics/argument_order.stderr +++ b/src/test/ui/const-generics/argument_order.full.stderr @@ -1,11 +1,11 @@ error: lifetime parameters must be declared prior to const parameters - --> $DIR/argument_order.rs:9:32 + --> $DIR/argument_order.rs:12:32 | LL | struct AlsoBad { | -----------------^^-----^^-------------------- help: reorder the parameters: lifetimes, then consts and types: `<'a, 'b, const N: usize, T, const M: usize, U>` error[E0747]: lifetime provided when a type was expected - --> $DIR/argument_order.rs:16:23 + --> $DIR/argument_order.rs:21:23 | LL | let _: AlsoBad<7, 'static, u32, 'static, 17, u16>; | ^^^^^^^ diff --git a/src/test/ui/const-generics/argument_order.min.stderr b/src/test/ui/const-generics/argument_order.min.stderr new file mode 100644 index 000000000000..c3068e0a2313 --- /dev/null +++ b/src/test/ui/const-generics/argument_order.min.stderr @@ -0,0 +1,30 @@ +error: type parameters must be declared prior to const parameters + --> $DIR/argument_order.rs:6:28 + | +LL | struct Bad { + | -----------------^- help: reorder the parameters: lifetimes, then types, then consts: `` + +error: lifetime parameters must be declared prior to const parameters + --> $DIR/argument_order.rs:12:32 + | +LL | struct AlsoBad { + | -----------------^^-----^^-------------------- help: reorder the parameters: lifetimes, then types, then consts: `<'a, 'b, T, U, const N: usize, const M: usize>` + +error: type parameters must be declared prior to const parameters + --> $DIR/argument_order.rs:12:36 + | +LL | struct AlsoBad { + | ---------------------^----------------------^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, 'b, T, U, const N: usize, const M: usize>` + +error[E0747]: lifetime provided when a type was expected + --> $DIR/argument_order.rs:21:23 + | +LL | let _: AlsoBad<7, 'static, u32, 'static, 17, u16>; + | ^^^^^^^ + | + = note: lifetime arguments must be provided before type arguments + = help: reorder the arguments: lifetimes, then types, then consts: `<'a, 'b, T, U, N, M>` + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0747`. diff --git a/src/test/ui/const-generics/argument_order.rs b/src/test/ui/const-generics/argument_order.rs index 9e071e674e70..aebf6cc846a6 100644 --- a/src/test/ui/const-generics/argument_order.rs +++ b/src/test/ui/const-generics/argument_order.rs @@ -1,18 +1,24 @@ -#![feature(const_generics)] -#![allow(incomplete_features)] +// revisions: full min +#![cfg_attr(full, feature(const_generics))] +#![cfg_attr(full, allow(incomplete_features))] +#![cfg_attr(min, feature(min_const_generics))] struct Bad { + //[min]~^ ERROR type parameters must be declared prior to const parameters arr: [u8; { N }], another: T, } struct AlsoBad { - //~^ ERROR lifetime parameters must be declared prior + //[full]~^ ERROR lifetime parameters must be declared prior + //[min]~^^ ERROR lifetime parameters must be declared prior to const parameters + //[min]~^^^ ERROR type parameters must be declared prior to const parameters a: &'a T, b: &'b U, } fn main() { let _: AlsoBad<7, 'static, u32, 'static, 17, u16>; - //~^ ERROR lifetime provided when a type was expected + //[full]~^ ERROR lifetime provided when a type was expected + //[min]~^^ ERROR lifetime provided when a type was expected } diff --git a/src/test/ui/const-generics/array-wrapper-struct-ctor.rs b/src/test/ui/const-generics/array-wrapper-struct-ctor.rs index 49fc53b32bd9..390b6cc2049e 100644 --- a/src/test/ui/const-generics/array-wrapper-struct-ctor.rs +++ b/src/test/ui/const-generics/array-wrapper-struct-ctor.rs @@ -1,7 +1,8 @@ // run-pass - -#![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))] #![allow(dead_code)] diff --git a/src/test/ui/const-generics/array-wrapper-struct-ctor.stderr b/src/test/ui/const-generics/array-wrapper-struct-ctor.stderr deleted file mode 100644 index e6eb2a0a7830..000000000000 --- a/src/test/ui/const-generics/array-wrapper-struct-ctor.stderr +++ /dev/null @@ -1,11 +0,0 @@ -warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/array-wrapper-struct-ctor.rs:3:12 - | -LL | #![feature(const_generics)] - | ^^^^^^^^^^^^^^ - | - = note: `#[warn(incomplete_features)]` on by default - = note: see issue #44580 for more information - -warning: 1 warning emitted - diff --git a/src/test/ui/const-generics/cannot-infer-type-for-const-param.rs b/src/test/ui/const-generics/cannot-infer-type-for-const-param.rs index aac5d195f76a..931f6ade7f15 100644 --- a/src/test/ui/const-generics/cannot-infer-type-for-const-param.rs +++ b/src/test/ui/const-generics/cannot-infer-type-for-const-param.rs @@ -1,6 +1,8 @@ // check-pass -#![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))] // This test confirms that the types can be inferred correctly for this example with const // generics. Previously this would ICE, and more recently error. diff --git a/src/test/ui/const-generics/cannot-infer-type-for-const-param.stderr b/src/test/ui/const-generics/cannot-infer-type-for-const-param.stderr deleted file mode 100644 index c5c48d7be468..000000000000 --- a/src/test/ui/const-generics/cannot-infer-type-for-const-param.stderr +++ /dev/null @@ -1,11 +0,0 @@ -warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/cannot-infer-type-for-const-param.rs:2:12 - | -LL | #![feature(const_generics)] - | ^^^^^^^^^^^^^^ - | - = note: `#[warn(incomplete_features)]` on by default - = note: see issue #44580 for more information - -warning: 1 warning emitted - diff --git a/src/test/ui/const-generics/const-arg-type-arg-misordered.stderr b/src/test/ui/const-generics/const-arg-type-arg-misordered.full.stderr similarity index 84% rename from src/test/ui/const-generics/const-arg-type-arg-misordered.stderr rename to src/test/ui/const-generics/const-arg-type-arg-misordered.full.stderr index 2e2bfed51fb2..3827002ff4bc 100644 --- a/src/test/ui/const-generics/const-arg-type-arg-misordered.stderr +++ b/src/test/ui/const-generics/const-arg-type-arg-misordered.full.stderr @@ -1,5 +1,5 @@ error[E0747]: constant provided when a type was expected - --> $DIR/const-arg-type-arg-misordered.rs:6:35 + --> $DIR/const-arg-type-arg-misordered.rs:8:35 | LL | fn foo() -> Array { | ^ diff --git a/src/test/ui/const-generics/const-arg-type-arg-misordered.min.stderr b/src/test/ui/const-generics/const-arg-type-arg-misordered.min.stderr new file mode 100644 index 000000000000..2c5fc8dcc01f --- /dev/null +++ b/src/test/ui/const-generics/const-arg-type-arg-misordered.min.stderr @@ -0,0 +1,12 @@ +error[E0747]: constant provided when a type was expected + --> $DIR/const-arg-type-arg-misordered.rs:8:35 + | +LL | fn foo() -> Array { + | ^ + | + = note: type arguments must be provided before constant arguments + = help: reorder the arguments: types, then consts: `` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0747`. diff --git a/src/test/ui/const-generics/const-arg-type-arg-misordered.rs b/src/test/ui/const-generics/const-arg-type-arg-misordered.rs index 13ca56ad3e69..ce45720ffb0d 100644 --- a/src/test/ui/const-generics/const-arg-type-arg-misordered.rs +++ b/src/test/ui/const-generics/const-arg-type-arg-misordered.rs @@ -1,9 +1,13 @@ -#![feature(const_generics)] -#![allow(incomplete_features)] +// revisions: full min +#![cfg_attr(full, feature(const_generics))] +#![cfg_attr(full, allow(incomplete_features))] +#![cfg_attr(min, feature(min_const_generics))] type Array = [T; N]; -fn foo() -> Array { //~ ERROR constant provided when a type was expected +fn foo() -> Array { + //[full]~^ ERROR constant provided when a type was expected + //[min]~^^ ERROR constant provided when a type was expected unimplemented!() } diff --git a/src/test/ui/const-generics/const-param-before-other-params.stderr b/src/test/ui/const-generics/const-param-before-other-params.full.stderr similarity index 84% rename from src/test/ui/const-generics/const-param-before-other-params.stderr rename to src/test/ui/const-generics/const-param-before-other-params.full.stderr index 1194dd30f61b..c2acaabbd883 100644 --- a/src/test/ui/const-generics/const-param-before-other-params.stderr +++ b/src/test/ui/const-generics/const-param-before-other-params.full.stderr @@ -1,5 +1,5 @@ error: lifetime parameters must be declared prior to const parameters - --> $DIR/const-param-before-other-params.rs:4:21 + --> $DIR/const-param-before-other-params.rs:6:21 | LL | fn bar(_: &'a ()) { | --------------^^- help: reorder the parameters: lifetimes, then consts and types: `<'a, const X: ()>` diff --git a/src/test/ui/const-generics/const-param-before-other-params.min.stderr b/src/test/ui/const-generics/const-param-before-other-params.min.stderr new file mode 100644 index 000000000000..fc197181deeb --- /dev/null +++ b/src/test/ui/const-generics/const-param-before-other-params.min.stderr @@ -0,0 +1,32 @@ +error: lifetime parameters must be declared prior to const parameters + --> $DIR/const-param-before-other-params.rs:6:21 + | +LL | fn bar(_: &'a ()) { + | --------------^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, const X: ()>` + +error: type parameters must be declared prior to const parameters + --> $DIR/const-param-before-other-params.rs:12:21 + | +LL | fn foo(_: &T) {} + | --------------^- help: reorder the parameters: lifetimes, then types, then consts: `` + +error: `()` is forbidden as the type of a const generic parameter + --> $DIR/const-param-before-other-params.rs:6:17 + | +LL | fn bar(_: &'a ()) { + | ^^ + | + = note: the only supported types are integers, `bool` and `char` + = note: more complex types are supported with `#[feature(const_generics)]` + +error: `()` is forbidden as the type of a const generic parameter + --> $DIR/const-param-before-other-params.rs:12:17 + | +LL | fn foo(_: &T) {} + | ^^ + | + = note: the only supported types are integers, `bool` and `char` + = note: more complex types are supported with `#[feature(const_generics)]` + +error: aborting due to 4 previous errors + diff --git a/src/test/ui/const-generics/const-param-before-other-params.rs b/src/test/ui/const-generics/const-param-before-other-params.rs index 0d787d9a67b5..5b98b6c518db 100644 --- a/src/test/ui/const-generics/const-param-before-other-params.rs +++ b/src/test/ui/const-generics/const-param-before-other-params.rs @@ -1,10 +1,16 @@ -#![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))] fn bar(_: &'a ()) { - //~^ ERROR lifetime parameters must be declared prior to const parameters + //[full]~^ ERROR lifetime parameters must be declared prior to const parameters + //[min]~^^ ERROR lifetime parameters must be declared prior to const parameters + //[min]~^^^ ERROR `()` is forbidden as the type of a const generic parameter } fn foo(_: &T) {} +//[min]~^ ERROR type parameters must be declared prior to const parameters +//[min]~^^ ERROR `()` is forbidden as the type of a const generic parameter fn main() {} diff --git a/src/test/ui/const-generics/issues/issue-71381.stderr b/src/test/ui/const-generics/issues/issue-71381.full.stderr similarity index 89% rename from src/test/ui/const-generics/issues/issue-71381.stderr rename to src/test/ui/const-generics/issues/issue-71381.full.stderr index fd4ebe3dead8..4586a80687a7 100644 --- a/src/test/ui/const-generics/issues/issue-71381.stderr +++ b/src/test/ui/const-generics/issues/issue-71381.full.stderr @@ -1,23 +1,23 @@ error[E0770]: the type of const parameters must not depend on other generic parameters - --> $DIR/issue-71381.rs:13:82 + --> $DIR/issue-71381.rs:15:82 | LL | pub fn call_me(&self) { | ^^^^ the type must not depend on the parameter `Args` error[E0770]: the type of const parameters must not depend on other generic parameters - --> $DIR/issue-71381.rs:22:40 + --> $DIR/issue-71381.rs:26:40 | LL | const FN: unsafe extern "C" fn(Args), | ^^^^ the type must not depend on the parameter `Args` error: using function pointers as const generic parameters is forbidden - --> $DIR/issue-71381.rs:13:61 + --> $DIR/issue-71381.rs:15:61 | LL | pub fn call_me(&self) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: using function pointers as const generic parameters is forbidden - --> $DIR/issue-71381.rs:22:19 + --> $DIR/issue-71381.rs:26:19 | LL | const FN: unsafe extern "C" fn(Args), | ^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/const-generics/issues/issue-71381.min.stderr b/src/test/ui/const-generics/issues/issue-71381.min.stderr new file mode 100644 index 000000000000..4586a80687a7 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-71381.min.stderr @@ -0,0 +1,27 @@ +error[E0770]: the type of const parameters must not depend on other generic parameters + --> $DIR/issue-71381.rs:15:82 + | +LL | pub fn call_me(&self) { + | ^^^^ the type must not depend on the parameter `Args` + +error[E0770]: the type of const parameters must not depend on other generic parameters + --> $DIR/issue-71381.rs:26:40 + | +LL | const FN: unsafe extern "C" fn(Args), + | ^^^^ the type must not depend on the parameter `Args` + +error: using function pointers as const generic parameters is forbidden + --> $DIR/issue-71381.rs:15:61 + | +LL | pub fn call_me(&self) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: using function pointers as const generic parameters is forbidden + --> $DIR/issue-71381.rs:26:19 + | +LL | const FN: unsafe extern "C" fn(Args), + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0770`. diff --git a/src/test/ui/const-generics/issues/issue-71381.rs b/src/test/ui/const-generics/issues/issue-71381.rs index 08f948239421..3203cf8fe765 100644 --- a/src/test/ui/const-generics/issues/issue-71381.rs +++ b/src/test/ui/const-generics/issues/issue-71381.rs @@ -1,5 +1,7 @@ -#![feature(const_generics)] -#![allow(incomplete_features)] +// revisions: full min +#![cfg_attr(full, feature(const_generics))] +#![cfg_attr(full, allow(incomplete_features))] +#![cfg_attr(min, feature(min_const_generics))] struct Test(*const usize); @@ -11,8 +13,10 @@ unsafe extern "C" fn pass(args: PassArg) { impl Test { pub fn call_me(&self) { - //~^ ERROR: using function pointers as const generic parameters is forbidden - //~| ERROR: the type of const parameters must not depend on other generic parameters + //[full]~^ ERROR: using function pointers as const generic parameters is forbidden + //[full]~| ERROR: the type of const parameters must not depend on other generic parameters + //[min]~^^^ ERROR: using function pointers as const generic parameters is forbidden + //[min]~| ERROR: the type of const parameters must not depend on other generic parameters self.0 = Self::trampiline:: as _ } @@ -20,8 +24,10 @@ impl Test { Args: Sized, const IDX: usize, const FN: unsafe extern "C" fn(Args), - //~^ ERROR: using function pointers as const generic parameters is forbidden - //~| ERROR: the type of const parameters must not depend on other generic parameters + //[full]~^ ERROR: using function pointers as const generic parameters is forbidden + //[full]~| ERROR: the type of const parameters must not depend on other generic parameters + //[min]~^^^ ERROR: using function pointers as const generic parameters is forbidden + //[min]~| ERROR: the type of const parameters must not depend on other generic parameters >( args: Args, ) { diff --git a/src/test/ui/const-generics/issues/issue-71382.stderr b/src/test/ui/const-generics/issues/issue-71382.full.stderr similarity index 85% rename from src/test/ui/const-generics/issues/issue-71382.stderr rename to src/test/ui/const-generics/issues/issue-71382.full.stderr index 1652b0bdfa87..3da85ee040de 100644 --- a/src/test/ui/const-generics/issues/issue-71382.stderr +++ b/src/test/ui/const-generics/issues/issue-71382.full.stderr @@ -1,5 +1,5 @@ error: using function pointers as const generic parameters is forbidden - --> $DIR/issue-71382.rs:15:23 + --> $DIR/issue-71382.rs:17:23 | LL | fn test(&self) { | ^^^^ diff --git a/src/test/ui/const-generics/issues/issue-71382.min.stderr b/src/test/ui/const-generics/issues/issue-71382.min.stderr new file mode 100644 index 000000000000..3da85ee040de --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-71382.min.stderr @@ -0,0 +1,8 @@ +error: using function pointers as const generic parameters is forbidden + --> $DIR/issue-71382.rs:17:23 + | +LL | fn test(&self) { + | ^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/const-generics/issues/issue-71382.rs b/src/test/ui/const-generics/issues/issue-71382.rs index e0cf9812d95e..e403b0f11991 100644 --- a/src/test/ui/const-generics/issues/issue-71382.rs +++ b/src/test/ui/const-generics/issues/issue-71382.rs @@ -1,5 +1,7 @@ -#![feature(const_generics)] -#![allow(incomplete_features)] +// revisions: full min +#![cfg_attr(full, feature(const_generics))] +#![cfg_attr(full, allow(incomplete_features))] +#![cfg_attr(min, feature(min_const_generics))] struct Test(); @@ -13,7 +15,8 @@ impl Test { } fn test(&self) { - //~^ ERROR: using function pointers as const generic parameters is forbidden + //[full]~^ ERROR: using function pointers as const generic parameters is forbidden + //[min]~^^ ERROR: using function pointers as const generic parameters is forbidden FN(); } } diff --git a/src/test/ui/const-generics/issues/issue-71611.stderr b/src/test/ui/const-generics/issues/issue-71611.full.stderr similarity index 89% rename from src/test/ui/const-generics/issues/issue-71611.stderr rename to src/test/ui/const-generics/issues/issue-71611.full.stderr index e2c9f22361eb..48d4bb361a18 100644 --- a/src/test/ui/const-generics/issues/issue-71611.stderr +++ b/src/test/ui/const-generics/issues/issue-71611.full.stderr @@ -1,11 +1,11 @@ error[E0770]: the type of const parameters must not depend on other generic parameters - --> $DIR/issue-71611.rs:4:31 + --> $DIR/issue-71611.rs:6:31 | LL | fn func(outer: A) { | ^ the type must not depend on the parameter `A` error: using function pointers as const generic parameters is forbidden - --> $DIR/issue-71611.rs:4:21 + --> $DIR/issue-71611.rs:6:21 | LL | fn func(outer: A) { | ^^^^^^^^^^^^ diff --git a/src/test/ui/const-generics/issues/issue-71611.min.stderr b/src/test/ui/const-generics/issues/issue-71611.min.stderr new file mode 100644 index 000000000000..48d4bb361a18 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-71611.min.stderr @@ -0,0 +1,15 @@ +error[E0770]: the type of const parameters must not depend on other generic parameters + --> $DIR/issue-71611.rs:6:31 + | +LL | fn func(outer: A) { + | ^ the type must not depend on the parameter `A` + +error: using function pointers as const generic parameters is forbidden + --> $DIR/issue-71611.rs:6:21 + | +LL | fn func(outer: A) { + | ^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0770`. diff --git a/src/test/ui/const-generics/issues/issue-71611.rs b/src/test/ui/const-generics/issues/issue-71611.rs index 06ff38dec66c..c9c95902f957 100644 --- a/src/test/ui/const-generics/issues/issue-71611.rs +++ b/src/test/ui/const-generics/issues/issue-71611.rs @@ -1,9 +1,13 @@ -#![feature(const_generics)] -#![allow(incomplete_features)] +// revisions: full min +#![cfg_attr(full, feature(const_generics))] +#![cfg_attr(full, allow(incomplete_features))] +#![cfg_attr(min, feature(min_const_generics))] fn func(outer: A) { - //~^ ERROR: using function pointers as const generic parameters is forbidden - //~| ERROR: the type of const parameters must not depend on other generic parameters + //[full]~^ ERROR: using function pointers as const generic parameters is forbidden + //[full]~| ERROR: the type of const parameters must not depend on other generic parameters + //[min]~^^^ ERROR: using function pointers as const generic parameters is forbidden + //[min]~| ERROR: the type of const parameters must not depend on other generic parameters F(outer); } diff --git a/src/test/ui/const-generics/issues/issue-72352.stderr b/src/test/ui/const-generics/issues/issue-72352.full.stderr similarity index 89% rename from src/test/ui/const-generics/issues/issue-72352.stderr rename to src/test/ui/const-generics/issues/issue-72352.full.stderr index bc48da103936..51f946784674 100644 --- a/src/test/ui/const-generics/issues/issue-72352.stderr +++ b/src/test/ui/const-generics/issues/issue-72352.full.stderr @@ -1,5 +1,5 @@ error: using function pointers as const generic parameters is forbidden - --> $DIR/issue-72352.rs:6:42 + --> $DIR/issue-72352.rs:8:42 | LL | unsafe fn unsafely_do_the_thing usize>(ptr: *const i8) -> usize { | ^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/const-generics/issues/issue-72352.min.stderr b/src/test/ui/const-generics/issues/issue-72352.min.stderr new file mode 100644 index 000000000000..51f946784674 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-72352.min.stderr @@ -0,0 +1,8 @@ +error: using function pointers as const generic parameters is forbidden + --> $DIR/issue-72352.rs:8:42 + | +LL | unsafe fn unsafely_do_the_thing usize>(ptr: *const i8) -> usize { + | ^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/const-generics/issues/issue-72352.rs b/src/test/ui/const-generics/issues/issue-72352.rs index e977af8deb71..b723b9dd7157 100644 --- a/src/test/ui/const-generics/issues/issue-72352.rs +++ b/src/test/ui/const-generics/issues/issue-72352.rs @@ -1,10 +1,13 @@ -#![feature(const_generics)] -#![allow(incomplete_features)] +// revisions: full min +#![cfg_attr(full, feature(const_generics))] +#![cfg_attr(full, allow(incomplete_features))] +#![cfg_attr(min, feature(min_const_generics))] use std::ffi::{CStr, CString}; unsafe fn unsafely_do_the_thing usize>(ptr: *const i8) -> usize { - //~^ ERROR: using function pointers as const generic parameters is forbidden + //[full]~^ ERROR: using function pointers as const generic parameters is forbidden + //[min]~^^ ERROR: using function pointers as const generic parameters is forbidden F(CStr::from_ptr(ptr)) } diff --git a/src/test/ui/const-generics/issues/issue-73491.min.stderr b/src/test/ui/const-generics/issues/issue-73491.min.stderr new file mode 100644 index 000000000000..5bf3671d38be --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-73491.min.stderr @@ -0,0 +1,11 @@ +error: `[u32; _]` is forbidden as the type of a const generic parameter + --> $DIR/issue-73491.rs:9:19 + | +LL | fn hoge() {} + | ^^^^^^^^^^ + | + = 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/issues/issue-73491.rs b/src/test/ui/const-generics/issues/issue-73491.rs index 05e1513bb75d..4f6c44ad2cdb 100644 --- a/src/test/ui/const-generics/issues/issue-73491.rs +++ b/src/test/ui/const-generics/issues/issue-73491.rs @@ -1,9 +1,12 @@ -// check-pass -#![feature(const_generics)] -#![allow(incomplete_features)] +// [full] check-pass +// revisions: full min +#![cfg_attr(full, feature(const_generics))] +#![cfg_attr(full, allow(incomplete_features))] +#![cfg_attr(min, feature(min_const_generics))] const LEN: usize = 1024; fn hoge() {} +//[min]~^ ERROR `[u32; _]` is forbidden as the type of a const generic parameter fn main() {} diff --git a/src/test/ui/const-generics/issues/issue-73508.full.stderr b/src/test/ui/const-generics/issues/issue-73508.full.stderr new file mode 100644 index 000000000000..0816bad35b2d --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-73508.full.stderr @@ -0,0 +1,8 @@ +error: using raw pointers as const generic parameters is forbidden + --> $DIR/issue-73508.rs:6:33 + | +LL | pub const fn func_name() {} + | ^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/const-generics/issues/issue-73508.min.stderr b/src/test/ui/const-generics/issues/issue-73508.min.stderr new file mode 100644 index 000000000000..0816bad35b2d --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-73508.min.stderr @@ -0,0 +1,8 @@ +error: using raw pointers as const generic parameters is forbidden + --> $DIR/issue-73508.rs:6:33 + | +LL | pub const fn func_name() {} + | ^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/const-generics/issues/issue-73508.rs b/src/test/ui/const-generics/issues/issue-73508.rs index ba2e2a38e747..1032f9389bc0 100644 --- a/src/test/ui/const-generics/issues/issue-73508.rs +++ b/src/test/ui/const-generics/issues/issue-73508.rs @@ -1,6 +1,10 @@ -#![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))] pub const fn func_name() {} -//~^ ERROR using raw pointers +//[full]~^ ERROR using raw pointers +//[min]~^^ ERROR using raw pointers as const generic parameters is forbidden fn main() {} diff --git a/src/test/ui/const-generics/issues/issue-73508.stderr b/src/test/ui/const-generics/issues/issue-73508.stderr deleted file mode 100644 index 23ad1818b6f3..000000000000 --- a/src/test/ui/const-generics/issues/issue-73508.stderr +++ /dev/null @@ -1,17 +0,0 @@ -warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/issue-73508.rs:1:12 - | -LL | #![feature(const_generics)] - | ^^^^^^^^^^^^^^ - | - = note: `#[warn(incomplete_features)]` on by default - = note: see issue #44580 for more information - -error: using raw pointers as const generic parameters is forbidden - --> $DIR/issue-73508.rs:3:33 - | -LL | pub const fn func_name() {} - | ^^^^^^^^^^ - -error: aborting due to previous error; 1 warning emitted - diff --git a/src/test/ui/const-generics/issues/issue-74101.min.stderr b/src/test/ui/const-generics/issues/issue-74101.min.stderr new file mode 100644 index 000000000000..8062faefbe60 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-74101.min.stderr @@ -0,0 +1,20 @@ +error: `[u8; _]` is forbidden as the type of a const generic parameter + --> $DIR/issue-74101.rs:7:18 + | +LL | fn test() {} + | ^^^^^^^^^^^ + | + = note: the only supported types are integers, `bool` and `char` + = note: more complex types are supported with `#[feature(const_generics)]` + +error: `[u8; _]` is forbidden as the type of a const generic parameter + --> $DIR/issue-74101.rs:10:21 + | +LL | struct Foo; + | ^^^^^^^^^^^ + | + = 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/issues/issue-74101.rs b/src/test/ui/const-generics/issues/issue-74101.rs index 2f427ef3a27d..2a7d31ac8dd6 100644 --- a/src/test/ui/const-generics/issues/issue-74101.rs +++ b/src/test/ui/const-generics/issues/issue-74101.rs @@ -1,9 +1,13 @@ -// check-pass -#![feature(const_generics)] -#![allow(incomplete_features)] +// [full] check-pass +// revisions: full min +#![cfg_attr(full, feature(const_generics))] +#![cfg_attr(full, allow(incomplete_features))] +#![cfg_attr(min, feature(min_const_generics))] fn test() {} +//[min]~^ ERROR `[u8; _]` is forbidden as the type of a const generic parameter struct Foo; +//[min]~^ ERROR `[u8; _]` is forbidden as the type of a const generic parameter fn main() {} diff --git a/src/test/ui/const-generics/issues/issue-74255.min.stderr b/src/test/ui/const-generics/issues/issue-74255.min.stderr new file mode 100644 index 000000000000..86937d715c97 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-74255.min.stderr @@ -0,0 +1,11 @@ +error: `IceEnum` is forbidden as the type of a const generic parameter + --> $DIR/issue-74255.rs:15:31 + | +LL | fn ice_struct_fn() {} + | ^^^^^^^ + | + = 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/issues/issue-74255.rs b/src/test/ui/const-generics/issues/issue-74255.rs index 55ccf57dc99c..b277c273461c 100644 --- a/src/test/ui/const-generics/issues/issue-74255.rs +++ b/src/test/ui/const-generics/issues/issue-74255.rs @@ -1,6 +1,8 @@ -// check-pass -#![feature(const_generics)] -#![allow(dead_code, incomplete_features)] +// [full] check-pass +// revisions: full min +#![cfg_attr(full, feature(const_generics))] +#![cfg_attr(full, allow(incomplete_features))] +#![cfg_attr(min, feature(min_const_generics))] #[derive(PartialEq, Eq)] enum IceEnum { @@ -11,6 +13,7 @@ struct IceStruct; impl IceStruct { fn ice_struct_fn() {} + //[min]~^ ERROR `IceEnum` is forbidden as the type of a const generic parameter } fn main() { diff --git a/src/test/ui/const-generics/issues/issue-75047.min.stderr b/src/test/ui/const-generics/issues/issue-75047.min.stderr new file mode 100644 index 000000000000..edc54b082dbc --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-75047.min.stderr @@ -0,0 +1,11 @@ +error: `[u8; _]` is forbidden as the type of a const generic parameter + --> $DIR/issue-75047.rs:15:21 + | +LL | struct Foo::value()]>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = 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/issues/issue-75047.rs b/src/test/ui/const-generics/issues/issue-75047.rs index 5d068d851c10..7bab7cdd0989 100644 --- a/src/test/ui/const-generics/issues/issue-75047.rs +++ b/src/test/ui/const-generics/issues/issue-75047.rs @@ -1,6 +1,8 @@ -// check-pass -#![feature(const_generics)] -#![allow(incomplete_features)] +// [full] check-pass +// revisions: full min +#![cfg_attr(full, feature(const_generics))] +#![cfg_attr(full, allow(incomplete_features))] +#![cfg_attr(min, feature(min_const_generics))] struct Bar(T); @@ -11,5 +13,6 @@ impl Bar { } struct Foo::value()]>; +//[min]~^ ERROR `[u8; _]` is forbidden as the type of a const generic parameter fn main() {} diff --git a/src/test/ui/const-generics/issues/issue70273-assoc-fn.rs b/src/test/ui/const-generics/issues/issue70273-assoc-fn.rs index c22e61d0ce33..28f80702dcf0 100644 --- a/src/test/ui/const-generics/issues/issue70273-assoc-fn.rs +++ b/src/test/ui/const-generics/issues/issue70273-assoc-fn.rs @@ -1,7 +1,8 @@ // check-pass - -#![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))] trait T { fn f(); diff --git a/src/test/ui/const-generics/issues/issue70273-assoc-fn.stderr b/src/test/ui/const-generics/issues/issue70273-assoc-fn.stderr deleted file mode 100644 index 931701b64b48..000000000000 --- a/src/test/ui/const-generics/issues/issue70273-assoc-fn.stderr +++ /dev/null @@ -1,11 +0,0 @@ -warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/issue70273-assoc-fn.rs:3:12 - | -LL | #![feature(const_generics)] - | ^^^^^^^^^^^^^^ - | - = note: `#[warn(incomplete_features)]` on by default - = note: see issue #44580 for more information - -warning: 1 warning emitted - diff --git a/src/test/ui/const-generics/std/const-generics-range.min.stderr b/src/test/ui/const-generics/std/const-generics-range.min.stderr new file mode 100644 index 000000000000..a71e74420215 --- /dev/null +++ b/src/test/ui/const-generics/std/const-generics-range.min.stderr @@ -0,0 +1,56 @@ +error: `std::ops::Range` is forbidden as the type of a const generic parameter + --> $DIR/const-generics-range.rs:8:24 + | +LL | struct _Range>; + | ^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the only supported types are integers, `bool` and `char` + = note: more complex types are supported with `#[feature(const_generics)]` + +error: `std::ops::RangeFrom` is forbidden as the type of a const generic parameter + --> $DIR/const-generics-range.rs:13:28 + | +LL | struct _RangeFrom>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the only supported types are integers, `bool` and `char` + = note: more complex types are supported with `#[feature(const_generics)]` + +error: `std::ops::RangeFull` is forbidden as the type of a const generic parameter + --> $DIR/const-generics-range.rs:18:28 + | +LL | struct _RangeFull; + | ^^^^^^^^^^^^^^^^^^^ + | + = note: the only supported types are integers, `bool` and `char` + = note: more complex types are supported with `#[feature(const_generics)]` + +error: `std::ops::RangeInclusive` is forbidden as the type of a const generic parameter + --> $DIR/const-generics-range.rs:24:33 + | +LL | struct _RangeInclusive>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the only supported types are integers, `bool` and `char` + = note: more complex types are supported with `#[feature(const_generics)]` + +error: `std::ops::RangeTo` is forbidden as the type of a const generic parameter + --> $DIR/const-generics-range.rs:29:26 + | +LL | struct _RangeTo>; + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the only supported types are integers, `bool` and `char` + = note: more complex types are supported with `#[feature(const_generics)]` + +error: `std::ops::RangeToInclusive` is forbidden as the type of a const generic parameter + --> $DIR/const-generics-range.rs:34:35 + | +LL | struct _RangeToInclusive>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the only supported types are integers, `bool` and `char` + = note: more complex types are supported with `#[feature(const_generics)]` + +error: aborting due to 6 previous errors + diff --git a/src/test/ui/const-generics/std/const-generics-range.rs b/src/test/ui/const-generics/std/const-generics-range.rs index 6d56fe0d7b8e..51562e61aaa3 100644 --- a/src/test/ui/const-generics/std/const-generics-range.rs +++ b/src/test/ui/const-generics/std/const-generics-range.rs @@ -1,30 +1,38 @@ -// check-pass -#![allow(incomplete_features)] -#![feature(const_generics)] +// [full] check-pass +// revisions: full min +#![cfg_attr(full, feature(const_generics))] +#![cfg_attr(full, allow(incomplete_features))] +#![cfg_attr(min, feature(min_const_generics))] // `Range` should be usable within const generics: struct _Range>; +//[min]~^ ERROR `std::ops::Range` is forbidden as the type of a const generic parameter const RANGE : _Range<{ 0 .. 1000 }> = _Range; // `RangeFrom` should be usable within const generics: struct _RangeFrom>; +//[min]~^ ERROR `std::ops::RangeFrom` is forbidden as the type of a const generic parameter const RANGE_FROM : _RangeFrom<{ 0 .. }> = _RangeFrom; // `RangeFull` should be usable within const generics: struct _RangeFull; +//[min]~^ ERROR `std::ops::RangeFull` is forbidden as the type of a const generic parameter const RANGE_FULL : _RangeFull<{ .. }> = _RangeFull; // Regression test for #70155 // `RangeInclusive` should be usable within const generics: struct _RangeInclusive>; +//[min]~^ ERROR `std::ops::RangeInclusive` is forbidden as the type of a const generic parameter const RANGE_INCLUSIVE : _RangeInclusive<{ 0 ..= 999 }> = _RangeInclusive; // `RangeTo` should be usable within const generics: struct _RangeTo>; +//[min]~^ ERROR `std::ops::RangeTo` is forbidden as the type of a const generic parameter const RANGE_TO : _RangeTo<{ .. 1000 }> = _RangeTo; // `RangeToInclusive` should be usable within const generics: struct _RangeToInclusive>; +//[min]~^ ERROR `std::ops::RangeToInclusive` is forbidden as the type of a const generic parameter const RANGE_TO_INCLUSIVE : _RangeToInclusive<{ ..= 999 }> = _RangeToInclusive; pub fn main() {} diff --git a/src/test/ui/const-generics/type-after-const-ok.min.stderr b/src/test/ui/const-generics/type-after-const-ok.min.stderr new file mode 100644 index 000000000000..67a44d2c5b4a --- /dev/null +++ b/src/test/ui/const-generics/type-after-const-ok.min.stderr @@ -0,0 +1,8 @@ +error: type parameters must be declared prior to const parameters + --> $DIR/type-after-const-ok.rs:9:26 + | +LL | struct A(T); + | -----------------^- help: reorder the parameters: lifetimes, then types, then consts: `` + +error: aborting due to previous error + diff --git a/src/test/ui/const-generics/type-after-const-ok.rs b/src/test/ui/const-generics/type-after-const-ok.rs index fc977d6617c5..69227cdf19c3 100644 --- a/src/test/ui/const-generics/type-after-const-ok.rs +++ b/src/test/ui/const-generics/type-after-const-ok.rs @@ -1,10 +1,12 @@ -// run-pass +// [full] run-pass +// revisions: full min // Verifies that having generic parameters after constants is permitted - -#![feature(const_generics)] -#![allow(incomplete_features)] +#![cfg_attr(full, feature(const_generics))] +#![cfg_attr(full, allow(incomplete_features))] +#![cfg_attr(min, feature(min_const_generics))] #[allow(dead_code)] struct A(T); +//[min]~^ ERROR type parameters must be declared prior to const parameters fn main() {} diff --git a/src/test/ui/const-generics/type-dependent/issue-61936.rs b/src/test/ui/const-generics/type-dependent/issue-61936.rs index a7a923c6a59b..1d42afa3f846 100644 --- a/src/test/ui/const-generics/type-dependent/issue-61936.rs +++ b/src/test/ui/const-generics/type-dependent/issue-61936.rs @@ -1,6 +1,8 @@ // run-pass -#![feature(const_generics)] -#![allow(incomplete_features)] +// revisions: full min +#![cfg_attr(full, feature(const_generics))] +#![cfg_attr(full, allow(incomplete_features))] +#![cfg_attr(min, feature(min_const_generics))] trait SliceExt { fn array_windows<'a, const N: usize>(&'a self) -> ArrayWindows<'a, T, N>; diff --git a/src/test/ui/const-generics/type-dependent/issue-63695.rs b/src/test/ui/const-generics/type-dependent/issue-63695.rs index f3c2e1775940..465b66b09ce2 100644 --- a/src/test/ui/const-generics/type-dependent/issue-63695.rs +++ b/src/test/ui/const-generics/type-dependent/issue-63695.rs @@ -1,6 +1,8 @@ // run-pass -#![feature(const_generics)] -#![allow(incomplete_features)] +// revisions: full min +#![cfg_attr(full, feature(const_generics))] +#![cfg_attr(full, allow(incomplete_features))] +#![cfg_attr(min, feature(min_const_generics))] trait T { fn test(&self) -> i32 { A } diff --git a/src/test/ui/const-generics/type-dependent/issue-67144-1.rs b/src/test/ui/const-generics/type-dependent/issue-67144-1.rs index a3d059591987..3d4910e9e4b4 100644 --- a/src/test/ui/const-generics/type-dependent/issue-67144-1.rs +++ b/src/test/ui/const-generics/type-dependent/issue-67144-1.rs @@ -1,6 +1,8 @@ // check-pass -#![feature(const_generics)] -#![allow(incomplete_features)] +// revisions: full min +#![cfg_attr(full, feature(const_generics))] +#![cfg_attr(full, allow(incomplete_features))] +#![cfg_attr(min, feature(min_const_generics))] struct X; diff --git a/src/test/ui/const-generics/type-dependent/issue-67144-2.rs b/src/test/ui/const-generics/type-dependent/issue-67144-2.rs index c53a149fa8d4..0868d309b337 100644 --- a/src/test/ui/const-generics/type-dependent/issue-67144-2.rs +++ b/src/test/ui/const-generics/type-dependent/issue-67144-2.rs @@ -1,6 +1,8 @@ // check-pass -#![feature(const_generics)] -#![allow(incomplete_features)] +// revisions: full min +#![cfg_attr(full, feature(const_generics))] +#![cfg_attr(full, allow(incomplete_features))] +#![cfg_attr(min, feature(min_const_generics))] struct A; diff --git a/src/test/ui/const-generics/type-dependent/issue-69816.rs b/src/test/ui/const-generics/type-dependent/issue-69816.rs index cbe86cef3230..4a374dc1db60 100644 --- a/src/test/ui/const-generics/type-dependent/issue-69816.rs +++ b/src/test/ui/const-generics/type-dependent/issue-69816.rs @@ -1,6 +1,8 @@ // run-pass -#![feature(const_generics)] -#![allow(incomplete_features)] +// revisions: full min +#![cfg_attr(full, feature(const_generics))] +#![cfg_attr(full, allow(incomplete_features))] +#![cfg_attr(min, feature(min_const_generics))] trait IterExt: Sized + Iterator { fn default_for_size(self) -> [Self::Item; N] diff --git a/src/test/ui/const-generics/type-dependent/issue-70217.rs b/src/test/ui/const-generics/type-dependent/issue-70217.rs index caa611cbd797..ba5a42e47e92 100644 --- a/src/test/ui/const-generics/type-dependent/issue-70217.rs +++ b/src/test/ui/const-generics/type-dependent/issue-70217.rs @@ -1,6 +1,9 @@ // check-pass -#![feature(const_generics)] -#![allow(incomplete_features)] +// revisions: full min + +#![cfg_attr(full, feature(const_generics))] +#![cfg_attr(full, allow(incomplete_features))] +#![cfg_attr(min, feature(min_const_generics))] struct Struct; diff --git a/src/test/ui/const-generics/type-dependent/issue-70507.rs b/src/test/ui/const-generics/type-dependent/issue-70507.rs index 6fcf4116d437..234c09e04ae6 100644 --- a/src/test/ui/const-generics/type-dependent/issue-70507.rs +++ b/src/test/ui/const-generics/type-dependent/issue-70507.rs @@ -1,6 +1,8 @@ // run-pass -#![feature(const_generics)] -#![allow(incomplete_features)] +// revisions: full min +#![cfg_attr(full, feature(const_generics))] +#![cfg_attr(full, allow(incomplete_features))] +#![cfg_attr(min, feature(min_const_generics))] trait ConstChunksExactTrait { fn const_chunks_exact(&self) -> ConstChunksExact<'_, T, {N}>; diff --git a/src/test/ui/const-generics/type-dependent/issue-70586.rs b/src/test/ui/const-generics/type-dependent/issue-70586.rs index 5a0888506eb1..fd52373cee21 100644 --- a/src/test/ui/const-generics/type-dependent/issue-70586.rs +++ b/src/test/ui/const-generics/type-dependent/issue-70586.rs @@ -1,6 +1,8 @@ // check-pass -#![feature(const_generics)] -#![allow(incomplete_features)] +// revisions: full min +#![cfg_attr(full, feature(const_generics))] +#![cfg_attr(full, allow(incomplete_features))] +#![cfg_attr(min, feature(min_const_generics))] use std::marker::PhantomData; diff --git a/src/test/ui/const-generics/type-dependent/issue-71348.min.stderr b/src/test/ui/const-generics/type-dependent/issue-71348.min.stderr new file mode 100644 index 000000000000..8656239605df --- /dev/null +++ b/src/test/ui/const-generics/type-dependent/issue-71348.min.stderr @@ -0,0 +1,20 @@ +error: `&'static str` is forbidden as the type of a const generic parameter + --> $DIR/issue-71348.rs:11:24 + | +LL | trait Get<'a, const N: &'static str> { + | ^^^^^^^^^^^^ + | + = note: the only supported types are integers, `bool` and `char` + = note: more complex types are supported with `#[feature(const_generics)]` + +error: `&'static str` is forbidden as the type of a const generic parameter + --> $DIR/issue-71348.rs:19:25 + | +LL | fn ask<'a, const N: &'static str>(&'a self) -> &'a >::Target + | ^^^^^^^^^^^^ + | + = 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/type-dependent/issue-71348.rs b/src/test/ui/const-generics/type-dependent/issue-71348.rs index ec22dcdf60b4..772e179746dd 100644 --- a/src/test/ui/const-generics/type-dependent/issue-71348.rs +++ b/src/test/ui/const-generics/type-dependent/issue-71348.rs @@ -1,12 +1,15 @@ -// run-pass -#![feature(const_generics)] -#![allow(incomplete_features)] +// [full] run-pass +// revisions: full min +#![cfg_attr(full, feature(const_generics))] +#![cfg_attr(full, allow(incomplete_features))] +#![cfg_attr(min, feature(min_const_generics))] struct Foo { i: i32, } trait Get<'a, const N: &'static str> { + //[min]~^ ERROR `&'static str` is forbidden as the type of a const generic parameter type Target: 'a; fn get(&'a self) -> &'a Self::Target; @@ -14,6 +17,7 @@ trait Get<'a, const N: &'static str> { impl Foo { fn ask<'a, const N: &'static str>(&'a self) -> &'a >::Target + //[min]~^ ERROR `&'static str` is forbidden as the type of a const generic parameter where Self: Get<'a, N>, { diff --git a/src/test/ui/const-generics/type-dependent/issue-71382.full.stderr b/src/test/ui/const-generics/type-dependent/issue-71382.full.stderr new file mode 100644 index 000000000000..da1d3270b7cc --- /dev/null +++ b/src/test/ui/const-generics/type-dependent/issue-71382.full.stderr @@ -0,0 +1,8 @@ +error: using function pointers as const generic parameters is forbidden + --> $DIR/issue-71382.rs:17:23 + | +LL | fn test u8>(&self) -> u8 { + | ^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/const-generics/type-dependent/issue-71382.min.stderr b/src/test/ui/const-generics/type-dependent/issue-71382.min.stderr new file mode 100644 index 000000000000..da1d3270b7cc --- /dev/null +++ b/src/test/ui/const-generics/type-dependent/issue-71382.min.stderr @@ -0,0 +1,8 @@ +error: using function pointers as const generic parameters is forbidden + --> $DIR/issue-71382.rs:17:23 + | +LL | fn test u8>(&self) -> u8 { + | ^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/const-generics/type-dependent/issue-71382.rs b/src/test/ui/const-generics/type-dependent/issue-71382.rs index 05abd488816f..eb453cd12aaa 100644 --- a/src/test/ui/const-generics/type-dependent/issue-71382.rs +++ b/src/test/ui/const-generics/type-dependent/issue-71382.rs @@ -1,5 +1,7 @@ -#![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 Test; @@ -13,7 +15,8 @@ impl Test { } fn test u8>(&self) -> u8 { - //~^ ERROR using function pointers as const generic parameters is forbidden + //[full]~^ ERROR using function pointers as const generic parameters is forbidden + //[min]~^^ ERROR using function pointers as const generic parameters is forbidden FN() } } diff --git a/src/test/ui/const-generics/type-dependent/issue-71382.stderr b/src/test/ui/const-generics/type-dependent/issue-71382.stderr deleted file mode 100644 index f441b71031ec..000000000000 --- a/src/test/ui/const-generics/type-dependent/issue-71382.stderr +++ /dev/null @@ -1,17 +0,0 @@ -warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/issue-71382.rs:1:12 - | -LL | #![feature(const_generics)] - | ^^^^^^^^^^^^^^ - | - = note: `#[warn(incomplete_features)]` on by default - = note: see issue #44580 for more information - -error: using function pointers as const generic parameters is forbidden - --> $DIR/issue-71382.rs:15:23 - | -LL | fn test u8>(&self) -> u8 { - | ^^^^^^^^^^ - -error: aborting due to previous error; 1 warning emitted - diff --git a/src/test/ui/const-generics/type-dependent/issue-71805.rs b/src/test/ui/const-generics/type-dependent/issue-71805.rs index 6823d780aefa..2aaf12cea4f8 100644 --- a/src/test/ui/const-generics/type-dependent/issue-71805.rs +++ b/src/test/ui/const-generics/type-dependent/issue-71805.rs @@ -1,6 +1,8 @@ // run-pass -#![feature(const_generics)] -#![allow(incomplete_features)] +// revisions: full min +#![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-dependent/issue-73730.rs b/src/test/ui/const-generics/type-dependent/issue-73730.rs index d90cc50ddc44..3e53190ee486 100644 --- a/src/test/ui/const-generics/type-dependent/issue-73730.rs +++ b/src/test/ui/const-generics/type-dependent/issue-73730.rs @@ -1,6 +1,8 @@ // check-pass -#![feature(const_generics)] -#![allow(incomplete_features)] +// revisions: full min +#![cfg_attr(full, feature(const_generics))] +#![cfg_attr(full, allow(incomplete_features))] +#![cfg_attr(min, feature(min_const_generics))] trait Foo<'a, A>: Iterator { fn bar(&mut self) -> *const [A; N]; diff --git a/src/test/ui/const-generics/type-dependent/non-local.rs b/src/test/ui/const-generics/type-dependent/non-local.rs index e6f3eb075f1d..747664a09629 100644 --- a/src/test/ui/const-generics/type-dependent/non-local.rs +++ b/src/test/ui/const-generics/type-dependent/non-local.rs @@ -1,7 +1,9 @@ // aux-build:type_dependent_lib.rs // run-pass -#![feature(const_generics)] -#![allow(incomplete_features)] +// revisions: full min +#![cfg_attr(full, feature(const_generics))] +#![cfg_attr(full, allow(incomplete_features))] +#![cfg_attr(min, feature(min_const_generics))] extern crate type_dependent_lib; diff --git a/src/test/ui/const-generics/type-dependent/qpath.rs b/src/test/ui/const-generics/type-dependent/qpath.rs index f3f98e5faf52..ec23ff1d2212 100644 --- a/src/test/ui/const-generics/type-dependent/qpath.rs +++ b/src/test/ui/const-generics/type-dependent/qpath.rs @@ -1,6 +1,8 @@ // run-pass -#![feature(const_generics)] -#![allow(incomplete_features)] +// revisions: full min +#![cfg_attr(full, feature(const_generics))] +#![cfg_attr(full, allow(incomplete_features))] +#![cfg_attr(min, feature(min_const_generics))] struct A; impl A { diff --git a/src/test/ui/const-generics/type-dependent/simple.rs b/src/test/ui/const-generics/type-dependent/simple.rs index cc7c50d8fd83..70af65509231 100644 --- a/src/test/ui/const-generics/type-dependent/simple.rs +++ b/src/test/ui/const-generics/type-dependent/simple.rs @@ -1,6 +1,8 @@ // run-pass -#![feature(const_generics)] -#![allow(incomplete_features)] +// revisions: full min +#![cfg_attr(full, feature(const_generics))] +#![cfg_attr(full, allow(incomplete_features))] +#![cfg_attr(min, feature(min_const_generics))] struct R; diff --git a/src/test/ui/const-generics/type-dependent/type-mismatch.full.stderr b/src/test/ui/const-generics/type-dependent/type-mismatch.full.stderr new file mode 100644 index 000000000000..a530e63449d4 --- /dev/null +++ b/src/test/ui/const-generics/type-dependent/type-mismatch.full.stderr @@ -0,0 +1,14 @@ +error[E0308]: mismatched types + --> $DIR/type-mismatch.rs:12:27 + | +LL | assert_eq!(R.method::<1u16>(), 1); + | ^^^^ expected `u8`, found `u16` + | +help: change the type of the numeric literal from `u16` to `u8` + | +LL | assert_eq!(R.method::<1u8>(), 1); + | ^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/const-generics/type-dependent/type-mismatch.min.stderr b/src/test/ui/const-generics/type-dependent/type-mismatch.min.stderr new file mode 100644 index 000000000000..a530e63449d4 --- /dev/null +++ b/src/test/ui/const-generics/type-dependent/type-mismatch.min.stderr @@ -0,0 +1,14 @@ +error[E0308]: mismatched types + --> $DIR/type-mismatch.rs:12:27 + | +LL | assert_eq!(R.method::<1u16>(), 1); + | ^^^^ expected `u8`, found `u16` + | +help: change the type of the numeric literal from `u16` to `u8` + | +LL | assert_eq!(R.method::<1u8>(), 1); + | ^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/const-generics/type-dependent/type-mismatch.rs b/src/test/ui/const-generics/type-dependent/type-mismatch.rs index 0c71f338bd26..4118cbf13d31 100644 --- a/src/test/ui/const-generics/type-dependent/type-mismatch.rs +++ b/src/test/ui/const-generics/type-dependent/type-mismatch.rs @@ -1,5 +1,7 @@ -#![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 R; @@ -8,5 +10,6 @@ impl R { } fn main() { assert_eq!(R.method::<1u16>(), 1); - //~^ ERROR mismatched types + //[full]~^ ERROR mismatched types + //[min]~^^ ERROR mismatched types } diff --git a/src/test/ui/const-generics/type-dependent/type-mismatch.stderr b/src/test/ui/const-generics/type-dependent/type-mismatch.stderr deleted file mode 100644 index 5bb7c5b0ea9b..000000000000 --- a/src/test/ui/const-generics/type-dependent/type-mismatch.stderr +++ /dev/null @@ -1,23 +0,0 @@ -warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/type-mismatch.rs:1:12 - | -LL | #![feature(const_generics)] - | ^^^^^^^^^^^^^^ - | - = note: `#[warn(incomplete_features)]` on by default - = note: see issue #44580 for more information - -error[E0308]: mismatched types - --> $DIR/type-mismatch.rs:10:27 - | -LL | assert_eq!(R.method::<1u16>(), 1); - | ^^^^ expected `u8`, found `u16` - | -help: change the type of the numeric literal from `u16` to `u8` - | -LL | assert_eq!(R.method::<1u8>(), 1); - | ^^^ - -error: aborting due to previous error; 1 warning emitted - -For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/const-generics/types-mismatch-const-args.stderr b/src/test/ui/const-generics/types-mismatch-const-args.full.stderr similarity index 64% rename from src/test/ui/const-generics/types-mismatch-const-args.stderr rename to src/test/ui/const-generics/types-mismatch-const-args.full.stderr index 49530c9d240b..175fa3004936 100644 --- a/src/test/ui/const-generics/types-mismatch-const-args.stderr +++ b/src/test/ui/const-generics/types-mismatch-const-args.full.stderr @@ -1,14 +1,5 @@ -warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/types-mismatch-const-args.rs:1:12 - | -LL | #![feature(const_generics)] - | ^^^^^^^^^^^^^^ - | - = note: `#[warn(incomplete_features)]` on by default - = note: see issue #44580 for more information - error[E0308]: mismatched types - --> $DIR/types-mismatch-const-args.rs:13:41 + --> $DIR/types-mismatch-const-args.rs:15:41 | LL | let _: A<'a, u32, {2u32}, {3u32}> = A::<'a, u32, {4u32}, {3u32}> { data: PhantomData }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `2_u32`, found `4_u32` @@ -17,7 +8,7 @@ LL | let _: A<'a, u32, {2u32}, {3u32}> = A::<'a, u32, {4u32}, {3u32}> { data found type `4_u32` error[E0308]: mismatched types - --> $DIR/types-mismatch-const-args.rs:15:41 + --> $DIR/types-mismatch-const-args.rs:18:41 | LL | let _: A<'a, u16, {2u32}, {3u32}> = A::<'b, u32, {2u32}, {3u32}> { data: PhantomData }; | -------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `u16`, found `u32` @@ -27,6 +18,6 @@ LL | let _: A<'a, u16, {2u32}, {3u32}> = A::<'b, u32, {2u32}, {3u32}> { data = note: expected struct `A<'a, u16, {2u32}, {3u32}>` found struct `A<'b, u32, {2u32}, {3u32}>` -error: aborting due to 2 previous errors; 1 warning emitted +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/const-generics/types-mismatch-const-args.min.stderr b/src/test/ui/const-generics/types-mismatch-const-args.min.stderr new file mode 100644 index 000000000000..fa2d1a2597fb --- /dev/null +++ b/src/test/ui/const-generics/types-mismatch-const-args.min.stderr @@ -0,0 +1,25 @@ +error[E0308]: mismatched types + --> $DIR/types-mismatch-const-args.rs:15:41 + | +LL | let _: A<'a, u32, {2u32}, {3u32}> = A::<'a, u32, {4u32}, {3u32}> { data: PhantomData }; + | -------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `2_u32`, found `4_u32` + | | + | expected due to this + | + = note: expected struct `A<'_, _, 2_u32, _>` + found struct `A<'_, _, 4_u32, _>` + +error[E0308]: mismatched types + --> $DIR/types-mismatch-const-args.rs:18:41 + | +LL | let _: A<'a, u16, {2u32}, {3u32}> = A::<'b, u32, {2u32}, {3u32}> { data: PhantomData }; + | -------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `u16`, found `u32` + | | + | expected due to this + | + = note: expected struct `A<'a, u16, _, _>` + found struct `A<'b, u32, _, _>` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/const-generics/types-mismatch-const-args.rs b/src/test/ui/const-generics/types-mismatch-const-args.rs index bf517c11262f..de2cf73392a1 100644 --- a/src/test/ui/const-generics/types-mismatch-const-args.rs +++ b/src/test/ui/const-generics/types-mismatch-const-args.rs @@ -1,5 +1,7 @@ -#![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))] // tests the diagnostic output of type mismatches for types that have const generics arguments. @@ -11,9 +13,11 @@ struct A<'a, T, const X: u32, const Y: u32> { fn a<'a, 'b>() { let _: A<'a, u32, {2u32}, {3u32}> = A::<'a, u32, {4u32}, {3u32}> { data: PhantomData }; - //~^ ERROR mismatched types + //[full]~^ ERROR mismatched types + //[min]~^^ ERROR mismatched types let _: A<'a, u16, {2u32}, {3u32}> = A::<'b, u32, {2u32}, {3u32}> { data: PhantomData }; - //~^ ERROR mismatched types + //[full]~^ ERROR mismatched types + //[min]~^^ ERROR mismatched types } pub fn main() {} diff --git a/src/test/ui/const-generics/uninferred-consts-during-codegen-1.rs b/src/test/ui/const-generics/uninferred-consts-during-codegen-1.rs index 7473718351e9..45afbdc9ab10 100644 --- a/src/test/ui/const-generics/uninferred-consts-during-codegen-1.rs +++ b/src/test/ui/const-generics/uninferred-consts-during-codegen-1.rs @@ -1,7 +1,8 @@ // run-pass - -#![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))] use std::fmt; diff --git a/src/test/ui/const-generics/uninferred-consts-during-codegen-1.stderr b/src/test/ui/const-generics/uninferred-consts-during-codegen-1.stderr deleted file mode 100644 index f41628d5d8ee..000000000000 --- a/src/test/ui/const-generics/uninferred-consts-during-codegen-1.stderr +++ /dev/null @@ -1,11 +0,0 @@ -warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/uninferred-consts-during-codegen-1.rs:3:12 - | -LL | #![feature(const_generics)] - | ^^^^^^^^^^^^^^ - | - = note: `#[warn(incomplete_features)]` on by default - = note: see issue #44580 for more information - -warning: 1 warning emitted - diff --git a/src/test/ui/const-generics/uninferred-consts-during-codegen-2.rs b/src/test/ui/const-generics/uninferred-consts-during-codegen-2.rs index 8b95a010473e..65ae05e11982 100644 --- a/src/test/ui/const-generics/uninferred-consts-during-codegen-2.rs +++ b/src/test/ui/const-generics/uninferred-consts-during-codegen-2.rs @@ -1,7 +1,8 @@ // run-pass - -#![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))] use std::fmt; diff --git a/src/test/ui/const-generics/uninferred-consts-during-codegen-2.stderr b/src/test/ui/const-generics/uninferred-consts-during-codegen-2.stderr deleted file mode 100644 index f1703bc3a2f8..000000000000 --- a/src/test/ui/const-generics/uninferred-consts-during-codegen-2.stderr +++ /dev/null @@ -1,11 +0,0 @@ -warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/uninferred-consts-during-codegen-2.rs:3:12 - | -LL | #![feature(const_generics)] - | ^^^^^^^^^^^^^^ - | - = note: `#[warn(incomplete_features)]` on by default - = note: see issue #44580 for more information - -warning: 1 warning emitted - From d89d2a972d3174504594ff2eba70423dacaddcfb Mon Sep 17 00:00:00 2001 From: Amjad Alsharafi Date: Wed, 26 Aug 2020 18:44:00 +0800 Subject: [PATCH 2/9] Added more min_const_generics revisions to tests --- .../issues/issue-63322-forbid-dyn.full.stderr | 9 ++++++ .../issues/issue-63322-forbid-dyn.min.stderr | 18 ++++++++++++ .../issues/issue-63322-forbid-dyn.rs | 10 +++++-- .../issues/issue-63322-forbid-dyn.stderr | 18 ------------ ...e-64494.stderr => issue-64494.full.stderr} | 4 +-- .../issues/issue-64494.min.stderr | 28 +++++++++++++++++++ .../ui/const-generics/issues/issue-64494.rs | 13 ++++++--- .../ui/const-generics/issues/issue-64519.rs | 7 +++-- .../issues/issue-66205.full.stderr | 10 +++++++ .../issues/issue-66205.min.stderr | 10 +++++++ .../ui/const-generics/issues/issue-66205.rs | 9 ++++-- .../const-generics/issues/issue-66205.stderr | 19 ------------- .../ui/const-generics/issues/issue-66906.rs | 7 +++-- .../const-generics/issues/issue-66906.stderr | 11 -------- .../ui/const-generics/issues/issue-67185-1.rs | 7 +++-- .../issues/issue-67185-1.stderr | 11 -------- .../ui/const-generics/issues/issue-68596.rs | 6 ++-- .../issues/issue-68615-adt.min.stderr | 11 ++++++++ .../const-generics/issues/issue-68615-adt.rs | 9 ++++-- .../issues/issue-68615-array.min.stderr | 11 ++++++++ .../issues/issue-68615-array.rs | 9 ++++-- .../issues/issue-68977.full.stderr | 10 +++++++ .../issues/issue-68977.min.stderr | 18 ++++++++++++ .../ui/const-generics/issues/issue-68977.rs | 10 +++++-- .../const-generics/issues/issue-68977.stderr | 19 ------------- .../ui/const-generics/issues/issue-70125-1.rs | 6 ++-- .../issues/issue-70125-1.stderr | 11 -------- .../ui/const-generics/issues/issue-70125-2.rs | 7 +++-- .../issues/issue-70125-2.stderr | 11 -------- .../ui/const-generics/issues/issue-70167.rs | 7 +++-- .../const-generics/issues/issue-70167.stderr | 11 -------- ...e-71169.stderr => issue-71169.full.stderr} | 4 +-- .../issues/issue-71169.min.stderr | 18 ++++++++++++ .../ui/const-generics/issues/issue-71169.rs | 12 +++++--- 34 files changed, 224 insertions(+), 157 deletions(-) create mode 100644 src/test/ui/const-generics/issues/issue-63322-forbid-dyn.full.stderr create mode 100644 src/test/ui/const-generics/issues/issue-63322-forbid-dyn.min.stderr delete mode 100644 src/test/ui/const-generics/issues/issue-63322-forbid-dyn.stderr rename src/test/ui/const-generics/issues/{issue-64494.stderr => issue-64494.full.stderr} (94%) create mode 100644 src/test/ui/const-generics/issues/issue-64494.min.stderr create mode 100644 src/test/ui/const-generics/issues/issue-66205.full.stderr create mode 100644 src/test/ui/const-generics/issues/issue-66205.min.stderr delete mode 100644 src/test/ui/const-generics/issues/issue-66205.stderr delete mode 100644 src/test/ui/const-generics/issues/issue-66906.stderr delete mode 100644 src/test/ui/const-generics/issues/issue-67185-1.stderr create mode 100644 src/test/ui/const-generics/issues/issue-68615-adt.min.stderr create mode 100644 src/test/ui/const-generics/issues/issue-68615-array.min.stderr create mode 100644 src/test/ui/const-generics/issues/issue-68977.full.stderr create mode 100644 src/test/ui/const-generics/issues/issue-68977.min.stderr delete mode 100644 src/test/ui/const-generics/issues/issue-68977.stderr delete mode 100644 src/test/ui/const-generics/issues/issue-70125-1.stderr delete mode 100644 src/test/ui/const-generics/issues/issue-70125-2.stderr delete mode 100644 src/test/ui/const-generics/issues/issue-70167.stderr rename src/test/ui/const-generics/issues/{issue-71169.stderr => issue-71169.full.stderr} (89%) create mode 100644 src/test/ui/const-generics/issues/issue-71169.min.stderr diff --git a/src/test/ui/const-generics/issues/issue-63322-forbid-dyn.full.stderr b/src/test/ui/const-generics/issues/issue-63322-forbid-dyn.full.stderr new file mode 100644 index 000000000000..a20c7264acfd --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-63322-forbid-dyn.full.stderr @@ -0,0 +1,9 @@ +error[E0741]: `&'static (dyn A + 'static)` must be annotated with `#[derive(PartialEq, Eq)]` to be used as the type of a const parameter + --> $DIR/issue-63322-forbid-dyn.rs:10:18 + | +LL | fn test() { + | ^^^^^^^^^^^^^^ `&'static (dyn A + 'static)` doesn't derive both `PartialEq` and `Eq` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0741`. diff --git a/src/test/ui/const-generics/issues/issue-63322-forbid-dyn.min.stderr b/src/test/ui/const-generics/issues/issue-63322-forbid-dyn.min.stderr new file mode 100644 index 000000000000..e6d9fb7a2468 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-63322-forbid-dyn.min.stderr @@ -0,0 +1,18 @@ +error: `&'static (dyn A + 'static)` is forbidden as the type of a const generic parameter + --> $DIR/issue-63322-forbid-dyn.rs:10:18 + | +LL | fn test() { + | ^^^^^^^^^^^^^^ + | + = note: the only supported types are integers, `bool` and `char` + = note: more complex types are supported with `#[feature(const_generics)]` + +error[E0741]: `&'static (dyn A + 'static)` must be annotated with `#[derive(PartialEq, Eq)]` to be used as the type of a const parameter + --> $DIR/issue-63322-forbid-dyn.rs:10:18 + | +LL | fn test() { + | ^^^^^^^^^^^^^^ `&'static (dyn A + 'static)` doesn't derive both `PartialEq` and `Eq` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0741`. diff --git a/src/test/ui/const-generics/issues/issue-63322-forbid-dyn.rs b/src/test/ui/const-generics/issues/issue-63322-forbid-dyn.rs index 2bcaa27b4d27..ae77b74bbd8b 100644 --- a/src/test/ui/const-generics/issues/issue-63322-forbid-dyn.rs +++ b/src/test/ui/const-generics/issues/issue-63322-forbid-dyn.rs @@ -1,12 +1,16 @@ -#![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))] trait A {} struct B; impl A for B {} fn test() { - //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` to be used + //[full]~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` to be used + //[min]~^^ ERROR `&'static (dyn A + 'static)` is forbidden as the type of a const generic parameter + //[min]~| ERROR must be annotated with `#[derive(PartialEq, Eq)]` to be used unimplemented!() } diff --git a/src/test/ui/const-generics/issues/issue-63322-forbid-dyn.stderr b/src/test/ui/const-generics/issues/issue-63322-forbid-dyn.stderr deleted file mode 100644 index 32054e43716c..000000000000 --- a/src/test/ui/const-generics/issues/issue-63322-forbid-dyn.stderr +++ /dev/null @@ -1,18 +0,0 @@ -warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/issue-63322-forbid-dyn.rs:1:12 - | -LL | #![feature(const_generics)] - | ^^^^^^^^^^^^^^ - | - = note: `#[warn(incomplete_features)]` on by default - = note: see issue #44580 for more information - -error[E0741]: `&'static (dyn A + 'static)` must be annotated with `#[derive(PartialEq, Eq)]` to be used as the type of a const parameter - --> $DIR/issue-63322-forbid-dyn.rs:8:18 - | -LL | fn test() { - | ^^^^^^^^^^^^^^ `&'static (dyn A + 'static)` doesn't derive both `PartialEq` and `Eq` - -error: aborting due to previous error; 1 warning emitted - -For more information about this error, try `rustc --explain E0741`. diff --git a/src/test/ui/const-generics/issues/issue-64494.stderr b/src/test/ui/const-generics/issues/issue-64494.full.stderr similarity index 94% rename from src/test/ui/const-generics/issues/issue-64494.stderr rename to src/test/ui/const-generics/issues/issue-64494.full.stderr index 30dca1696431..a97ec9308f81 100644 --- a/src/test/ui/const-generics/issues/issue-64494.stderr +++ b/src/test/ui/const-generics/issues/issue-64494.full.stderr @@ -1,5 +1,5 @@ error: constant expression depends on a generic parameter - --> $DIR/issue-64494.rs:14:53 + --> $DIR/issue-64494.rs:16:53 | LL | impl MyTrait for T where Is<{T::VAL == 5}>: True {} | ^^^^ @@ -7,7 +7,7 @@ LL | impl MyTrait for T where Is<{T::VAL == 5}>: True {} = note: this may fail depending on what value the parameter takes error: constant expression depends on a generic parameter - --> $DIR/issue-64494.rs:16:53 + --> $DIR/issue-64494.rs:19:53 | LL | impl MyTrait for T where Is<{T::VAL == 6}>: True {} | ^^^^ diff --git a/src/test/ui/const-generics/issues/issue-64494.min.stderr b/src/test/ui/const-generics/issues/issue-64494.min.stderr new file mode 100644 index 000000000000..69fe0974a791 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-64494.min.stderr @@ -0,0 +1,28 @@ +error: generic parameters must not be used inside of non trivial constant values + --> $DIR/issue-64494.rs:16:38 + | +LL | impl MyTrait for T where Is<{T::VAL == 5}>: True {} + | ^^^^^^ non-trivial anonymous constants must not depend on the parameter `T` + | + = help: it is currently only allowed to use either `T` or `{ T }` as generic constants + +error: generic parameters must not be used inside of non trivial constant values + --> $DIR/issue-64494.rs:19:38 + | +LL | impl MyTrait for T where Is<{T::VAL == 6}>: True {} + | ^^^^^^ non-trivial anonymous constants must not depend on the parameter `T` + | + = help: it is currently only allowed to use either `T` or `{ T }` as generic constants + +error[E0119]: conflicting implementations of trait `MyTrait`: + --> $DIR/issue-64494.rs:19:1 + | +LL | impl MyTrait for T where Is<{T::VAL == 5}>: True {} + | ------------------------------------ first implementation here +... +LL | impl MyTrait for T where Is<{T::VAL == 6}>: True {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/const-generics/issues/issue-64494.rs b/src/test/ui/const-generics/issues/issue-64494.rs index 4c755530b997..3b598a415223 100644 --- a/src/test/ui/const-generics/issues/issue-64494.rs +++ b/src/test/ui/const-generics/issues/issue-64494.rs @@ -1,5 +1,7 @@ -#![feature(const_generics)] -#![allow(incomplete_features)] +// revisions: full min +#![cfg_attr(full, feature(const_generics))] +#![cfg_attr(full, allow(incomplete_features))] +#![cfg_attr(min, feature(min_const_generics))] trait Foo { const VAL: usize; @@ -12,8 +14,11 @@ struct Is; impl True for Is<{true}> {} impl MyTrait for T where Is<{T::VAL == 5}>: True {} -//~^ 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 constant values impl MyTrait for T where Is<{T::VAL == 6}>: True {} -//~^ 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 constant values +//[min]~| ERROR conflicting implementations of trait `MyTrait` fn main() {} diff --git a/src/test/ui/const-generics/issues/issue-64519.rs b/src/test/ui/const-generics/issues/issue-64519.rs index e9391096b04d..1ca709d09755 100644 --- a/src/test/ui/const-generics/issues/issue-64519.rs +++ b/src/test/ui/const-generics/issues/issue-64519.rs @@ -1,7 +1,8 @@ // check-pass - -#![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 Foo { state: Option<[u8; D]>, diff --git a/src/test/ui/const-generics/issues/issue-66205.full.stderr b/src/test/ui/const-generics/issues/issue-66205.full.stderr new file mode 100644 index 000000000000..a1520912e4e2 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-66205.full.stderr @@ -0,0 +1,10 @@ +error: constant expression depends on a generic parameter + --> $DIR/issue-66205.rs:8:12 + | +LL | fact::<{ N - 1 }>(); + | ^^^^^^^^^ + | + = note: this may fail depending on what value the parameter takes + +error: aborting due to previous error + diff --git a/src/test/ui/const-generics/issues/issue-66205.min.stderr b/src/test/ui/const-generics/issues/issue-66205.min.stderr new file mode 100644 index 000000000000..86709c389b62 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-66205.min.stderr @@ -0,0 +1,10 @@ +error: generic parameters must not be used inside of non trivial constant values + --> $DIR/issue-66205.rs:8:14 + | +LL | fact::<{ 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 previous error + diff --git a/src/test/ui/const-generics/issues/issue-66205.rs b/src/test/ui/const-generics/issues/issue-66205.rs index 7cedf51ca040..e115eff356a7 100644 --- a/src/test/ui/const-generics/issues/issue-66205.rs +++ b/src/test/ui/const-generics/issues/issue-66205.rs @@ -1,10 +1,13 @@ +// revisions: full min +#![cfg_attr(full, feature(const_generics))] +#![cfg_attr(full, allow(incomplete_features))] +#![cfg_attr(min, feature(min_const_generics))] #![allow(dead_code, unconditional_recursion)] -#![feature(const_generics)] -//~^ WARN the feature `const_generics` is incomplete fn fact() { fact::<{ 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 constant values } fn main() {} diff --git a/src/test/ui/const-generics/issues/issue-66205.stderr b/src/test/ui/const-generics/issues/issue-66205.stderr deleted file mode 100644 index 1e9c0f2f3d9e..000000000000 --- a/src/test/ui/const-generics/issues/issue-66205.stderr +++ /dev/null @@ -1,19 +0,0 @@ -warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/issue-66205.rs:2:12 - | -LL | #![feature(const_generics)] - | ^^^^^^^^^^^^^^ - | - = note: `#[warn(incomplete_features)]` on by default - = note: see issue #44580 for more information - -error: constant expression depends on a generic parameter - --> $DIR/issue-66205.rs:6:12 - | -LL | fact::<{ N - 1 }>(); - | ^^^^^^^^^ - | - = note: this may fail depending on what value the parameter takes - -error: aborting due to previous error; 1 warning emitted - diff --git a/src/test/ui/const-generics/issues/issue-66906.rs b/src/test/ui/const-generics/issues/issue-66906.rs index 486c72d8a349..3e048593c9b2 100644 --- a/src/test/ui/const-generics/issues/issue-66906.rs +++ b/src/test/ui/const-generics/issues/issue-66906.rs @@ -1,7 +1,8 @@ // check-pass - -#![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))] pub struct Tuple; diff --git a/src/test/ui/const-generics/issues/issue-66906.stderr b/src/test/ui/const-generics/issues/issue-66906.stderr deleted file mode 100644 index 8e8b552f90eb..000000000000 --- a/src/test/ui/const-generics/issues/issue-66906.stderr +++ /dev/null @@ -1,11 +0,0 @@ -warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/issue-66906.rs:3:12 - | -LL | #![feature(const_generics)] - | ^^^^^^^^^^^^^^ - | - = note: `#[warn(incomplete_features)]` on by default - = note: see issue #44580 for more information - -warning: 1 warning emitted - diff --git a/src/test/ui/const-generics/issues/issue-67185-1.rs b/src/test/ui/const-generics/issues/issue-67185-1.rs index b08057851a1b..09d88ef89a30 100644 --- a/src/test/ui/const-generics/issues/issue-67185-1.rs +++ b/src/test/ui/const-generics/issues/issue-67185-1.rs @@ -1,7 +1,8 @@ // check-pass - -#![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))] trait Baz { type Quaks; diff --git a/src/test/ui/const-generics/issues/issue-67185-1.stderr b/src/test/ui/const-generics/issues/issue-67185-1.stderr deleted file mode 100644 index 9cc797d6d8a0..000000000000 --- a/src/test/ui/const-generics/issues/issue-67185-1.stderr +++ /dev/null @@ -1,11 +0,0 @@ -warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/issue-67185-1.rs:3:12 - | -LL | #![feature(const_generics)] - | ^^^^^^^^^^^^^^ - | - = note: `#[warn(incomplete_features)]` on by default - = note: see issue #44580 for more information - -warning: 1 warning emitted - diff --git a/src/test/ui/const-generics/issues/issue-68596.rs b/src/test/ui/const-generics/issues/issue-68596.rs index 1f96e7d3b410..3b27d4d68c5d 100644 --- a/src/test/ui/const-generics/issues/issue-68596.rs +++ b/src/test/ui/const-generics/issues/issue-68596.rs @@ -1,6 +1,8 @@ // check-pass -#![feature(const_generics)] -#![allow(incomplete_features)] +// revisions: full min +#![cfg_attr(full, feature(const_generics))] +#![cfg_attr(full, allow(incomplete_features))] +#![cfg_attr(min, feature(min_const_generics))] pub struct S(u8); diff --git a/src/test/ui/const-generics/issues/issue-68615-adt.min.stderr b/src/test/ui/const-generics/issues/issue-68615-adt.min.stderr new file mode 100644 index 000000000000..81c8f4392c73 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-68615-adt.min.stderr @@ -0,0 +1,11 @@ +error: `[usize; 0]` is forbidden as the type of a const generic parameter + --> $DIR/issue-68615-adt.rs:7:23 + | +LL | struct Const {} + | ^^^^^^^^^^ + | + = 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/issues/issue-68615-adt.rs b/src/test/ui/const-generics/issues/issue-68615-adt.rs index 140bb28ec5a4..d616f3ab95a8 100644 --- a/src/test/ui/const-generics/issues/issue-68615-adt.rs +++ b/src/test/ui/const-generics/issues/issue-68615-adt.rs @@ -1,8 +1,11 @@ -// check-pass -#![feature(const_generics)] -#![allow(incomplete_features)] +// [full] check-pass +// revisions: full min +#![cfg_attr(full, feature(const_generics))] +#![cfg_attr(full, allow(incomplete_features))] +#![cfg_attr(min, feature(min_const_generics))] struct Const {} +//[min]~^ ERROR `[usize; 0]` is forbidden as the type of a const generic parameter type MyConst = Const<{ [] }>; fn main() { diff --git a/src/test/ui/const-generics/issues/issue-68615-array.min.stderr b/src/test/ui/const-generics/issues/issue-68615-array.min.stderr new file mode 100644 index 000000000000..8f55a92fce9a --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-68615-array.min.stderr @@ -0,0 +1,11 @@ +error: `[usize; 0]` is forbidden as the type of a const generic parameter + --> $DIR/issue-68615-array.rs:7:21 + | +LL | struct Foo {} + | ^^^^^^^^^^ + | + = 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/issues/issue-68615-array.rs b/src/test/ui/const-generics/issues/issue-68615-array.rs index c384bc1e36d0..24c9a59a1855 100644 --- a/src/test/ui/const-generics/issues/issue-68615-array.rs +++ b/src/test/ui/const-generics/issues/issue-68615-array.rs @@ -1,8 +1,11 @@ -// check-pass -#![feature(const_generics)] -#![allow(incomplete_features)] +// [full] check-pass +// revisions: full min +#![cfg_attr(full, feature(const_generics))] +#![cfg_attr(full, allow(incomplete_features))] +#![cfg_attr(min, feature(min_const_generics))] struct Foo {} +//[min]~^ ERROR `[usize; 0]` is forbidden as the type of a const generic parameter type MyFoo = Foo<{ [] }>; diff --git a/src/test/ui/const-generics/issues/issue-68977.full.stderr b/src/test/ui/const-generics/issues/issue-68977.full.stderr new file mode 100644 index 000000000000..3690bac3eb34 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-68977.full.stderr @@ -0,0 +1,10 @@ +error: constant expression depends on a generic parameter + --> $DIR/issue-68977.rs:35:44 + | +LL | FxpStorageHelper: FxpStorage, + | ^^^^^^^^^^ + | + = note: this may fail depending on what value the parameter takes + +error: aborting due to previous error + diff --git a/src/test/ui/const-generics/issues/issue-68977.min.stderr b/src/test/ui/const-generics/issues/issue-68977.min.stderr new file mode 100644 index 000000000000..5b2137b244cb --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-68977.min.stderr @@ -0,0 +1,18 @@ +error: generic parameters must not be used inside of non trivial constant values + --> $DIR/issue-68977.rs:29:17 + | +LL | PhantomU8<{(INT_BITS + FRAC_BITS + 7) / 8}>; + | ^^^^^^^^ non-trivial anonymous constants must not depend on the parameter `INT_BITS` + | + = help: it is currently only allowed to use either `INT_BITS` or `{ INT_BITS }` as generic constants + +error: generic parameters must not be used inside of non trivial constant values + --> $DIR/issue-68977.rs:29:28 + | +LL | PhantomU8<{(INT_BITS + FRAC_BITS + 7) / 8}>; + | ^^^^^^^^^ non-trivial anonymous constants must not depend on the parameter `FRAC_BITS` + | + = help: it is currently only allowed to use either `FRAC_BITS` or `{ FRAC_BITS }` as generic constants + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/const-generics/issues/issue-68977.rs b/src/test/ui/const-generics/issues/issue-68977.rs index 346ea3c20424..02e634efec3e 100644 --- a/src/test/ui/const-generics/issues/issue-68977.rs +++ b/src/test/ui/const-generics/issues/issue-68977.rs @@ -1,5 +1,7 @@ -#![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 PhantomU8; @@ -25,11 +27,13 @@ fxp_storage_impls! { type FxpStorageHelper = PhantomU8<{(INT_BITS + FRAC_BITS + 7) / 8}>; + //[min]~^ ERROR generic parameters must not be used inside of non trivial constant values + //[min]~| ERROR generic parameters must not be used inside of non trivial constant values struct Fxp where FxpStorageHelper: FxpStorage, - //~^ ERROR constant expression depends on a generic parameter + //[full]~^ ERROR constant expression depends on a generic parameter { storage: as FxpStorage>::SInt, } diff --git a/src/test/ui/const-generics/issues/issue-68977.stderr b/src/test/ui/const-generics/issues/issue-68977.stderr deleted file mode 100644 index e1190d9026da..000000000000 --- a/src/test/ui/const-generics/issues/issue-68977.stderr +++ /dev/null @@ -1,19 +0,0 @@ -warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/issue-68977.rs:1:12 - | -LL | #![feature(const_generics)] - | ^^^^^^^^^^^^^^ - | - = note: `#[warn(incomplete_features)]` on by default - = note: see issue #44580 for more information - -error: constant expression depends on a generic parameter - --> $DIR/issue-68977.rs:31:44 - | -LL | FxpStorageHelper: FxpStorage, - | ^^^^^^^^^^ - | - = note: this may fail depending on what value the parameter takes - -error: aborting due to previous error; 1 warning emitted - diff --git a/src/test/ui/const-generics/issues/issue-70125-1.rs b/src/test/ui/const-generics/issues/issue-70125-1.rs index 08a8309d4319..04175089dc06 100644 --- a/src/test/ui/const-generics/issues/issue-70125-1.rs +++ b/src/test/ui/const-generics/issues/issue-70125-1.rs @@ -1,6 +1,8 @@ // run-pass -#![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))] const L: usize = 4; diff --git a/src/test/ui/const-generics/issues/issue-70125-1.stderr b/src/test/ui/const-generics/issues/issue-70125-1.stderr deleted file mode 100644 index 8ad4b25ae5bc..000000000000 --- a/src/test/ui/const-generics/issues/issue-70125-1.stderr +++ /dev/null @@ -1,11 +0,0 @@ -warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/issue-70125-1.rs:2:12 - | -LL | #![feature(const_generics)] - | ^^^^^^^^^^^^^^ - | - = note: `#[warn(incomplete_features)]` on by default - = note: see issue #44580 for more information - -warning: 1 warning emitted - diff --git a/src/test/ui/const-generics/issues/issue-70125-2.rs b/src/test/ui/const-generics/issues/issue-70125-2.rs index fb7d4886a7c1..ceefc2dcb32c 100644 --- a/src/test/ui/const-generics/issues/issue-70125-2.rs +++ b/src/test/ui/const-generics/issues/issue-70125-2.rs @@ -1,7 +1,8 @@ // run-pass - -#![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))] fn main() { <()>::foo(); diff --git a/src/test/ui/const-generics/issues/issue-70125-2.stderr b/src/test/ui/const-generics/issues/issue-70125-2.stderr deleted file mode 100644 index c1f9634810e4..000000000000 --- a/src/test/ui/const-generics/issues/issue-70125-2.stderr +++ /dev/null @@ -1,11 +0,0 @@ -warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/issue-70125-2.rs:3:12 - | -LL | #![feature(const_generics)] - | ^^^^^^^^^^^^^^ - | - = note: `#[warn(incomplete_features)]` on by default - = note: see issue #44580 for more information - -warning: 1 warning emitted - diff --git a/src/test/ui/const-generics/issues/issue-70167.rs b/src/test/ui/const-generics/issues/issue-70167.rs index b53cec80071f..04c76a4dcaff 100644 --- a/src/test/ui/const-generics/issues/issue-70167.rs +++ b/src/test/ui/const-generics/issues/issue-70167.rs @@ -1,7 +1,8 @@ // check-pass - -#![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))] pub trait Trait: From<>::Item> { type Item; diff --git a/src/test/ui/const-generics/issues/issue-70167.stderr b/src/test/ui/const-generics/issues/issue-70167.stderr deleted file mode 100644 index 5d647e933c4c..000000000000 --- a/src/test/ui/const-generics/issues/issue-70167.stderr +++ /dev/null @@ -1,11 +0,0 @@ -warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/issue-70167.rs:3:12 - | -LL | #![feature(const_generics)] - | ^^^^^^^^^^^^^^ - | - = note: `#[warn(incomplete_features)]` on by default - = note: see issue #44580 for more information - -warning: 1 warning emitted - diff --git a/src/test/ui/const-generics/issues/issue-71169.stderr b/src/test/ui/const-generics/issues/issue-71169.full.stderr similarity index 89% rename from src/test/ui/const-generics/issues/issue-71169.stderr rename to src/test/ui/const-generics/issues/issue-71169.full.stderr index 6d4cf4027c14..e9f312d934ab 100644 --- a/src/test/ui/const-generics/issues/issue-71169.stderr +++ b/src/test/ui/const-generics/issues/issue-71169.full.stderr @@ -1,11 +1,11 @@ error[E0770]: the type of const parameters must not depend on other generic parameters - --> $DIR/issue-71169.rs:4:43 + --> $DIR/issue-71169.rs:6:43 | LL | fn foo() {} | ^^^ the type must not depend on the parameter `LEN` error: constant expression depends on a generic parameter - --> $DIR/issue-71169.rs:8:14 + --> $DIR/issue-71169.rs:12:14 | LL | foo::<4, DATA>(); | ^^^^ diff --git a/src/test/ui/const-generics/issues/issue-71169.min.stderr b/src/test/ui/const-generics/issues/issue-71169.min.stderr new file mode 100644 index 000000000000..79d63443351f --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-71169.min.stderr @@ -0,0 +1,18 @@ +error[E0770]: the type of const parameters must not depend on other generic parameters + --> $DIR/issue-71169.rs:6:43 + | +LL | fn foo() {} + | ^^^ the type must not depend on the parameter `LEN` + +error: `[u8; _]` is forbidden as the type of a const generic parameter + --> $DIR/issue-71169.rs:6:38 + | +LL | fn foo() {} + | ^^^^^^^^^ + | + = 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 + +For more information about this error, try `rustc --explain E0770`. diff --git a/src/test/ui/const-generics/issues/issue-71169.rs b/src/test/ui/const-generics/issues/issue-71169.rs index 943a16cfcd6a..26cd9f0e31c5 100644 --- a/src/test/ui/const-generics/issues/issue-71169.rs +++ b/src/test/ui/const-generics/issues/issue-71169.rs @@ -1,10 +1,14 @@ -#![feature(const_generics)] -#![allow(incomplete_features)] +// revisions: full min +#![cfg_attr(full, feature(const_generics))] +#![cfg_attr(full, allow(incomplete_features))] +#![cfg_attr(min, feature(min_const_generics))] fn foo() {} -//~^ ERROR the type of const parameters must not +//[full]~^ ERROR the type of const parameters must not +//[min]~^^ ERROR the type of const parameters must not +//[min]~| ERROR `[u8; _]` is forbidden as the type of a const generic parameter fn main() { const DATA: [u8; 4] = *b"ABCD"; foo::<4, DATA>(); - //~^ ERROR constant expression depends on + //[full]~^ ERROR constant expression depends on } From 7a7a28d6bbfa6bbbbd3c4d65a11e9b33995cd63f Mon Sep 17 00:00:00 2001 From: Amjad Alsharafi Date: Wed, 26 Aug 2020 19:17:07 +0800 Subject: [PATCH 3/9] Fixed file formatting and made `tidy` happy --- src/test/ui/const-generics/issues/issue-63322-forbid-dyn.rs | 3 ++- .../ui/const-generics/std/const-generics-range.min.stderr | 4 ++-- src/test/ui/const-generics/std/const-generics-range.rs | 6 ++++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/test/ui/const-generics/issues/issue-63322-forbid-dyn.rs b/src/test/ui/const-generics/issues/issue-63322-forbid-dyn.rs index ae77b74bbd8b..356652d67aae 100644 --- a/src/test/ui/const-generics/issues/issue-63322-forbid-dyn.rs +++ b/src/test/ui/const-generics/issues/issue-63322-forbid-dyn.rs @@ -9,7 +9,8 @@ impl A for B {} fn test() { //[full]~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` to be used - //[min]~^^ ERROR `&'static (dyn A + 'static)` is forbidden as the type of a const generic parameter + //[min]~^^ ERROR `&'static (dyn A + 'static)` is forbidden as the type of + // a const generic parameter //[min]~| ERROR must be annotated with `#[derive(PartialEq, Eq)]` to be used unimplemented!() } diff --git a/src/test/ui/const-generics/std/const-generics-range.min.stderr b/src/test/ui/const-generics/std/const-generics-range.min.stderr index a71e74420215..00edcbc53ce4 100644 --- a/src/test/ui/const-generics/std/const-generics-range.min.stderr +++ b/src/test/ui/const-generics/std/const-generics-range.min.stderr @@ -35,7 +35,7 @@ LL | struct _RangeInclusive>; = note: more complex types are supported with `#[feature(const_generics)]` error: `std::ops::RangeTo` is forbidden as the type of a const generic parameter - --> $DIR/const-generics-range.rs:29:26 + --> $DIR/const-generics-range.rs:30:26 | LL | struct _RangeTo>; | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -44,7 +44,7 @@ LL | struct _RangeTo>; = note: more complex types are supported with `#[feature(const_generics)]` error: `std::ops::RangeToInclusive` is forbidden as the type of a const generic parameter - --> $DIR/const-generics-range.rs:34:35 + --> $DIR/const-generics-range.rs:35:35 | LL | struct _RangeToInclusive>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/const-generics/std/const-generics-range.rs b/src/test/ui/const-generics/std/const-generics-range.rs index 51562e61aaa3..209aa39775d7 100644 --- a/src/test/ui/const-generics/std/const-generics-range.rs +++ b/src/test/ui/const-generics/std/const-generics-range.rs @@ -22,7 +22,8 @@ const RANGE_FULL : _RangeFull<{ .. }> = _RangeFull; // Regression test for #70155 // `RangeInclusive` should be usable within const generics: struct _RangeInclusive>; -//[min]~^ ERROR `std::ops::RangeInclusive` is forbidden as the type of a const generic parameter +//[min]~^ ERROR `std::ops::RangeInclusive` is forbidden as the type of a const generic +// parameter const RANGE_INCLUSIVE : _RangeInclusive<{ 0 ..= 999 }> = _RangeInclusive; // `RangeTo` should be usable within const generics: @@ -32,7 +33,8 @@ const RANGE_TO : _RangeTo<{ .. 1000 }> = _RangeTo; // `RangeToInclusive` should be usable within const generics: struct _RangeToInclusive>; -//[min]~^ ERROR `std::ops::RangeToInclusive` is forbidden as the type of a const generic parameter +//[min]~^ ERROR `std::ops::RangeToInclusive` is forbidden as the type of a const generic +// parameter const RANGE_TO_INCLUSIVE : _RangeToInclusive<{ ..= 999 }> = _RangeToInclusive; pub fn main() {} From ccffea5b6b3372cefd4e15bc738a2669bc6f69a0 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 29 Aug 2020 12:10:16 +0200 Subject: [PATCH 4/9] Move lexer unit tests to rustc_lexer StringReader is an intornal abstraction which at the moment changes a lot, so these unit tests cause quite a bit of friction. Moving them to rustc_lexer and more ingerated-testing style should make them much less annoying, hopefully without decreasing their usefulness much. Note that coloncolon tests are removed (it's unclear what those are testing). \r\n tests are removed as well, as we normalize line endings even before lexing. --- Cargo.lock | 15 +- compiler/rustc_expand/src/lib.rs | 5 - .../rustc_expand/src/parse/lexer/tests.rs | 252 ------------------ compiler/rustc_lexer/src/tests.rs | 160 +++++++++-- 4 files changed, 154 insertions(+), 278 deletions(-) delete mode 100644 compiler/rustc_expand/src/parse/lexer/tests.rs diff --git a/Cargo.lock b/Cargo.lock index ffc1f0dec1d9..d54939694339 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -342,7 +342,7 @@ dependencies = [ name = "cargo-miri" version = "0.1.0" dependencies = [ - "cargo_metadata 0.11.1", + "cargo_metadata 0.9.1", "directories", "rustc-workspace-hack", "rustc_version", @@ -391,6 +391,18 @@ dependencies = [ "serde_json", ] +[[package]] +name = "cargo_metadata" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46e3374c604fb39d1a2f35ed5e4a4e30e60d01fab49446e08f1b3e9a90aef202" +dependencies = [ + "semver 0.9.0", + "serde", + "serde_derive", + "serde_json", +] + [[package]] name = "cargo_metadata" version = "0.11.1" @@ -1979,6 +1991,7 @@ dependencies = [ name = "miri" version = "0.1.0" dependencies = [ + "byteorder", "colored", "compiletest_rs", "env_logger 0.7.1", diff --git a/compiler/rustc_expand/src/lib.rs b/compiler/rustc_expand/src/lib.rs index 7f631cb71afa..5436b1ef737f 100644 --- a/compiler/rustc_expand/src/lib.rs +++ b/compiler/rustc_expand/src/lib.rs @@ -39,11 +39,6 @@ mod tests; mod parse { #[cfg(test)] mod tests; - #[cfg(test)] - mod lexer { - #[cfg(test)] - mod tests; - } } #[cfg(test)] mod tokenstream { diff --git a/compiler/rustc_expand/src/parse/lexer/tests.rs b/compiler/rustc_expand/src/parse/lexer/tests.rs deleted file mode 100644 index 871844442839..000000000000 --- a/compiler/rustc_expand/src/parse/lexer/tests.rs +++ /dev/null @@ -1,252 +0,0 @@ -use rustc_ast::ast::AttrStyle; -use rustc_ast::token::{self, CommentKind, Token, TokenKind}; -use rustc_data_structures::sync::Lrc; -use rustc_errors::{emitter::EmitterWriter, Handler}; -use rustc_parse::lexer::StringReader; -use rustc_session::parse::ParseSess; -use rustc_span::source_map::{FilePathMapping, SourceMap}; -use rustc_span::symbol::Symbol; -use rustc_span::with_default_session_globals; -use rustc_span::{BytePos, Span}; - -use std::io; -use std::path::PathBuf; - -fn mk_sess(sm: Lrc) -> ParseSess { - let emitter = EmitterWriter::new( - Box::new(io::sink()), - Some(sm.clone()), - false, - false, - false, - None, - false, - ); - ParseSess::with_span_handler(Handler::with_emitter(true, None, Box::new(emitter)), sm) -} - -// Creates a string reader for the given string. -fn setup<'a>(sm: &SourceMap, sess: &'a ParseSess, teststr: String) -> StringReader<'a> { - let sf = sm.new_source_file(PathBuf::from(teststr.clone()).into(), teststr); - StringReader::new(sess, sf, None) -} - -#[test] -fn t1() { - with_default_session_globals(|| { - let sm = Lrc::new(SourceMap::new(FilePathMapping::empty())); - let sh = mk_sess(sm.clone()); - let mut string_reader = setup( - &sm, - &sh, - "/* my source file */ fn main() { println!(\"zebra\"); }\n".to_string(), - ); - assert_eq!(string_reader.next_token(), token::Comment); - assert_eq!(string_reader.next_token(), token::Whitespace); - let tok1 = string_reader.next_token(); - let tok2 = Token::new(mk_ident("fn"), Span::with_root_ctxt(BytePos(21), BytePos(23))); - assert_eq!(tok1.kind, tok2.kind); - assert_eq!(tok1.span, tok2.span); - assert_eq!(string_reader.next_token(), token::Whitespace); - // Read another token. - let tok3 = string_reader.next_token(); - assert_eq!(string_reader.pos(), BytePos(28)); - let tok4 = Token::new(mk_ident("main"), Span::with_root_ctxt(BytePos(24), BytePos(28))); - assert_eq!(tok3.kind, tok4.kind); - assert_eq!(tok3.span, tok4.span); - - assert_eq!(string_reader.next_token(), token::OpenDelim(token::Paren)); - assert_eq!(string_reader.pos(), BytePos(29)) - }) -} - -// Checks that the given reader produces the desired stream -// of tokens (stop checking after exhausting `expected`). -fn check_tokenization(mut string_reader: StringReader<'_>, expected: Vec) { - for expected_tok in &expected { - assert_eq!(&string_reader.next_token(), expected_tok); - } -} - -// Makes the identifier by looking up the string in the interner. -fn mk_ident(id: &str) -> TokenKind { - token::Ident(Symbol::intern(id), false) -} - -fn mk_lit(kind: token::LitKind, symbol: &str, suffix: Option<&str>) -> TokenKind { - TokenKind::lit(kind, Symbol::intern(symbol), suffix.map(Symbol::intern)) -} - -#[test] -fn doublecolon_parsing() { - with_default_session_globals(|| { - let sm = Lrc::new(SourceMap::new(FilePathMapping::empty())); - let sh = mk_sess(sm.clone()); - check_tokenization( - setup(&sm, &sh, "a b".to_string()), - vec![mk_ident("a"), token::Whitespace, mk_ident("b")], - ); - }) -} - -#[test] -fn doublecolon_parsing_2() { - with_default_session_globals(|| { - let sm = Lrc::new(SourceMap::new(FilePathMapping::empty())); - let sh = mk_sess(sm.clone()); - check_tokenization( - setup(&sm, &sh, "a::b".to_string()), - vec![mk_ident("a"), token::Colon, token::Colon, mk_ident("b")], - ); - }) -} - -#[test] -fn doublecolon_parsing_3() { - with_default_session_globals(|| { - let sm = Lrc::new(SourceMap::new(FilePathMapping::empty())); - let sh = mk_sess(sm.clone()); - check_tokenization( - setup(&sm, &sh, "a ::b".to_string()), - vec![mk_ident("a"), token::Whitespace, token::Colon, token::Colon, mk_ident("b")], - ); - }) -} - -#[test] -fn doublecolon_parsing_4() { - with_default_session_globals(|| { - let sm = Lrc::new(SourceMap::new(FilePathMapping::empty())); - let sh = mk_sess(sm.clone()); - check_tokenization( - setup(&sm, &sh, "a:: b".to_string()), - vec![mk_ident("a"), token::Colon, token::Colon, token::Whitespace, mk_ident("b")], - ); - }) -} - -#[test] -fn character_a() { - with_default_session_globals(|| { - let sm = Lrc::new(SourceMap::new(FilePathMapping::empty())); - let sh = mk_sess(sm.clone()); - assert_eq!(setup(&sm, &sh, "'a'".to_string()).next_token(), mk_lit(token::Char, "a", None),); - }) -} - -#[test] -fn character_space() { - with_default_session_globals(|| { - let sm = Lrc::new(SourceMap::new(FilePathMapping::empty())); - let sh = mk_sess(sm.clone()); - assert_eq!(setup(&sm, &sh, "' '".to_string()).next_token(), mk_lit(token::Char, " ", None),); - }) -} - -#[test] -fn character_escaped() { - with_default_session_globals(|| { - let sm = Lrc::new(SourceMap::new(FilePathMapping::empty())); - let sh = mk_sess(sm.clone()); - assert_eq!( - setup(&sm, &sh, "'\\n'".to_string()).next_token(), - mk_lit(token::Char, "\\n", None), - ); - }) -} - -#[test] -fn lifetime_name() { - with_default_session_globals(|| { - let sm = Lrc::new(SourceMap::new(FilePathMapping::empty())); - let sh = mk_sess(sm.clone()); - assert_eq!( - setup(&sm, &sh, "'abc".to_string()).next_token(), - token::Lifetime(Symbol::intern("'abc")), - ); - }) -} - -#[test] -fn raw_string() { - with_default_session_globals(|| { - let sm = Lrc::new(SourceMap::new(FilePathMapping::empty())); - let sh = mk_sess(sm.clone()); - assert_eq!( - setup(&sm, &sh, "r###\"\"#a\\b\x00c\"\"###".to_string()).next_token(), - mk_lit(token::StrRaw(3), "\"#a\\b\x00c\"", None), - ); - }) -} - -#[test] -fn literal_suffixes() { - with_default_session_globals(|| { - let sm = Lrc::new(SourceMap::new(FilePathMapping::empty())); - let sh = mk_sess(sm.clone()); - macro_rules! test { - ($input: expr, $tok_type: ident, $tok_contents: expr) => {{ - assert_eq!( - setup(&sm, &sh, format!("{}suffix", $input)).next_token(), - mk_lit(token::$tok_type, $tok_contents, Some("suffix")), - ); - // with a whitespace separator - assert_eq!( - setup(&sm, &sh, format!("{} suffix", $input)).next_token(), - mk_lit(token::$tok_type, $tok_contents, None), - ); - }}; - } - - test!("'a'", Char, "a"); - test!("b'a'", Byte, "a"); - test!("\"a\"", Str, "a"); - test!("b\"a\"", ByteStr, "a"); - test!("1234", Integer, "1234"); - test!("0b101", Integer, "0b101"); - test!("0xABC", Integer, "0xABC"); - test!("1.0", Float, "1.0"); - test!("1.0e10", Float, "1.0e10"); - - assert_eq!( - setup(&sm, &sh, "2us".to_string()).next_token(), - mk_lit(token::Integer, "2", Some("us")), - ); - assert_eq!( - setup(&sm, &sh, "r###\"raw\"###suffix".to_string()).next_token(), - mk_lit(token::StrRaw(3), "raw", Some("suffix")), - ); - assert_eq!( - setup(&sm, &sh, "br###\"raw\"###suffix".to_string()).next_token(), - mk_lit(token::ByteStrRaw(3), "raw", Some("suffix")), - ); - }) -} - -#[test] -fn nested_block_comments() { - with_default_session_globals(|| { - let sm = Lrc::new(SourceMap::new(FilePathMapping::empty())); - let sh = mk_sess(sm.clone()); - let mut lexer = setup(&sm, &sh, "/* /* */ */'a'".to_string()); - assert_eq!(lexer.next_token(), token::Comment); - assert_eq!(lexer.next_token(), mk_lit(token::Char, "a", None)); - }) -} - -#[test] -fn crlf_comments() { - with_default_session_globals(|| { - let sm = Lrc::new(SourceMap::new(FilePathMapping::empty())); - let sh = mk_sess(sm.clone()); - let mut lexer = setup(&sm, &sh, "// test\r\n/// test\r\n".to_string()); - let comment = lexer.next_token(); - assert_eq!(comment.kind, token::Comment); - assert_eq!((comment.span.lo(), comment.span.hi()), (BytePos(0), BytePos(7))); - assert_eq!(lexer.next_token(), token::Whitespace); - assert_eq!( - lexer.next_token(), - token::DocComment(CommentKind::Line, AttrStyle::Outer, Symbol::intern(" test")) - ); - }) -} diff --git a/compiler/rustc_lexer/src/tests.rs b/compiler/rustc_lexer/src/tests.rs index a1ea5ceb1f61..94017b7b286e 100644 --- a/compiler/rustc_lexer/src/tests.rs +++ b/compiler/rustc_lexer/src/tests.rs @@ -128,6 +128,34 @@ fn check_lexing(src: &str, expect: Expect) { expect.assert_eq(&actual) } +#[test] +fn smoke_test() { + check_lexing( + "/* my source file */ fn main() { println!(\"zebra\"); }\n", + expect![[r#" + Token { kind: BlockComment { doc_style: None, terminated: true }, len: 20 } + Token { kind: Whitespace, len: 1 } + Token { kind: Ident, len: 2 } + Token { kind: Whitespace, len: 1 } + Token { kind: Ident, len: 4 } + Token { kind: OpenParen, len: 1 } + Token { kind: CloseParen, len: 1 } + Token { kind: Whitespace, len: 1 } + Token { kind: OpenBrace, len: 1 } + Token { kind: Whitespace, len: 1 } + Token { kind: Ident, len: 7 } + Token { kind: Bang, len: 1 } + Token { kind: OpenParen, len: 1 } + Token { kind: Literal { kind: Str { terminated: true }, suffix_start: 7 }, len: 7 } + Token { kind: CloseParen, len: 1 } + Token { kind: Semi, len: 1 } + Token { kind: Whitespace, len: 1 } + Token { kind: CloseBrace, len: 1 } + Token { kind: Whitespace, len: 1 } + "#]], + ) +} + #[test] fn comment_flavors() { check_lexing( @@ -143,25 +171,117 @@ fn comment_flavors() { /*! inner doc block */ ", expect![[r#" - Token { kind: Whitespace, len: 1 } - Token { kind: LineComment { doc_style: None }, len: 7 } - Token { kind: Whitespace, len: 1 } - Token { kind: LineComment { doc_style: None }, len: 17 } - Token { kind: Whitespace, len: 1 } - Token { kind: LineComment { doc_style: Some(Outer) }, len: 18 } - Token { kind: Whitespace, len: 1 } - Token { kind: LineComment { doc_style: Some(Inner) }, len: 18 } - Token { kind: Whitespace, len: 1 } - Token { kind: BlockComment { doc_style: None, terminated: true }, len: 11 } - Token { kind: Whitespace, len: 1 } - Token { kind: BlockComment { doc_style: None, terminated: true }, len: 4 } - Token { kind: Whitespace, len: 1 } - Token { kind: BlockComment { doc_style: None, terminated: true }, len: 18 } - Token { kind: Whitespace, len: 1 } - Token { kind: BlockComment { doc_style: Some(Outer), terminated: true }, len: 22 } - Token { kind: Whitespace, len: 1 } - Token { kind: BlockComment { doc_style: Some(Inner), terminated: true }, len: 22 } - Token { kind: Whitespace, len: 1 } - "#]], + Token { kind: Whitespace, len: 1 } + Token { kind: LineComment { doc_style: None }, len: 7 } + Token { kind: Whitespace, len: 1 } + Token { kind: LineComment { doc_style: None }, len: 17 } + Token { kind: Whitespace, len: 1 } + Token { kind: LineComment { doc_style: Some(Outer) }, len: 18 } + Token { kind: Whitespace, len: 1 } + Token { kind: LineComment { doc_style: Some(Inner) }, len: 18 } + Token { kind: Whitespace, len: 1 } + Token { kind: BlockComment { doc_style: None, terminated: true }, len: 11 } + Token { kind: Whitespace, len: 1 } + Token { kind: BlockComment { doc_style: None, terminated: true }, len: 4 } + Token { kind: Whitespace, len: 1 } + Token { kind: BlockComment { doc_style: None, terminated: true }, len: 18 } + Token { kind: Whitespace, len: 1 } + Token { kind: BlockComment { doc_style: Some(Outer), terminated: true }, len: 22 } + Token { kind: Whitespace, len: 1 } + Token { kind: BlockComment { doc_style: Some(Inner), terminated: true }, len: 22 } + Token { kind: Whitespace, len: 1 } + "#]], + ) +} + +#[test] +fn nested_block_comments() { + check_lexing( + "/* /* */ */'a'", + expect![[r#" + Token { kind: BlockComment { doc_style: None, terminated: true }, len: 11 } + Token { kind: Literal { kind: Char { terminated: true }, suffix_start: 3 }, len: 3 } + "#]], + ) +} + +#[test] +fn characters() { + check_lexing( + "'a' ' ' '\\n'", + expect![[r#" + Token { kind: Literal { kind: Char { terminated: true }, suffix_start: 3 }, len: 3 } + Token { kind: Whitespace, len: 1 } + Token { kind: Literal { kind: Char { terminated: true }, suffix_start: 3 }, len: 3 } + Token { kind: Whitespace, len: 1 } + Token { kind: Literal { kind: Char { terminated: true }, suffix_start: 4 }, len: 4 } + "#]], + ); +} + +#[test] +fn lifetime() { + check_lexing( + "'abc", + expect![[r#" + Token { kind: Lifetime { starts_with_number: false }, len: 4 } + "#]], + ); +} + +#[test] +fn raw_string() { + check_lexing( + "r###\"\"#a\\b\x00c\"\"###", + expect![[r#" + Token { kind: Literal { kind: RawStr { n_hashes: 3, err: None }, suffix_start: 17 }, len: 17 } + "#]], + ) +} + +#[test] +fn literal_suffixes() { + check_lexing( + r####" +'a' +b'a' +"a" +b"a" +1234 +0b101 +0xABC +1.0 +1.0e10 +2us +r###"raw"###suffix +br###"raw"###suffix +"####, + expect![[r#" + Token { kind: Whitespace, len: 1 } + Token { kind: Literal { kind: Char { terminated: true }, suffix_start: 3 }, len: 3 } + Token { kind: Whitespace, len: 1 } + Token { kind: Literal { kind: Byte { terminated: true }, suffix_start: 4 }, len: 4 } + Token { kind: Whitespace, len: 1 } + Token { kind: Literal { kind: Str { terminated: true }, suffix_start: 3 }, len: 3 } + Token { kind: Whitespace, len: 1 } + Token { kind: Literal { kind: ByteStr { terminated: true }, suffix_start: 4 }, len: 4 } + Token { kind: Whitespace, len: 1 } + Token { kind: Literal { kind: Int { base: Decimal, empty_int: false }, suffix_start: 4 }, len: 4 } + Token { kind: Whitespace, len: 1 } + Token { kind: Literal { kind: Int { base: Binary, empty_int: false }, suffix_start: 5 }, len: 5 } + Token { kind: Whitespace, len: 1 } + Token { kind: Literal { kind: Int { base: Hexadecimal, empty_int: false }, suffix_start: 5 }, len: 5 } + Token { kind: Whitespace, len: 1 } + Token { kind: Literal { kind: Float { base: Decimal, empty_exponent: false }, suffix_start: 3 }, len: 3 } + Token { kind: Whitespace, len: 1 } + Token { kind: Literal { kind: Float { base: Decimal, empty_exponent: false }, suffix_start: 6 }, len: 6 } + Token { kind: Whitespace, len: 1 } + Token { kind: Literal { kind: Int { base: Decimal, empty_int: false }, suffix_start: 1 }, len: 3 } + Token { kind: Whitespace, len: 1 } + Token { kind: Literal { kind: RawStr { n_hashes: 3, err: None }, suffix_start: 12 }, len: 18 } + Token { kind: Whitespace, len: 1 } + Token { kind: Literal { kind: RawByteStr { n_hashes: 3, err: None }, suffix_start: 13 }, len: 19 } + Token { kind: Whitespace, len: 1 } + "#]], ) } From 518cac91902d34567ac8bfea3022f426a7de53f6 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 29 Aug 2020 11:00:59 +0200 Subject: [PATCH 5/9] Remove unused function --- Cargo.lock | 15 +-------------- compiler/rustc_parse/src/lexer/mod.rs | 4 ---- 2 files changed, 1 insertion(+), 18 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d54939694339..ffc1f0dec1d9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -342,7 +342,7 @@ dependencies = [ name = "cargo-miri" version = "0.1.0" dependencies = [ - "cargo_metadata 0.9.1", + "cargo_metadata 0.11.1", "directories", "rustc-workspace-hack", "rustc_version", @@ -391,18 +391,6 @@ dependencies = [ "serde_json", ] -[[package]] -name = "cargo_metadata" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46e3374c604fb39d1a2f35ed5e4a4e30e60d01fab49446e08f1b3e9a90aef202" -dependencies = [ - "semver 0.9.0", - "serde", - "serde_derive", - "serde_json", -] - [[package]] name = "cargo_metadata" version = "0.11.1" @@ -1991,7 +1979,6 @@ dependencies = [ name = "miri" version = "0.1.0" dependencies = [ - "byteorder", "colored", "compiletest_rs", "env_logger 0.7.1", diff --git a/compiler/rustc_parse/src/lexer/mod.rs b/compiler/rustc_parse/src/lexer/mod.rs index a65d34468192..c4ef35bc30c7 100644 --- a/compiler/rustc_parse/src/lexer/mod.rs +++ b/compiler/rustc_parse/src/lexer/mod.rs @@ -439,10 +439,6 @@ impl<'a> StringReader<'a> { (lit_kind, id) } - pub fn pos(&self) -> BytePos { - self.pos - } - #[inline] fn src_index(&self, pos: BytePos) -> usize { (pos - self.start_pos).to_usize() From 883b1e7592dec6e309db018a2a87253d91d50b4a Mon Sep 17 00:00:00 2001 From: Caleb Cartwright Date: Sun, 30 Aug 2020 13:04:36 -0500 Subject: [PATCH 6/9] parser: restore some fn visibility for rustfmt --- compiler/rustc_parse/src/parser/mod.rs | 3 ++- compiler/rustc_parse/src/parser/stmt.rs | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_parse/src/parser/mod.rs b/compiler/rustc_parse/src/parser/mod.rs index d67ed74bc997..d90a61cd34af 100644 --- a/compiler/rustc_parse/src/parser/mod.rs +++ b/compiler/rustc_parse/src/parser/mod.rs @@ -1014,7 +1014,8 @@ impl<'a> Parser<'a> { /// If the following element can't be a tuple (i.e., it's a function definition), then /// it's not a tuple struct field), and the contents within the parentheses isn't valid, /// so emit a proper diagnostic. - pub(crate) fn parse_visibility(&mut self, fbt: FollowedByType) -> PResult<'a, Visibility> { + // Public for rustfmt usage. + pub fn parse_visibility(&mut self, fbt: FollowedByType) -> PResult<'a, Visibility> { maybe_whole!(self, NtVis, |x| x); self.expected_tokens.push(TokenType::Keyword(kw::Crate)); diff --git a/compiler/rustc_parse/src/parser/stmt.rs b/compiler/rustc_parse/src/parser/stmt.rs index ac067cb0eab8..0f522fd788c8 100644 --- a/compiler/rustc_parse/src/parser/stmt.rs +++ b/compiler/rustc_parse/src/parser/stmt.rs @@ -21,7 +21,8 @@ use std::mem; impl<'a> Parser<'a> { /// Parses a statement. This stops just before trailing semicolons on everything but items. /// e.g., a `StmtKind::Semi` parses to a `StmtKind::Expr`, leaving the trailing `;` unconsumed. - pub(super) fn parse_stmt(&mut self) -> PResult<'a, Option> { + // Public for rustfmt usage. + pub fn parse_stmt(&mut self) -> PResult<'a, Option> { Ok(self.parse_stmt_without_recovery().unwrap_or_else(|mut e| { e.emit(); self.recover_stmt_(SemiColonMode::Break, BlockMode::Ignore); From 68500ffacb4d28586a9c17799ab73e41aa2cfe94 Mon Sep 17 00:00:00 2001 From: marmeladema Date: Sat, 29 Aug 2020 19:16:49 +0100 Subject: [PATCH 7/9] datastructures: replace `once_cell` crate with an impl from std --- Cargo.lock | 1 - compiler/rustc_data_structures/Cargo.toml | 1 - compiler/rustc_data_structures/src/lib.rs | 1 + compiler/rustc_data_structures/src/sync.rs | 4 ++-- compiler/rustc_driver/src/lib.rs | 1 + compiler/rustc_interface/src/lib.rs | 1 + compiler/rustc_middle/src/lib.rs | 1 + compiler/rustc_session/src/lib.rs | 1 + 8 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ffc1f0dec1d9..13d9a962e37a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3420,7 +3420,6 @@ dependencies = [ "lazy_static", "libc", "measureme", - "once_cell", "parking_lot 0.10.2", "rustc-hash", "rustc-rayon", diff --git a/compiler/rustc_data_structures/Cargo.toml b/compiler/rustc_data_structures/Cargo.toml index f929d9911f91..464f8c984dde 100644 --- a/compiler/rustc_data_structures/Cargo.toml +++ b/compiler/rustc_data_structures/Cargo.toml @@ -13,7 +13,6 @@ indexmap = "1.5.1" tracing = "0.1" jobserver_crate = { version = "0.1.13", package = "jobserver" } lazy_static = "1" -once_cell = { version = "1", features = ["parking_lot"] } rustc_serialize = { path = "../rustc_serialize" } rustc_macros = { path = "../rustc_macros" } rustc_graphviz = { path = "../rustc_graphviz" } diff --git a/compiler/rustc_data_structures/src/lib.rs b/compiler/rustc_data_structures/src/lib.rs index af4a7bd18813..78b7e08ceede 100644 --- a/compiler/rustc_data_structures/src/lib.rs +++ b/compiler/rustc_data_structures/src/lib.rs @@ -26,6 +26,7 @@ #![feature(extend_one)] #![feature(const_panic)] #![feature(const_generics)] +#![feature(once_cell)] #![allow(rustc::default_hash_types)] #[macro_use] diff --git a/compiler/rustc_data_structures/src/sync.rs b/compiler/rustc_data_structures/src/sync.rs index 53d831749ceb..d22f3adfb016 100644 --- a/compiler/rustc_data_structures/src/sync.rs +++ b/compiler/rustc_data_structures/src/sync.rs @@ -229,7 +229,7 @@ cfg_if! { pub use std::cell::RefMut as LockGuard; pub use std::cell::RefMut as MappedLockGuard; - pub use once_cell::unsync::OnceCell; + pub use std::lazy::OnceCell; use std::cell::RefCell as InnerRwLock; use std::cell::RefCell as InnerLock; @@ -314,7 +314,7 @@ cfg_if! { pub use parking_lot::MutexGuard as LockGuard; pub use parking_lot::MappedMutexGuard as MappedLockGuard; - pub use once_cell::sync::OnceCell; + pub use std::lazy::SyncOnceCell as OnceCell; pub use std::sync::atomic::{AtomicBool, AtomicUsize, AtomicU32, AtomicU64}; diff --git a/compiler/rustc_driver/src/lib.rs b/compiler/rustc_driver/src/lib.rs index 09f5b22cc638..0d8332a20aea 100644 --- a/compiler/rustc_driver/src/lib.rs +++ b/compiler/rustc_driver/src/lib.rs @@ -6,6 +6,7 @@ #![doc(html_root_url = "https://doc.rust-lang.org/nightly/")] #![feature(nll)] +#![feature(once_cell)] #![recursion_limit = "256"] #[macro_use] diff --git a/compiler/rustc_interface/src/lib.rs b/compiler/rustc_interface/src/lib.rs index fe40c615f79c..88d2efe96d16 100644 --- a/compiler/rustc_interface/src/lib.rs +++ b/compiler/rustc_interface/src/lib.rs @@ -4,6 +4,7 @@ #![feature(nll)] #![feature(generator_trait)] #![feature(generators)] +#![feature(once_cell)] #![recursion_limit = "256"] mod callbacks; diff --git a/compiler/rustc_middle/src/lib.rs b/compiler/rustc_middle/src/lib.rs index 1b2dea8a378c..a675aae5b17d 100644 --- a/compiler/rustc_middle/src/lib.rs +++ b/compiler/rustc_middle/src/lib.rs @@ -38,6 +38,7 @@ #![feature(exhaustive_patterns)] #![feature(extern_types)] #![feature(nll)] +#![feature(once_cell)] #![feature(option_expect_none)] #![feature(or_patterns)] #![feature(min_specialization)] diff --git a/compiler/rustc_session/src/lib.rs b/compiler/rustc_session/src/lib.rs index c2ea141a06fe..a808261798da 100644 --- a/compiler/rustc_session/src/lib.rs +++ b/compiler/rustc_session/src/lib.rs @@ -1,4 +1,5 @@ #![feature(crate_visibility_modifier)] +#![feature(once_cell)] #![feature(or_patterns)] #[macro_use] From 21c624a230dd52098501497e8ed04943e0b36d91 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Sun, 30 Aug 2020 17:51:17 +0300 Subject: [PATCH 8/9] rustbuild: Remove one LLD workaround --- src/bootstrap/builder.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 54eb2e99b8ff..cecc9ef75ea8 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -1041,15 +1041,11 @@ impl<'a> Builder<'a> { } } - // FIXME: Don't use LLD with MSVC if we're compiling libtest, since it fails to link it. - // See https://github.com/rust-lang/rust/issues/68647. - let can_use_lld = mode != Mode::Std; - - if let Some(host_linker) = self.linker(compiler.host, can_use_lld) { + if let Some(host_linker) = self.linker(compiler.host, true) { cargo.env("RUSTC_HOST_LINKER", host_linker); } - if let Some(target_linker) = self.linker(target, can_use_lld) { + if let Some(target_linker) = self.linker(target, true) { let target = crate::envify(&target.triple); cargo.env(&format!("CARGO_TARGET_{}_LINKER", target), target_linker); } From 668f63d83302c858dfae998e22fe3881d56d4e52 Mon Sep 17 00:00:00 2001 From: Amjad Alsharafi Date: Mon, 31 Aug 2020 18:35:04 +0800 Subject: [PATCH 9/9] Fix duplicate error messages in const_generics tests --- .../ui/const-generics/argument_order.full.stderr | 2 +- .../ui/const-generics/argument_order.min.stderr | 2 +- src/test/ui/const-generics/argument_order.rs | 8 +++----- .../const-arg-type-arg-misordered.rs | 3 +-- .../const-param-before-other-params.min.stderr | 4 ++-- .../const-param-before-other-params.rs | 5 ++--- .../issues/issue-63322-forbid-dyn.rs | 6 ++---- .../const-generics/issues/issue-71169.full.stderr | 2 +- src/test/ui/const-generics/issues/issue-71169.rs | 5 ++--- .../const-generics/issues/issue-71381.full.stderr | 4 ++-- .../const-generics/issues/issue-71381.min.stderr | 4 ++-- src/test/ui/const-generics/issues/issue-71381.rs | 12 ++++-------- src/test/ui/const-generics/issues/issue-71382.rs | 3 +-- src/test/ui/const-generics/issues/issue-71611.rs | 6 ++---- src/test/ui/const-generics/issues/issue-72352.rs | 3 +-- src/test/ui/const-generics/issues/issue-73508.rs | 3 +-- .../std/const-generics-range.min.stderr | 4 ++-- .../ui/const-generics/std/const-generics-range.rs | 14 ++++++-------- .../const-generics/type-dependent/issue-71382.rs | 3 +-- .../const-generics/type-dependent/type-mismatch.rs | 3 +-- .../types-mismatch-const-args.full.stderr | 2 +- .../types-mismatch-const-args.min.stderr | 2 +- .../ui/const-generics/types-mismatch-const-args.rs | 6 ++---- 23 files changed, 42 insertions(+), 64 deletions(-) diff --git a/src/test/ui/const-generics/argument_order.full.stderr b/src/test/ui/const-generics/argument_order.full.stderr index 5068fd6d7343..b52e50507033 100644 --- a/src/test/ui/const-generics/argument_order.full.stderr +++ b/src/test/ui/const-generics/argument_order.full.stderr @@ -5,7 +5,7 @@ LL | struct AlsoBad { | -----------------^^-----^^-------------------- help: reorder the parameters: lifetimes, then consts and types: `<'a, 'b, const N: usize, T, const M: usize, U>` error[E0747]: lifetime provided when a type was expected - --> $DIR/argument_order.rs:21:23 + --> $DIR/argument_order.rs:20:23 | LL | let _: AlsoBad<7, 'static, u32, 'static, 17, u16>; | ^^^^^^^ diff --git a/src/test/ui/const-generics/argument_order.min.stderr b/src/test/ui/const-generics/argument_order.min.stderr index c3068e0a2313..728ae69b41f1 100644 --- a/src/test/ui/const-generics/argument_order.min.stderr +++ b/src/test/ui/const-generics/argument_order.min.stderr @@ -17,7 +17,7 @@ LL | struct AlsoBad { | ---------------------^----------------------^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, 'b, T, U, const N: usize, const M: usize>` error[E0747]: lifetime provided when a type was expected - --> $DIR/argument_order.rs:21:23 + --> $DIR/argument_order.rs:20:23 | LL | let _: AlsoBad<7, 'static, u32, 'static, 17, u16>; | ^^^^^^^ diff --git a/src/test/ui/const-generics/argument_order.rs b/src/test/ui/const-generics/argument_order.rs index aebf6cc846a6..507baf5fd755 100644 --- a/src/test/ui/const-generics/argument_order.rs +++ b/src/test/ui/const-generics/argument_order.rs @@ -10,15 +10,13 @@ struct Bad { } struct AlsoBad { - //[full]~^ ERROR lifetime parameters must be declared prior - //[min]~^^ ERROR lifetime parameters must be declared prior to const parameters - //[min]~^^^ ERROR type parameters must be declared prior to const parameters + //~^ ERROR lifetime parameters must be declared prior + //[min]~^^ ERROR type parameters must be declared prior to const parameters a: &'a T, b: &'b U, } fn main() { let _: AlsoBad<7, 'static, u32, 'static, 17, u16>; - //[full]~^ ERROR lifetime provided when a type was expected - //[min]~^^ ERROR lifetime provided when a type was expected + //~^ ERROR lifetime provided when a type was expected } diff --git a/src/test/ui/const-generics/const-arg-type-arg-misordered.rs b/src/test/ui/const-generics/const-arg-type-arg-misordered.rs index ce45720ffb0d..6680f772fa3f 100644 --- a/src/test/ui/const-generics/const-arg-type-arg-misordered.rs +++ b/src/test/ui/const-generics/const-arg-type-arg-misordered.rs @@ -6,8 +6,7 @@ type Array = [T; N]; fn foo() -> Array { - //[full]~^ ERROR constant provided when a type was expected - //[min]~^^ ERROR constant provided when a type was expected + //~^ ERROR constant provided when a type was expected unimplemented!() } diff --git a/src/test/ui/const-generics/const-param-before-other-params.min.stderr b/src/test/ui/const-generics/const-param-before-other-params.min.stderr index fc197181deeb..c7e6d1be4216 100644 --- a/src/test/ui/const-generics/const-param-before-other-params.min.stderr +++ b/src/test/ui/const-generics/const-param-before-other-params.min.stderr @@ -5,7 +5,7 @@ LL | fn bar(_: &'a ()) { | --------------^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, const X: ()>` error: type parameters must be declared prior to const parameters - --> $DIR/const-param-before-other-params.rs:12:21 + --> $DIR/const-param-before-other-params.rs:11:21 | LL | fn foo(_: &T) {} | --------------^- help: reorder the parameters: lifetimes, then types, then consts: `` @@ -20,7 +20,7 @@ LL | fn bar(_: &'a ()) { = note: more complex types are supported with `#[feature(const_generics)]` error: `()` is forbidden as the type of a const generic parameter - --> $DIR/const-param-before-other-params.rs:12:17 + --> $DIR/const-param-before-other-params.rs:11:17 | LL | fn foo(_: &T) {} | ^^ diff --git a/src/test/ui/const-generics/const-param-before-other-params.rs b/src/test/ui/const-generics/const-param-before-other-params.rs index 5b98b6c518db..f1be90cf2e41 100644 --- a/src/test/ui/const-generics/const-param-before-other-params.rs +++ b/src/test/ui/const-generics/const-param-before-other-params.rs @@ -4,9 +4,8 @@ #![cfg_attr(min, feature(min_const_generics))] fn bar(_: &'a ()) { - //[full]~^ ERROR lifetime parameters must be declared prior to const parameters - //[min]~^^ ERROR lifetime parameters must be declared prior to const parameters - //[min]~^^^ ERROR `()` is forbidden as the type of a const generic parameter + //~^ ERROR lifetime parameters must be declared prior to const parameters + //[min]~^^ ERROR `()` is forbidden as the type of a const generic parameter } fn foo(_: &T) {} diff --git a/src/test/ui/const-generics/issues/issue-63322-forbid-dyn.rs b/src/test/ui/const-generics/issues/issue-63322-forbid-dyn.rs index 356652d67aae..2194eb97a410 100644 --- a/src/test/ui/const-generics/issues/issue-63322-forbid-dyn.rs +++ b/src/test/ui/const-generics/issues/issue-63322-forbid-dyn.rs @@ -8,10 +8,8 @@ struct B; impl A for B {} fn test() { - //[full]~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` to be used - //[min]~^^ ERROR `&'static (dyn A + 'static)` is forbidden as the type of - // a const generic parameter - //[min]~| ERROR must be annotated with `#[derive(PartialEq, Eq)]` to be used + //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` to be used + //[min]~^^ ERROR `&'static (dyn A + 'static)` is forbidden unimplemented!() } diff --git a/src/test/ui/const-generics/issues/issue-71169.full.stderr b/src/test/ui/const-generics/issues/issue-71169.full.stderr index e9f312d934ab..b87825d20ce3 100644 --- a/src/test/ui/const-generics/issues/issue-71169.full.stderr +++ b/src/test/ui/const-generics/issues/issue-71169.full.stderr @@ -5,7 +5,7 @@ LL | fn foo() {} | ^^^ the type must not depend on the parameter `LEN` error: constant expression depends on a generic parameter - --> $DIR/issue-71169.rs:12:14 + --> $DIR/issue-71169.rs:11:14 | LL | foo::<4, DATA>(); | ^^^^ diff --git a/src/test/ui/const-generics/issues/issue-71169.rs b/src/test/ui/const-generics/issues/issue-71169.rs index 26cd9f0e31c5..7007ec222caa 100644 --- a/src/test/ui/const-generics/issues/issue-71169.rs +++ b/src/test/ui/const-generics/issues/issue-71169.rs @@ -4,9 +4,8 @@ #![cfg_attr(min, feature(min_const_generics))] fn foo() {} -//[full]~^ ERROR the type of const parameters must not -//[min]~^^ ERROR the type of const parameters must not -//[min]~| ERROR `[u8; _]` is forbidden as the type of a const generic parameter +//~^ ERROR the type of const parameters must not +//[min]~^^ ERROR `[u8; _]` is forbidden as the type of a const generic parameter fn main() { const DATA: [u8; 4] = *b"ABCD"; foo::<4, DATA>(); diff --git a/src/test/ui/const-generics/issues/issue-71381.full.stderr b/src/test/ui/const-generics/issues/issue-71381.full.stderr index 4586a80687a7..453ef00e6dc1 100644 --- a/src/test/ui/const-generics/issues/issue-71381.full.stderr +++ b/src/test/ui/const-generics/issues/issue-71381.full.stderr @@ -5,7 +5,7 @@ LL | pub fn call_me $DIR/issue-71381.rs:26:40 + --> $DIR/issue-71381.rs:24:40 | LL | const FN: unsafe extern "C" fn(Args), | ^^^^ the type must not depend on the parameter `Args` @@ -17,7 +17,7 @@ LL | pub fn call_me $DIR/issue-71381.rs:26:19 + --> $DIR/issue-71381.rs:24:19 | LL | const FN: unsafe extern "C" fn(Args), | ^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/const-generics/issues/issue-71381.min.stderr b/src/test/ui/const-generics/issues/issue-71381.min.stderr index 4586a80687a7..453ef00e6dc1 100644 --- a/src/test/ui/const-generics/issues/issue-71381.min.stderr +++ b/src/test/ui/const-generics/issues/issue-71381.min.stderr @@ -5,7 +5,7 @@ LL | pub fn call_me $DIR/issue-71381.rs:26:40 + --> $DIR/issue-71381.rs:24:40 | LL | const FN: unsafe extern "C" fn(Args), | ^^^^ the type must not depend on the parameter `Args` @@ -17,7 +17,7 @@ LL | pub fn call_me $DIR/issue-71381.rs:26:19 + --> $DIR/issue-71381.rs:24:19 | LL | const FN: unsafe extern "C" fn(Args), | ^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/const-generics/issues/issue-71381.rs b/src/test/ui/const-generics/issues/issue-71381.rs index 3203cf8fe765..65d88e553b9e 100644 --- a/src/test/ui/const-generics/issues/issue-71381.rs +++ b/src/test/ui/const-generics/issues/issue-71381.rs @@ -13,10 +13,8 @@ unsafe extern "C" fn pass(args: PassArg) { impl Test { pub fn call_me(&self) { - //[full]~^ ERROR: using function pointers as const generic parameters is forbidden - //[full]~| ERROR: the type of const parameters must not depend on other generic parameters - //[min]~^^^ ERROR: using function pointers as const generic parameters is forbidden - //[min]~| ERROR: the type of const parameters must not depend on other generic parameters + //~^ ERROR: using function pointers as const generic parameters is forbidden + //~| ERROR: the type of const parameters must not depend on other generic parameters self.0 = Self::trampiline:: as _ } @@ -24,10 +22,8 @@ impl Test { Args: Sized, const IDX: usize, const FN: unsafe extern "C" fn(Args), - //[full]~^ ERROR: using function pointers as const generic parameters is forbidden - //[full]~| ERROR: the type of const parameters must not depend on other generic parameters - //[min]~^^^ ERROR: using function pointers as const generic parameters is forbidden - //[min]~| ERROR: the type of const parameters must not depend on other generic parameters + //~^ ERROR: using function pointers as const generic parameters is forbidden + //~| ERROR: the type of const parameters must not depend on other generic parameters >( args: Args, ) { diff --git a/src/test/ui/const-generics/issues/issue-71382.rs b/src/test/ui/const-generics/issues/issue-71382.rs index e403b0f11991..12a7d08382a3 100644 --- a/src/test/ui/const-generics/issues/issue-71382.rs +++ b/src/test/ui/const-generics/issues/issue-71382.rs @@ -15,8 +15,7 @@ impl Test { } fn test(&self) { - //[full]~^ ERROR: using function pointers as const generic parameters is forbidden - //[min]~^^ ERROR: using function pointers as const generic parameters is forbidden + //~^ ERROR: using function pointers as const generic parameters is forbidden FN(); } } diff --git a/src/test/ui/const-generics/issues/issue-71611.rs b/src/test/ui/const-generics/issues/issue-71611.rs index c9c95902f957..9b8e8be6bc6f 100644 --- a/src/test/ui/const-generics/issues/issue-71611.rs +++ b/src/test/ui/const-generics/issues/issue-71611.rs @@ -4,10 +4,8 @@ #![cfg_attr(min, feature(min_const_generics))] fn func(outer: A) { - //[full]~^ ERROR: using function pointers as const generic parameters is forbidden - //[full]~| ERROR: the type of const parameters must not depend on other generic parameters - //[min]~^^^ ERROR: using function pointers as const generic parameters is forbidden - //[min]~| ERROR: the type of const parameters must not depend on other generic parameters + //~^ ERROR: using function pointers as const generic parameters is forbidden + //~| ERROR: the type of const parameters must not depend on other generic parameters F(outer); } diff --git a/src/test/ui/const-generics/issues/issue-72352.rs b/src/test/ui/const-generics/issues/issue-72352.rs index b723b9dd7157..1517f3dae4ff 100644 --- a/src/test/ui/const-generics/issues/issue-72352.rs +++ b/src/test/ui/const-generics/issues/issue-72352.rs @@ -6,8 +6,7 @@ use std::ffi::{CStr, CString}; unsafe fn unsafely_do_the_thing usize>(ptr: *const i8) -> usize { - //[full]~^ ERROR: using function pointers as const generic parameters is forbidden - //[min]~^^ ERROR: using function pointers as const generic parameters is forbidden + //~^ ERROR: using function pointers as const generic parameters is forbidden F(CStr::from_ptr(ptr)) } diff --git a/src/test/ui/const-generics/issues/issue-73508.rs b/src/test/ui/const-generics/issues/issue-73508.rs index 1032f9389bc0..21b87f7f9014 100644 --- a/src/test/ui/const-generics/issues/issue-73508.rs +++ b/src/test/ui/const-generics/issues/issue-73508.rs @@ -4,7 +4,6 @@ #![cfg_attr(min, feature(min_const_generics))] pub const fn func_name() {} -//[full]~^ ERROR using raw pointers -//[min]~^^ ERROR using raw pointers as const generic parameters is forbidden +//~^ ERROR using raw pointers fn main() {} diff --git a/src/test/ui/const-generics/std/const-generics-range.min.stderr b/src/test/ui/const-generics/std/const-generics-range.min.stderr index 00edcbc53ce4..a71e74420215 100644 --- a/src/test/ui/const-generics/std/const-generics-range.min.stderr +++ b/src/test/ui/const-generics/std/const-generics-range.min.stderr @@ -35,7 +35,7 @@ LL | struct _RangeInclusive>; = note: more complex types are supported with `#[feature(const_generics)]` error: `std::ops::RangeTo` is forbidden as the type of a const generic parameter - --> $DIR/const-generics-range.rs:30:26 + --> $DIR/const-generics-range.rs:29:26 | LL | struct _RangeTo>; | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -44,7 +44,7 @@ LL | struct _RangeTo>; = note: more complex types are supported with `#[feature(const_generics)]` error: `std::ops::RangeToInclusive` is forbidden as the type of a const generic parameter - --> $DIR/const-generics-range.rs:35:35 + --> $DIR/const-generics-range.rs:34:35 | LL | struct _RangeToInclusive>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/const-generics/std/const-generics-range.rs b/src/test/ui/const-generics/std/const-generics-range.rs index 209aa39775d7..c04f4a3acfbb 100644 --- a/src/test/ui/const-generics/std/const-generics-range.rs +++ b/src/test/ui/const-generics/std/const-generics-range.rs @@ -6,35 +6,33 @@ // `Range` should be usable within const generics: struct _Range>; -//[min]~^ ERROR `std::ops::Range` is forbidden as the type of a const generic parameter +//[min]~^ ERROR `std::ops::Range` is forbidden const RANGE : _Range<{ 0 .. 1000 }> = _Range; // `RangeFrom` should be usable within const generics: struct _RangeFrom>; -//[min]~^ ERROR `std::ops::RangeFrom` is forbidden as the type of a const generic parameter +//[min]~^ ERROR `std::ops::RangeFrom` is forbidden const RANGE_FROM : _RangeFrom<{ 0 .. }> = _RangeFrom; // `RangeFull` should be usable within const generics: struct _RangeFull; -//[min]~^ ERROR `std::ops::RangeFull` is forbidden as the type of a const generic parameter +//[min]~^ ERROR `std::ops::RangeFull` is forbidden const RANGE_FULL : _RangeFull<{ .. }> = _RangeFull; // Regression test for #70155 // `RangeInclusive` should be usable within const generics: struct _RangeInclusive>; -//[min]~^ ERROR `std::ops::RangeInclusive` is forbidden as the type of a const generic -// parameter +//[min]~^ ERROR `std::ops::RangeInclusive` is forbidden const RANGE_INCLUSIVE : _RangeInclusive<{ 0 ..= 999 }> = _RangeInclusive; // `RangeTo` should be usable within const generics: struct _RangeTo>; -//[min]~^ ERROR `std::ops::RangeTo` is forbidden as the type of a const generic parameter +//[min]~^ ERROR `std::ops::RangeTo` is forbidden const RANGE_TO : _RangeTo<{ .. 1000 }> = _RangeTo; // `RangeToInclusive` should be usable within const generics: struct _RangeToInclusive>; -//[min]~^ ERROR `std::ops::RangeToInclusive` is forbidden as the type of a const generic -// parameter +//[min]~^ ERROR `std::ops::RangeToInclusive` is forbidden const RANGE_TO_INCLUSIVE : _RangeToInclusive<{ ..= 999 }> = _RangeToInclusive; pub fn main() {} diff --git a/src/test/ui/const-generics/type-dependent/issue-71382.rs b/src/test/ui/const-generics/type-dependent/issue-71382.rs index eb453cd12aaa..497fd1381de7 100644 --- a/src/test/ui/const-generics/type-dependent/issue-71382.rs +++ b/src/test/ui/const-generics/type-dependent/issue-71382.rs @@ -15,8 +15,7 @@ impl Test { } fn test u8>(&self) -> u8 { - //[full]~^ ERROR using function pointers as const generic parameters is forbidden - //[min]~^^ ERROR using function pointers as const generic parameters is forbidden + //~^ ERROR using function pointers as const generic parameters is forbidden FN() } } diff --git a/src/test/ui/const-generics/type-dependent/type-mismatch.rs b/src/test/ui/const-generics/type-dependent/type-mismatch.rs index 4118cbf13d31..67d80973f039 100644 --- a/src/test/ui/const-generics/type-dependent/type-mismatch.rs +++ b/src/test/ui/const-generics/type-dependent/type-mismatch.rs @@ -10,6 +10,5 @@ impl R { } fn main() { assert_eq!(R.method::<1u16>(), 1); - //[full]~^ ERROR mismatched types - //[min]~^^ ERROR mismatched types + //~^ ERROR mismatched types } diff --git a/src/test/ui/const-generics/types-mismatch-const-args.full.stderr b/src/test/ui/const-generics/types-mismatch-const-args.full.stderr index 175fa3004936..265e9ee618be 100644 --- a/src/test/ui/const-generics/types-mismatch-const-args.full.stderr +++ b/src/test/ui/const-generics/types-mismatch-const-args.full.stderr @@ -8,7 +8,7 @@ LL | let _: A<'a, u32, {2u32}, {3u32}> = A::<'a, u32, {4u32}, {3u32}> { data found type `4_u32` error[E0308]: mismatched types - --> $DIR/types-mismatch-const-args.rs:18:41 + --> $DIR/types-mismatch-const-args.rs:17:41 | LL | let _: A<'a, u16, {2u32}, {3u32}> = A::<'b, u32, {2u32}, {3u32}> { data: PhantomData }; | -------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `u16`, found `u32` diff --git a/src/test/ui/const-generics/types-mismatch-const-args.min.stderr b/src/test/ui/const-generics/types-mismatch-const-args.min.stderr index fa2d1a2597fb..27277f0c0bef 100644 --- a/src/test/ui/const-generics/types-mismatch-const-args.min.stderr +++ b/src/test/ui/const-generics/types-mismatch-const-args.min.stderr @@ -10,7 +10,7 @@ LL | let _: A<'a, u32, {2u32}, {3u32}> = A::<'a, u32, {4u32}, {3u32}> { data found struct `A<'_, _, 4_u32, _>` error[E0308]: mismatched types - --> $DIR/types-mismatch-const-args.rs:18:41 + --> $DIR/types-mismatch-const-args.rs:17:41 | LL | let _: A<'a, u16, {2u32}, {3u32}> = A::<'b, u32, {2u32}, {3u32}> { data: PhantomData }; | -------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `u16`, found `u32` diff --git a/src/test/ui/const-generics/types-mismatch-const-args.rs b/src/test/ui/const-generics/types-mismatch-const-args.rs index de2cf73392a1..34b85304cc4d 100644 --- a/src/test/ui/const-generics/types-mismatch-const-args.rs +++ b/src/test/ui/const-generics/types-mismatch-const-args.rs @@ -13,11 +13,9 @@ struct A<'a, T, const X: u32, const Y: u32> { fn a<'a, 'b>() { let _: A<'a, u32, {2u32}, {3u32}> = A::<'a, u32, {4u32}, {3u32}> { data: PhantomData }; - //[full]~^ ERROR mismatched types - //[min]~^^ ERROR mismatched types + //~^ ERROR mismatched types let _: A<'a, u16, {2u32}, {3u32}> = A::<'b, u32, {2u32}, {3u32}> { data: PhantomData }; - //[full]~^ ERROR mismatched types - //[min]~^^ ERROR mismatched types + //~^ ERROR mismatched types } pub fn main() {}