Split part of adt_const_params into unsized_const_params

This commit is contained in:
Boxy 2024-07-14 13:38:51 +01:00 committed by Boxy
parent 42cc42b942
commit d0c11bf6e3
140 changed files with 1130 additions and 559 deletions

View File

@ -38,7 +38,44 @@ pub(crate) fn expand_deriving_const_param_ty(
) {
let trait_def = TraitDef {
span,
path: path_std!(marker::ConstParamTy),
path: path_std!(marker::ConstParamTy_),
skip_path_as_bound: false,
needs_copy_as_bound_if_packed: false,
additional_bounds: vec![ty::Ty::Path(path_std!(cmp::Eq))],
supports_unions: false,
methods: Vec::new(),
associated_types: Vec::new(),
is_const,
};
trait_def.expand(cx, mitem, item, push);
let trait_def = TraitDef {
span,
path: path_std!(marker::UnsizedConstParamTy),
skip_path_as_bound: false,
needs_copy_as_bound_if_packed: false,
additional_bounds: vec![ty::Ty::Path(path_std!(cmp::Eq))],
supports_unions: false,
methods: Vec::new(),
associated_types: Vec::new(),
is_const,
};
trait_def.expand(cx, mitem, item, push);
}
pub(crate) fn expand_deriving_unsized_const_param_ty(
cx: &ExtCtxt<'_>,
span: Span,
mitem: &MetaItem,
item: &Annotatable,
push: &mut dyn FnMut(Annotatable),
is_const: bool,
) {
let trait_def = TraitDef {
span,
path: path_std!(marker::UnsizedConstParamTy),
skip_path_as_bound: false,
needs_copy_as_bound_if_packed: false,
additional_bounds: vec![ty::Ty::Path(path_std!(cmp::Eq))],

View File

@ -118,6 +118,7 @@ pub fn register_builtin_macros(resolver: &mut dyn ResolverExpand) {
Clone: clone::expand_deriving_clone,
Copy: bounds::expand_deriving_copy,
ConstParamTy: bounds::expand_deriving_const_param_ty,
UnsizedConstParamTy: bounds::expand_deriving_unsized_const_param_ty,
Debug: debug::expand_deriving_debug,
Default: default::expand_deriving_default,
Eq: eq::expand_deriving_eq,

View File

@ -6,7 +6,7 @@ allowed.
Erroneous code example:
```compile_fail,E0770
#![feature(adt_const_params)]
#![feature(adt_const_params, unsized_const_params)]
fn function_with_str<'a, const STRING: &'a str>() {} // error!
```
@ -15,7 +15,7 @@ To fix this issue, the lifetime in the const generic need to be changed to
`'static`:
```
#![feature(adt_const_params)]
#![feature(adt_const_params, unsized_const_params)]
fn function_with_str<const STRING: &'static str>() {} // ok!
```

View File

@ -630,6 +630,9 @@ pub fn internal(&self, feature: Symbol) -> bool {
(unstable, unsafe_attributes, "1.80.0", Some(123757)),
/// Allows unsafe on extern declarations and safety qualifiers over internal items.
(unstable, unsafe_extern_blocks, "1.80.0", Some(123743)),
/// Allows const generic parameters to be defined with types that
/// are not `Sized`, e.g. `fn foo<const N: [u8]>() {`.
(incomplete, unsized_const_params, "CURRENT_RUSTC_VERSION", Some(95174)),
/// Allows unsized fn parameters.
(internal, unsized_fn_params, "1.49.0", Some(48055)),
/// Allows unsized rvalues at arguments and parameters.

View File

@ -358,6 +358,7 @@ pub fn extract(attrs: &[ast::Attribute]) -> Option<(Symbol, Span)> {
PointerLike, sym::pointer_like, pointer_like, Target::Trait, GenericRequirement::Exact(0);
ConstParamTy, sym::const_param_ty, const_param_ty_trait, Target::Trait, GenericRequirement::Exact(0);
UnsizedConstParamTy, sym::unsized_const_param_ty, unsized_const_param_ty_trait, Target::Trait, GenericRequirement::Exact(0);
Poll, sym::Poll, poll, Target::Enum, GenericRequirement::None;
PollReady, sym::Ready, poll_ready_variant, Target::Variant, GenericRequirement::None;

View File

@ -78,14 +78,14 @@ hir_analysis_const_impl_for_non_const_trait =
.note = marking a trait with `#[const_trait]` ensures all default method bodies are `const`
.adding = adding a non-const method body in the future would be a breaking change
hir_analysis_const_param_ty_impl_on_unsized =
the trait `ConstParamTy` may not be implemented for this type
.label = type is not `Sized`
hir_analysis_const_param_ty_impl_on_non_adt =
the trait `ConstParamTy` may not be implemented for this type
.label = type is not a structure or enumeration
hir_analysis_const_param_ty_impl_on_unsized =
the trait `ConstParamTy` may not be implemented for this type
.label = type is not `Sized`
hir_analysis_const_specialize = cannot specialize on const impl with non-const impl
hir_analysis_copy_impl_on_non_adt =

View File

@ -922,7 +922,21 @@ fn check_param_wf(tcx: TyCtxt<'_>, param: &hir::GenericParam<'_>) -> Result<(),
} => {
let ty = tcx.type_of(param.def_id).instantiate_identity();
if tcx.features().adt_const_params {
if tcx.features().unsized_const_params {
enter_wf_checking_ctxt(tcx, hir_ty.span, param.def_id, |wfcx| {
wfcx.register_bound(
ObligationCause::new(
hir_ty.span,
param.def_id,
ObligationCauseCode::ConstParam(ty),
),
wfcx.param_env,
ty,
tcx.require_lang_item(LangItem::UnsizedConstParamTy, Some(hir_ty.span)),
);
Ok(())
})
} else if tcx.features().adt_const_params {
enter_wf_checking_ctxt(tcx, hir_ty.span, param.def_id, |wfcx| {
wfcx.register_bound(
ObligationCause::new(
@ -934,12 +948,6 @@ fn check_param_wf(tcx: TyCtxt<'_>, param: &hir::GenericParam<'_>) -> Result<(),
ty,
tcx.require_lang_item(LangItem::ConstParamTy, Some(hir_ty.span)),
);
wfcx.register_bound(
ObligationCause::new(hir_ty.span, param.def_id, ObligationCauseCode::Misc),
wfcx.param_env,
ty,
tcx.require_lang_item(LangItem::Sized, Some(hir_ty.span)),
);
Ok(())
})
} else {
@ -962,18 +970,29 @@ fn check_param_wf(tcx: TyCtxt<'_>, param: &hir::GenericParam<'_>) -> Result<(),
diag.note("the only supported types are integers, `bool` and `char`");
let cause = ObligationCause::misc(hir_ty.span, param.def_id);
let adt_const_params_feature_string =
" more complex and user defined types".to_string();
let may_suggest_feature = match type_allowed_to_implement_const_param_ty(
tcx,
tcx.param_env(param.def_id),
ty,
LangItem::ConstParamTy,
cause,
) {
// Can never implement `ConstParamTy`, don't suggest anything.
Err(
ConstParamTyImplementationError::NotAnAdtOrBuiltinAllowed
| ConstParamTyImplementationError::InvalidInnerTyOfBuiltinTy(..)
| ConstParamTyImplementationError::TypeNotSized,
) => false,
| ConstParamTyImplementationError::InvalidInnerTyOfBuiltinTy(..),
) => None,
Err(ConstParamTyImplementationError::UnsizedConstParamsFeatureRequired) => {
Some(vec![
(adt_const_params_feature_string, sym::adt_const_params),
(
" references to implement the `ConstParamTy` trait".into(),
sym::unsized_const_params,
),
])
}
// 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(..)) => {
@ -993,20 +1012,16 @@ fn ty_is_local(ty: Ty<'_>) -> bool {
}
}
ty_is_local(ty)
ty_is_local(ty).then_some(vec![(
adt_const_params_feature_string,
sym::adt_const_params,
)])
}
// Implments `ConstParamTy`, suggest adding the feature to enable.
Ok(..) => true,
Ok(..) => Some(vec![(adt_const_params_feature_string, sym::adt_const_params)]),
};
if may_suggest_feature {
tcx.disabled_nightly_features(
&mut diag,
Some(param.hir_id),
[(
" more complex and user defined types".to_string(),
sym::adt_const_params,
)],
);
if let Some(features) = may_suggest_feature {
tcx.disabled_nightly_features(&mut diag, Some(param.hir_id), features);
}
Err(diag.emit())

View File

@ -36,9 +36,13 @@ pub(super) fn check_trait<'tcx>(
let checker = Checker { tcx, trait_def_id, impl_def_id, impl_header };
let mut res = checker.check(lang_items.drop_trait(), visit_implementation_of_drop);
res = res.and(checker.check(lang_items.copy_trait(), visit_implementation_of_copy));
res = res.and(
checker.check(lang_items.const_param_ty_trait(), visit_implementation_of_const_param_ty),
);
res = res.and(checker.check(lang_items.const_param_ty_trait(), |checker| {
visit_implementation_of_const_param_ty(checker, LangItem::ConstParamTy)
}));
res = res.and(checker.check(lang_items.unsized_const_param_ty_trait(), |checker| {
visit_implementation_of_const_param_ty(checker, LangItem::UnsizedConstParamTy)
}));
res = res.and(
checker.check(lang_items.coerce_unsized_trait(), visit_implementation_of_coerce_unsized),
);
@ -122,7 +126,12 @@ fn visit_implementation_of_copy(checker: &Checker<'_>) -> Result<(), ErrorGuaran
}
}
fn visit_implementation_of_const_param_ty(checker: &Checker<'_>) -> Result<(), ErrorGuaranteed> {
fn visit_implementation_of_const_param_ty(
checker: &Checker<'_>,
kind: LangItem,
) -> Result<(), ErrorGuaranteed> {
assert!(matches!(kind, LangItem::ConstParamTy | LangItem::UnsizedConstParamTy));
let tcx = checker.tcx;
let header = checker.impl_header;
let impl_did = checker.impl_def_id;
@ -136,7 +145,7 @@ fn visit_implementation_of_const_param_ty(checker: &Checker<'_>) -> Result<(), E
}
let cause = traits::ObligationCause::misc(DUMMY_SP, impl_did);
match type_allowed_to_implement_const_param_ty(tcx, param_env, self_type, cause) {
match type_allowed_to_implement_const_param_ty(tcx, param_env, self_type, kind, cause) {
Ok(()) => Ok(()),
Err(ConstParamTyImplementationError::InfrigingFields(fields)) => {
let span = tcx.hir().expect_item(impl_did).expect_impl().self_ty.span;
@ -162,7 +171,7 @@ fn visit_implementation_of_const_param_ty(checker: &Checker<'_>) -> Result<(), E
span,
))
}
Err(ConstParamTyImplementationError::TypeNotSized) => {
Err(ConstParamTyImplementationError::UnsizedConstParamsFeatureRequired) => {
let span = tcx.hir().expect_item(impl_did).expect_impl().self_ty.span;
Err(tcx.dcx().emit_err(errors::ConstParamTyImplOnUnsized { span }))
}

View File

@ -177,6 +177,7 @@
CoerceUnsized,
Command,
ConstParamTy,
ConstParamTy_,
Context,
Continue,
Copy,
@ -336,6 +337,7 @@
TyKind,
Unknown,
Unsize,
UnsizedConstParamTy,
Upvars,
Vec,
VecDeque,
@ -2000,6 +2002,8 @@
unsafe_no_drop_flag,
unsafe_pin_internals,
unsize,
unsized_const_param_ty,
unsized_const_params,
unsized_fn_params,
unsized_locals,
unsized_tuple_coercion,

View File

@ -4,6 +4,7 @@
use crate::traits::{self, FulfillmentError, ObligationCause};
use hir::LangItem;
use rustc_ast::Mutability;
use rustc_data_structures::fx::FxIndexSet;
use rustc_hir as hir;
use rustc_infer::infer::outlives::env::OutlivesEnvironment;
@ -19,7 +20,7 @@ pub enum CopyImplementationError<'tcx> {
}
pub enum ConstParamTyImplementationError<'tcx> {
TypeNotSized,
UnsizedConstParamsFeatureRequired,
InvalidInnerTyOfBuiltinTy(Vec<(Ty<'tcx>, InfringingFieldsReason<'tcx>)>),
InfrigingFields(Vec<(&'tcx ty::FieldDef, Ty<'tcx>, InfringingFieldsReason<'tcx>)>),
NotAnAdtOrBuiltinAllowed,
@ -79,9 +80,9 @@ pub fn type_allowed_to_implement_copy<'tcx>(
Ok(())
}
/// Checks that the fields of the type (an ADT) all implement `ConstParamTy`.
/// Checks that the fields of the type (an ADT) all implement `(Unsized?)ConstParamTy`.
///
/// If fields don't implement `ConstParamTy`, return an error containing a list of
/// If fields don't implement `(Unsized?)ConstParamTy`, return an error containing a list of
/// those violating fields.
///
/// If it's not an ADT, int ty, `bool` or `char`, returns `Err(NotAnAdtOrBuiltinAllowed)`.
@ -89,30 +90,10 @@ pub fn type_allowed_to_implement_const_param_ty<'tcx>(
tcx: TyCtxt<'tcx>,
param_env: ty::ParamEnv<'tcx>,
self_type: Ty<'tcx>,
lang_item: LangItem,
parent_cause: ObligationCause<'tcx>,
) -> Result<(), ConstParamTyImplementationError<'tcx>> {
{
// Check for sizedness before recursing into ADT fields so that if someone tries to write:
// ```rust
// #[derive(ConstParamTy)]
// struct Foo([u8])
// ```
// They are told that const parameter types must be sized, instead of it saying that
// the trait implementation `[u8]: ConstParamTy` is not satisfied.
let infcx = tcx.infer_ctxt().build();
let ocx = traits::ObligationCtxt::new_with_diagnostics(&infcx);
ocx.register_bound(
parent_cause.clone(),
param_env,
self_type,
tcx.require_lang_item(LangItem::Sized, Some(parent_cause.span)),
);
if !ocx.select_all_or_error().is_empty() {
return Err(ConstParamTyImplementationError::TypeNotSized);
}
};
assert!(matches!(lang_item, LangItem::ConstParamTy | LangItem::UnsizedConstParamTy));
let inner_tys: Vec<_> = match *self_type.kind() {
// Trivially okay as these types are all:
@ -121,14 +102,23 @@ pub fn type_allowed_to_implement_const_param_ty<'tcx>(
// - Have structural equality
ty::Uint(_) | ty::Int(_) | ty::Bool | ty::Char => return Ok(()),
ty::Ref(..) => return Err(ConstParamTyImplementationError::NotAnAdtOrBuiltinAllowed),
// Handle types gated under `feature(unsized_const_params)`
// FIXME(unsized_const_params): Make `const N: [u8]` work then forbid references
ty::Slice(inner_ty) | ty::Ref(_, inner_ty, Mutability::Not)
if lang_item == LangItem::UnsizedConstParamTy =>
{
vec![inner_ty]
}
ty::Str if lang_item == LangItem::UnsizedConstParamTy => {
vec![Ty::new_slice(tcx, tcx.types.u8)]
}
ty::Str | ty::Slice(..) | ty::Ref(_, _, Mutability::Not) => {
return Err(ConstParamTyImplementationError::UnsizedConstParamsFeatureRequired);
}
ty::Array(inner_ty, _) => vec![inner_ty],
// Even if we currently require const params to be `Sized` we may aswell handle them correctly
// here anyway.
ty::Slice(inner_ty) | ty::Array(inner_ty, _) => vec![inner_ty],
// `str` morally acts like a newtype around `[u8]`
ty::Str => vec![Ty::new_slice(tcx, tcx.types.u8)],
ty::Tuple(inner_tys) => inner_tys.into_iter().collect(),
ty::Adt(adt, args) if adt.is_enum() || adt.is_struct() => {
@ -139,7 +129,7 @@ pub fn type_allowed_to_implement_const_param_ty<'tcx>(
adt,
args,
parent_cause.clone(),
hir::LangItem::ConstParamTy,
lang_item,
)
.map_err(ConstParamTyImplementationError::InfrigingFields)?;
@ -159,7 +149,7 @@ pub fn type_allowed_to_implement_const_param_ty<'tcx>(
parent_cause.clone(),
param_env,
inner_ty,
tcx.require_lang_item(LangItem::ConstParamTy, Some(parent_cause.span)),
tcx.require_lang_item(lang_item, Some(parent_cause.span)),
);
let errors = ocx.select_all_or_error();

View File

@ -248,6 +248,7 @@
#![feature(transparent_unions)]
#![feature(try_blocks)]
#![feature(unboxed_closures)]
#![feature(unsized_const_params)]
#![feature(unsized_fn_params)]
#![feature(with_negative_coherence)]
// tidy-alphabetical-end

View File

@ -975,41 +975,74 @@ pub trait PointerLike {}
/// that all fields are also `ConstParamTy`, which implies that recursively, all fields
/// are `StructuralPartialEq`.
#[lang = "const_param_ty"]
#[unstable(feature = "adt_const_params", issue = "95174")]
#[unstable(feature = "unsized_const_params", issue = "95174")]
#[diagnostic::on_unimplemented(message = "`{Self}` can't be used as a const parameter type")]
#[allow(multiple_supertrait_upcastable)]
pub trait ConstParamTy: StructuralPartialEq + Eq {}
// We name this differently than the derive macro so that the `adt_const_params` can
// be used independently of `unsized_const_params` without requiring a full path
// to the derive macro every time it is used. This should be renamed on stabilization.
pub trait ConstParamTy_: UnsizedConstParamTy + StructuralPartialEq + Eq {}
/// Derive macro generating an impl of the trait `ConstParamTy`.
#[rustc_builtin_macro]
#[allow_internal_unstable(unsized_const_params)]
#[unstable(feature = "adt_const_params", issue = "95174")]
pub macro ConstParamTy($item:item) {
/* compiler built-in */
}
#[cfg_attr(not(bootstrap), lang = "unsized_const_param_ty")]
#[unstable(feature = "unsized_const_params", issue = "95174")]
#[diagnostic::on_unimplemented(message = "`{Self}` can't be used as a const parameter type")]
/// A marker for types which can be used as types of `const` generic parameters.
///
/// Equivalent to [`ConstParamTy_`] except that this is used by
/// the `unsized_const_params` to allow for fake unstable impls.
pub trait UnsizedConstParamTy: StructuralPartialEq + Eq {}
/// Derive macro generating an impl of the trait `ConstParamTy`.
#[cfg(not(bootstrap))]
#[cfg_attr(not(bootstrap), rustc_builtin_macro)]
#[cfg_attr(not(bootstrap), allow_internal_unstable(unsized_const_params))]
#[cfg_attr(not(bootstrap), unstable(feature = "unsized_const_params", issue = "95174"))]
pub macro UnsizedConstParamTy($item:item) {
/* compiler built-in */
}
// FIXME(adt_const_params): handle `ty::FnDef`/`ty::Closure`
marker_impls! {
#[unstable(feature = "adt_const_params", issue = "95174")]
ConstParamTy for
ConstParamTy_ for
usize, u8, u16, u32, u64, u128,
isize, i8, i16, i32, i64, i128,
bool,
char,
(),
{T: ConstParamTy, const N: usize} [T; N],
{T: ConstParamTy_, const N: usize} [T; N],
}
#[cfg(bootstrap)]
marker_impls! {
#[unstable(feature = "adt_const_params", issue = "95174")]
ConstParamTy_ for
str,
{T: ConstParamTy_} [T],
{T: ConstParamTy_ + ?Sized} &T,
}
#[unstable(feature = "adt_const_params", issue = "95174")]
#[rustc_reservation_impl = "types that are not `Sized` are not supported as the type of a const generic parameter"]
impl<T> ConstParamTy for [T] {}
marker_impls! {
#[unstable(feature = "unsized_const_params", issue = "95174")]
UnsizedConstParamTy for
usize, u8, u16, u32, u64, u128,
isize, i8, i16, i32, i64, i128,
bool,
char,
(),
{T: UnsizedConstParamTy, const N: usize} [T; N],
#[unstable(feature = "adt_const_params", issue = "95174")]
#[rustc_reservation_impl = "types that are not `Sized` are not supported as the type of a const generic parameter"]
impl ConstParamTy for str {}
#[unstable(feature = "adt_const_params", issue = "95174")]
#[rustc_reservation_impl = "references are not supported as the type of a const generic parameter"]
impl<T: ?Sized> ConstParamTy for &T {}
str,
{T: UnsizedConstParamTy} [T],
{T: UnsizedConstParamTy + ?Sized} &T,
}
/// A common trait implemented by all function pointers.
#[unstable(

View File

@ -1,4 +1,4 @@
use crate::marker::ConstParamTy;
use crate::marker::{ConstParamTy_, UnsizedConstParamTy};
/// Are values of a type transmutable into values of another type?
///
@ -39,7 +39,9 @@ pub struct Assume {
}
#[unstable(feature = "transmutability", issue = "99571")]
impl ConstParamTy for Assume {}
impl ConstParamTy_ for Assume {}
#[unstable(feature = "transmutability", issue = "99571")]
impl UnsizedConstParamTy for Assume {}
impl Assume {
/// Do not assume that *you* have ensured any safety properties are met.

View File

@ -1,8 +1,9 @@
// See core/src/primitive_docs.rs for documentation.
use crate::cmp::Ordering::{self, *};
use crate::marker::ConstParamTy;
use crate::marker::ConstParamTy_;
use crate::marker::StructuralPartialEq;
use crate::marker::UnsizedConstParamTy;
// Recursive macro for implementing n-ary tuple functions and operations
//
@ -49,8 +50,15 @@ impl<$($T: Eq),+> Eq for ($($T,)+)
maybe_tuple_doc! {
$($T)+ @
#[unstable(feature = "structural_match", issue = "31434")]
impl<$($T: ConstParamTy),+> ConstParamTy for ($($T,)+)
#[unstable(feature = "adt_const_params", issue = "95174")]
impl<$($T: ConstParamTy_),+> ConstParamTy_ for ($($T,)+)
{}
}
maybe_tuple_doc! {
$($T)+ @
#[unstable(feature = "unsized_const_params", issue = "95174")]
impl<$($T: UnsizedConstParamTy),+> UnsizedConstParamTy for ($($T,)+)
{}
}

View File

@ -1,25 +0,0 @@
//@ known-bug: #119299
#![feature(adt_const_params)]
#![allow(incomplete_features)]
use std::marker::ConstParamTy;
#[derive(Eq, PartialEq)]
struct ConstStrU(*const u8, usize);
impl ConstParamTy for &'static ConstStrU {}
impl ConstStrU {
const fn from_bytes(bytes: &'static [u8]) -> Self {
Self(bytes.as_ptr(), bytes.len())
}
}
const fn chars_s<const S: &'static ConstStrU>() -> [char; 3] {
['a','b','c']
}
fn main() {
const A: &'static ConstStrU = &ConstStrU::from_bytes(b"abc");
chars_s::<A>();
}

View File

@ -3,7 +3,7 @@
//@ compile-flags: -Zmir-enable-passes=+RemoveZsts
// Verify that we can pretty print invalid constants.
#![feature(adt_const_params)]
#![feature(adt_const_params, unsized_const_params)]
#![allow(incomplete_features)]
#[derive(Copy, Clone)]

View File

@ -1,7 +1,7 @@
// skip-filecheck
// EMIT_MIR_FOR_EACH_BIT_WIDTH
#![feature(adt_const_params)]
#![feature(adt_const_params, unsized_const_params)]
#![allow(incomplete_features)]
pub fn function_with_bytes<const BYTES: &'static [u8; 4]>() -> &'static [u8] {

View File

@ -1,5 +1,5 @@
#![allow(incomplete_features)]
#![feature(adt_const_params)]
#![feature(adt_const_params, unsized_const_params)]
#![crate_name = "foo"]
use std::marker::ConstParamTy;

View File

@ -1,13 +1,12 @@
//@ check-pass
#![feature(adt_const_params)]
//~^ WARN the feature `adt_const_params` is incomplete
#![feature(adt_const_params, unsized_const_params)]
//~^ WARN the feature `unsized_const_params` is incomplete
#![feature(with_negative_coherence, negative_impls)]
pub trait A<const K: &'static str> {}
pub trait C {}
struct W<T>(T);
// Negative coherence:

View File

@ -1,8 +1,8 @@
warning: the feature `adt_const_params` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/regions-in-canonical.rs:3:12
warning: the feature `unsized_const_params` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/regions-in-canonical.rs:3:30
|
LL | #![feature(adt_const_params)]
| ^^^^^^^^^^^^^^^^
LL | #![feature(adt_const_params, unsized_const_params)]
| ^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #95174 <https://github.com/rust-lang/rust/issues/95174> for more information
= note: `#[warn(incomplete_features)]` on by default

View File

@ -1,7 +1,6 @@
//@ check-pass
#![feature(adt_const_params, lazy_type_alias)]
//~^ WARN: the feature `adt_const_params` is incomplete
//~| WARN: the feature `lazy_type_alias` is incomplete
//~^ WARN: the feature `lazy_type_alias` is incomplete
pub type Matrix = [usize; 1];
const EMPTY_MATRIX: Matrix = [0; 1];

View File

@ -1,12 +1,3 @@
warning: the feature `adt_const_params` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/alias_const_param_ty-1.rs:2:12
|
LL | #![feature(adt_const_params, lazy_type_alias)]
| ^^^^^^^^^^^^^^^^
|
= note: see issue #95174 <https://github.com/rust-lang/rust/issues/95174> for more information
= note: `#[warn(incomplete_features)]` on by default
warning: the feature `lazy_type_alias` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/alias_const_param_ty-1.rs:2:30
|
@ -14,6 +5,7 @@ LL | #![feature(adt_const_params, lazy_type_alias)]
| ^^^^^^^^^^^^^^^
|
= note: see issue #112792 <https://github.com/rust-lang/rust/issues/112792> for more information
= note: `#[warn(incomplete_features)]` on by default
warning: 2 warnings emitted
warning: 1 warning emitted

View File

@ -1,6 +1,5 @@
//@ check-pass
#![feature(adt_const_params)]
//~^ WARN: the feature `adt_const_params` is incomplete
const EMPTY_MATRIX: <Type as Trait>::Matrix = [0; 1];

View File

@ -1,11 +0,0 @@
warning: the feature `adt_const_params` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/alias_const_param_ty-2.rs:2:12
|
LL | #![feature(adt_const_params)]
| ^^^^^^^^^^^^^^^^
|
= note: see issue #95174 <https://github.com/rust-lang/rust/issues/95174> for more information
= note: `#[warn(incomplete_features)]` on by default
warning: 1 warning emitted

View File

@ -0,0 +1,7 @@
#![feature(adt_const_params, unsized_const_params)]
#[derive(std::marker::UnsizedConstParamTy, Eq, PartialEq)]
pub struct Foo([u8]);
#[derive(std::marker::ConstParamTy, Eq, PartialEq)]
pub struct GenericNotUnsizedParam<T>(T);

View File

@ -1,13 +1,13 @@
#![allow(incomplete_features)]
#![feature(adt_const_params)]
#![feature(adt_const_params, unsized_const_params)]
fn check(_: impl std::marker::ConstParamTy) {}
fn check(_: impl std::marker::UnsizedConstParamTy) {}
fn main() {
check(main); //~ error: `fn() {main}` can't be used as a const parameter type
check(|| {}); //~ error: `{closure@$DIR/const_param_ty_bad.rs:8:11: 8:13}` can't be used as a const parameter type
check(main as fn()); //~ error: `fn()` can't be used as a const parameter type
check(&mut ()); //~ error: `&mut ()` can't be used as a const parameter type
check(main); //~ error: `fn() {main}` can't be used as a const parameter type
check(|| {}); //~ error: `{closure@$DIR/const_param_ty_bad.rs:8:11: 8:13}` can't be used as a const parameter type
check(main as fn()); //~ error: `fn()` can't be used as a const parameter type
check(&mut ()); //~ error: `&mut ()` can't be used as a const parameter type
check(&mut () as *mut ()); //~ error: `*mut ()` can't be used as a const parameter type
check(&() as *const ()); //~ error: `*const ()` can't be used as a const parameter type
check(&() as *const ()); //~ error: `*const ()` can't be used as a const parameter type
}

View File

@ -2,15 +2,15 @@ error[E0277]: `fn() {main}` can't be used as a const parameter type
--> $DIR/const_param_ty_bad.rs:7:11
|
LL | check(main);
| ----- ^^^^ the trait `ConstParamTy` is not implemented for fn item `fn() {main}`
| ----- ^^^^ the trait `UnsizedConstParamTy` is not implemented for fn item `fn() {main}`
| |
| required by a bound introduced by this call
|
note: required by a bound in `check`
--> $DIR/const_param_ty_bad.rs:4:18
|
LL | fn check(_: impl std::marker::ConstParamTy) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `check`
LL | fn check(_: impl std::marker::UnsizedConstParamTy) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `check`
help: use parentheses to call this function
|
LL | check(main());
@ -20,15 +20,15 @@ error[E0277]: `{closure@$DIR/const_param_ty_bad.rs:8:11: 8:13}` can't be used as
--> $DIR/const_param_ty_bad.rs:8:11
|
LL | check(|| {});
| ----- ^^^^^ the trait `ConstParamTy` is not implemented for closure `{closure@$DIR/const_param_ty_bad.rs:8:11: 8:13}`
| ----- ^^^^^ the trait `UnsizedConstParamTy` is not implemented for closure `{closure@$DIR/const_param_ty_bad.rs:8:11: 8:13}`
| |
| required by a bound introduced by this call
|
note: required by a bound in `check`
--> $DIR/const_param_ty_bad.rs:4:18
|
LL | fn check(_: impl std::marker::ConstParamTy) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `check`
LL | fn check(_: impl std::marker::UnsizedConstParamTy) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `check`
help: use parentheses to call this closure
|
LL | check(|| {}());
@ -38,15 +38,15 @@ error[E0277]: `fn()` can't be used as a const parameter type
--> $DIR/const_param_ty_bad.rs:9:11
|
LL | check(main as fn());
| ----- ^^^^^^^^^^^^ the trait `ConstParamTy` is not implemented for `fn()`
| ----- ^^^^^^^^^^^^ the trait `UnsizedConstParamTy` is not implemented for `fn()`
| |
| required by a bound introduced by this call
|
note: required by a bound in `check`
--> $DIR/const_param_ty_bad.rs:4:18
|
LL | fn check(_: impl std::marker::ConstParamTy) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `check`
LL | fn check(_: impl std::marker::UnsizedConstParamTy) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `check`
help: use parentheses to call this function pointer
|
LL | check(main as fn()());
@ -56,16 +56,16 @@ error[E0277]: `&mut ()` can't be used as a const parameter type
--> $DIR/const_param_ty_bad.rs:10:11
|
LL | check(&mut ());
| ----- ^^^^^^^ the trait `ConstParamTy` is not implemented for `&mut ()`
| ----- ^^^^^^^ the trait `UnsizedConstParamTy` is not implemented for `&mut ()`
| |
| required by a bound introduced by this call
|
= note: `ConstParamTy` is implemented for `&()`, but not for `&mut ()`
= note: `UnsizedConstParamTy` is implemented for `&()`, but not for `&mut ()`
note: required by a bound in `check`
--> $DIR/const_param_ty_bad.rs:4:18
|
LL | fn check(_: impl std::marker::ConstParamTy) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `check`
LL | fn check(_: impl std::marker::UnsizedConstParamTy) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `check`
help: consider removing the leading `&`-reference
|
LL - check(&mut ());
@ -76,31 +76,31 @@ error[E0277]: `*mut ()` can't be used as a const parameter type
--> $DIR/const_param_ty_bad.rs:11:11
|
LL | check(&mut () as *mut ());
| ----- ^^^^^^^^^^^^^^^^^^ the trait `ConstParamTy` is not implemented for `*mut ()`
| ----- ^^^^^^^^^^^^^^^^^^ the trait `UnsizedConstParamTy` is not implemented for `*mut ()`
| |
| required by a bound introduced by this call
|
= help: the trait `ConstParamTy` is implemented for `()`
= help: the trait `UnsizedConstParamTy` is implemented for `()`
note: required by a bound in `check`
--> $DIR/const_param_ty_bad.rs:4:18
|
LL | fn check(_: impl std::marker::ConstParamTy) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `check`
LL | fn check(_: impl std::marker::UnsizedConstParamTy) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `check`
error[E0277]: `*const ()` can't be used as a const parameter type
--> $DIR/const_param_ty_bad.rs:12:11
|
LL | check(&() as *const ());
| ----- ^^^^^^^^^^^^^^^^ the trait `ConstParamTy` is not implemented for `*const ()`
| ----- ^^^^^^^^^^^^^^^^ the trait `UnsizedConstParamTy` is not implemented for `*const ()`
| |
| required by a bound introduced by this call
|
= help: the trait `ConstParamTy` is implemented for `()`
= help: the trait `UnsizedConstParamTy` is implemented for `()`
note: required by a bound in `check`
--> $DIR/const_param_ty_bad.rs:4:18
|
LL | fn check(_: impl std::marker::ConstParamTy) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `check`
LL | fn check(_: impl std::marker::UnsizedConstParamTy) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `check`
error: aborting due to 6 previous errors

View File

@ -1,10 +1,10 @@
#![allow(incomplete_features)]
#![feature(adt_const_params)]
#![feature(adt_const_params, unsized_const_params)]
#[derive(PartialEq, Eq)]
struct NotParam;
fn check<T: std::marker::ConstParamTy>() {}
fn check<T: std::marker::ConstParamTy_>() {}
fn main() {
check::<[NotParam; 0]>();

View File

@ -2,14 +2,14 @@ error[E0277]: `NotParam` can't be used as a const parameter type
--> $DIR/const_param_ty_bad_empty_array.rs:10:13
|
LL | check::<[NotParam; 0]>();
| ^^^^^^^^^^^^^ the trait `ConstParamTy` is not implemented for `NotParam`, which is required by `[NotParam; 0]: ConstParamTy`
| ^^^^^^^^^^^^^ the trait `ConstParamTy_` is not implemented for `NotParam`, which is required by `[NotParam; 0]: ConstParamTy_`
|
= note: required for `[NotParam; 0]` to implement `ConstParamTy`
= note: required for `[NotParam; 0]` to implement `ConstParamTy_`
note: required by a bound in `check`
--> $DIR/const_param_ty_bad_empty_array.rs:7:13
|
LL | fn check<T: std::marker::ConstParamTy>() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `check`
LL | fn check<T: std::marker::ConstParamTy_>() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `check`
error: aborting due to 1 previous error

View File

@ -1,13 +1,13 @@
#![allow(incomplete_features)]
#![feature(adt_const_params)]
#![feature(adt_const_params, unsized_const_params)]
#[derive(PartialEq, Eq)]
struct NotParam;
fn check<T: std::marker::ConstParamTy + ?Sized>() {}
fn check<T: std::marker::UnsizedConstParamTy + ?Sized>() {}
fn main() {
check::<&NotParam>(); //~ error: `NotParam` can't be used as a const parameter type
check::<[NotParam]>(); //~ error: `NotParam` can't be used as a const parameter type
check::<&NotParam>(); //~ error: `NotParam` can't be used as a const parameter type
check::<[NotParam]>(); //~ error: `NotParam` can't be used as a const parameter type
check::<[NotParam; 17]>(); //~ error: `NotParam` can't be used as a const parameter type
}

View File

@ -2,40 +2,40 @@ error[E0277]: `NotParam` can't be used as a const parameter type
--> $DIR/const_param_ty_generic_bounds_do_not_hold.rs:10:13
|
LL | check::<&NotParam>();
| ^^^^^^^^^ the trait `ConstParamTy` is not implemented for `NotParam`, which is required by `&NotParam: ConstParamTy`
| ^^^^^^^^^ the trait `UnsizedConstParamTy` is not implemented for `NotParam`, which is required by `&NotParam: UnsizedConstParamTy`
|
= note: required for `&NotParam` to implement `ConstParamTy`
= note: required for `&NotParam` to implement `UnsizedConstParamTy`
note: required by a bound in `check`
--> $DIR/const_param_ty_generic_bounds_do_not_hold.rs:7:13
|
LL | fn check<T: std::marker::ConstParamTy + ?Sized>() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `check`
LL | fn check<T: std::marker::UnsizedConstParamTy + ?Sized>() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `check`
error[E0277]: `NotParam` can't be used as a const parameter type
--> $DIR/const_param_ty_generic_bounds_do_not_hold.rs:11:13
|
LL | check::<[NotParam]>();
| ^^^^^^^^^^ the trait `ConstParamTy` is not implemented for `NotParam`, which is required by `[NotParam]: ConstParamTy`
| ^^^^^^^^^^ the trait `UnsizedConstParamTy` is not implemented for `NotParam`, which is required by `[NotParam]: UnsizedConstParamTy`
|
= note: required for `[NotParam]` to implement `ConstParamTy`
= note: required for `[NotParam]` to implement `UnsizedConstParamTy`
note: required by a bound in `check`
--> $DIR/const_param_ty_generic_bounds_do_not_hold.rs:7:13
|
LL | fn check<T: std::marker::ConstParamTy + ?Sized>() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `check`
LL | fn check<T: std::marker::UnsizedConstParamTy + ?Sized>() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `check`
error[E0277]: `NotParam` can't be used as a const parameter type
--> $DIR/const_param_ty_generic_bounds_do_not_hold.rs:12:13
|
LL | check::<[NotParam; 17]>();
| ^^^^^^^^^^^^^^ the trait `ConstParamTy` is not implemented for `NotParam`, which is required by `[NotParam; 17]: ConstParamTy`
| ^^^^^^^^^^^^^^ the trait `UnsizedConstParamTy` is not implemented for `NotParam`, which is required by `[NotParam; 17]: UnsizedConstParamTy`
|
= note: required for `[NotParam; 17]` to implement `ConstParamTy`
= note: required for `[NotParam; 17]` to implement `UnsizedConstParamTy`
note: required by a bound in `check`
--> $DIR/const_param_ty_generic_bounds_do_not_hold.rs:7:13
|
LL | fn check<T: std::marker::ConstParamTy + ?Sized>() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `check`
LL | fn check<T: std::marker::UnsizedConstParamTy + ?Sized>() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `check`
error: aborting due to 3 previous errors

View File

@ -1,7 +1,9 @@
//@ check-pass
#![feature(adt_const_params, unsized_const_params)]
#![allow(incomplete_features)]
#![feature(adt_const_params)]
use std::marker::ConstParamTy;
use std::marker::UnsizedConstParamTy;
#[derive(PartialEq, Eq)]
struct S<T> {
@ -9,16 +11,15 @@ struct S<T> {
gen: T,
}
impl<T: ConstParamTy> ConstParamTy for S<T> {}
impl<T: UnsizedConstParamTy> UnsizedConstParamTy for S<T> {}
#[derive(PartialEq, Eq, ConstParamTy)]
#[derive(PartialEq, Eq, UnsizedConstParamTy)]
struct D<T> {
field: u8,
gen: T,
}
fn check<T: ConstParamTy + ?Sized>() {}
fn check<T: UnsizedConstParamTy + ?Sized>() {}
fn main() {
check::<u8>();

View File

@ -1,5 +1,5 @@
#![allow(incomplete_features)]
#![feature(adt_const_params)]
#![feature(adt_const_params, unsized_const_params)]
#[derive(PartialEq, Eq)]
struct NotParam;
@ -7,11 +7,11 @@
#[derive(PartialEq, Eq)]
struct CantParam(NotParam);
impl std::marker::ConstParamTy for CantParam {}
//~^ error: the trait `ConstParamTy` cannot be implemented for this type
impl std::marker::UnsizedConstParamTy for CantParam {}
//~^ error: the trait `ConstParamTy_` cannot be implemented for this type
#[derive(std::marker::ConstParamTy, Eq, PartialEq)]
//~^ error: the trait `ConstParamTy` cannot be implemented for this type
#[derive(std::marker::UnsizedConstParamTy, Eq, PartialEq)]
//~^ error: the trait `ConstParamTy_` cannot be implemented for this type
struct CantParamDerive(NotParam);
fn main() {}

View File

@ -1,22 +1,22 @@
error[E0204]: the trait `ConstParamTy` cannot be implemented for this type
--> $DIR/const_param_ty_impl_bad_field.rs:10:36
error[E0204]: the trait `ConstParamTy_` cannot be implemented for this type
--> $DIR/const_param_ty_impl_bad_field.rs:10:43
|
LL | struct CantParam(NotParam);
| -------- this field does not implement `ConstParamTy`
| -------- this field does not implement `ConstParamTy_`
LL |
LL | impl std::marker::ConstParamTy for CantParam {}
| ^^^^^^^^^
LL | impl std::marker::UnsizedConstParamTy for CantParam {}
| ^^^^^^^^^
error[E0204]: the trait `ConstParamTy` cannot be implemented for this type
error[E0204]: the trait `ConstParamTy_` cannot be implemented for this type
--> $DIR/const_param_ty_impl_bad_field.rs:13:10
|
LL | #[derive(std::marker::ConstParamTy, Eq, PartialEq)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^
LL | #[derive(std::marker::UnsizedConstParamTy, Eq, PartialEq)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL |
LL | struct CantParamDerive(NotParam);
| -------- this field does not implement `ConstParamTy`
| -------- this field does not implement `ConstParamTy_`
|
= note: this error originates in the derive macro `std::marker::ConstParamTy` (in Nightly builds, run with -Z macro-backtrace for more info)
= note: this error originates in the derive macro `std::marker::UnsizedConstParamTy` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 2 previous errors

View File

@ -1,22 +1,22 @@
#![allow(incomplete_features)]
#![feature(adt_const_params)]
#![feature(adt_const_params, unsized_const_params)]
#[derive(PartialEq, Eq)]
struct ImplementsConstParamTy;
impl std::marker::ConstParamTy for ImplementsConstParamTy {}
impl std::marker::UnsizedConstParamTy for ImplementsConstParamTy {}
struct CantParam(ImplementsConstParamTy);
impl std::marker::ConstParamTy for CantParam {}
impl std::marker::UnsizedConstParamTy for CantParam {}
//~^ error: the type `CantParam` does not `#[derive(PartialEq)]`
//~| the trait bound `CantParam: Eq` is not satisfied
#[derive(std::marker::ConstParamTy)]
#[derive(std::marker::UnsizedConstParamTy)]
//~^ error: the type `CantParamDerive` does not `#[derive(PartialEq)]`
//~| the trait bound `CantParamDerive: Eq` is not satisfied
struct CantParamDerive(ImplementsConstParamTy);
fn check<T: std::marker::ConstParamTy>() {}
fn check<T: std::marker::UnsizedConstParamTy>() {}
fn main() {
check::<ImplementsConstParamTy>();

View File

@ -1,10 +1,10 @@
error[E0277]: the trait bound `CantParam: Eq` is not satisfied
--> $DIR/const_param_ty_impl_no_structural_eq.rs:10:36
--> $DIR/const_param_ty_impl_no_structural_eq.rs:10:43
|
LL | impl std::marker::ConstParamTy for CantParam {}
| ^^^^^^^^^ the trait `Eq` is not implemented for `CantParam`
LL | impl std::marker::UnsizedConstParamTy for CantParam {}
| ^^^^^^^^^ the trait `Eq` is not implemented for `CantParam`
|
note: required by a bound in `ConstParamTy`
note: required by a bound in `UnsizedConstParamTy`
--> $SRC_DIR/core/src/marker.rs:LL:COL
help: consider annotating `CantParam` with `#[derive(Eq)]`
|
@ -13,23 +13,23 @@ LL | struct CantParam(ImplementsConstParamTy);
|
error[E0277]: the type `CantParam` does not `#[derive(PartialEq)]`
--> $DIR/const_param_ty_impl_no_structural_eq.rs:10:36
--> $DIR/const_param_ty_impl_no_structural_eq.rs:10:43
|
LL | impl std::marker::ConstParamTy for CantParam {}
| ^^^^^^^^^ the trait `StructuralPartialEq` is not implemented for `CantParam`
LL | impl std::marker::UnsizedConstParamTy for CantParam {}
| ^^^^^^^^^ the trait `StructuralPartialEq` is not implemented for `CantParam`
|
note: required by a bound in `ConstParamTy`
note: required by a bound in `UnsizedConstParamTy`
--> $SRC_DIR/core/src/marker.rs:LL:COL
error[E0277]: the trait bound `CantParamDerive: Eq` is not satisfied
--> $DIR/const_param_ty_impl_no_structural_eq.rs:14:10
|
LL | #[derive(std::marker::ConstParamTy)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Eq` is not implemented for `CantParamDerive`
LL | #[derive(std::marker::UnsizedConstParamTy)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Eq` is not implemented for `CantParamDerive`
|
note: required by a bound in `ConstParamTy`
note: required by a bound in `UnsizedConstParamTy`
--> $SRC_DIR/core/src/marker.rs:LL:COL
= note: this error originates in the derive macro `std::marker::ConstParamTy` (in Nightly builds, run with -Z macro-backtrace for more info)
= note: this error originates in the derive macro `std::marker::UnsizedConstParamTy` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider annotating `CantParamDerive` with `#[derive(Eq)]`
|
LL + #[derive(Eq)]
@ -39,12 +39,12 @@ LL | struct CantParamDerive(ImplementsConstParamTy);
error[E0277]: the type `CantParamDerive` does not `#[derive(PartialEq)]`
--> $DIR/const_param_ty_impl_no_structural_eq.rs:14:10
|
LL | #[derive(std::marker::ConstParamTy)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `StructuralPartialEq` is not implemented for `CantParamDerive`
LL | #[derive(std::marker::UnsizedConstParamTy)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `StructuralPartialEq` is not implemented for `CantParamDerive`
|
note: required by a bound in `ConstParamTy`
note: required by a bound in `UnsizedConstParamTy`
--> $SRC_DIR/core/src/marker.rs:LL:COL
= note: this error originates in the derive macro `std::marker::ConstParamTy` (in Nightly builds, run with -Z macro-backtrace for more info)
= note: this error originates in the derive macro `std::marker::UnsizedConstParamTy` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 4 previous errors

View File

@ -1,5 +1,5 @@
#![allow(incomplete_features)]
#![feature(adt_const_params)]
#![feature(adt_const_params, unsized_const_params)]
union Union {
a: u8,
@ -12,10 +12,10 @@ fn eq(&self, other: &Union) -> bool {
}
impl Eq for Union {}
impl std::marker::ConstParamTy for Union {}
//~^ ERROR the type `Union` does not `#[derive(PartialEq)]`
impl std::marker::UnsizedConstParamTy for Union {}
//~^ ERROR the trait `ConstParamTy` may not be implemented for this type
#[derive(std::marker::ConstParamTy)]
#[derive(std::marker::UnsizedConstParamTy)]
//~^ ERROR this trait cannot be derived for unions
union UnionDerive {
a: u8,
@ -28,5 +28,4 @@ fn eq(&self, other: &UnionDerive) -> bool {
}
impl Eq for UnionDerive {}
fn main() {}

View File

@ -1,18 +1,14 @@
error: this trait cannot be derived for unions
--> $DIR/const_param_ty_impl_union.rs:18:10
|
LL | #[derive(std::marker::ConstParamTy)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^
LL | #[derive(std::marker::UnsizedConstParamTy)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0277]: the type `Union` does not `#[derive(PartialEq)]`
--> $DIR/const_param_ty_impl_union.rs:15:36
error: the trait `ConstParamTy` may not be implemented for this type
--> $DIR/const_param_ty_impl_union.rs:15:43
|
LL | impl std::marker::ConstParamTy for Union {}
| ^^^^^ the trait `StructuralPartialEq` is not implemented for `Union`
|
note: required by a bound in `ConstParamTy`
--> $SRC_DIR/core/src/marker.rs:LL:COL
LL | impl std::marker::UnsizedConstParamTy for Union {}
| ^^^^^ type is not a structure or enumeration
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0277`.

View File

@ -0,0 +1,12 @@
#![feature(adt_const_params, unsized_const_params)]
#![allow(incomplete_features)]
use std::marker::{ConstParamTy_, UnsizedConstParamTy};
fn foo(a: &dyn ConstParamTy_) {}
//~^ ERROR: the trait `ConstParamTy_`
fn bar(a: &dyn UnsizedConstParamTy) {}
//~^ ERROR: the trait `UnsizedConstParamTy`
fn main() {}

View File

@ -0,0 +1,33 @@
error[E0038]: the trait `ConstParamTy_` cannot be made into an object
--> $DIR/const_param_ty_object_safety.rs:6:12
|
LL | fn foo(a: &dyn ConstParamTy_) {}
| ^^^^^^^^^^^^^^^^^ `ConstParamTy_` cannot be made into an object
|
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $SRC_DIR/core/src/cmp.rs:LL:COL
|
= note: the trait cannot be made into an object because it uses `Self` as a type parameter
help: consider using an opaque type instead
|
LL | fn foo(a: &impl ConstParamTy_) {}
| ~~~~
error[E0038]: the trait `UnsizedConstParamTy` cannot be made into an object
--> $DIR/const_param_ty_object_safety.rs:9:12
|
LL | fn bar(a: &dyn UnsizedConstParamTy) {}
| ^^^^^^^^^^^^^^^^^^^^^^^ `UnsizedConstParamTy` cannot be made into an object
|
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $SRC_DIR/core/src/cmp.rs:LL:COL
|
= note: the trait cannot be made into an object because it uses `Self` as a type parameter
help: consider using an opaque type instead
|
LL | fn bar(a: &impl UnsizedConstParamTy) {}
| ~~~~
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0038`.

View File

@ -1,18 +1,30 @@
// issue: rust-lang/rust/#83993
#![feature(adt_const_params)]
//~^ WARN the feature `adt_const_params` is incomplete and may not be safe to use and/or cause compiler crashes
fn bug<'a>()
where
for<'b> [(); {
let x: &'b ();
//~^ ERROR generic parameters may not be used in const operations
0
}]:
{}
}]:,
{
}
fn bad() where for<'b> [();{let _:&'b (); 0}]: Sized { }
//~^ ERROR generic parameters may not be used in const operations
fn good() where for<'b> [();{0}]: Sized { }
fn bad()
where
for<'b> [(); {
let _: &'b ();
//~^ ERROR generic parameters may not be used in const operations
0
}]: Sized,
{
}
fn good()
where
for<'b> [(); { 0 }]: Sized,
{
}
pub fn main() {}

View File

@ -8,22 +8,13 @@ LL | let x: &'b ();
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions
error: generic parameters may not be used in const operations
--> $DIR/index-oob-ice-83993.rs:14:36
--> $DIR/index-oob-ice-83993.rs:18:17
|
LL | fn bad() where for<'b> [();{let _:&'b (); 0}]: Sized { }
| ^^ cannot perform const operation using `'b`
LL | let _: &'b ();
| ^^ cannot perform const operation using `'b`
|
= note: lifetime parameters may not be used in const expressions
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions
warning: the feature `adt_const_params` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/index-oob-ice-83993.rs:3:12
|
LL | #![feature(adt_const_params)]
| ^^^^^^^^^^^^^^^^
|
= note: see issue #95174 <https://github.com/rust-lang/rust/issues/95174> for more information
= note: `#[warn(incomplete_features)]` on by default
error: aborting due to 2 previous errors; 1 warning emitted
error: aborting due to 2 previous errors

View File

@ -4,15 +4,18 @@
use std::marker::ConstParamTy;
#[derive(ConstParamTy)]
//~^ the trait `ConstParamTy` cannot be implemented for this ty
//~^ the trait `ConstParamTy_` cannot be implemented for this ty
//~| the trait `ConstParamTy_` cannot be implemented for this ty
struct Foo([*const u8; 1]);
#[derive(ConstParamTy)]
//~^ the trait `ConstParamTy` cannot be implemented for this ty
//~^ the trait `ConstParamTy_` cannot be implemented for this ty
//~| the trait `ConstParamTy_` cannot be implemented for this ty
struct Foo2([*mut u8; 1]);
#[derive(ConstParamTy)]
//~^ the trait `ConstParamTy` cannot be implemented for this ty
//~^ the trait `ConstParamTy_` cannot be implemented for this ty
//~| the trait `ConstParamTy_` cannot be implemented for this ty
struct Foo3([fn(); 1]);
fn main() {}

View File

@ -1,51 +1,99 @@
error[E0204]: the trait `ConstParamTy` cannot be implemented for this type
error[E0204]: the trait `ConstParamTy_` cannot be implemented for this type
--> $DIR/nested_bad_const_param_ty.rs:6:10
|
LL | #[derive(ConstParamTy)]
| ^^^^^^^^^^^^
LL |
...
LL | struct Foo([*const u8; 1]);
| -------------- this field does not implement `ConstParamTy`
| -------------- this field does not implement `ConstParamTy_`
|
note: the `ConstParamTy` impl for `[*const u8; 1]` requires that `*const u8: ConstParamTy`
--> $DIR/nested_bad_const_param_ty.rs:8:12
note: the `ConstParamTy_` impl for `[*const u8; 1]` requires that `*const u8: ConstParamTy_`
--> $DIR/nested_bad_const_param_ty.rs:9:12
|
LL | struct Foo([*const u8; 1]);
| ^^^^^^^^^^^^^^
= note: this error originates in the derive macro `ConstParamTy` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0204]: the trait `ConstParamTy` cannot be implemented for this type
--> $DIR/nested_bad_const_param_ty.rs:10:10
error[E0204]: the trait `ConstParamTy_` cannot be implemented for this type
--> $DIR/nested_bad_const_param_ty.rs:11:10
|
LL | #[derive(ConstParamTy)]
| ^^^^^^^^^^^^
LL |
...
LL | struct Foo2([*mut u8; 1]);
| ------------ this field does not implement `ConstParamTy`
| ------------ this field does not implement `ConstParamTy_`
|
note: the `ConstParamTy` impl for `[*mut u8; 1]` requires that `*mut u8: ConstParamTy`
--> $DIR/nested_bad_const_param_ty.rs:12:13
note: the `ConstParamTy_` impl for `[*mut u8; 1]` requires that `*mut u8: ConstParamTy_`
--> $DIR/nested_bad_const_param_ty.rs:14:13
|
LL | struct Foo2([*mut u8; 1]);
| ^^^^^^^^^^^^
= note: this error originates in the derive macro `ConstParamTy` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0204]: the trait `ConstParamTy` cannot be implemented for this type
--> $DIR/nested_bad_const_param_ty.rs:14:10
error[E0204]: the trait `ConstParamTy_` cannot be implemented for this type
--> $DIR/nested_bad_const_param_ty.rs:16:10
|
LL | #[derive(ConstParamTy)]
| ^^^^^^^^^^^^
LL |
...
LL | struct Foo3([fn(); 1]);
| --------- this field does not implement `ConstParamTy`
| --------- this field does not implement `ConstParamTy_`
|
note: the `ConstParamTy` impl for `[fn(); 1]` requires that `fn(): ConstParamTy`
--> $DIR/nested_bad_const_param_ty.rs:16:13
note: the `ConstParamTy_` impl for `[fn(); 1]` requires that `fn(): ConstParamTy_`
--> $DIR/nested_bad_const_param_ty.rs:19:13
|
LL | struct Foo3([fn(); 1]);
| ^^^^^^^^^
= note: this error originates in the derive macro `ConstParamTy` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 3 previous errors
error[E0204]: the trait `ConstParamTy_` cannot be implemented for this type
--> $DIR/nested_bad_const_param_ty.rs:6:10
|
LL | #[derive(ConstParamTy)]
| ^^^^^^^^^^^^
...
LL | struct Foo([*const u8; 1]);
| -------------- this field does not implement `ConstParamTy_`
|
note: the `ConstParamTy_` impl for `[*const u8; 1]` requires that `*const u8: UnsizedConstParamTy`
--> $DIR/nested_bad_const_param_ty.rs:9:12
|
LL | struct Foo([*const u8; 1]);
| ^^^^^^^^^^^^^^
= note: this error originates in the derive macro `ConstParamTy` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0204]: the trait `ConstParamTy_` cannot be implemented for this type
--> $DIR/nested_bad_const_param_ty.rs:11:10
|
LL | #[derive(ConstParamTy)]
| ^^^^^^^^^^^^
...
LL | struct Foo2([*mut u8; 1]);
| ------------ this field does not implement `ConstParamTy_`
|
note: the `ConstParamTy_` impl for `[*mut u8; 1]` requires that `*mut u8: UnsizedConstParamTy`
--> $DIR/nested_bad_const_param_ty.rs:14:13
|
LL | struct Foo2([*mut u8; 1]);
| ^^^^^^^^^^^^
= note: this error originates in the derive macro `ConstParamTy` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0204]: the trait `ConstParamTy_` cannot be implemented for this type
--> $DIR/nested_bad_const_param_ty.rs:16:10
|
LL | #[derive(ConstParamTy)]
| ^^^^^^^^^^^^
...
LL | struct Foo3([fn(); 1]);
| --------- this field does not implement `ConstParamTy_`
|
note: the `ConstParamTy_` impl for `[fn(); 1]` requires that `fn(): UnsizedConstParamTy`
--> $DIR/nested_bad_const_param_ty.rs:19:13
|
LL | struct Foo3([fn(); 1]);
| ^^^^^^^^^
= note: this error originates in the derive macro `ConstParamTy` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 6 previous errors
For more information about this error, try `rustc --explain E0204`.

View File

@ -3,7 +3,7 @@
// issues rust-lang/rust#111911
// test for ICE opaque type with non-universal region substs
#![feature(adt_const_params)]
#![feature(adt_const_params, unsized_const_params)]
#![allow(incomplete_features)]
pub async fn foo<const X: &'static str>() {}

View File

@ -0,0 +1,11 @@
#![feature(adt_const_params, unsized_const_params)]
#![allow(incomplete_features)]
use std::marker::UnsizedConstParamTy;
struct Foo;
impl UnsizedConstParamTy for &'static Foo {}
//~^ ERROR: the trait `ConstParamTy_` cannot be implemented for this type
fn main() {}

View File

@ -0,0 +1,9 @@
error[E0204]: the trait `ConstParamTy_` cannot be implemented for this type
--> $DIR/reference_pointee_is_const_param-1.rs:8:30
|
LL | impl UnsizedConstParamTy for &'static Foo {}
| ^^^^^^^^^^^^ this field does not implement `ConstParamTy_`
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0204`.

View File

@ -0,0 +1,27 @@
#![feature(adt_const_params, unsized_const_params)]
#![allow(incomplete_features)]
// Regression test for #119299
use std::marker::UnsizedConstParamTy;
#[derive(Eq, PartialEq)]
struct ConstStrU(*const u8, usize);
impl UnsizedConstParamTy for &'static ConstStrU {}
//~^ ERROR: the trait `ConstParamTy_` cannot be implemented for this type
impl ConstStrU {
const fn from_bytes(bytes: &'static [u8]) -> Self {
Self(bytes.as_ptr(), bytes.len())
}
}
const fn chars_s<const S: &'static ConstStrU>() -> [char; 3] {
['a', 'b', 'c']
}
fn main() {
const A: &'static ConstStrU = &ConstStrU::from_bytes(b"abc");
chars_s::<A>();
}

View File

@ -0,0 +1,9 @@
error[E0204]: the trait `ConstParamTy_` cannot be implemented for this type
--> $DIR/reference_pointee_is_const_param-2.rs:11:30
|
LL | impl UnsizedConstParamTy for &'static ConstStrU {}
| ^^^^^^^^^^^^^^^^^^ this field does not implement `ConstParamTy_`
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0204`.

View File

@ -8,9 +8,8 @@ fn uwu_0<const N: &'static mut ()>() {}
//~| HELP: add `#![feature(adt_const_params)]`
//~| HELP: add `#![feature(adt_const_params)]`
//~| HELP: add `#![feature(adt_const_params)]`
//~| HELP: add `#![feature(adt_const_params)]`
//~| HELP: add `#![feature(adt_const_params)]`
//~| HELP: add `#![feature(adt_const_params)]`
//~| HELP: add `#![feature(unsized_const_params)]`
//~| HELP: add `#![feature(unsized_const_params)]`
// Needs the feature but can be used, so suggest adding the feature.
fn owo_0<const N: &'static u32>() {}

View File

@ -7,7 +7,7 @@ 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:16:19
--> $DIR/suggest_feature_only_when_possible.rs:15:19
|
LL | fn owo_0<const N: &'static u32>() {}
| ^^^^^^^^^^^^
@ -17,9 +17,13 @@ help: add `#![feature(adt_const_params)]` to the crate attributes to enable more
|
LL + #![feature(adt_const_params)]
|
help: add `#![feature(unsized_const_params)]` to the crate attributes to enable references to implement the `ConstParamTy` trait
|
LL + #![feature(unsized_const_params)]
|
error: `Meow` is forbidden as the type of a const generic parameter
--> $DIR/suggest_feature_only_when_possible.rs:24:20
--> $DIR/suggest_feature_only_when_possible.rs:23:20
|
LL | fn meow_0<const N: Meow>() {}
| ^^^^
@ -31,7 +35,7 @@ LL + #![feature(adt_const_params)]
|
error: `&'static Meow` is forbidden as the type of a const generic parameter
--> $DIR/suggest_feature_only_when_possible.rs:26:20
--> $DIR/suggest_feature_only_when_possible.rs:25:20
|
LL | fn meow_1<const N: &'static Meow>() {}
| ^^^^^^^^^^^^^
@ -41,45 +45,37 @@ help: add `#![feature(adt_const_params)]` to the crate attributes to enable more
|
LL + #![feature(adt_const_params)]
|
help: add `#![feature(unsized_const_params)]` to the crate attributes to enable references to implement the `ConstParamTy` trait
|
LL + #![feature(unsized_const_params)]
|
error: `[Meow; 100]` is forbidden as the type of a const generic parameter
--> $DIR/suggest_feature_only_when_possible.rs:28:20
--> $DIR/suggest_feature_only_when_possible.rs:27: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
|
LL + #![feature(adt_const_params)]
|
error: `(Meow, u8)` is forbidden as the type of a const generic parameter
--> $DIR/suggest_feature_only_when_possible.rs:30:20
--> $DIR/suggest_feature_only_when_possible.rs:29: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
|
LL + #![feature(adt_const_params)]
|
error: `(Meow, String)` is forbidden as the type of a const generic parameter
--> $DIR/suggest_feature_only_when_possible.rs:35:20
--> $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
|
LL + #![feature(adt_const_params)]
|
error: `String` is forbidden as the type of a const generic parameter
--> $DIR/suggest_feature_only_when_possible.rs:39:19
--> $DIR/suggest_feature_only_when_possible.rs:38:19
|
LL | fn nya_0<const N: String>() {}
| ^^^^^^
@ -87,7 +83,7 @@ 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
--> $DIR/suggest_feature_only_when_possible.rs:40:19
|
LL | fn nya_1<const N: Vec<u32>>() {}
| ^^^^^^^^

View File

@ -0,0 +1,13 @@
#![feature(adt_const_params, unsized_const_params)]
#![allow(incomplete_features)]
use std::marker::UnsizedConstParamTy;
trait Trait {}
impl UnsizedConstParamTy for dyn Trait {}
//~^ ERROR: the trait `ConstParamTy` may not be implemented for this type
fn foo<const N: dyn Trait>() {}
fn main() {}

View File

@ -0,0 +1,8 @@
error: the trait `ConstParamTy` may not be implemented for this type
--> $DIR/trait_objects_as_a_const_generic.rs:8:30
|
LL | impl UnsizedConstParamTy for dyn Trait {}
| ^^^^^^^^^ type is not a structure or enumeration
error: aborting due to 1 previous error

View File

@ -0,0 +1,20 @@
//@ aux-build:unsized_const_param.rs
#![feature(adt_const_params)]
extern crate unsized_const_param;
use std::marker::ConstParamTy;
#[derive(ConstParamTy, Eq, PartialEq)]
//~^ ERROR: the trait `ConstParamTy_` cannot be implemented for this type
struct A([u8]);
#[derive(ConstParamTy, Eq, PartialEq)]
//~^ ERROR: the trait `ConstParamTy_` cannot be implemented for this type
struct B(&'static [u8]);
#[derive(ConstParamTy, Eq, PartialEq)]
//~^ ERROR: the trait `ConstParamTy_` cannot be implemented for this type
struct C(unsized_const_param::Foo);
fn main() {}

View File

@ -0,0 +1,36 @@
error[E0204]: the trait `ConstParamTy_` cannot be implemented for this type
--> $DIR/unsized_field-1.rs:8:10
|
LL | #[derive(ConstParamTy, Eq, PartialEq)]
| ^^^^^^^^^^^^
LL |
LL | struct A([u8]);
| ---- this field does not implement `ConstParamTy_`
|
= note: this error originates in the derive macro `ConstParamTy` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0204]: the trait `ConstParamTy_` cannot be implemented for this type
--> $DIR/unsized_field-1.rs:12:10
|
LL | #[derive(ConstParamTy, Eq, PartialEq)]
| ^^^^^^^^^^^^
LL |
LL | struct B(&'static [u8]);
| ------------- this field does not implement `ConstParamTy_`
|
= note: this error originates in the derive macro `ConstParamTy` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0204]: the trait `ConstParamTy_` cannot be implemented for this type
--> $DIR/unsized_field-1.rs:16:10
|
LL | #[derive(ConstParamTy, Eq, PartialEq)]
| ^^^^^^^^^^^^
LL |
LL | struct C(unsized_const_param::Foo);
| ------------------------ this field does not implement `ConstParamTy_`
|
= note: this error originates in the derive macro `ConstParamTy` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0204`.

View File

@ -0,0 +1,14 @@
//@ aux-build:unsized_const_param.rs
#![feature(adt_const_params, unsized_const_params)]
//~^ WARN: the feature `unsized_const_params` is incomplete
extern crate unsized_const_param;
#[derive(std::marker::ConstParamTy, Eq, PartialEq)]
//~^ ERROR: the trait `ConstParamTy_` cannot be implemented for this type
struct A(unsized_const_param::GenericNotUnsizedParam<&'static [u8]>);
#[derive(std::marker::UnsizedConstParamTy, Eq, PartialEq)]
struct B(unsized_const_param::GenericNotUnsizedParam<&'static [u8]>);
fn main() {}

View File

@ -0,0 +1,28 @@
warning: the feature `unsized_const_params` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/unsized_field-2.rs:2:30
|
LL | #![feature(adt_const_params, unsized_const_params)]
| ^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #95174 <https://github.com/rust-lang/rust/issues/95174> for more information
= note: `#[warn(incomplete_features)]` on by default
error[E0204]: the trait `ConstParamTy_` cannot be implemented for this type
--> $DIR/unsized_field-2.rs:7:10
|
LL | #[derive(std::marker::ConstParamTy, Eq, PartialEq)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^
LL |
LL | struct A(unsized_const_param::GenericNotUnsizedParam<&'static [u8]>);
| ---------------------------------------------------------- this field does not implement `ConstParamTy_`
|
note: the `ConstParamTy_` impl for `GenericNotUnsizedParam<&'static [u8]>` requires that `&'static [u8]: ConstParamTy_`
--> $DIR/unsized_field-2.rs:9:10
|
LL | struct A(unsized_const_param::GenericNotUnsizedParam<&'static [u8]>);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in the derive macro `std::marker::ConstParamTy` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 1 previous error; 1 warning emitted
For more information about this error, try `rustc --explain E0204`.

View File

@ -39,6 +39,10 @@ help: add `#![feature(adt_const_params)]` to the crate attributes to enable more
|
LL + #![feature(adt_const_params)]
|
help: add `#![feature(unsized_const_params)]` to the crate attributes to enable references to implement the `ConstParamTy` trait
|
LL + #![feature(unsized_const_params)]
|
error: `&u8` is forbidden as the type of a const generic parameter
--> $DIR/const-param-elided-lifetime.rs:14:15
@ -51,6 +55,10 @@ help: add `#![feature(adt_const_params)]` to the crate attributes to enable more
|
LL + #![feature(adt_const_params)]
|
help: add `#![feature(unsized_const_params)]` to the crate attributes to enable references to implement the `ConstParamTy` trait
|
LL + #![feature(unsized_const_params)]
|
error: `&u8` is forbidden as the type of a const generic parameter
--> $DIR/const-param-elided-lifetime.rs:22:15
@ -63,6 +71,10 @@ help: add `#![feature(adt_const_params)]` to the crate attributes to enable more
|
LL + #![feature(adt_const_params)]
|
help: add `#![feature(unsized_const_params)]` to the crate attributes to enable references to implement the `ConstParamTy` trait
|
LL + #![feature(unsized_const_params)]
|
error: `&u8` is forbidden as the type of a const generic parameter
--> $DIR/const-param-elided-lifetime.rs:26:17
@ -75,6 +87,10 @@ help: add `#![feature(adt_const_params)]` to the crate attributes to enable more
|
LL + #![feature(adt_const_params)]
|
help: add `#![feature(unsized_const_params)]` to the crate attributes to enable references to implement the `ConstParamTy` trait
|
LL + #![feature(unsized_const_params)]
|
error: `&u8` is forbidden as the type of a const generic parameter
--> $DIR/const-param-elided-lifetime.rs:17:21
@ -87,6 +103,10 @@ help: add `#![feature(adt_const_params)]` to the crate attributes to enable more
|
LL + #![feature(adt_const_params)]
|
help: add `#![feature(unsized_const_params)]` to the crate attributes to enable references to implement the `ConstParamTy` trait
|
LL + #![feature(unsized_const_params)]
|
error: aborting due to 10 previous errors

View File

@ -3,7 +3,7 @@
// elided lifetimes within the type of a const generic parameters to be 'static, like elided
// lifetimes within const/static items.
//@ revisions: full min
#![cfg_attr(full, feature(adt_const_params))]
#![cfg_attr(full, feature(adt_const_params, unsized_const_params))]
#![cfg_attr(full, allow(incomplete_features))]
struct A<const N: &u8>;
@ -12,8 +12,8 @@
trait B {}
impl<const N: &u8> A<N> {
//~^ ERROR `&` without an explicit lifetime name cannot be used here
//[min]~^^ ERROR `&u8` is forbidden
//~^ ERROR `&` without an explicit lifetime name cannot be used here
//[min]~^^ ERROR `&u8` is forbidden
fn foo<const M: &u8>(&self) {}
//~^ ERROR `&` without an explicit lifetime name cannot be used here
//[min]~^^ ERROR `&u8` is forbidden

View File

@ -1,14 +1,14 @@
#![feature(adt_const_params)]
#![feature(adt_const_params, unsized_const_params)]
#![allow(incomplete_features)]
use std::marker::ConstParamTy;
use std::marker::UnsizedConstParamTy;
#[derive(Eq, PartialEq)]
struct Foo<T>(T);
trait Other {}
impl<T> ConstParamTy for Foo<T> where T: Other + ConstParamTy {}
impl<T> UnsizedConstParamTy for Foo<T> where T: Other + UnsizedConstParamTy {}
fn foo<const N: Foo<u8>>() {}
//~^ ERROR `Foo<u8>` must implement `ConstParamTy` to be used as the type of a const generic parameter

View File

@ -1,5 +1,5 @@
error[E0741]: `f32` is forbidden as the type of a const generic parameter
--> $DIR/float-generic.rs:5:17
--> $DIR/float-generic.rs:7:17
|
LL | fn foo<const F: f32>() {}
| ^^^

View File

@ -0,0 +1,9 @@
error[E0741]: `f32` is forbidden as the type of a const generic parameter
--> $DIR/float-generic.rs:7:17
|
LL | fn foo<const F: f32>() {}
| ^^^
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0741`.

View File

@ -1,4 +1,6 @@
//@ revisions: simple adt_const_params
//@ revisions: simple adt_const_params full
#![cfg_attr(full, feature(adt_const_params, unsized_const_params))]
#![cfg_attr(full, allow(incomplete_features))]
#![cfg_attr(adt_const_params, feature(adt_const_params))]
#![cfg_attr(adt_const_params, allow(incomplete_features))]

View File

@ -1,5 +1,5 @@
error: `f32` is forbidden as the type of a const generic parameter
--> $DIR/float-generic.rs:5:17
--> $DIR/float-generic.rs:7:17
|
LL | fn foo<const F: f32>() {}
| ^^^

View File

@ -0,0 +1,15 @@
error[E0741]: using function pointers as const generic parameters is forbidden
--> $DIR/fn-const-param-call.rs:13:25
|
LL | struct Wrapper<const F: fn() -> u32>;
| ^^^^^^^^^^^
error[E0741]: using function pointers as const generic parameters is forbidden
--> $DIR/fn-const-param-call.rs:15:15
|
LL | impl<const F: fn() -> u32> Wrapper<F> {
| ^^^^^^^^^^^
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0741`.

View File

@ -1,11 +1,11 @@
error[E0741]: using function pointers as const generic parameters is forbidden
--> $DIR/fn-const-param-call.rs:11:25
--> $DIR/fn-const-param-call.rs:13:25
|
LL | struct Wrapper<const F: fn() -> u32>;
| ^^^^^^^^^^^
error[E0741]: using function pointers as const generic parameters is forbidden
--> $DIR/fn-const-param-call.rs:13:15
--> $DIR/fn-const-param-call.rs:15:15
|
LL | impl<const F: fn() -> u32> Wrapper<F> {
| ^^^^^^^^^^^

View File

@ -1,5 +1,5 @@
error: using function pointers as const generic parameters is forbidden
--> $DIR/fn-const-param-call.rs:11:25
--> $DIR/fn-const-param-call.rs:13:25
|
LL | struct Wrapper<const F: fn() -> u32>;
| ^^^^^^^^^^^
@ -7,7 +7,7 @@ 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
--> $DIR/fn-const-param-call.rs:15:15
|
LL | impl<const F: fn() -> u32> Wrapper<F> {
| ^^^^^^^^^^^

View File

@ -1,8 +1,10 @@
// Check that functions cannot be used as const parameters.
//@ revisions: full min
//@ revisions: min adt_const_params full
#![cfg_attr(full, feature(adt_const_params))]
#![cfg_attr(full, feature(adt_const_params, unsized_const_params))]
#![cfg_attr(full, allow(incomplete_features))]
#![cfg_attr(adt_const_params, feature(adt_const_params))]
#![cfg_attr(adt_const_params, allow(incomplete_features))]
fn function() -> u32 {
17
@ -11,7 +13,7 @@ fn function() -> u32 {
struct Wrapper<const F: fn() -> u32>; //~ ERROR: using function pointers as const generic parameters
impl<const F: fn() -> u32> Wrapper<F> {
//~^ ERROR: using function pointers as const generic parameters
//~^ ERROR: using function pointers as const generic parameters
fn call() -> u32 {
F()
}

View File

@ -0,0 +1,30 @@
error[E0741]: using function pointers as const generic parameters is forbidden
--> $DIR/fn-const-param-infer.rs:8:25
|
LL | struct Checked<const F: fn(usize) -> bool>;
| ^^^^^^^^^^^^^^^^^
error[E0308]: mismatched types
--> $DIR/fn-const-param-infer.rs:33:25
|
LL | let _ = Checked::<{ generic_arg::<u32> }>;
| ^^^^^^^^^^^^^^^^^^ expected fn pointer, found fn item
|
= note: expected fn pointer `fn(usize) -> _`
found fn item `fn(u32) -> _ {generic_arg::<u32>}`
error[E0282]: type annotations needed
--> $DIR/fn-const-param-infer.rs:35:23
|
LL | let _ = Checked::<generic>;
| ^^^^^^^ cannot infer type of the type parameter `T` declared on the function `generic`
|
help: consider specifying the generic argument
|
LL | let _ = Checked::<generic::<T>>;
| +++++
error: aborting due to 3 previous errors
Some errors have detailed explanations: E0282, E0308, E0741.
For more information about an error, try `rustc --explain E0282`.

View File

@ -1,20 +1,20 @@
error[E0741]: using function pointers as const generic parameters is forbidden
--> $DIR/fn-const-param-infer.rs:6:25
--> $DIR/fn-const-param-infer.rs:8:25
|
LL | struct Checked<const F: fn(usize) -> bool>;
| ^^^^^^^^^^^^^^^^^
error[E0308]: mismatched types
--> $DIR/fn-const-param-infer.rs:23:24
--> $DIR/fn-const-param-infer.rs:33:25
|
LL | let _ = Checked::<{generic_arg::<u32>}>;
| ^^^^^^^^^^^^^^^^^^ expected fn pointer, found fn item
LL | let _ = Checked::<{ generic_arg::<u32> }>;
| ^^^^^^^^^^^^^^^^^^ expected fn pointer, found fn item
|
= note: expected fn pointer `fn(usize) -> _`
found fn item `fn(u32) -> _ {generic_arg::<u32>}`
error[E0282]: type annotations needed
--> $DIR/fn-const-param-infer.rs:25:23
--> $DIR/fn-const-param-infer.rs:35:23
|
LL | let _ = Checked::<generic>;
| ^^^^^^^ cannot infer type of the type parameter `T` declared on the function `generic`

View File

@ -1,5 +1,5 @@
error: using function pointers as const generic parameters is forbidden
--> $DIR/fn-const-param-infer.rs:6:25
--> $DIR/fn-const-param-infer.rs:8:25
|
LL | struct Checked<const F: fn(usize) -> bool>;
| ^^^^^^^^^^^^^^^^^
@ -7,16 +7,16 @@ LL | struct Checked<const F: fn(usize) -> bool>;
= note: the only supported types are integers, `bool` and `char`
error[E0308]: mismatched types
--> $DIR/fn-const-param-infer.rs:23:24
--> $DIR/fn-const-param-infer.rs:33:25
|
LL | let _ = Checked::<{generic_arg::<u32>}>;
| ^^^^^^^^^^^^^^^^^^ expected fn pointer, found fn item
LL | let _ = Checked::<{ generic_arg::<u32> }>;
| ^^^^^^^^^^^^^^^^^^ expected fn pointer, found fn item
|
= note: expected fn pointer `fn(usize) -> _`
found fn item `fn(u32) -> _ {generic_arg::<u32>}`
error[E0282]: type annotations needed
--> $DIR/fn-const-param-infer.rs:25:23
--> $DIR/fn-const-param-infer.rs:35:23
|
LL | let _ = Checked::<generic>;
| ^^^^^^^ cannot infer type of the type parameter `T` declared on the function `generic`

View File

@ -1,17 +1,27 @@
//@ revisions: full min
//@ revisions: min adt_const_params full
#![cfg_attr(full, feature(adt_const_params))]
#![cfg_attr(full, feature(adt_const_params, unsized_const_params))]
#![cfg_attr(full, allow(incomplete_features))]
#![cfg_attr(adt_const_params, feature(adt_const_params))]
#![cfg_attr(adt_const_params, allow(incomplete_features))]
struct Checked<const F: fn(usize) -> bool>;
//~^ ERROR: using function pointers as const generic parameters
fn not_one(val: usize) -> bool { val != 1 }
fn not_two(val: usize) -> bool { val != 2 }
fn not_one(val: usize) -> bool {
val != 1
}
fn not_two(val: usize) -> bool {
val != 2
}
fn generic_arg<T>(val: T) -> bool { true }
fn generic_arg<T>(val: T) -> bool {
true
}
fn generic<T>(val: usize) -> bool { val != 1 }
fn generic<T>(val: usize) -> bool {
val != 1
}
fn main() {
let _: Option<Checked<not_one>> = None;
@ -19,11 +29,11 @@ fn main() {
let _: Checked<not_one> = Checked::<not_two>;
let _ = Checked::<generic_arg>;
let _ = Checked::<{generic_arg::<usize>}>;
let _ = Checked::<{generic_arg::<u32>}>; //~ ERROR: mismatched types
let _ = Checked::<{ generic_arg::<usize> }>;
let _ = Checked::<{ generic_arg::<u32> }>; //~ ERROR: mismatched types
let _ = Checked::<generic>; //~ ERROR: type annotations needed
let _ = Checked::<{generic::<u16>}>;
let _: Checked<{generic::<u16>}> = Checked::<{generic::<u16>}>;
let _: Checked<{generic::<u32>}> = Checked::<{generic::<u16>}>;
let _ = Checked::<{ generic::<u16> }>;
let _: Checked<{ generic::<u16> }> = Checked::<{ generic::<u16> }>;
let _: Checked<{ generic::<u32> }> = Checked::<{ generic::<u16> }>;
}

View File

@ -1,7 +1,7 @@
//@ check-pass
// (this requires debug assertions)
#![feature(adt_const_params)]
#![feature(adt_const_params, unsized_const_params)]
#![allow(incomplete_features)]
fn foo<const B: &'static bool>(arg: &'static bool) -> bool {

View File

@ -1,7 +1,7 @@
//@ check-pass
// (this requires debug assertions)
#![feature(adt_const_params)]
#![feature(adt_const_params, unsized_const_params)]
#![allow(incomplete_features)]
pub const BAR: () = ice::<"">();

View File

@ -1,7 +1,7 @@
//@ check-pass
#![feature(adt_const_params, generic_const_exprs)]
//~^ WARN the feature `adt_const_params` is incomplete and may not be safe to use and/or cause compiler crashes [incomplete_features]
#![feature(adt_const_params, unsized_const_params, generic_const_exprs)]
//~^ WARN the feature `unsized_const_params` is incomplete and may not be safe to use and/or cause compiler crashes [incomplete_features]
//~^^ WARN the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes [incomplete_features]
pub struct Changes<const CHANGES: &'static [&'static str]>
@ -16,9 +16,7 @@ impl<const CHANGES: &'static [&'static str]> Changes<CHANGES>
[(); CHANGES.len()]:,
{
pub const fn new() -> Self {
Self {
changes: [0; CHANGES.len()],
}
Self { changes: [0; CHANGES.len()] }
}
}

View File

@ -1,17 +1,17 @@
warning: the feature `adt_const_params` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/issue-97047-ice-1.rs:3:12
warning: the feature `unsized_const_params` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/issue-97047-ice-1.rs:3:30
|
LL | #![feature(adt_const_params, generic_const_exprs)]
| ^^^^^^^^^^^^^^^^
LL | #![feature(adt_const_params, unsized_const_params, generic_const_exprs)]
| ^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #95174 <https://github.com/rust-lang/rust/issues/95174> for more information
= note: `#[warn(incomplete_features)]` on by default
warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/issue-97047-ice-1.rs:3:30
--> $DIR/issue-97047-ice-1.rs:3:52
|
LL | #![feature(adt_const_params, generic_const_exprs)]
| ^^^^^^^^^^^^^^^^^^^
LL | #![feature(adt_const_params, unsized_const_params, generic_const_exprs)]
| ^^^^^^^^^^^^^^^^^^^
|
= note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information

View File

@ -1,7 +1,7 @@
//@ check-pass
#![feature(adt_const_params, generic_const_exprs)]
//~^ WARN the feature `adt_const_params` is incomplete and may not be safe to use and/or cause compiler crashes [incomplete_features]
#![feature(adt_const_params, unsized_const_params, generic_const_exprs)]
//~^ WARN the feature `unsized_const_params` is incomplete and may not be safe to use and/or cause compiler crashes [incomplete_features]
//~^^ WARN the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes [incomplete_features]
pub struct Changes<const CHANGES: &'static [&'static str]>

View File

@ -1,17 +1,17 @@
warning: the feature `adt_const_params` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/issue-97047-ice-2.rs:3:12
warning: the feature `unsized_const_params` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/issue-97047-ice-2.rs:3:30
|
LL | #![feature(adt_const_params, generic_const_exprs)]
| ^^^^^^^^^^^^^^^^
LL | #![feature(adt_const_params, unsized_const_params, generic_const_exprs)]
| ^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #95174 <https://github.com/rust-lang/rust/issues/95174> for more information
= note: `#[warn(incomplete_features)]` on by default
warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/issue-97047-ice-2.rs:3:30
--> $DIR/issue-97047-ice-2.rs:3:52
|
LL | #![feature(adt_const_params, generic_const_exprs)]
| ^^^^^^^^^^^^^^^^^^^
LL | #![feature(adt_const_params, unsized_const_params, generic_const_exprs)]
| ^^^^^^^^^^^^^^^^^^^
|
= note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information

View File

@ -1,14 +1,14 @@
error: generic parameters may not be used in const operations
--> $DIR/intrinsics-type_name-as-const-argument.rs:15:44
--> $DIR/intrinsics-type_name-as-const-argument.rs:14:45
|
LL | T: Trait<{std::intrinsics::type_name::<T>()}>
| ^ cannot perform const operation using `T`
LL | T: Trait<{ std::intrinsics::type_name::<T>() }>,
| ^ cannot perform const operation using `T`
|
= note: type parameters may not be used in const expressions
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions
error: `&'static str` is forbidden as the type of a const generic parameter
--> $DIR/intrinsics-type_name-as-const-argument.rs:10:22
--> $DIR/intrinsics-type_name-as-const-argument.rs:9:22
|
LL | trait Trait<const S: &'static str> {}
| ^^^^^^^^^^^^
@ -18,6 +18,10 @@ help: add `#![feature(adt_const_params)]` to the crate attributes to enable more
|
LL + #![feature(adt_const_params)]
|
help: add `#![feature(unsized_const_params)]` to the crate attributes to enable references to implement the `ConstParamTy` trait
|
LL + #![feature(unsized_const_params)]
|
error: aborting due to 2 previous errors

View File

@ -2,8 +2,7 @@
//@ revisions: full min
#![cfg_attr(full, allow(incomplete_features))]
#![cfg_attr(full, feature(adt_const_params, generic_const_exprs))]
#![cfg_attr(full, feature(adt_const_params, unsized_const_params, generic_const_exprs))]
#![feature(core_intrinsics)]
#![feature(const_type_name)]
@ -12,10 +11,10 @@ trait Trait<const S: &'static str> {}
struct Bug<T>
where
T: Trait<{std::intrinsics::type_name::<T>()}>
T: Trait<{ std::intrinsics::type_name::<T>() }>,
//[min]~^ ERROR generic parameters may not be used in const operations
{
t: T
t: T,
}
fn main() {}

View File

@ -1,30 +1,20 @@
#![feature(adt_const_params)]
#![feature(adt_const_params, unsized_const_params)]
#![allow(incomplete_features)]
use std::marker::ConstParamTy;
use std::marker::UnsizedConstParamTy;
#[derive(Debug, PartialEq, Eq, ConstParamTy)]
#[derive(Debug, PartialEq, Eq, UnsizedConstParamTy)]
struct Foo {
value: i32,
nested: &'static Bar<i32>,
}
#[derive(Debug, PartialEq, Eq, ConstParamTy)]
#[derive(Debug, PartialEq, Eq, UnsizedConstParamTy)]
struct Bar<T>(T);
struct Test<const F: Foo>;
fn main() {
let x: Test<{
Foo {
value: 3,
nested: &Bar(4),
}
}> = Test;
let y: Test<{
Foo {
value: 3,
nested: &Bar(5),
}
}> = x; //~ ERROR mismatched types
let x: Test<{ Foo { value: 3, nested: &Bar(4) } }> = Test;
let y: Test<{ Foo { value: 3, nested: &Bar(5) } }> = x; //~ ERROR mismatched types
}

View File

@ -1,16 +1,10 @@
error[E0308]: mismatched types
--> $DIR/issue-66451.rs:29:10
--> $DIR/issue-66451.rs:19:58
|
LL | let y: Test<{
| ____________-
LL | | Foo {
LL | | value: 3,
LL | | nested: &Bar(5),
LL | | }
LL | | }> = x;
| | - ^ expected `Foo { value: 3, nested: &Bar::<i32>(5) }`, found `Foo { value: 3, nested: &Bar::<i32>(4) }`
| |______|
| expected due to this
LL | let y: Test<{ Foo { value: 3, nested: &Bar(5) } }> = x;
| ------------------------------------------- ^ expected `Foo { value: 3, nested: &Bar::<i32>(5) }`, found `Foo { value: 3, nested: &Bar::<i32>(4) }`
| |
| expected due to this
|
= note: expected struct `Test<Foo { value: 3, nested: &Bar::<i32>(5) }>`
found struct `Test<Foo { value: 3, nested: &Bar::<i32>(4) }>`

View File

@ -1,6 +1,6 @@
//@ build-pass
#![feature(adt_const_params)]
#![feature(adt_const_params, unsized_const_params)]
#![allow(incomplete_features)]
pub fn function_with_bytes<const BYTES: &'static [u8; 4]>() -> &'static [u8] {

View File

@ -1,5 +1,4 @@
#![feature(adt_const_params)]
//~^ WARN the feature `adt_const_params` is incomplete and may not be safe to use and/or cause compiler crashes [incomplete_features]
#[derive(PartialEq, Eq)]
enum Nat {

View File

@ -1,14 +1,5 @@
warning: the feature `adt_const_params` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/issue-80471.rs:1:12
|
LL | #![feature(adt_const_params)]
| ^^^^^^^^^^^^^^^^
|
= note: see issue #95174 <https://github.com/rust-lang/rust/issues/95174> for more information
= note: `#[warn(incomplete_features)]` on by default
error[E0741]: `Nat` must implement `ConstParamTy` to be used as the type of a const generic parameter
--> $DIR/issue-80471.rs:10:17
--> $DIR/issue-80471.rs:9:17
|
LL | fn foo<const N: Nat>() {}
| ^^^
@ -19,6 +10,6 @@ LL + #[derive(ConstParamTy)]
LL | enum Nat {
|
error: aborting due to 1 previous error; 1 warning emitted
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0741`.

View File

@ -1,10 +1,10 @@
#![allow(incomplete_features)]
#![feature(const_mut_refs)]
#![feature(adt_const_params)]
#![feature(adt_const_params, unsized_const_params)]
struct T<const B: &'static bool>;
impl <const B: &'static bool> T<B> {
impl<const B: &'static bool> T<B> {
const fn set_false(&self) {
unsafe {
*(B as *const bool as *mut bool) = false;
@ -14,7 +14,7 @@ const fn set_false(&self) {
}
const _: () = {
let x = T::<{&true}>;
let x = T::<{ &true }>;
x.set_false();
};

View File

@ -4,7 +4,7 @@
// a failing test, we just started masking the bug.
#![allow(incomplete_features)]
#![feature(adt_const_params, generic_const_exprs)]
#![feature(adt_const_params, unsized_const_params, generic_const_exprs)]
#![allow(dead_code)]
const fn catone<const M: usize>(_a: &[u8; M]) -> [u8; M + 1]

View File

@ -17,6 +17,10 @@ help: add `#![feature(adt_const_params)]` to the crate attributes to enable more
|
LL + #![feature(adt_const_params)]
|
help: add `#![feature(unsized_const_params)]` to the crate attributes to enable references to implement the `ConstParamTy` trait
|
LL + #![feature(unsized_const_params)]
|
error: aborting due to 2 previous errors

View File

@ -1,6 +1,6 @@
// Regression test for https://github.com/rust-lang/rust/issues/56445#issuecomment-518402995.
//@ revisions: full min
#![cfg_attr(full, feature(adt_const_params))]
#![cfg_attr(full, feature(adt_const_params, unsized_const_params))]
#![cfg_attr(full, allow(incomplete_features))]
#![crate_type = "lib"]

View File

@ -4,7 +4,7 @@ error[E0741]: `&'static (dyn A + 'static)` can't be used as a const parameter ty
LL | fn test<const T: &'static dyn A>() {
| ^^^^^^^^^^^^^^
|
= note: `(dyn A + 'static)` must implement `ConstParamTy`, but it does not
= note: `(dyn A + 'static)` must implement `UnsizedConstParamTy`, but it does not
error: aborting due to 1 previous error

View File

@ -9,6 +9,10 @@ help: add `#![feature(adt_const_params)]` to the crate attributes to enable more
|
LL + #![feature(adt_const_params)]
|
help: add `#![feature(unsized_const_params)]` to the crate attributes to enable references to implement the `ConstParamTy` trait
|
LL + #![feature(unsized_const_params)]
|
error: aborting due to 1 previous error

View File

@ -1,5 +1,5 @@
//@ revisions: full min
#![cfg_attr(full, feature(adt_const_params))]
#![cfg_attr(full, feature(adt_const_params, unsized_const_params))]
#![cfg_attr(full, allow(incomplete_features))]
trait A {}

View File

@ -1,8 +1,7 @@
//@ check-pass
#![feature(adt_const_params)]
#![feature(adt_const_params, unsized_const_params)]
#![allow(incomplete_features)]
trait Trait<const NAME: &'static str> {
type Assoc;
}

View File

@ -1,6 +1,6 @@
//@ check-pass
#![feature(adt_const_params)]
#![feature(adt_const_params, unsized_const_params)]
#![allow(incomplete_features)]
pub trait GetType<const N: &'static str> {

View File

@ -9,6 +9,10 @@ help: add `#![feature(adt_const_params)]` to the crate attributes to enable more
|
LL + #![feature(adt_const_params)]
|
help: add `#![feature(unsized_const_params)]` to the crate attributes to enable references to implement the `ConstParamTy` trait
|
LL + #![feature(unsized_const_params)]
|
error: aborting due to 1 previous error

View File

@ -3,12 +3,12 @@
//@ revisions: full min
//@[full]check-pass
#![cfg_attr(full, feature(adt_const_params))]
#![cfg_attr(full, feature(adt_const_params, unsized_const_params))]
#![cfg_attr(full, allow(incomplete_features))]
fn a<const X: &'static [u32]>() {}
//[min]~^ ERROR `&'static [u32]` is forbidden as the type of a const generic parameter
fn main() {
a::<{&[]}>();
a::<{ &[] }>();
}

View File

@ -1,10 +1,12 @@
//@ run-pass
#![feature(adt_const_params, generic_const_exprs)]
#![feature(adt_const_params, unsized_const_params, generic_const_exprs)]
#![allow(incomplete_features)]
pub trait Foo {
const ASSOC_C: usize;
fn foo() where [(); Self::ASSOC_C]:;
fn foo()
where
[(); Self::ASSOC_C]:;
}
#[allow(dead_code)]
@ -12,7 +14,10 @@ pub trait Foo {
impl<const N: &'static ()> Foo for Bar<N> {
const ASSOC_C: usize = 3;
fn foo() where [u8; Self::ASSOC_C]: {
fn foo()
where
[u8; Self::ASSOC_C]:,
{
let _: [u8; Self::ASSOC_C] = loop {};
}
}

View File

@ -1,5 +1,5 @@
//@ run-pass
#![feature(adt_const_params, generic_const_exprs)]
#![feature(adt_const_params, unsized_const_params, generic_const_exprs)]
#![allow(incomplete_features, unused_variables)]
#[allow(dead_code)]

View File

@ -1,5 +1,5 @@
//@ run-rustfix
#![feature(generic_const_exprs, adt_const_params)]
#![feature(generic_const_exprs, unsized_const_params, adt_const_params)]
#![allow(incomplete_features, dead_code)]
struct FieldElement<const N: &'static str> where [(); num_limbs(N)]: {

View File

@ -1,5 +1,5 @@
//@ run-rustfix
#![feature(generic_const_exprs, adt_const_params)]
#![feature(generic_const_exprs, unsized_const_params, adt_const_params)]
#![allow(incomplete_features, dead_code)]
struct FieldElement<const N: &'static str> {

Some files were not shown because too many files have changed in this diff Show More