mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-03 20:23:59 +00:00
Added a lot of min_const_generics revisions
This commit is contained in:
parent
bf4342114e
commit
d39cc45cf2
@ -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<const N: usize, 'a, T, 'b, const M: usize, U> {
|
||||
| -----------------^^-----^^-------------------- 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>;
|
||||
| ^^^^^^^
|
30
src/test/ui/const-generics/argument_order.min.stderr
Normal file
30
src/test/ui/const-generics/argument_order.min.stderr
Normal file
@ -0,0 +1,30 @@
|
||||
error: type parameters must be declared prior to const parameters
|
||||
--> $DIR/argument_order.rs:6:28
|
||||
|
|
||||
LL | struct Bad<const N: usize, T> {
|
||||
| -----------------^- help: reorder the parameters: lifetimes, then types, then consts: `<T, const N: usize>`
|
||||
|
||||
error: lifetime parameters must be declared prior to const parameters
|
||||
--> $DIR/argument_order.rs:12:32
|
||||
|
|
||||
LL | struct AlsoBad<const N: usize, 'a, T, 'b, const M: usize, U> {
|
||||
| -----------------^^-----^^-------------------- 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<const N: usize, 'a, T, 'b, const M: usize, U> {
|
||||
| ---------------------^----------------------^- 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`.
|
@ -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<const N: usize, T> {
|
||||
//[min]~^ ERROR type parameters must be declared prior to const parameters
|
||||
arr: [u8; { N }],
|
||||
another: T,
|
||||
}
|
||||
|
||||
struct AlsoBad<const N: usize, 'a, T, 'b, const M: usize, U> {
|
||||
//~^ 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
|
||||
}
|
||||
|
@ -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)]
|
||||
|
||||
|
@ -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 <https://github.com/rust-lang/rust/issues/44580> for more information
|
||||
|
||||
warning: 1 warning emitted
|
||||
|
@ -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.
|
||||
|
@ -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 <https://github.com/rust-lang/rust/issues/44580> for more information
|
||||
|
||||
warning: 1 warning emitted
|
||||
|
@ -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<const N: usize>() -> Array<N, ()> {
|
||||
| ^
|
@ -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<const N: usize>() -> Array<N, ()> {
|
||||
| ^
|
||||
|
|
||||
= note: type arguments must be provided before constant arguments
|
||||
= help: reorder the arguments: types, then consts: `<T, N>`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0747`.
|
@ -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, const N: usize> = [T; N];
|
||||
|
||||
fn foo<const N: usize>() -> Array<N, ()> { //~ ERROR constant provided when a type was expected
|
||||
fn foo<const N: usize>() -> Array<N, ()> {
|
||||
//[full]~^ ERROR constant provided when a type was expected
|
||||
//[min]~^^ ERROR constant provided when a type was expected
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
|
@ -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<const X: (), 'a>(_: &'a ()) {
|
||||
| --------------^^- help: reorder the parameters: lifetimes, then consts and types: `<'a, const X: ()>`
|
@ -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<const X: (), 'a>(_: &'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<const X: (), T>(_: &T) {}
|
||||
| --------------^- help: reorder the parameters: lifetimes, then types, then consts: `<T, const X: ()>`
|
||||
|
||||
error: `()` is forbidden as the type of a const generic parameter
|
||||
--> $DIR/const-param-before-other-params.rs:6:17
|
||||
|
|
||||
LL | fn bar<const X: (), 'a>(_: &'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<const X: (), T>(_: &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
|
||||
|
@ -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<const X: (), 'a>(_: &'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<const X: (), T>(_: &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() {}
|
||||
|
@ -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<Args: Sized, const IDX: usize, const FN: unsafe extern "C" fn(Args)>(&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<Args: Sized, const IDX: usize, const FN: unsafe extern "C" fn(Args)>(&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),
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
27
src/test/ui/const-generics/issues/issue-71381.min.stderr
Normal file
27
src/test/ui/const-generics/issues/issue-71381.min.stderr
Normal file
@ -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<Args: Sized, const IDX: usize, const FN: unsafe extern "C" fn(Args)>(&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<Args: Sized, const IDX: usize, const FN: unsafe extern "C" fn(Args)>(&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`.
|
@ -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<Args: Sized, const IDX: usize, const FN: unsafe extern "C" fn(Args)>(&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::<Args, IDX, FN> 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,
|
||||
) {
|
||||
|
@ -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<const FN: fn()>(&self) {
|
||||
| ^^^^
|
8
src/test/ui/const-generics/issues/issue-71382.min.stderr
Normal file
8
src/test/ui/const-generics/issues/issue-71382.min.stderr
Normal file
@ -0,0 +1,8 @@
|
||||
error: using function pointers as const generic parameters is forbidden
|
||||
--> $DIR/issue-71382.rs:17:23
|
||||
|
|
||||
LL | fn test<const FN: fn()>(&self) {
|
||||
| ^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
@ -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<const FN: fn()>(&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();
|
||||
}
|
||||
}
|
||||
|
@ -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<A, const F: fn(inner: A)>(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<A, const F: fn(inner: A)>(outer: A) {
|
||||
| ^^^^^^^^^^^^
|
15
src/test/ui/const-generics/issues/issue-71611.min.stderr
Normal file
15
src/test/ui/const-generics/issues/issue-71611.min.stderr
Normal file
@ -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<A, const F: fn(inner: A)>(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<A, const F: fn(inner: A)>(outer: A) {
|
||||
| ^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0770`.
|
@ -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<A, const F: fn(inner: A)>(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);
|
||||
}
|
||||
|
||||
|
@ -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<const F: fn(&CStr) -> usize>(ptr: *const i8) -> usize {
|
||||
| ^^^^^^^^^^^^^^^^^^
|
8
src/test/ui/const-generics/issues/issue-72352.min.stderr
Normal file
8
src/test/ui/const-generics/issues/issue-72352.min.stderr
Normal file
@ -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<const F: fn(&CStr) -> usize>(ptr: *const i8) -> usize {
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
@ -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<const F: fn(&CStr) -> 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))
|
||||
}
|
||||
|
||||
|
11
src/test/ui/const-generics/issues/issue-73491.min.stderr
Normal file
11
src/test/ui/const-generics/issues/issue-73491.min.stderr
Normal file
@ -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<const IN: [u32; LEN]>() {}
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
= 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
|
||||
|
@ -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<const IN: [u32; LEN]>() {}
|
||||
//[min]~^ ERROR `[u32; _]` is forbidden as the type of a const generic parameter
|
||||
|
||||
fn main() {}
|
||||
|
@ -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<const X: *const u32>() {}
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
8
src/test/ui/const-generics/issues/issue-73508.min.stderr
Normal file
8
src/test/ui/const-generics/issues/issue-73508.min.stderr
Normal file
@ -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<const X: *const u32>() {}
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
@ -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<const X: *const u32>() {}
|
||||
//~^ ERROR using raw pointers
|
||||
//[full]~^ ERROR using raw pointers
|
||||
//[min]~^^ ERROR using raw pointers as const generic parameters is forbidden
|
||||
|
||||
fn main() {}
|
||||
|
@ -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 <https://github.com/rust-lang/rust/issues/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<const X: *const u32>() {}
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error; 1 warning emitted
|
||||
|
20
src/test/ui/const-generics/issues/issue-74101.min.stderr
Normal file
20
src/test/ui/const-generics/issues/issue-74101.min.stderr
Normal file
@ -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<const N: [u8; 1 + 2]>() {}
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
= 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<const N: [u8; 1 + 2]>;
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
= 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
|
||||
|
@ -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<const N: [u8; 1 + 2]>() {}
|
||||
//[min]~^ ERROR `[u8; _]` is forbidden as the type of a const generic parameter
|
||||
|
||||
struct Foo<const N: [u8; 1 + 2]>;
|
||||
//[min]~^ ERROR `[u8; _]` is forbidden as the type of a const generic parameter
|
||||
|
||||
fn main() {}
|
||||
|
11
src/test/ui/const-generics/issues/issue-74255.min.stderr
Normal file
11
src/test/ui/const-generics/issues/issue-74255.min.stderr
Normal file
@ -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<const I: IceEnum>() {}
|
||||
| ^^^^^^^
|
||||
|
|
||||
= 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
|
||||
|
@ -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<const I: IceEnum>() {}
|
||||
//[min]~^ ERROR `IceEnum` is forbidden as the type of a const generic parameter
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
11
src/test/ui/const-generics/issues/issue-75047.min.stderr
Normal file
11
src/test/ui/const-generics/issues/issue-75047.min.stderr
Normal file
@ -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<const N: [u8; Bar::<u32>::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
|
||||
|
@ -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>(T);
|
||||
|
||||
@ -11,5 +13,6 @@ impl<T> Bar<T> {
|
||||
}
|
||||
|
||||
struct Foo<const N: [u8; Bar::<u32>::value()]>;
|
||||
//[min]~^ ERROR `[u8; _]` is forbidden as the type of a const generic parameter
|
||||
|
||||
fn main() {}
|
||||
|
@ -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<const A: usize> {
|
||||
fn f();
|
||||
|
@ -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 <https://github.com/rust-lang/rust/issues/44580> for more information
|
||||
|
||||
warning: 1 warning emitted
|
||||
|
@ -0,0 +1,56 @@
|
||||
error: `std::ops::Range<usize>` is forbidden as the type of a const generic parameter
|
||||
--> $DIR/const-generics-range.rs:8:24
|
||||
|
|
||||
LL | struct _Range<const R: std::ops::Range<usize>>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= note: more complex types are supported with `#[feature(const_generics)]`
|
||||
|
||||
error: `std::ops::RangeFrom<usize>` is forbidden as the type of a const generic parameter
|
||||
--> $DIR/const-generics-range.rs:13:28
|
||||
|
|
||||
LL | struct _RangeFrom<const R: std::ops::RangeFrom<usize>>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= 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<const R: std::ops::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<usize>` is forbidden as the type of a const generic parameter
|
||||
--> $DIR/const-generics-range.rs:24:33
|
||||
|
|
||||
LL | struct _RangeInclusive<const R: std::ops::RangeInclusive<usize>>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= note: more complex types are supported with `#[feature(const_generics)]`
|
||||
|
||||
error: `std::ops::RangeTo<usize>` is forbidden as the type of a const generic parameter
|
||||
--> $DIR/const-generics-range.rs:29:26
|
||||
|
|
||||
LL | struct _RangeTo<const R: std::ops::RangeTo<usize>>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= note: more complex types are supported with `#[feature(const_generics)]`
|
||||
|
||||
error: `std::ops::RangeToInclusive<usize>` is forbidden as the type of a const generic parameter
|
||||
--> $DIR/const-generics-range.rs:34:35
|
||||
|
|
||||
LL | struct _RangeToInclusive<const R: std::ops::RangeToInclusive<usize>>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= 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
|
||||
|
@ -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<const R: std::ops::Range<usize>>;
|
||||
//[min]~^ ERROR `std::ops::Range<usize>` 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<const R: std::ops::RangeFrom<usize>>;
|
||||
//[min]~^ ERROR `std::ops::RangeFrom<usize>` 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<const R: std::ops::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<const R: std::ops::RangeInclusive<usize>>;
|
||||
//[min]~^ ERROR `std::ops::RangeInclusive<usize>` 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<const R: std::ops::RangeTo<usize>>;
|
||||
//[min]~^ ERROR `std::ops::RangeTo<usize>` 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<const R: std::ops::RangeToInclusive<usize>>;
|
||||
//[min]~^ ERROR `std::ops::RangeToInclusive<usize>` is forbidden as the type of a const generic parameter
|
||||
const RANGE_TO_INCLUSIVE : _RangeToInclusive<{ ..= 999 }> = _RangeToInclusive;
|
||||
|
||||
pub fn main() {}
|
||||
|
@ -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<const N: usize, T>(T);
|
||||
| -----------------^- help: reorder the parameters: lifetimes, then types, then consts: `<T, const N: usize>`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
@ -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<const N: usize, T>(T);
|
||||
//[min]~^ ERROR type parameters must be declared prior to const parameters
|
||||
|
||||
fn main() {}
|
||||
|
@ -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<T: Clone> {
|
||||
fn array_windows<'a, const N: usize>(&'a self) -> ArrayWindows<'a, T, N>;
|
||||
|
@ -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<const A: i32>(&self) -> i32 { A }
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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<const N: usize>;
|
||||
|
||||
|
@ -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<const N: usize>(self) -> [Self::Item; N]
|
||||
|
@ -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<const N: usize>;
|
||||
|
||||
|
@ -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<T> {
|
||||
fn const_chunks_exact<const N: usize>(&self) -> ConstChunksExact<'_, T, {N}>;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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 <Self as Get<N>>::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
|
||||
|
@ -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 <Self as Get<N>>::Target
|
||||
//[min]~^ ERROR `&'static str` is forbidden as the type of a const generic parameter
|
||||
where
|
||||
Self: Get<'a, N>,
|
||||
{
|
||||
|
@ -0,0 +1,8 @@
|
||||
error: using function pointers as const generic parameters is forbidden
|
||||
--> $DIR/issue-71382.rs:17:23
|
||||
|
|
||||
LL | fn test<const FN: fn() -> u8>(&self) -> u8 {
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
@ -0,0 +1,8 @@
|
||||
error: using function pointers as const generic parameters is forbidden
|
||||
--> $DIR/issue-71382.rs:17:23
|
||||
|
|
||||
LL | fn test<const FN: fn() -> u8>(&self) -> u8 {
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
@ -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<const FN: fn() -> 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()
|
||||
}
|
||||
}
|
||||
|
@ -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 <https://github.com/rust-lang/rust/issues/44580> for more information
|
||||
|
||||
error: using function pointers as const generic parameters is forbidden
|
||||
--> $DIR/issue-71382.rs:15:23
|
||||
|
|
||||
LL | fn test<const FN: fn() -> u8>(&self) -> u8 {
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error; 1 warning emitted
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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<Item=A> {
|
||||
fn bar<const N: usize>(&mut self) -> *const [A; N];
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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 {
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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`.
|
@ -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`.
|
@ -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
|
||||
}
|
||||
|
@ -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 <https://github.com/rust-lang/rust/issues/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`.
|
@ -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 <https://github.com/rust-lang/rust/issues/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`.
|
@ -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`.
|
@ -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() {}
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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 <https://github.com/rust-lang/rust/issues/44580> for more information
|
||||
|
||||
warning: 1 warning emitted
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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 <https://github.com/rust-lang/rust/issues/44580> for more information
|
||||
|
||||
warning: 1 warning emitted
|
||||
|
Loading…
Reference in New Issue
Block a user