make adt_const_params feature suggestion more consistent with others and only suggest it when the type can probably work
This commit is contained in:
parent
1393ef1fa0
commit
b53a1b3808
@ -24,6 +24,9 @@ use rustc_span::symbol::{sym, Ident, Symbol};
|
||||
use rustc_span::{Span, DUMMY_SP};
|
||||
use rustc_target::spec::abi::Abi;
|
||||
use rustc_trait_selection::traits::error_reporting::TypeErrCtxtExt;
|
||||
use rustc_trait_selection::traits::misc::{
|
||||
type_allowed_to_implement_const_param_ty, ConstParamTyImplementationError,
|
||||
};
|
||||
use rustc_trait_selection::traits::outlives_bounds::InferCtxtExt as _;
|
||||
use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt as _;
|
||||
use rustc_trait_selection::traits::{
|
||||
@ -865,43 +868,65 @@ fn check_param_wf(tcx: TyCtxt<'_>, param: &hir::GenericParam<'_>) {
|
||||
);
|
||||
});
|
||||
} else {
|
||||
let err_ty_str;
|
||||
let mut is_ptr = true;
|
||||
|
||||
let err = match ty.kind() {
|
||||
let diag = match ty.kind() {
|
||||
ty::Bool | ty::Char | ty::Int(_) | ty::Uint(_) | ty::Error(_) => None,
|
||||
ty::FnPtr(_) => Some("function pointers"),
|
||||
ty::RawPtr(_) => Some("raw pointers"),
|
||||
_ => {
|
||||
is_ptr = false;
|
||||
err_ty_str = format!("`{ty}`");
|
||||
Some(err_ty_str.as_str())
|
||||
}
|
||||
ty::FnPtr(_) => Some(tcx.sess.struct_span_err(
|
||||
hir_ty.span,
|
||||
"using function pointers as const generic parameters is forbidden",
|
||||
)),
|
||||
ty::RawPtr(_) => Some(tcx.sess.struct_span_err(
|
||||
hir_ty.span,
|
||||
"using raw pointers as const generic parameters is forbidden",
|
||||
)),
|
||||
_ => Some(tcx.sess.struct_span_err(
|
||||
hir_ty.span,
|
||||
format!("`{}` is forbidden as the type of a const generic parameter", ty),
|
||||
)),
|
||||
};
|
||||
|
||||
if let Some(unsupported_type) = err {
|
||||
if is_ptr {
|
||||
tcx.sess.span_err(
|
||||
hir_ty.span,
|
||||
format!(
|
||||
"using {unsupported_type} as const generic parameters is forbidden",
|
||||
),
|
||||
);
|
||||
} else {
|
||||
let mut err = tcx.sess.struct_span_err(
|
||||
hir_ty.span,
|
||||
format!(
|
||||
"{unsupported_type} is forbidden as the type of a const generic parameter",
|
||||
),
|
||||
);
|
||||
err.note("the only supported types are integers, `bool` and `char`");
|
||||
if tcx.sess.is_nightly_build() {
|
||||
err.help(
|
||||
"more complex types are supported with `#![feature(adt_const_params)]`",
|
||||
);
|
||||
if let Some(mut diag) = diag {
|
||||
diag.note("the only supported types are integers, `bool` and `char`");
|
||||
|
||||
let cause = ObligationCause::misc(hir_ty.span, param.def_id);
|
||||
let may_suggest_feature = match type_allowed_to_implement_const_param_ty(
|
||||
tcx,
|
||||
tcx.param_env(param.def_id),
|
||||
ty,
|
||||
cause,
|
||||
) {
|
||||
// Can never implement `ConstParamTy`, don't suggest anything.
|
||||
Err(ConstParamTyImplementationError::NotAnAdtOrBuiltinAllowed) => false,
|
||||
// May be able to implement `ConstParamTy`. Only emit the feature help
|
||||
// if the type is local, since the user may be able to fix the local type.
|
||||
Err(ConstParamTyImplementationError::InfrigingFields(..)) => {
|
||||
fn ty_is_local(ty: Ty<'_>) -> bool {
|
||||
match ty.kind() {
|
||||
ty::Adt(adt_def, ..) => adt_def.did().is_local(),
|
||||
// Arrays and slices use the inner type's `ConstParamTy`.
|
||||
ty::Array(ty, ..) => ty_is_local(*ty),
|
||||
ty::Slice(ty) => ty_is_local(*ty),
|
||||
// `&` references use the inner type's `ConstParamTy`.
|
||||
// `&mut` are not supported.
|
||||
ty::Ref(_, ty, ast::Mutability::Not) => ty_is_local(*ty),
|
||||
// Say that a tuple is local if any of its components are local.
|
||||
// This is not strictly correct, but it's likely that the user can fix the local component.
|
||||
ty::Tuple(tys) => tys.iter().any(|ty| ty_is_local(ty)),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
ty_is_local(ty)
|
||||
}
|
||||
err.emit();
|
||||
// Implments `ConstParamTy`, suggest adding the feature to enable.
|
||||
Ok(..) => true,
|
||||
};
|
||||
if may_suggest_feature && tcx.sess.is_nightly_build() {
|
||||
diag.help(
|
||||
"add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types",
|
||||
);
|
||||
}
|
||||
|
||||
diag.emit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,44 @@
|
||||
// Test that when adt_const_params is not enabled, we suggest adding the feature only when
|
||||
// it would be possible for the type to be used as a const generic or when it's likely
|
||||
// possible for the user to fix their type to be used.
|
||||
|
||||
// Can never be used as const generics.
|
||||
fn uwu_0<const N: &'static mut ()>() {}
|
||||
//~^ ERROR: forbidden as the type of a const generic
|
||||
|
||||
// Needs the feature but can be used, so suggest adding the feature.
|
||||
fn owo_0<const N: &'static u32>() {}
|
||||
//~^ ERROR: forbidden as the type of a const generic
|
||||
//~^^ HELP: add `#![feature(adt_const_params)]`
|
||||
|
||||
// Can only be used in const generics with changes.
|
||||
struct Meow {
|
||||
meow: u8,
|
||||
}
|
||||
|
||||
fn meow_0<const N: Meow>() {}
|
||||
//~^ ERROR: forbidden as the type of a const generic
|
||||
//~^^ HELP: add `#![feature(adt_const_params)]`
|
||||
fn meow_1<const N: &'static Meow>() {}
|
||||
//~^ ERROR: forbidden as the type of a const generic
|
||||
//~^^ HELP: add `#![feature(adt_const_params)]`
|
||||
fn meow_2<const N: [Meow; 100]>() {}
|
||||
//~^ ERROR: forbidden as the type of a const generic
|
||||
//~^^ HELP: add `#![feature(adt_const_params)]`
|
||||
fn meow_3<const N: (Meow, u8)>() {}
|
||||
//~^ ERROR: forbidden as the type of a const generic
|
||||
//~^^ HELP: add `#![feature(adt_const_params)]`
|
||||
|
||||
// This is suboptimal that it thinks it can be used
|
||||
// but better to suggest the feature to the user.
|
||||
fn meow_4<const N: (Meow, String)>() {}
|
||||
//~^ ERROR: forbidden as the type of a const generic
|
||||
//~^^ HELP: add `#![feature(adt_const_params)]`
|
||||
|
||||
// Non-local ADT that does not impl `ConstParamTy`
|
||||
fn nya_0<const N: String>() {}
|
||||
//~^ ERROR: forbidden as the type of a const generic
|
||||
fn nya_1<const N: Vec<u32>>() {}
|
||||
//~^ ERROR: forbidden as the type of a const generic
|
||||
|
||||
fn main() {}
|
@ -0,0 +1,80 @@
|
||||
error: `&'static mut ()` is forbidden as the type of a const generic parameter
|
||||
--> $DIR/suggest_feature_only_when_possible.rs:6:19
|
||||
|
|
||||
LL | fn uwu_0<const N: &'static mut ()>() {}
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
|
||||
error: `&'static u32` is forbidden as the type of a const generic parameter
|
||||
--> $DIR/suggest_feature_only_when_possible.rs:10:19
|
||||
|
|
||||
LL | fn owo_0<const N: &'static u32>() {}
|
||||
| ^^^^^^^^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
|
||||
|
||||
error: `Meow` is forbidden as the type of a const generic parameter
|
||||
--> $DIR/suggest_feature_only_when_possible.rs:19:20
|
||||
|
|
||||
LL | fn meow_0<const N: Meow>() {}
|
||||
| ^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
|
||||
|
||||
error: `&'static Meow` is forbidden as the type of a const generic parameter
|
||||
--> $DIR/suggest_feature_only_when_possible.rs:22:20
|
||||
|
|
||||
LL | fn meow_1<const N: &'static Meow>() {}
|
||||
| ^^^^^^^^^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
|
||||
|
||||
error: `[Meow; 100]` is forbidden as the type of a const generic parameter
|
||||
--> $DIR/suggest_feature_only_when_possible.rs:25:20
|
||||
|
|
||||
LL | fn meow_2<const N: [Meow; 100]>() {}
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
|
||||
|
||||
error: `(Meow, u8)` is forbidden as the type of a const generic parameter
|
||||
--> $DIR/suggest_feature_only_when_possible.rs:28:20
|
||||
|
|
||||
LL | fn meow_3<const N: (Meow, u8)>() {}
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
|
||||
|
||||
error: `(Meow, String)` is forbidden as the type of a const generic parameter
|
||||
--> $DIR/suggest_feature_only_when_possible.rs:34:20
|
||||
|
|
||||
LL | fn meow_4<const N: (Meow, String)>() {}
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
|
||||
|
||||
error: `String` is forbidden as the type of a const generic parameter
|
||||
--> $DIR/suggest_feature_only_when_possible.rs:39:19
|
||||
|
|
||||
LL | fn nya_0<const N: String>() {}
|
||||
| ^^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
|
||||
error: `Vec<u32>` is forbidden as the type of a const generic parameter
|
||||
--> $DIR/suggest_feature_only_when_possible.rs:41:19
|
||||
|
|
||||
LL | fn nya_1<const N: Vec<u32>>() {}
|
||||
| ^^^^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
|
||||
error: aborting due to 9 previous errors
|
||||
|
@ -35,7 +35,7 @@ LL | struct A<const N: &u8>;
|
||||
| ^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= help: more complex types are supported with `#![feature(adt_const_params)]`
|
||||
= help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
|
||||
|
||||
error: `&u8` is forbidden as the type of a const generic parameter
|
||||
--> $DIR/const-param-elided-lifetime.rs:14:15
|
||||
@ -44,7 +44,7 @@ LL | impl<const N: &u8> A<N> {
|
||||
| ^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= help: more complex types are supported with `#![feature(adt_const_params)]`
|
||||
= help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
|
||||
|
||||
error: `&u8` is forbidden as the type of a const generic parameter
|
||||
--> $DIR/const-param-elided-lifetime.rs:22:15
|
||||
@ -53,7 +53,7 @@ LL | impl<const N: &u8> B for A<N> {}
|
||||
| ^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= help: more complex types are supported with `#![feature(adt_const_params)]`
|
||||
= help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
|
||||
|
||||
error: `&u8` is forbidden as the type of a const generic parameter
|
||||
--> $DIR/const-param-elided-lifetime.rs:26:17
|
||||
@ -62,7 +62,7 @@ LL | fn bar<const N: &u8>() {}
|
||||
| ^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= help: more complex types are supported with `#![feature(adt_const_params)]`
|
||||
= help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
|
||||
|
||||
error: `&u8` is forbidden as the type of a const generic parameter
|
||||
--> $DIR/const-param-elided-lifetime.rs:17:21
|
||||
@ -71,7 +71,7 @@ LL | fn foo<const M: &u8>(&self) {}
|
||||
| ^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= help: more complex types are supported with `#![feature(adt_const_params)]`
|
||||
= help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
|
||||
|
||||
error: aborting due to 10 previous errors
|
||||
|
||||
|
@ -21,7 +21,7 @@ LL | pub struct Dependent<const N: usize, const X: [u8; N]>([(); N]);
|
||||
| ^^^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= help: more complex types are supported with `#![feature(adt_const_params)]`
|
||||
= help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
|
||||
|
||||
error: `[u8; N]` is forbidden as the type of a const generic parameter
|
||||
--> $DIR/const-param-type-depends-on-const-param.rs:15:35
|
||||
@ -30,7 +30,7 @@ LL | pub struct SelfDependent<const N: [u8; N]>;
|
||||
| ^^^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= help: more complex types are supported with `#![feature(adt_const_params)]`
|
||||
= help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
|
@ -5,7 +5,6 @@ LL | fn foo<const F: f32>() {}
|
||||
| ^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= help: more complex types are supported with `#![feature(adt_const_params)]`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -3,12 +3,16 @@ error: using function pointers as const generic parameters is forbidden
|
||||
|
|
||||
LL | struct Wrapper<const F: fn() -> u32>;
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
|
||||
error: using function pointers as const generic parameters is forbidden
|
||||
--> $DIR/fn-const-param-call.rs:13:15
|
||||
|
|
||||
LL | impl<const F: fn() -> u32> Wrapper<F> {
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
@ -3,6 +3,8 @@ error: using function pointers as const generic parameters is forbidden
|
||||
|
|
||||
LL | struct Checked<const F: fn(usize) -> bool>;
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -23,7 +23,7 @@ LL | struct B<const CFG: Config> {
|
||||
| ^^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= help: more complex types are supported with `#![feature(adt_const_params)]`
|
||||
= help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
|
@ -14,7 +14,7 @@ LL | trait Trait<const S: &'static str> {}
|
||||
| ^^^^^^^^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= help: more complex types are supported with `#![feature(adt_const_params)]`
|
||||
= help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
@ -13,7 +13,7 @@ LL | struct Bug<'a, const S: &'a str>(PhantomData<&'a ()>);
|
||||
| ^^^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= help: more complex types are supported with `#![feature(adt_const_params)]`
|
||||
= help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
@ -13,7 +13,7 @@ LL | fn foo<const N: usize, const A: [u8; N]>() {}
|
||||
| ^^^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= help: more complex types are supported with `#![feature(adt_const_params)]`
|
||||
= help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
@ -5,7 +5,7 @@ LL | fn test<const T: &'static dyn A>() {
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= help: more complex types are supported with `#![feature(adt_const_params)]`
|
||||
= help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -5,7 +5,7 @@ LL | struct Const<const V: [usize; 0]> {}
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= help: more complex types are supported with `#![feature(adt_const_params)]`
|
||||
= help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -5,7 +5,7 @@ LL | struct Foo<const V: [usize; 0] > {}
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= help: more complex types are supported with `#![feature(adt_const_params)]`
|
||||
= help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -13,7 +13,7 @@ LL | fn foo<const LEN: usize, const DATA: [u8; LEN]>() {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= help: more complex types are supported with `#![feature(adt_const_params)]`
|
||||
= help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
@ -19,12 +19,16 @@ error: using function pointers as const generic parameters is forbidden
|
||||
|
|
||||
LL | pub fn call_me<Args: Sized, const IDX: usize, const FN: unsafe extern "C" fn(Args)>(&self) {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
|
||||
error: using function pointers as const generic parameters is forbidden
|
||||
--> $DIR/issue-71381.rs:23:19
|
||||
|
|
||||
LL | const FN: unsafe extern "C" fn(Args),
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
|
@ -3,6 +3,8 @@ error: using function pointers as const generic parameters is forbidden
|
||||
|
|
||||
LL | fn test<const FN: fn()>(&self) {
|
||||
| ^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -11,6 +11,8 @@ error: using function pointers as const generic parameters is forbidden
|
||||
|
|
||||
LL | fn func<A, const F: fn(inner: A)>(outer: A) {
|
||||
| ^^^^^^^^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
@ -3,6 +3,8 @@ error: using function pointers as const generic parameters is forbidden
|
||||
|
|
||||
LL | unsafe fn unsafely_do_the_thing<const F: fn(&CStr) -> usize>(ptr: *const i8) -> usize {
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -5,7 +5,7 @@ LL | fn hoge<const IN: [u32; LEN]>() {}
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= help: more complex types are supported with `#![feature(adt_const_params)]`
|
||||
= help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -5,7 +5,7 @@ LL | fn a<const X: &'static [u32]>() {}
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= help: more complex types are supported with `#![feature(adt_const_params)]`
|
||||
= help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -5,7 +5,7 @@ LL | fn test<const N: [u8; 1 + 2]>() {}
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= help: more complex types are supported with `#![feature(adt_const_params)]`
|
||||
= help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
|
||||
|
||||
error: `[u8; 1 + 2]` is forbidden as the type of a const generic parameter
|
||||
--> $DIR/issue-74101.rs:9:21
|
||||
@ -14,7 +14,7 @@ LL | struct Foo<const N: [u8; 1 + 2]>;
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= help: more complex types are supported with `#![feature(adt_const_params)]`
|
||||
= help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
@ -5,7 +5,7 @@ LL | fn ice_struct_fn<const I: IceEnum>() {}
|
||||
| ^^^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= help: more complex types are supported with `#![feature(adt_const_params)]`
|
||||
= help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -5,7 +5,7 @@ LL | struct Outer<const I: Inner>;
|
||||
| ^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= help: more complex types are supported with `#![feature(adt_const_params)]`
|
||||
= help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
|
||||
|
||||
error: `Inner` is forbidden as the type of a const generic parameter
|
||||
--> $DIR/issue-74950.rs:20:23
|
||||
@ -14,7 +14,7 @@ LL | struct Outer<const I: Inner>;
|
||||
| ^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= help: more complex types are supported with `#![feature(adt_const_params)]`
|
||||
= help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
|
||||
|
||||
error: `Inner` is forbidden as the type of a const generic parameter
|
||||
--> $DIR/issue-74950.rs:20:23
|
||||
@ -23,7 +23,7 @@ LL | struct Outer<const I: Inner>;
|
||||
| ^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= help: more complex types are supported with `#![feature(adt_const_params)]`
|
||||
= help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
|
||||
|
||||
error: `Inner` is forbidden as the type of a const generic parameter
|
||||
--> $DIR/issue-74950.rs:20:23
|
||||
@ -32,7 +32,7 @@ LL | struct Outer<const I: Inner>;
|
||||
| ^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= help: more complex types are supported with `#![feature(adt_const_params)]`
|
||||
= help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
|
||||
|
||||
error: `Inner` is forbidden as the type of a const generic parameter
|
||||
--> $DIR/issue-74950.rs:20:23
|
||||
@ -41,7 +41,7 @@ LL | struct Outer<const I: Inner>;
|
||||
| ^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= help: more complex types are supported with `#![feature(adt_const_params)]`
|
||||
= help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
|
||||
|
@ -5,7 +5,7 @@ LL | struct Foo<const N: [u8; Bar::<u32>::value()]>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= help: more complex types are supported with `#![feature(adt_const_params)]`
|
||||
= help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -11,7 +11,7 @@ LL | struct S<'a, const N: S2>(&'a ());
|
||||
| ^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= help: more complex types are supported with `#![feature(adt_const_params)]`
|
||||
= help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
@ -5,7 +5,7 @@ LL | struct Foo<const N: [u8; 0]>;
|
||||
| ^^^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= help: more complex types are supported with `#![feature(adt_const_params)]`
|
||||
= help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
|
||||
|
||||
error: `()` is forbidden as the type of a const generic parameter
|
||||
--> $DIR/complex-types.rs:6:21
|
||||
@ -14,7 +14,7 @@ LL | struct Bar<const N: ()>;
|
||||
| ^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= help: more complex types are supported with `#![feature(adt_const_params)]`
|
||||
= help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
|
||||
|
||||
error: `No` is forbidden as the type of a const generic parameter
|
||||
--> $DIR/complex-types.rs:11:21
|
||||
@ -23,7 +23,7 @@ LL | struct Fez<const N: No>;
|
||||
| ^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= help: more complex types are supported with `#![feature(adt_const_params)]`
|
||||
= help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
|
||||
|
||||
error: `&'static u8` is forbidden as the type of a const generic parameter
|
||||
--> $DIR/complex-types.rs:14:21
|
||||
@ -32,7 +32,7 @@ LL | struct Faz<const N: &'static u8>;
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= help: more complex types are supported with `#![feature(adt_const_params)]`
|
||||
= help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
|
||||
|
||||
error: `!` is forbidden as the type of a const generic parameter
|
||||
--> $DIR/complex-types.rs:17:21
|
||||
@ -41,7 +41,6 @@ LL | struct Fiz<const N: !>;
|
||||
| ^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= help: more complex types are supported with `#![feature(adt_const_params)]`
|
||||
|
||||
error: `()` is forbidden as the type of a const generic parameter
|
||||
--> $DIR/complex-types.rs:20:19
|
||||
@ -50,7 +49,7 @@ LL | enum Goo<const N: ()> { A, B }
|
||||
| ^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= help: more complex types are supported with `#![feature(adt_const_params)]`
|
||||
= help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
|
||||
|
||||
error: `()` is forbidden as the type of a const generic parameter
|
||||
--> $DIR/complex-types.rs:23:20
|
||||
@ -59,7 +58,7 @@ LL | union Boo<const N: ()> { a: () }
|
||||
| ^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= help: more complex types are supported with `#![feature(adt_const_params)]`
|
||||
= help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
|
||||
|
||||
error: aborting due to 7 previous errors
|
||||
|
||||
|
@ -30,7 +30,7 @@ LL | | }]>;
|
||||
| |__^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= help: more complex types are supported with `#![feature(adt_const_params)]`
|
||||
= help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
@ -5,7 +5,6 @@ LL | pub fn foo<const X: <i32 as Identity>::Identity>() {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= help: more complex types are supported with `#![feature(adt_const_params)]`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -3,12 +3,16 @@ error: using raw pointers as const generic parameters is forbidden
|
||||
|
|
||||
LL | struct Const<const P: *const u32>;
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
|
||||
error: using raw pointers as const generic parameters is forbidden
|
||||
--> $DIR/raw-ptr-const-param-deref.rs:11:15
|
||||
|
|
||||
LL | impl<const P: *const u32> Const<P> {
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
@ -3,6 +3,8 @@ error: using raw pointers as const generic parameters is forbidden
|
||||
|
|
||||
LL | struct Const<const P: *const u32>;
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -5,7 +5,7 @@ LL | struct ConstString<const T: &'static str>;
|
||||
| ^^^^^^^^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= help: more complex types are supported with `#![feature(adt_const_params)]`
|
||||
= help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
|
||||
|
||||
error: `&'static [u8]` is forbidden as the type of a const generic parameter
|
||||
--> $DIR/slice-const-param-mismatch.rs:9:28
|
||||
@ -14,7 +14,7 @@ LL | struct ConstBytes<const T: &'static [u8]>;
|
||||
| ^^^^^^^^^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= help: more complex types are supported with `#![feature(adt_const_params)]`
|
||||
= help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
@ -5,7 +5,7 @@ LL | struct _Range<const R: std::ops::Range<usize>>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= help: more complex types are supported with `#![feature(adt_const_params)]`
|
||||
= help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
|
||||
|
||||
error: `RangeFrom<usize>` is forbidden as the type of a const generic parameter
|
||||
--> $DIR/const-generics-range.rs:13:28
|
||||
@ -14,7 +14,7 @@ LL | struct _RangeFrom<const R: std::ops::RangeFrom<usize>>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= help: more complex types are supported with `#![feature(adt_const_params)]`
|
||||
= help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
|
||||
|
||||
error: `RangeFull` is forbidden as the type of a const generic parameter
|
||||
--> $DIR/const-generics-range.rs:18:28
|
||||
@ -23,7 +23,7 @@ LL | struct _RangeFull<const R: std::ops::RangeFull>;
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= help: more complex types are supported with `#![feature(adt_const_params)]`
|
||||
= help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
|
||||
|
||||
error: `RangeInclusive<usize>` is forbidden as the type of a const generic parameter
|
||||
--> $DIR/const-generics-range.rs:24:33
|
||||
@ -32,7 +32,7 @@ LL | struct _RangeInclusive<const R: std::ops::RangeInclusive<usize>>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= help: more complex types are supported with `#![feature(adt_const_params)]`
|
||||
= help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
|
||||
|
||||
error: `RangeTo<usize>` is forbidden as the type of a const generic parameter
|
||||
--> $DIR/const-generics-range.rs:29:26
|
||||
@ -41,7 +41,7 @@ LL | struct _RangeTo<const R: std::ops::RangeTo<usize>>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= help: more complex types are supported with `#![feature(adt_const_params)]`
|
||||
= help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
|
||||
|
||||
error: `RangeToInclusive<usize>` is forbidden as the type of a const generic parameter
|
||||
--> $DIR/const-generics-range.rs:34:35
|
||||
@ -50,7 +50,7 @@ LL | struct _RangeToInclusive<const R: std::ops::RangeToInclusive<usize>>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= help: more complex types are supported with `#![feature(adt_const_params)]`
|
||||
= help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
|
||||
|
||||
error: aborting due to 6 previous errors
|
||||
|
||||
|
@ -5,7 +5,7 @@ LL | struct Const<const P: &'static ()>;
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= help: more complex types are supported with `#![feature(adt_const_params)]`
|
||||
= help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -5,7 +5,7 @@ LL | trait Get<'a, const N: &'static str> {
|
||||
| ^^^^^^^^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= help: more complex types are supported with `#![feature(adt_const_params)]`
|
||||
= help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
|
||||
|
||||
error: `&'static str` is forbidden as the type of a const generic parameter
|
||||
--> $DIR/issue-71348.rs:18:25
|
||||
@ -14,7 +14,7 @@ LL | fn ask<'a, const N: &'static str>(&'a self) -> &'a <Self as Get<N>>::Ta
|
||||
| ^^^^^^^^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= help: more complex types are supported with `#![feature(adt_const_params)]`
|
||||
= help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
@ -3,6 +3,8 @@ error: using function pointers as const generic parameters is forbidden
|
||||
|
|
||||
LL | fn test<const FN: fn() -> u8>(&self) -> u8 {
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -5,7 +5,7 @@ LL | struct Foo<const NAME: &'static str>;
|
||||
| ^^^^^^^^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= help: more complex types are supported with `#![feature(adt_const_params)]`
|
||||
= help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -28,7 +28,7 @@ LL | const I<const S: &str>: &str = "";
|
||||
| ^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= help: more complex types are supported with `#![feature(adt_const_params)]`
|
||||
= help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
|
@ -56,7 +56,7 @@ LL | fn d<const C: S>() {}
|
||||
| ^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= help: more complex types are supported with `#![feature(adt_const_params)]`
|
||||
= help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
|
||||
|
||||
error: `&dyn for<'a> Foo<'a>` is forbidden as the type of a const generic parameter
|
||||
--> $DIR/unusual-rib-combinations.rs:29:21
|
||||
@ -65,7 +65,7 @@ LL | struct Bar<const N: &'a (dyn for<'a> Foo<'a>)>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= help: more complex types are supported with `#![feature(adt_const_params)]`
|
||||
= help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
|
||||
|
||||
error: aborting due to 9 previous errors
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user