1
Fork 0

change const param ty warning message

This commit is contained in:
Bastian Kauschke 2020-08-18 22:44:06 +02:00
parent 6ad01e9932
commit 7542615c21
27 changed files with 78 additions and 86 deletions

View file

@ -289,12 +289,14 @@ fn check_param_wf(tcx: TyCtxt<'_>, param: &hir::GenericParam<'_>) {
let ty = tcx.type_of(tcx.hir().local_def_id(param.hir_id)); let ty = tcx.type_of(tcx.hir().local_def_id(param.hir_id));
let err_ty_str; let err_ty_str;
let mut is_ptr = true;
let err = if tcx.features().min_const_generics { let err = if tcx.features().min_const_generics {
match ty.kind { match ty.kind {
ty::Bool | ty::Char | ty::Int(_) | ty::Uint(_) | ty::Error(_) => None, ty::Bool | ty::Char | ty::Int(_) | ty::Uint(_) | ty::Error(_) => None,
ty::FnPtr(_) => Some("function pointers"), ty::FnPtr(_) => Some("function pointers"),
ty::RawPtr(_) => Some("raw pointers"), ty::RawPtr(_) => Some("raw pointers"),
_ => { _ => {
is_ptr = false;
err_ty_str = format!("`{}`", ty); err_ty_str = format!("`{}`", ty);
Some(err_ty_str.as_str()) Some(err_ty_str.as_str())
} }
@ -307,19 +309,29 @@ fn check_param_wf(tcx: TyCtxt<'_>, param: &hir::GenericParam<'_>) {
} }
}; };
if let Some(unsupported_type) = err { if let Some(unsupported_type) = err {
let mut err = tcx.sess.struct_span_err( if is_ptr {
hir_ty.span, tcx.sess.span_err(
&format!("using {} as const generic parameters is forbidden", unsupported_type), hir_ty.span,
); &format!(
"using {} as const generic parameters is forbidden",
if tcx.features().min_const_generics { unsupported_type
err.note("the only supported types are integers, `bool` and `char`") ),
)
} else {
tcx.sess
.struct_span_err(
hir_ty.span,
&format!(
"{} is forbidden as the type of a const generic parameter",
unsupported_type
),
)
.note("the only supported types are integers, `bool` and `char`")
.note("more complex types are supported with `#[feature(const_generics)]`") .note("more complex types are supported with `#[feature(const_generics)]`")
.emit() .emit()
} else {
err.emit();
} }
}; };
if traits::search_for_structural_match_violation(param.hir_id, param.span, tcx, ty) if traits::search_for_structural_match_violation(param.hir_id, param.span, tcx, ty)
.is_some() .is_some()
{ {

View file

@ -14,7 +14,7 @@ LL | arr: [u8; CFG.arr_size],
| |
= help: it is currently only allowed to use either `CFG` or `{ CFG }` as generic constants = help: it is currently only allowed to use either `CFG` or `{ CFG }` as generic constants
error: using `Config` as const generic parameters is forbidden error: `Config` is forbidden as the type of a const generic parameter
--> $DIR/array-size-in-generic-struct-param.rs:18:21 --> $DIR/array-size-in-generic-struct-param.rs:18:21
| |
LL | struct B<const CFG: Config> { LL | struct B<const CFG: Config> {

View file

@ -16,7 +16,7 @@ struct Config {
} }
struct B<const CFG: Config> { struct B<const CFG: Config> {
//[min]~^ ERROR using `Config` as const generic parameters is forbidden //[min]~^ ERROR `Config` is forbidden
arr: [u8; CFG.arr_size], arr: [u8; CFG.arr_size],
//[full]~^ 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 //[min]~^^ ERROR generic parameters must not be used inside of non trivial

View file

@ -28,7 +28,7 @@ error[E0637]: `&` without an explicit lifetime name cannot be used here
LL | fn bar<const N: &u8>() {} LL | fn bar<const N: &u8>() {}
| ^ explicit lifetime name needed here | ^ explicit lifetime name needed here
error: using `&'static u8` as const generic parameters is forbidden error: `&'static u8` is forbidden as the type of a const generic parameter
--> $DIR/const-param-elided-lifetime.rs:11:19 --> $DIR/const-param-elided-lifetime.rs:11:19
| |
LL | struct A<const N: &u8>; LL | struct A<const N: &u8>;
@ -37,7 +37,7 @@ LL | struct A<const N: &u8>;
= note: the only supported types are integers, `bool` and `char` = note: the only supported types are integers, `bool` and `char`
= note: more complex types are supported with `#[feature(const_generics)]` = note: more complex types are supported with `#[feature(const_generics)]`
error: using `&'static u8` as const generic parameters is forbidden error: `&'static u8` is forbidden as the type of a const generic parameter
--> $DIR/const-param-elided-lifetime.rs:16:15 --> $DIR/const-param-elided-lifetime.rs:16:15
| |
LL | impl<const N: &u8> A<N> { LL | impl<const N: &u8> A<N> {
@ -46,7 +46,7 @@ LL | impl<const N: &u8> A<N> {
= note: the only supported types are integers, `bool` and `char` = note: the only supported types are integers, `bool` and `char`
= note: more complex types are supported with `#[feature(const_generics)]` = note: more complex types are supported with `#[feature(const_generics)]`
error: using `&'static u8` as const generic parameters is forbidden error: `&'static u8` is forbidden as the type of a const generic parameter
--> $DIR/const-param-elided-lifetime.rs:24:15 --> $DIR/const-param-elided-lifetime.rs:24:15
| |
LL | impl<const N: &u8> B for A<N> {} LL | impl<const N: &u8> B for A<N> {}
@ -55,7 +55,7 @@ LL | impl<const N: &u8> B for A<N> {}
= note: the only supported types are integers, `bool` and `char` = note: the only supported types are integers, `bool` and `char`
= note: more complex types are supported with `#[feature(const_generics)]` = note: more complex types are supported with `#[feature(const_generics)]`
error: using `&'static u8` as const generic parameters is forbidden error: `&'static u8` is forbidden as the type of a const generic parameter
--> $DIR/const-param-elided-lifetime.rs:28:17 --> $DIR/const-param-elided-lifetime.rs:28:17
| |
LL | fn bar<const N: &u8>() {} LL | fn bar<const N: &u8>() {}
@ -64,7 +64,7 @@ LL | fn bar<const N: &u8>() {}
= note: the only supported types are integers, `bool` and `char` = note: the only supported types are integers, `bool` and `char`
= note: more complex types are supported with `#[feature(const_generics)]` = note: more complex types are supported with `#[feature(const_generics)]`
error: using `&'static u8` as const generic parameters is forbidden error: `&'static u8` is forbidden as the type of a const generic parameter
--> $DIR/const-param-elided-lifetime.rs:19:21 --> $DIR/const-param-elided-lifetime.rs:19:21
| |
LL | fn foo<const M: &u8>(&self) {} LL | fn foo<const M: &u8>(&self) {}

View file

@ -10,23 +10,23 @@
struct A<const N: &u8>; struct A<const N: &u8>;
//~^ ERROR `&` without an explicit lifetime name cannot be used here //~^ ERROR `&` without an explicit lifetime name cannot be used here
//[min]~^^ ERROR using `&'static u8` as const generic parameters is forbidden //[min]~^^ ERROR `&'static u8` is forbidden
trait B {} trait B {}
impl<const N: &u8> A<N> { impl<const N: &u8> A<N> {
//~^ ERROR `&` without an explicit lifetime name cannot be used here //~^ ERROR `&` without an explicit lifetime name cannot be used here
//[min]~^^ ERROR using `&'static u8` as const generic parameters is forbidden //[min]~^^ ERROR `&'static u8` is forbidden
fn foo<const M: &u8>(&self) {} fn foo<const M: &u8>(&self) {}
//~^ ERROR `&` without an explicit lifetime name cannot be used here //~^ ERROR `&` without an explicit lifetime name cannot be used here
//[min]~^^ ERROR using `&'static u8` as const generic parameters is forbidden //[min]~^^ ERROR `&'static u8` is forbidden
} }
impl<const N: &u8> B for A<N> {} impl<const N: &u8> B for A<N> {}
//~^ ERROR `&` without an explicit lifetime name cannot be used here //~^ ERROR `&` without an explicit lifetime name cannot be used here
//[min]~^^ ERROR using `&'static u8` as const generic parameters is forbidden //[min]~^^ ERROR `&'static u8` is forbidden
fn bar<const N: &u8>() {} fn bar<const N: &u8>() {}
//~^ ERROR `&` without an explicit lifetime name cannot be used here //~^ ERROR `&` without an explicit lifetime name cannot be used here
//[min]~^^ ERROR using `&'static u8` as const generic parameters is forbidden //[min]~^^ ERROR `&'static u8` is forbidden
fn main() {} fn main() {}

View file

@ -10,7 +10,7 @@ error[E0770]: the type of const parameters must not depend on other generic para
LL | pub struct SelfDependent<const N: [u8; N]>; LL | pub struct SelfDependent<const N: [u8; N]>;
| ^ the type must not depend on the parameter `N` | ^ the type must not depend on the parameter `N`
error: using `[u8; _]` as const generic parameters is forbidden error: `[u8; _]` is forbidden as the type of a const generic parameter
--> $DIR/const-param-type-depends-on-const-param.rs:12:47 --> $DIR/const-param-type-depends-on-const-param.rs:12:47
| |
LL | pub struct Dependent<const N: usize, const X: [u8; N]>([(); N]); LL | pub struct Dependent<const N: usize, const X: [u8; N]>([(); N]);
@ -19,7 +19,7 @@ LL | pub struct Dependent<const N: usize, const X: [u8; N]>([(); N]);
= note: the only supported types are integers, `bool` and `char` = note: the only supported types are integers, `bool` and `char`
= note: more complex types are supported with `#[feature(const_generics)]` = note: more complex types are supported with `#[feature(const_generics)]`
error: using `[u8; _]` as const generic parameters is forbidden error: `[u8; _]` is forbidden as the type of a const generic parameter
--> $DIR/const-param-type-depends-on-const-param.rs:16:35 --> $DIR/const-param-type-depends-on-const-param.rs:16:35
| |
LL | pub struct SelfDependent<const N: [u8; N]>; LL | pub struct SelfDependent<const N: [u8; N]>;

View file

@ -11,10 +11,10 @@
pub struct Dependent<const N: usize, const X: [u8; N]>([(); N]); pub struct Dependent<const N: usize, const X: [u8; N]>([(); N]);
//~^ ERROR: the type of const parameters must not depend on other generic parameters //~^ ERROR: the type of const parameters must not depend on other generic parameters
//[min]~^^ ERROR using `[u8; _]` as const generic parameters is forbidden //[min]~^^ ERROR `[u8; _]` is forbidden
pub struct SelfDependent<const N: [u8; N]>; pub struct SelfDependent<const N: [u8; N]>;
//~^ ERROR: the type of const parameters must not depend on other generic parameters //~^ ERROR: the type of const parameters must not depend on other generic parameters
//[min]~^^ ERROR using `[u8; _]` as const generic parameters is forbidden //[min]~^^ ERROR `[u8; _]` is forbidden
fn main() {} fn main() {}

View file

@ -1,4 +1,4 @@
error: using `[usize; 1]` as const generic parameters is forbidden error: `[usize; 1]` is forbidden as the type of a const generic parameter
--> $DIR/different_byref.rs:8:23 --> $DIR/different_byref.rs:8:23
| |
LL | struct Const<const V: [usize; 1]> {} LL | struct Const<const V: [usize; 1]> {}

View file

@ -6,7 +6,7 @@
#![cfg_attr(min, feature(min_const_generics))] #![cfg_attr(min, feature(min_const_generics))]
struct Const<const V: [usize; 1]> {} struct Const<const V: [usize; 1]> {}
//[min]~^ using `[usize; 1]` as const generic parameters is forbidden //[min]~^ ERROR `[usize; 1]` is forbidden
fn main() { fn main() {
let mut x = Const::<{ [3] }> {}; let mut x = Const::<{ [3] }> {};

View file

@ -3,18 +3,12 @@ error: using function pointers as const generic parameters is forbidden
| |
LL | struct Wrapper<const F: fn() -> u32>; LL | struct Wrapper<const F: fn() -> u32>;
| ^^^^^^^^^^^ | ^^^^^^^^^^^
|
= note: the only supported types are integers, `bool` and `char`
= note: more complex types are supported with `#[feature(const_generics)]`
error: using function pointers as const generic parameters is forbidden error: using function pointers as const generic parameters is forbidden
--> $DIR/fn-const-param-call.rs:14:15 --> $DIR/fn-const-param-call.rs:14:15
| |
LL | impl<const F: fn() -> u32> Wrapper<F> { LL | impl<const F: fn() -> u32> Wrapper<F> {
| ^^^^^^^^^^^ | ^^^^^^^^^^^
|
= 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 error: aborting due to 2 previous errors

View file

@ -3,9 +3,6 @@ error: using function pointers as const generic parameters is forbidden
| |
LL | struct Checked<const F: fn(usize) -> bool>; LL | struct Checked<const F: fn(usize) -> bool>;
| ^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^
|
= 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 error: aborting due to previous error

View file

@ -1,4 +1,4 @@
error: using `A` as const generic parameters is forbidden error: `A` is forbidden as the type of a const generic parameter
--> $DIR/forbid-non-structural_match-types.rs:10:19 --> $DIR/forbid-non-structural_match-types.rs:10:19
| |
LL | struct B<const X: A>; // ok LL | struct B<const X: A>; // ok
@ -7,7 +7,7 @@ LL | struct B<const X: A>; // ok
= note: the only supported types are integers, `bool` and `char` = note: the only supported types are integers, `bool` and `char`
= note: more complex types are supported with `#[feature(const_generics)]` = note: more complex types are supported with `#[feature(const_generics)]`
error: using `C` as const generic parameters is forbidden error: `C` is forbidden as the type of a const generic parameter
--> $DIR/forbid-non-structural_match-types.rs:15:19 --> $DIR/forbid-non-structural_match-types.rs:15:19
| |
LL | struct D<const X: C>; LL | struct D<const X: C>;

View file

@ -8,11 +8,11 @@
struct A; struct A;
struct B<const X: A>; // ok struct B<const X: A>; // ok
//[min]~^ ERROR using `A` as const generic parameters is forbidden //[min]~^ ERROR `A` is forbidden
struct C; struct C;
struct D<const X: C>; //~ ERROR `C` must be annotated with `#[derive(PartialEq, Eq)]` struct D<const X: C>; //~ ERROR `C` must be annotated with `#[derive(PartialEq, Eq)]`
//[min]~^ ERROR using `C` as const generic parameters is forbidden //[min]~^ ERROR `C` is forbidden
fn main() {} fn main() {}

View file

@ -1,4 +1,4 @@
error: using `&'static str` as const generic parameters is forbidden error: `&'static str` is forbidden as the type of a const generic parameter
--> $DIR/issue-66596-impl-trait-for-str-const-arg.rs:9:25 --> $DIR/issue-66596-impl-trait-for-str-const-arg.rs:9:25
| |
LL | trait Trait<const NAME: &'static str> { LL | trait Trait<const NAME: &'static str> {

View file

@ -7,7 +7,7 @@
trait Trait<const NAME: &'static str> { trait Trait<const NAME: &'static str> {
//[min]~^ ERROR using `&'static str` as const generic parameters is forbidden //[min]~^ ERROR `&'static str` is forbidden
type Assoc; type Assoc;
} }

View file

@ -1,4 +1,4 @@
error: using `Inner` as const generic parameters is forbidden error: `Inner` is forbidden as the type of a const generic parameter
--> $DIR/issue-74950.rs:18:23 --> $DIR/issue-74950.rs:18:23
| |
LL | struct Outer<const I: Inner>; LL | struct Outer<const I: Inner>;
@ -7,7 +7,7 @@ LL | struct Outer<const I: Inner>;
= note: the only supported types are integers, `bool` and `char` = note: the only supported types are integers, `bool` and `char`
= note: more complex types are supported with `#[feature(const_generics)]` = note: more complex types are supported with `#[feature(const_generics)]`
error: using `Inner` as const generic parameters is forbidden error: `Inner` is forbidden as the type of a const generic parameter
--> $DIR/issue-74950.rs:18:23 --> $DIR/issue-74950.rs:18:23
| |
LL | struct Outer<const I: Inner>; LL | struct Outer<const I: Inner>;
@ -16,7 +16,7 @@ LL | struct Outer<const I: Inner>;
= note: the only supported types are integers, `bool` and `char` = note: the only supported types are integers, `bool` and `char`
= note: more complex types are supported with `#[feature(const_generics)]` = note: more complex types are supported with `#[feature(const_generics)]`
error: using `Inner` as const generic parameters is forbidden error: `Inner` is forbidden as the type of a const generic parameter
--> $DIR/issue-74950.rs:18:23 --> $DIR/issue-74950.rs:18:23
| |
LL | struct Outer<const I: Inner>; LL | struct Outer<const I: Inner>;
@ -25,7 +25,7 @@ LL | struct Outer<const I: Inner>;
= note: the only supported types are integers, `bool` and `char` = note: the only supported types are integers, `bool` and `char`
= note: more complex types are supported with `#[feature(const_generics)]` = note: more complex types are supported with `#[feature(const_generics)]`
error: using `Inner` as const generic parameters is forbidden error: `Inner` is forbidden as the type of a const generic parameter
--> $DIR/issue-74950.rs:18:23 --> $DIR/issue-74950.rs:18:23
| |
LL | struct Outer<const I: Inner>; LL | struct Outer<const I: Inner>;
@ -34,7 +34,7 @@ LL | struct Outer<const I: Inner>;
= note: the only supported types are integers, `bool` and `char` = note: the only supported types are integers, `bool` and `char`
= note: more complex types are supported with `#[feature(const_generics)]` = note: more complex types are supported with `#[feature(const_generics)]`
error: using `Inner` as const generic parameters is forbidden error: `Inner` is forbidden as the type of a const generic parameter
--> $DIR/issue-74950.rs:18:23 --> $DIR/issue-74950.rs:18:23
| |
LL | struct Outer<const I: Inner>; LL | struct Outer<const I: Inner>;

View file

@ -16,10 +16,10 @@ struct Inner;
// - impl StructuralEq // - impl StructuralEq
#[derive(PartialEq, Eq)] #[derive(PartialEq, Eq)]
struct Outer<const I: Inner>; struct Outer<const I: Inner>;
//[min]~^ using `Inner` as const generic parameters is forbidden //[min]~^ `Inner` is forbidden
//[min]~| using `Inner` as const generic parameters is forbidden //[min]~| `Inner` is forbidden
//[min]~| using `Inner` as const generic parameters is forbidden //[min]~| `Inner` is forbidden
//[min]~| using `Inner` as const generic parameters is forbidden //[min]~| `Inner` is forbidden
//[min]~| using `Inner` as const generic parameters is forbidden //[min]~| `Inner` is forbidden
fn main() {} fn main() {}

View file

@ -1,18 +1,17 @@
#![feature(min_const_generics)] #![feature(min_const_generics)]
struct Foo<const N: [u8; 0]>; struct Foo<const N: [u8; 0]>;
//~^ ERROR using `[u8; 0]` as const generic parameters is forbidden //~^ ERROR `[u8; 0]` is forbidden
struct Bar<const N: ()>; struct Bar<const N: ()>;
//~^ ERROR using `()` as const generic parameters is forbidden //~^ ERROR `()` is forbidden
#[derive(PartialEq, Eq)] #[derive(PartialEq, Eq)]
struct No; struct No;
struct Fez<const N: No>; struct Fez<const N: No>;
//~^ ERROR using `No` as const generic parameters is forbidden //~^ ERROR `No` is forbidden
struct Faz<const N: &'static u8>; struct Faz<const N: &'static u8>;
//~^ ERROR using `&'static u8` as const generic parameters is forbidden //~^ ERROR `&'static u8` is forbidden
fn main() {} fn main() {}

View file

@ -1,4 +1,4 @@
error: using `[u8; 0]` as const generic parameters is forbidden error: `[u8; 0]` is forbidden as the type of a const generic parameter
--> $DIR/complex-types.rs:3:21 --> $DIR/complex-types.rs:3:21
| |
LL | struct Foo<const N: [u8; 0]>; LL | struct Foo<const N: [u8; 0]>;
@ -7,7 +7,7 @@ LL | struct Foo<const N: [u8; 0]>;
= note: the only supported types are integers, `bool` and `char` = note: the only supported types are integers, `bool` and `char`
= note: more complex types are supported with `#[feature(const_generics)]` = note: more complex types are supported with `#[feature(const_generics)]`
error: using `()` as const generic parameters is forbidden error: `()` is forbidden as the type of a const generic parameter
--> $DIR/complex-types.rs:6:21 --> $DIR/complex-types.rs:6:21
| |
LL | struct Bar<const N: ()>; LL | struct Bar<const N: ()>;
@ -16,8 +16,8 @@ LL | struct Bar<const N: ()>;
= note: the only supported types are integers, `bool` and `char` = note: the only supported types are integers, `bool` and `char`
= note: more complex types are supported with `#[feature(const_generics)]` = note: more complex types are supported with `#[feature(const_generics)]`
error: using `No` as const generic parameters is forbidden error: `No` is forbidden as the type of a const generic parameter
--> $DIR/complex-types.rs:12:21 --> $DIR/complex-types.rs:11:21
| |
LL | struct Fez<const N: No>; LL | struct Fez<const N: No>;
| ^^ | ^^
@ -25,8 +25,8 @@ LL | struct Fez<const N: No>;
= note: the only supported types are integers, `bool` and `char` = note: the only supported types are integers, `bool` and `char`
= note: more complex types are supported with `#[feature(const_generics)]` = note: more complex types are supported with `#[feature(const_generics)]`
error: using `&'static u8` as const generic parameters is forbidden error: `&'static u8` is forbidden as the type of a const generic parameter
--> $DIR/complex-types.rs:15:21 --> $DIR/complex-types.rs:14:21
| |
LL | struct Faz<const N: &'static u8>; LL | struct Faz<const N: &'static u8>;
| ^^^^^^^^^^^ | ^^^^^^^^^^^

View file

@ -1,11 +1,11 @@
error[E0015]: calls in constants are limited to constant functions, tuple structs and tuple variants error[E0015]: calls in constants are limited to constant functions, tuple structs and tuple variants
--> $DIR/nested-type.rs:17:5 --> $DIR/nested-type.rs:16:5
| |
LL | Foo::<17>::value() LL | Foo::<17>::value()
| ^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^
error[E0080]: evaluation of constant value failed error[E0080]: evaluation of constant value failed
--> $DIR/nested-type.rs:17:5 --> $DIR/nested-type.rs:16:5
| |
LL | Foo::<17>::value() LL | Foo::<17>::value()
| ^^^^^^^^^^^^^^^^^^ calling non-const function `Foo::{{constant}}#0::Foo::<17_usize>::value` | ^^^^^^^^^^^^^^^^^^ calling non-const function `Foo::{{constant}}#0::Foo::<17_usize>::value`

View file

@ -1,11 +1,11 @@
error: using `[u8; _]` as const generic parameters is forbidden error: `[u8; _]` is forbidden as the type of a const generic parameter
--> $DIR/nested-type.rs:7:21 --> $DIR/nested-type.rs:7:21
| |
LL | struct Foo<const N: [u8; { LL | struct Foo<const N: [u8; {
| _____________________^ | _____________________^
LL | |
LL | | struct Foo<const N: usize>; LL | | struct Foo<const N: usize>;
LL | | LL | |
LL | | impl<const N: usize> Foo<N> {
... | ... |
LL | | LL | |
LL | | }]>; LL | | }]>;
@ -15,13 +15,13 @@ LL | | }]>;
= note: more complex types are supported with `#[feature(const_generics)]` = note: more complex types are supported with `#[feature(const_generics)]`
error[E0015]: calls in constants are limited to constant functions, tuple structs and tuple variants error[E0015]: calls in constants are limited to constant functions, tuple structs and tuple variants
--> $DIR/nested-type.rs:17:5 --> $DIR/nested-type.rs:16:5
| |
LL | Foo::<17>::value() LL | Foo::<17>::value()
| ^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^
error[E0080]: evaluation of constant value failed error[E0080]: evaluation of constant value failed
--> $DIR/nested-type.rs:17:5 --> $DIR/nested-type.rs:16:5
| |
LL | Foo::<17>::value() LL | Foo::<17>::value()
| ^^^^^^^^^^^^^^^^^^ calling non-const function `Foo::{{constant}}#0::Foo::<17_usize>::value` | ^^^^^^^^^^^^^^^^^^ calling non-const function `Foo::{{constant}}#0::Foo::<17_usize>::value`

View file

@ -4,8 +4,7 @@
#![cfg_attr(full, allow(incomplete_features))] #![cfg_attr(full, allow(incomplete_features))]
#![cfg_attr(min, feature(min_const_generics))] #![cfg_attr(min, feature(min_const_generics))]
struct Foo<const N: [u8; { struct Foo<const N: [u8; { //[min]~ ERROR `[u8; _]` is forbidden
//[min]~^ ERROR using `[u8; _]` as const generic
struct Foo<const N: usize>; struct Foo<const N: usize>;
impl<const N: usize> Foo<N> { impl<const N: usize> Foo<N> {

View file

@ -3,18 +3,12 @@ error: using raw pointers as const generic parameters is forbidden
| |
LL | struct Const<const P: *const u32>; LL | struct Const<const P: *const u32>;
| ^^^^^^^^^^ | ^^^^^^^^^^
|
= note: the only supported types are integers, `bool` and `char`
= note: more complex types are supported with `#[feature(const_generics)]`
error: using raw pointers as const generic parameters is forbidden error: using raw pointers as const generic parameters is forbidden
--> $DIR/raw-ptr-const-param-deref.rs:12:15 --> $DIR/raw-ptr-const-param-deref.rs:12:15
| |
LL | impl<const P: *const u32> Const<P> { LL | impl<const P: *const u32> Const<P> {
| ^^^^^^^^^^ | ^^^^^^^^^^
|
= note: the only supported types are integers, `bool` and `char`
= note: more complex types are supported with `#[feature(const_generics)]`
error: aborting due to 2 previous errors error: aborting due to 2 previous errors

View file

@ -3,9 +3,6 @@ error: using raw pointers as const generic parameters is forbidden
| |
LL | struct Const<const P: *const u32>; LL | struct Const<const P: *const u32>;
| ^^^^^^^^^^ | ^^^^^^^^^^
|
= note: the only supported types are integers, `bool` and `char`
= note: more complex types are supported with `#[feature(const_generics)]`
error: aborting due to previous error error: aborting due to previous error

View file

@ -1,4 +1,4 @@
error: using `&'static str` as const generic parameters is forbidden error: `&'static str` is forbidden as the type of a const generic parameter
--> $DIR/slice-const-param-mismatch.rs:8:29 --> $DIR/slice-const-param-mismatch.rs:8:29
| |
LL | struct ConstString<const T: &'static str>; LL | struct ConstString<const T: &'static str>;
@ -7,7 +7,7 @@ LL | struct ConstString<const T: &'static str>;
= note: the only supported types are integers, `bool` and `char` = note: the only supported types are integers, `bool` and `char`
= note: more complex types are supported with `#[feature(const_generics)]` = note: more complex types are supported with `#[feature(const_generics)]`
error: using `&'static [u8]` as const generic parameters is forbidden error: `&'static [u8]` is forbidden as the type of a const generic parameter
--> $DIR/slice-const-param-mismatch.rs:10:28 --> $DIR/slice-const-param-mismatch.rs:10:28
| |
LL | struct ConstBytes<const T: &'static [u8]>; LL | struct ConstBytes<const T: &'static [u8]>;

View file

@ -1,4 +1,4 @@
error: using `&'static str` as const generic parameters is forbidden error: `&'static str` is forbidden as the type of a const generic parameter
--> $DIR/slice-const-param.rs:8:40 --> $DIR/slice-const-param.rs:8:40
| |
LL | pub fn function_with_str<const STRING: &'static str>() -> &'static str { LL | pub fn function_with_str<const STRING: &'static str>() -> &'static str {
@ -7,7 +7,7 @@ LL | pub fn function_with_str<const STRING: &'static str>() -> &'static str {
= note: the only supported types are integers, `bool` and `char` = note: the only supported types are integers, `bool` and `char`
= note: more complex types are supported with `#[feature(const_generics)]` = note: more complex types are supported with `#[feature(const_generics)]`
error: using `&'static [u8]` as const generic parameters is forbidden error: `&'static [u8]` is forbidden as the type of a const generic parameter
--> $DIR/slice-const-param.rs:13:41 --> $DIR/slice-const-param.rs:13:41
| |
LL | pub fn function_with_bytes<const BYTES: &'static [u8]>() -> &'static [u8] { LL | pub fn function_with_bytes<const BYTES: &'static [u8]>() -> &'static [u8] {

View file

@ -6,12 +6,12 @@
#![cfg_attr(min, feature(min_const_generics))] #![cfg_attr(min, feature(min_const_generics))]
pub fn function_with_str<const STRING: &'static str>() -> &'static str { pub fn function_with_str<const STRING: &'static str>() -> &'static str {
//[min]~^ ERROR using `&'static str` as const //[min]~^ ERROR `&'static str` is forbidden
STRING STRING
} }
pub fn function_with_bytes<const BYTES: &'static [u8]>() -> &'static [u8] { pub fn function_with_bytes<const BYTES: &'static [u8]>() -> &'static [u8] {
//[min]~^ ERROR using `&'static [u8]` as const //[min]~^ ERROR `&'static [u8]` is forbidden
BYTES BYTES
} }