Rollup merge of #145095 - tiif:unstable_const_param, r=BoxyUwU

Migrate `UnsizedConstParamTy`  to unstable impl of `ConstParamTy_`

Now that we have ``#[unstable_feature_bound]``, we can remove ``UnsizedConstParamTy`` that was meant to be an unstable impl of stable type and ``ConstParamTy_`` trait.

r? `@BoxyUwU`
This commit is contained in:
Stuart Cook 2025-09-16 10:25:38 +10:00 committed by GitHub
commit edd6721583
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
53 changed files with 266 additions and 405 deletions

View file

@ -51,43 +51,4 @@ pub(crate) fn expand_deriving_const_param_ty(
};
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,
is_staged_api_crate: cx.ecfg.features.staged_api(),
};
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))],
supports_unions: false,
methods: Vec::new(),
associated_types: Vec::new(),
is_const,
is_staged_api_crate: cx.ecfg.features.staged_api(),
};
trait_def.expand(cx, mitem, item, push);
}

View file

@ -129,7 +129,6 @@ 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

@ -370,7 +370,6 @@ language_item_table! {
CoercePointeeValidated, sym::coerce_pointee_validated, coerce_pointee_validated_trait, 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

@ -819,17 +819,7 @@ fn check_param_wf(tcx: TyCtxt<'_>, param: &ty::GenericParamDef) -> Result<(), Er
let span = tcx.def_span(param.def_id);
let def_id = param.def_id.expect_local();
if tcx.features().unsized_const_params() {
enter_wf_checking_ctxt(tcx, tcx.local_parent(def_id), |wfcx| {
wfcx.register_bound(
ObligationCause::new(span, def_id, ObligationCauseCode::ConstParam(ty)),
wfcx.param_env,
ty,
tcx.require_lang_item(LangItem::UnsizedConstParamTy, span),
);
Ok(())
})
} else if tcx.features().adt_const_params() {
if tcx.features().adt_const_params() {
enter_wf_checking_ctxt(tcx, tcx.local_parent(def_id), |wfcx| {
wfcx.register_bound(
ObligationCause::new(span, def_id, ObligationCauseCode::ConstParam(ty)),
@ -880,7 +870,6 @@ fn check_param_wf(tcx: TyCtxt<'_>, param: &ty::GenericParamDef) -> Result<(), Er
tcx,
tcx.param_env(param.def_id),
ty,
LangItem::ConstParamTy,
cause,
) {
// Can never implement `ConstParamTy`, don't suggest anything.

View file

@ -1,7 +1,6 @@
//! Check properties that are required by built-in traits and set
//! up data structures required by type-checking/codegen.
use std::assert_matches::assert_matches;
use std::collections::BTreeMap;
use rustc_data_structures::fx::FxHashSet;
@ -40,10 +39,7 @@ pub(super) fn check_trait<'tcx>(
checker.check(lang_items.async_drop_trait(), visit_implementation_of_drop)?;
checker.check(lang_items.copy_trait(), visit_implementation_of_copy)?;
checker.check(lang_items.const_param_ty_trait(), |checker| {
visit_implementation_of_const_param_ty(checker, LangItem::ConstParamTy)
})?;
checker.check(lang_items.unsized_const_param_ty_trait(), |checker| {
visit_implementation_of_const_param_ty(checker, LangItem::UnsizedConstParamTy)
visit_implementation_of_const_param_ty(checker)
})?;
checker.check(lang_items.coerce_unsized_trait(), visit_implementation_of_coerce_unsized)?;
checker
@ -138,12 +134,7 @@ fn visit_implementation_of_copy(checker: &Checker<'_>) -> Result<(), ErrorGuaran
}
}
fn visit_implementation_of_const_param_ty(
checker: &Checker<'_>,
kind: LangItem,
) -> Result<(), ErrorGuaranteed> {
assert_matches!(kind, LangItem::ConstParamTy | LangItem::UnsizedConstParamTy);
fn visit_implementation_of_const_param_ty(checker: &Checker<'_>) -> Result<(), ErrorGuaranteed> {
let tcx = checker.tcx;
let header = checker.impl_header;
let impl_did = checker.impl_def_id;
@ -157,7 +148,7 @@ fn visit_implementation_of_const_param_ty(
}
let cause = traits::ObligationCause::misc(DUMMY_SP, impl_did);
match type_allowed_to_implement_const_param_ty(tcx, param_env, self_type, kind, cause) {
match type_allowed_to_implement_const_param_ty(tcx, param_env, self_type, cause) {
Ok(()) => Ok(()),
Err(ConstParamTyImplementationError::InfrigingFields(fields)) => {
let span = tcx.hir_expect_item(impl_did).expect_impl().self_ty.span;

View file

@ -72,12 +72,27 @@ pub trait TraitEngine<'tcx, E: 'tcx>: 'tcx {
self.register_predicate_obligation(infcx, obligation);
}
}
/// Go over the list of pending obligations and try to evaluate them.
///
/// For each result:
/// Ok: remove the obligation from the list
/// Ambiguous: leave the obligation in the list to be evaluated later
/// Err: remove the obligation from the list and return an error
///
/// Returns a list of errors from obligations that evaluated to Err.
#[must_use]
fn select_where_possible(&mut self, infcx: &InferCtxt<'tcx>) -> Vec<E>;
fn collect_remaining_errors(&mut self, infcx: &InferCtxt<'tcx>) -> Vec<E>;
/// Evaluate all pending obligations, return error if they can't be evaluated.
///
/// For each result:
/// Ok: remove the obligation from the list
/// Ambiguous: remove the obligation from the list and return an error
/// Err: remove the obligation from the list and return an error
///
/// Returns a list of errors from obligations that evaluated to Ambiguous or Err.
#[must_use]
fn select_all_or_error(&mut self, infcx: &InferCtxt<'tcx>) -> Vec<E> {
let errors = self.select_where_possible(infcx);

View file

@ -1,15 +1,14 @@
//! Miscellaneous type-system utilities that are too small to deserve their own modules.
use std::assert_matches::assert_matches;
use hir::LangItem;
use rustc_ast::Mutability;
use rustc_hir as hir;
use rustc_infer::infer::{RegionResolutionError, TyCtxtInferExt};
use rustc_middle::ty::{self, AdtDef, Ty, TyCtxt, TypeVisitableExt, TypingMode};
use rustc_span::sym;
use crate::regions::InferCtxtRegionExt;
use crate::traits::{self, FulfillmentError, ObligationCause};
use crate::traits::{self, FulfillmentError, Obligation, ObligationCause};
pub enum CopyImplementationError<'tcx> {
InfringingFields(Vec<(&'tcx ty::FieldDef, Ty<'tcx>, InfringingFieldsReason<'tcx>)>),
@ -98,10 +97,9 @@ 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>> {
assert_matches!(lang_item, LangItem::ConstParamTy | LangItem::UnsizedConstParamTy);
let mut need_unstable_feature_bound = false;
let inner_tys: Vec<_> = match *self_type.kind() {
// Trivially okay as these types are all:
@ -112,18 +110,14 @@ pub fn type_allowed_to_implement_const_param_ty<'tcx>(
// 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 =>
{
ty::Slice(inner_ty) | ty::Ref(_, inner_ty, Mutability::Not) => {
need_unstable_feature_bound = true;
vec![inner_ty]
}
ty::Str if lang_item == LangItem::UnsizedConstParamTy => {
ty::Str => {
need_unstable_feature_bound = true;
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],
// `str` morally acts like a newtype around `[u8]`
@ -137,7 +131,7 @@ pub fn type_allowed_to_implement_const_param_ty<'tcx>(
adt,
args,
parent_cause.clone(),
lang_item,
LangItem::ConstParamTy,
)
.map_err(ConstParamTyImplementationError::InfrigingFields)?;
@ -153,11 +147,25 @@ pub fn type_allowed_to_implement_const_param_ty<'tcx>(
let infcx = tcx.infer_ctxt().build(TypingMode::non_body_analysis());
let ocx = traits::ObligationCtxt::new_with_diagnostics(&infcx);
// Make sure impls certain types are gated with #[unstable_feature_bound(unsized_const_params)]
if need_unstable_feature_bound {
ocx.register_obligation(Obligation::new(
tcx,
parent_cause.clone(),
param_env,
ty::ClauseKind::UnstableFeature(sym::unsized_const_params),
));
if !ocx.select_all_or_error().is_empty() {
return Err(ConstParamTyImplementationError::UnsizedConstParamsFeatureRequired);
}
}
ocx.register_bound(
parent_cause.clone(),
param_env,
inner_ty,
tcx.require_lang_item(lang_item, parent_cause.span),
tcx.require_lang_item(LangItem::ConstParamTy, parent_cause.span),
);
let errors = ocx.select_all_or_error();

View file

@ -1083,7 +1083,7 @@ pub trait Tuple {}
// 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 {}
pub trait ConstParamTy_: StructuralPartialEq + Eq {}
/// Derive macro generating an impl of the trait `ConstParamTy`.
#[rustc_builtin_macro]
@ -1093,23 +1093,6 @@ pub macro ConstParamTy($item:item) {
/* compiler built-in */
}
#[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`.
#[rustc_builtin_macro]
#[allow_internal_unstable(unsized_const_params)]
#[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")]
@ -1124,17 +1107,11 @@ marker_impls! {
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_bound(unsized_const_params)]
ConstParamTy_ for
str,
{T: UnsizedConstParamTy} [T],
{T: UnsizedConstParamTy + ?Sized} &T,
{T: ConstParamTy_} [T],
{T: ConstParamTy_ + ?Sized} &T,
}
/// A common trait implemented by all function pointers.

View file

@ -1,4 +1,4 @@
use crate::marker::{ConstParamTy_, UnsizedConstParamTy};
use crate::marker::ConstParamTy_;
/// Marks that `Src` is transmutable into `Self`.
///
@ -83,6 +83,7 @@ use crate::marker::{ConstParamTy_, UnsizedConstParamTy};
/// Furthermore, stability does not imply portability. For example, the size of
/// `usize` is stable, but not portable.
#[unstable(feature = "transmutability", issue = "99571")]
#[unstable_feature_bound(transmutability)]
#[lang = "transmute_trait"]
#[rustc_deny_explicit_impl]
#[rustc_do_not_implement_via_object]
@ -288,9 +289,8 @@ pub struct Assume {
}
#[unstable(feature = "transmutability", issue = "99571")]
#[unstable_feature_bound(transmutability)]
impl ConstParamTy_ for Assume {}
#[unstable(feature = "transmutability", issue = "99571")]
impl UnsizedConstParamTy for Assume {}
impl Assume {
/// With this, [`TransmuteFrom`] does not assume you have ensured any safety

View file

@ -1,7 +1,7 @@
// See core/src/primitive_docs.rs for documentation.
use crate::cmp::Ordering::{self, *};
use crate::marker::{ConstParamTy_, StructuralPartialEq, UnsizedConstParamTy};
use crate::marker::{ConstParamTy_, StructuralPartialEq};
use crate::ops::ControlFlow::{self, Break, Continue};
// Recursive macro for implementing n-ary tuple functions and operations
@ -47,17 +47,11 @@ macro_rules! tuple_impls {
maybe_tuple_doc! {
$($T)+ @
#[unstable(feature = "adt_const_params", issue = "95174")]
#[unstable_feature_bound(unsized_const_params)]
impl<$($T: ConstParamTy_),+> ConstParamTy_ for ($($T,)+)
{}
}
maybe_tuple_doc! {
$($T)+ @
#[unstable(feature = "unsized_const_params", issue = "95174")]
impl<$($T: UnsizedConstParamTy),+> UnsizedConstParamTy for ($($T,)+)
{}
}
maybe_tuple_doc! {
$($T)+ @
#[unstable(feature = "structural_match", issue = "31434")]

View file

@ -1,6 +1,6 @@
#![feature(adt_const_params, unsized_const_params)]
#[derive(std::marker::UnsizedConstParamTy, Eq, PartialEq)]
#[derive(std::marker::ConstParamTy, Eq, PartialEq)]
pub struct Foo([u8]);
#[derive(std::marker::ConstParamTy, Eq, PartialEq)]

View file

@ -1,7 +1,7 @@
#![allow(incomplete_features)]
#![feature(adt_const_params, unsized_const_params)]
fn check(_: impl std::marker::UnsizedConstParamTy) {}
fn check(_: impl std::marker::ConstParamTy_) {}
fn main() {
check(main); //~ error: `fn() {main}` 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 `UnsizedConstParamTy` is not implemented for fn item `fn() {main}`
| ----- ^^^^ the trait `ConstParamTy_` 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::UnsizedConstParamTy) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `check`
LL | fn check(_: impl std::marker::ConstParamTy_) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `check`
help: use parentheses to call this function
|
LL | check(main());
@ -24,12 +24,12 @@ LL | check(|| {});
| |
| required by a bound introduced by this call
|
= help: the trait `UnsizedConstParamTy` is not implemented for closure `{closure@$DIR/const_param_ty_bad.rs:8:11: 8:13}`
= help: the trait `ConstParamTy_` is not implemented for closure `{closure@$DIR/const_param_ty_bad.rs:8:11: 8:13}`
note: required by a bound in `check`
--> $DIR/const_param_ty_bad.rs:4:18
|
LL | fn check(_: impl std::marker::UnsizedConstParamTy) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `check`
LL | fn check(_: impl std::marker::ConstParamTy_) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `check`
help: use parentheses to call this closure
|
LL - check(|| {});
@ -40,15 +40,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 `UnsizedConstParamTy` is not implemented for `fn()`
| ----- ^^^^^^^^^^^^ the trait `ConstParamTy_` 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::UnsizedConstParamTy) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `check`
LL | fn check(_: impl std::marker::ConstParamTy_) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `check`
help: use parentheses to call this function pointer
|
LL | check(main as fn()());
@ -58,16 +58,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 `UnsizedConstParamTy` is not implemented for `&mut ()`
| ----- ^^^^^^^ the trait `ConstParamTy_` is not implemented for `&mut ()`
| |
| required by a bound introduced by this call
|
= note: `UnsizedConstParamTy` is implemented for `&()`, but not for `&mut ()`
= note: `ConstParamTy_` 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::UnsizedConstParamTy) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `check`
LL | fn check(_: impl std::marker::ConstParamTy_) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `check`
help: consider removing the leading `&`-reference
|
LL - check(&mut ());
@ -78,31 +78,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 `UnsizedConstParamTy` is not implemented for `*mut ()`
| ----- ^^^^^^^^^^^^^^^^^^ the trait `ConstParamTy_` is not implemented for `*mut ()`
| |
| required by a bound introduced by this call
|
= help: the trait `UnsizedConstParamTy` is implemented for `()`
= help: the trait `ConstParamTy_` is implemented for `()`
note: required by a bound in `check`
--> $DIR/const_param_ty_bad.rs:4:18
|
LL | fn check(_: impl std::marker::UnsizedConstParamTy) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `check`
LL | fn check(_: impl std::marker::ConstParamTy_) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 `UnsizedConstParamTy` is not implemented for `*const ()`
| ----- ^^^^^^^^^^^^^^^^ the trait `ConstParamTy_` is not implemented for `*const ()`
| |
| required by a bound introduced by this call
|
= help: the trait `UnsizedConstParamTy` is implemented for `()`
= help: the trait `ConstParamTy_` is implemented for `()`
note: required by a bound in `check`
--> $DIR/const_param_ty_bad.rs:4:18
|
LL | fn check(_: impl std::marker::UnsizedConstParamTy) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `check`
LL | fn check(_: impl std::marker::ConstParamTy_) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `check`
error: aborting due to 6 previous errors

View file

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

View file

@ -15,23 +15,6 @@ LL - fn foo(a: &dyn ConstParamTy_) {}
LL + fn foo(a: &impl ConstParamTy_) {}
|
error[E0038]: the trait `UnsizedConstParamTy` is not dyn compatible
--> $DIR/const_param_ty_dyn_compatibility.rs:9:16
|
LL | fn bar(a: &dyn UnsizedConstParamTy) {}
| ^^^^^^^^^^^^^^^^^^^ `UnsizedConstParamTy` is not dyn compatible
|
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
--> $SRC_DIR/core/src/cmp.rs:LL:COL
|
= note: the trait is not dyn compatible because it uses `Self` as a type parameter
help: consider using an opaque type instead
|
LL - fn bar(a: &dyn UnsizedConstParamTy) {}
LL + fn bar(a: &impl UnsizedConstParamTy) {}
|
error: aborting due to 2 previous errors
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0038`.

View file

@ -4,7 +4,7 @@
#[derive(PartialEq, Eq)]
struct NotParam;
fn check<T: std::marker::UnsizedConstParamTy + ?Sized>() {}
fn check<T: std::marker::ConstParamTy_ + ?Sized>() {}
fn main() {
check::<&NotParam>(); //~ error: `NotParam` can't be used as a const parameter type

View file

@ -4,17 +4,17 @@ error[E0277]: `NotParam` can't be used as a const parameter type
LL | check::<&NotParam>();
| ^^^^^^^^^ unsatisfied trait bound
|
help: the trait `UnsizedConstParamTy` is not implemented for `NotParam`
help: the trait `ConstParamTy_` is not implemented for `NotParam`
--> $DIR/const_param_ty_generic_bounds_do_not_hold.rs:5:1
|
LL | struct NotParam;
| ^^^^^^^^^^^^^^^
= note: required for `&NotParam` to implement `UnsizedConstParamTy`
= note: required for `&NotParam` to implement `ConstParamTy_`
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::UnsizedConstParamTy + ?Sized>() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `check`
LL | fn check<T: std::marker::ConstParamTy_ + ?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
@ -22,17 +22,17 @@ error[E0277]: `NotParam` can't be used as a const parameter type
LL | check::<[NotParam]>();
| ^^^^^^^^^^ unsatisfied trait bound
|
help: the trait `UnsizedConstParamTy` is not implemented for `NotParam`
help: the trait `ConstParamTy_` is not implemented for `NotParam`
--> $DIR/const_param_ty_generic_bounds_do_not_hold.rs:5:1
|
LL | struct NotParam;
| ^^^^^^^^^^^^^^^
= note: required for `[NotParam]` to implement `UnsizedConstParamTy`
= note: required for `[NotParam]` to implement `ConstParamTy_`
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::UnsizedConstParamTy + ?Sized>() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `check`
LL | fn check<T: std::marker::ConstParamTy_ + ?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
@ -40,17 +40,17 @@ error[E0277]: `NotParam` can't be used as a const parameter type
LL | check::<[NotParam; 17]>();
| ^^^^^^^^^^^^^^ unsatisfied trait bound
|
help: the trait `UnsizedConstParamTy` is not implemented for `NotParam`
help: the trait `ConstParamTy_` is not implemented for `NotParam`
--> $DIR/const_param_ty_generic_bounds_do_not_hold.rs:5:1
|
LL | struct NotParam;
| ^^^^^^^^^^^^^^^
= note: required for `[NotParam; 17]` to implement `UnsizedConstParamTy`
= note: required for `[NotParam; 17]` to implement `ConstParamTy_`
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::UnsizedConstParamTy + ?Sized>() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `check`
LL | fn check<T: std::marker::ConstParamTy_ + ?Sized>() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `check`
error: aborting due to 3 previous errors

View file

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

View file

@ -7,10 +7,10 @@ struct NotParam;
#[derive(PartialEq, Eq)]
struct CantParam(NotParam);
impl std::marker::UnsizedConstParamTy for CantParam {}
impl std::marker::ConstParamTy_ for CantParam {}
//~^ error: the trait `ConstParamTy_` cannot be implemented for this type
#[derive(std::marker::UnsizedConstParamTy, Eq, PartialEq)]
#[derive(std::marker::ConstParamTy, Eq, PartialEq)]
//~^ error: the trait `ConstParamTy_` cannot be implemented for this type
struct CantParamDerive(NotParam);

View file

@ -1,17 +1,17 @@
error[E0204]: the trait `ConstParamTy_` cannot be implemented for this type
--> $DIR/const_param_ty_impl_bad_field.rs:10:43
--> $DIR/const_param_ty_impl_bad_field.rs:10:37
|
LL | struct CantParam(NotParam);
| -------- this field does not implement `ConstParamTy_`
LL |
LL | impl std::marker::UnsizedConstParamTy for CantParam {}
| ^^^^^^^^^
LL | impl std::marker::ConstParamTy_ for CantParam {}
| ^^^^^^^^^
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::UnsizedConstParamTy, Eq, PartialEq)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | #[derive(std::marker::ConstParamTy, Eq, PartialEq)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^
LL |
LL | struct CantParamDerive(NotParam);
| -------- this field does not implement `ConstParamTy_`

View file

@ -3,20 +3,20 @@
#[derive(PartialEq, Eq)]
struct ImplementsConstParamTy;
impl std::marker::UnsizedConstParamTy for ImplementsConstParamTy {}
impl std::marker::ConstParamTy_ for ImplementsConstParamTy {}
struct CantParam(ImplementsConstParamTy);
impl std::marker::UnsizedConstParamTy for CantParam {}
impl std::marker::ConstParamTy_ for CantParam {}
//~^ error: the type `CantParam` does not `#[derive(PartialEq)]`
//~| ERROR the trait bound `CantParam: Eq` is not satisfied
#[derive(std::marker::UnsizedConstParamTy)]
#[derive(std::marker::ConstParamTy)]
//~^ error: the type `CantParamDerive` does not `#[derive(PartialEq)]`
//~| ERROR the trait bound `CantParamDerive: Eq` is not satisfied
struct CantParamDerive(ImplementsConstParamTy);
fn check<T: std::marker::UnsizedConstParamTy>() {}
fn check<T: std::marker::ConstParamTy_>() {}
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:43
--> $DIR/const_param_ty_impl_no_structural_eq.rs:10:37
|
LL | impl std::marker::UnsizedConstParamTy for CantParam {}
| ^^^^^^^^^ the trait `Eq` is not implemented for `CantParam`
LL | impl std::marker::ConstParamTy_ for CantParam {}
| ^^^^^^^^^ the trait `Eq` is not implemented for `CantParam`
|
note: required by a bound in `UnsizedConstParamTy`
note: required by a bound in `ConstParamTy_`
--> $SRC_DIR/core/src/marker.rs:LL:COL
help: consider annotating `CantParam` with `#[derive(Eq)]`
|
@ -13,26 +13,26 @@ LL | struct CantParam(ImplementsConstParamTy);
|
error[E0277]: the type `CantParam` does not `#[derive(PartialEq)]`
--> $DIR/const_param_ty_impl_no_structural_eq.rs:10:43
--> $DIR/const_param_ty_impl_no_structural_eq.rs:10:37
|
LL | impl std::marker::UnsizedConstParamTy for CantParam {}
| ^^^^^^^^^ unsatisfied trait bound
LL | impl std::marker::ConstParamTy_ for CantParam {}
| ^^^^^^^^^ unsatisfied trait bound
|
help: the trait `StructuralPartialEq` is not implemented for `CantParam`
--> $DIR/const_param_ty_impl_no_structural_eq.rs:8:1
|
LL | struct CantParam(ImplementsConstParamTy);
| ^^^^^^^^^^^^^^^^
note: required by a bound in `UnsizedConstParamTy`
note: required by a bound in `ConstParamTy_`
--> $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::UnsizedConstParamTy)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Eq` is not implemented for `CantParamDerive`
LL | #[derive(std::marker::ConstParamTy)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Eq` is not implemented for `CantParamDerive`
|
note: required by a bound in `UnsizedConstParamTy`
note: required by a bound in `ConstParamTy_`
--> $SRC_DIR/core/src/marker.rs:LL:COL
help: consider annotating `CantParamDerive` with `#[derive(Eq)]`
|
@ -43,15 +43,15 @@ 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::UnsizedConstParamTy)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound
LL | #[derive(std::marker::ConstParamTy)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound
|
help: the trait `StructuralPartialEq` is not implemented for `CantParamDerive`
--> $DIR/const_param_ty_impl_no_structural_eq.rs:17:1
|
LL | struct CantParamDerive(ImplementsConstParamTy);
| ^^^^^^^^^^^^^^^^^^^^^^
note: required by a bound in `UnsizedConstParamTy`
note: required by a bound in `ConstParamTy_`
--> $SRC_DIR/core/src/marker.rs:LL:COL
error: aborting due to 4 previous errors

View file

@ -12,10 +12,10 @@ impl PartialEq for Union {
}
impl Eq for Union {}
impl std::marker::UnsizedConstParamTy for Union {}
impl std::marker::ConstParamTy_ for Union {}
//~^ ERROR the trait `ConstParamTy` may not be implemented for this type
#[derive(std::marker::UnsizedConstParamTy)]
#[derive(std::marker::ConstParamTy)]
//~^ ERROR this trait cannot be derived for unions
union UnionDerive {
a: u8,

View file

@ -1,14 +1,14 @@
error: this trait cannot be derived for unions
--> $DIR/const_param_ty_impl_union.rs:18:10
|
LL | #[derive(std::marker::UnsizedConstParamTy)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | #[derive(std::marker::ConstParamTy)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^
error: the trait `ConstParamTy` may not be implemented for this type
--> $DIR/const_param_ty_impl_union.rs:15:43
--> $DIR/const_param_ty_impl_union.rs:15:37
|
LL | impl std::marker::UnsizedConstParamTy for Union {}
| ^^^^^ type is not a structure or enumeration
LL | impl std::marker::ConstParamTy_ for Union {}
| ^^^^^ type is not a structure or enumeration
error: aborting due to 2 previous errors

View file

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

View file

@ -3,91 +3,46 @@ error[E0204]: the trait `ConstParamTy_` cannot be implemented for this type
|
LL | #[derive(ConstParamTy)]
| ^^^^^^^^^^^^
...
LL |
LL | struct Foo([*const u8; 1]);
| -------------- 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:9:12
--> $DIR/nested_bad_const_param_ty.rs:8:12
|
LL | struct Foo([*const u8; 1]);
| ^^^^^^^^^^^^^^
error[E0204]: the trait `ConstParamTy_` cannot be implemented for this type
--> $DIR/nested_bad_const_param_ty.rs:11:10
--> $DIR/nested_bad_const_param_ty.rs:10:10
|
LL | #[derive(ConstParamTy)]
| ^^^^^^^^^^^^
...
LL |
LL | struct Foo2([*mut u8; 1]);
| ------------ 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:14:13
--> $DIR/nested_bad_const_param_ty.rs:12:13
|
LL | struct Foo2([*mut u8; 1]);
| ^^^^^^^^^^^^
error[E0204]: the trait `ConstParamTy_` cannot be implemented for this type
--> $DIR/nested_bad_const_param_ty.rs:16:10
--> $DIR/nested_bad_const_param_ty.rs:14:10
|
LL | #[derive(ConstParamTy)]
| ^^^^^^^^^^^^
...
LL |
LL | struct Foo3([fn(); 1]);
| --------- this field does not implement `ConstParamTy_`
|
note: the `ConstParamTy_` impl for `[fn(); 1]` requires that `fn(): ConstParamTy_`
--> $DIR/nested_bad_const_param_ty.rs:19:13
--> $DIR/nested_bad_const_param_ty.rs:16:13
|
LL | struct Foo3([fn(); 1]);
| ^^^^^^^^^
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]);
| ^^^^^^^^^^^^^^
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]);
| ^^^^^^^^^^^^
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]);
| ^^^^^^^^^
error: aborting due to 6 previous errors
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0204`.

View file

@ -9,11 +9,13 @@ help: you might be missing a const parameter
LL | impl<const bar: /* Type */> Wrapper<{ bar() }> {
| +++++++++++++++++++++++
error[E0741]: using function pointers as const generic parameters is forbidden
error: using function pointers as const generic parameters is forbidden
--> $DIR/non_valtreeable_const_arg-2.rs:8:25
|
LL | struct Wrapper<const F: fn()>;
| ^^^^
|
= note: the only supported types are integers, `bool`, and `char`
error[E0599]: the function or associated item `call` exists for struct `Wrapper<function>`, but its trait bounds were not satisfied
--> $DIR/non_valtreeable_const_arg-2.rs:17:26
@ -35,5 +37,5 @@ note: the trait `Fn` must be implemented
error: aborting due to 3 previous errors
Some errors have detailed explanations: E0425, E0599, E0741.
Some errors have detailed explanations: E0425, E0599.
For more information about an error, try `rustc --explain E0425`.

View file

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

View file

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

View file

@ -3,12 +3,12 @@
// Regression test for #119299
use std::marker::UnsizedConstParamTy;
use std::marker::ConstParamTy_;
#[derive(Eq, PartialEq)]
struct ConstStrU(*const u8, usize);
impl UnsizedConstParamTy for &'static ConstStrU {}
impl ConstParamTy_ for &'static ConstStrU {}
//~^ ERROR: the trait `ConstParamTy_` cannot be implemented for this type
impl ConstStrU {

View file

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

View file

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

View file

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

View file

@ -14,7 +14,10 @@ struct A([u8]);
struct B(&'static [u8]);
#[derive(ConstParamTy, Eq, PartialEq)]
//~^ ERROR: the trait `ConstParamTy_` cannot be implemented for this type
struct C(unsized_const_param::Foo);
#[derive(std::marker::ConstParamTy, Eq, PartialEq)]
//~^ ERROR: the trait `ConstParamTy_` cannot be implemented for this type
struct D(unsized_const_param::GenericNotUnsizedParam<&'static [u8]>);
fn main() {}

View file

@ -6,6 +6,12 @@ LL | #[derive(ConstParamTy, Eq, PartialEq)]
LL |
LL | struct A([u8]);
| ---- this field does not implement `ConstParamTy_`
|
note: the `ConstParamTy_` impl for `[u8]` requires that `unstable feature: `unsized_const_params``
--> $DIR/unsized_field-1.rs:10:10
|
LL | struct A([u8]);
| ^^^^
error[E0204]: the trait `ConstParamTy_` cannot be implemented for this type
--> $DIR/unsized_field-1.rs:12:10
@ -15,15 +21,27 @@ LL | #[derive(ConstParamTy, Eq, PartialEq)]
LL |
LL | struct B(&'static [u8]);
| ------------- this field does not implement `ConstParamTy_`
|
note: the `ConstParamTy_` impl for `&'static [u8]` requires that `unstable feature: `unsized_const_params``
--> $DIR/unsized_field-1.rs:14:10
|
LL | struct B(&'static [u8]);
| ^^^^^^^^^^^^^
error[E0204]: the trait `ConstParamTy_` cannot be implemented for this type
--> $DIR/unsized_field-1.rs:16:10
--> $DIR/unsized_field-1.rs:19:10
|
LL | #[derive(ConstParamTy, Eq, PartialEq)]
| ^^^^^^^^^^^^
LL | #[derive(std::marker::ConstParamTy, Eq, PartialEq)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^
LL |
LL | struct C(unsized_const_param::Foo);
| ------------------------ this field does not implement `ConstParamTy_`
LL | struct D(unsized_const_param::GenericNotUnsizedParam<&'static [u8]>);
| ---------------------------------------------------------- this field does not implement `ConstParamTy_`
|
note: the `ConstParamTy_` impl for `GenericNotUnsizedParam<&'static [u8]>` requires that `unstable feature: `unsized_const_params``
--> $DIR/unsized_field-1.rs:21:10
|
LL | struct D(unsized_const_param::GenericNotUnsizedParam<&'static [u8]>);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 3 previous errors

View file

@ -1,14 +0,0 @@
//@ 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

@ -1,27 +0,0 @@
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]>);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 1 previous error; 1 warning emitted
For more information about this error, try `rustc --explain E0204`.

View file

@ -7,7 +7,6 @@ use std::marker::ConstParamTy;
#[derive(Debug, PartialEq, Eq, ConstParamTy)]
//~^ ERROR the trait `ConstParamTy_`
//~| ERROR the trait `ConstParamTy_`
struct Foo {
nested: &'static Bar<dyn std::fmt::Debug>,
//~^ ERROR the size for values

View file

@ -1,17 +1,17 @@
error[E0277]: the size for values of type `(dyn Debug + 'static)` cannot be known at compilation time
--> $DIR/unsizing-wfcheck-issue-126272.rs:12:13
--> $DIR/unsizing-wfcheck-issue-126272.rs:11:13
|
LL | nested: &'static Bar<dyn std::fmt::Debug>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `(dyn Debug + 'static)`
note: required by an implicit `Sized` bound in `Bar`
--> $DIR/unsizing-wfcheck-issue-126272.rs:21:12
--> $DIR/unsizing-wfcheck-issue-126272.rs:20:12
|
LL | struct Bar<T>(T);
| ^ required by the implicit `Sized` requirement on this type parameter in `Bar`
help: you could relax the implicit `Sized` bound on `T` if it were used through indirection like `&T` or `Box<T>`
--> $DIR/unsizing-wfcheck-issue-126272.rs:21:12
--> $DIR/unsizing-wfcheck-issue-126272.rs:20:12
|
LL | struct Bar<T>(T);
| ^ - ...if indirection were used here: `Box<T>`
@ -26,34 +26,25 @@ LL | #[derive(Debug, PartialEq, Eq, ConstParamTy)]
...
LL | nested: &'static Bar<dyn std::fmt::Debug>,
| ----------------------------------------- this field does not implement `ConstParamTy_`
error[E0204]: the trait `ConstParamTy_` cannot be implemented for this type
--> $DIR/unsizing-wfcheck-issue-126272.rs:8:32
|
LL | #[derive(Debug, PartialEq, Eq, ConstParamTy)]
| ^^^^^^^^^^^^
...
note: the `ConstParamTy_` impl for `&'static Bar<(dyn Debug + 'static)>` requires that `(dyn Debug + 'static): ConstParamTy_`
--> $DIR/unsizing-wfcheck-issue-126272.rs:11:13
|
LL | nested: &'static Bar<dyn std::fmt::Debug>,
| ----------------------------------------- this field does not implement `ConstParamTy_`
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: the `ConstParamTy_` impl for `&'static Bar<(dyn Debug + 'static)>` requires that `(dyn Debug + 'static): Eq`
--> $DIR/unsizing-wfcheck-issue-126272.rs:12:13
--> $DIR/unsizing-wfcheck-issue-126272.rs:11:13
|
LL | nested: &'static Bar<dyn std::fmt::Debug>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: the `ConstParamTy_` impl for `&'static Bar<(dyn Debug + 'static)>` requires that `(dyn Debug + 'static): Sized`
--> $DIR/unsizing-wfcheck-issue-126272.rs:12:13
|
LL | nested: &'static Bar<dyn std::fmt::Debug>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: the `ConstParamTy_` impl for `&'static Bar<(dyn Debug + 'static)>` requires that `(dyn Debug + 'static): UnsizedConstParamTy`
--> $DIR/unsizing-wfcheck-issue-126272.rs:12:13
--> $DIR/unsizing-wfcheck-issue-126272.rs:11:13
|
LL | nested: &'static Bar<dyn std::fmt::Debug>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0277]: the size for values of type `(dyn Debug + 'static)` cannot be known at compilation time
--> $DIR/unsizing-wfcheck-issue-126272.rs:12:5
--> $DIR/unsizing-wfcheck-issue-126272.rs:11:5
|
LL | #[derive(Debug, PartialEq, Eq, ConstParamTy)]
| ----- in this derive macro expansion
@ -64,7 +55,7 @@ LL | nested: &'static Bar<dyn std::fmt::Debug>,
= help: the trait `Sized` is not implemented for `(dyn Debug + 'static)`
= help: the trait `Debug` is implemented for `Bar<T>`
note: required for `Bar<(dyn Debug + 'static)>` to implement `Debug`
--> $DIR/unsizing-wfcheck-issue-126272.rs:20:10
--> $DIR/unsizing-wfcheck-issue-126272.rs:19:10
|
LL | #[derive(Debug, PartialEq, Eq, ConstParamTy)]
| ^^^^^
@ -75,7 +66,7 @@ LL | struct Bar<T>(T);
= note: required for the cast from `&&&'static Bar<(dyn Debug + 'static)>` to `&dyn Debug`
error[E0369]: binary operation `==` cannot be applied to type `&Bar<dyn Debug>`
--> $DIR/unsizing-wfcheck-issue-126272.rs:12:5
--> $DIR/unsizing-wfcheck-issue-126272.rs:11:5
|
LL | #[derive(Debug, PartialEq, Eq, ConstParamTy)]
| --------- in this derive macro expansion
@ -84,7 +75,7 @@ LL | nested: &'static Bar<dyn std::fmt::Debug>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0277]: the trait bound `dyn Debug: Eq` is not satisfied
--> $DIR/unsizing-wfcheck-issue-126272.rs:12:5
--> $DIR/unsizing-wfcheck-issue-126272.rs:11:5
|
LL | #[derive(Debug, PartialEq, Eq, ConstParamTy)]
| -- in this derive macro expansion
@ -94,7 +85,7 @@ LL | nested: &'static Bar<dyn std::fmt::Debug>,
|
= help: the trait `Eq` is implemented for `Bar<T>`
note: required for `Bar<dyn Debug>` to implement `Eq`
--> $DIR/unsizing-wfcheck-issue-126272.rs:20:28
--> $DIR/unsizing-wfcheck-issue-126272.rs:19:28
|
LL | #[derive(Debug, PartialEq, Eq, ConstParamTy)]
| ^^ unsatisfied trait bound introduced in this `derive` macro
@ -104,7 +95,7 @@ note: required by a bound in `AssertParamIsEq`
--> $SRC_DIR/core/src/cmp.rs:LL:COL
error[E0277]: the size for values of type `dyn Debug` cannot be known at compilation time
--> $DIR/unsizing-wfcheck-issue-126272.rs:12:5
--> $DIR/unsizing-wfcheck-issue-126272.rs:11:5
|
LL | #[derive(Debug, PartialEq, Eq, ConstParamTy)]
| -- in this derive macro expansion
@ -114,12 +105,12 @@ LL | nested: &'static Bar<dyn std::fmt::Debug>,
|
= help: the trait `Sized` is not implemented for `dyn Debug`
note: required by an implicit `Sized` bound in `Bar`
--> $DIR/unsizing-wfcheck-issue-126272.rs:21:12
--> $DIR/unsizing-wfcheck-issue-126272.rs:20:12
|
LL | struct Bar<T>(T);
| ^ required by the implicit `Sized` requirement on this type parameter in `Bar`
help: you could relax the implicit `Sized` bound on `T` if it were used through indirection like `&T` or `Box<T>`
--> $DIR/unsizing-wfcheck-issue-126272.rs:21:12
--> $DIR/unsizing-wfcheck-issue-126272.rs:20:12
|
LL | struct Bar<T>(T);
| ^ - ...if indirection were used here: `Box<T>`
@ -127,26 +118,26 @@ LL | struct Bar<T>(T);
| this could be changed to `T: ?Sized`...
error[E0277]: the size for values of type `(dyn Debug + 'static)` cannot be known at compilation time
--> $DIR/unsizing-wfcheck-issue-126272.rs:26:33
--> $DIR/unsizing-wfcheck-issue-126272.rs:25:33
|
LL | let x: Test<{ Foo { nested: &Bar(4) } }> = Test;
| ^^^^^^^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `(dyn Debug + 'static)`
note: required by an implicit `Sized` bound in `Bar`
--> $DIR/unsizing-wfcheck-issue-126272.rs:21:12
--> $DIR/unsizing-wfcheck-issue-126272.rs:20:12
|
LL | struct Bar<T>(T);
| ^ required by the implicit `Sized` requirement on this type parameter in `Bar`
help: you could relax the implicit `Sized` bound on `T` if it were used through indirection like `&T` or `Box<T>`
--> $DIR/unsizing-wfcheck-issue-126272.rs:21:12
--> $DIR/unsizing-wfcheck-issue-126272.rs:20:12
|
LL | struct Bar<T>(T);
| ^ - ...if indirection were used here: `Box<T>`
| |
| this could be changed to `T: ?Sized`...
error: aborting due to 8 previous errors
error: aborting due to 7 previous errors
Some errors have detailed explanations: E0204, E0277, E0369.
For more information about an error, try `rustc --explain E0204`.

View file

@ -1,14 +1,14 @@
#![feature(adt_const_params, unsized_const_params)]
#![allow(incomplete_features)]
use std::marker::UnsizedConstParamTy;
use std::marker::ConstParamTy_;
#[derive(Eq, PartialEq)]
struct Foo<T>(T);
trait Other {}
impl<T> UnsizedConstParamTy for Foo<T> where T: Other + UnsizedConstParamTy {}
impl<T> ConstParamTy_ for Foo<T> where T: Other + ConstParamTy_ {}
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

@ -4,7 +4,7 @@ error[E0741]: `[T; N]` can't be used as a const parameter type
LL | struct UsesType<T, const N: usize, const M: [T; N]>(PhantomData<T>);
| ^^^^^^
|
= note: `T` must implement `UnsizedConstParamTy`, but it does not
= note: `T` must implement `ConstParamTy_`, but it does not
error: aborting due to 1 previous error

View file

@ -1,15 +1,15 @@
#![feature(adt_const_params, unsized_const_params)]
#![allow(incomplete_features)]
use std::marker::UnsizedConstParamTy;
use std::marker::ConstParamTy;
#[derive(Debug, PartialEq, Eq, UnsizedConstParamTy)]
#[derive(Debug, PartialEq, Eq, ConstParamTy)]
struct Foo {
value: i32,
nested: &'static Bar<i32>,
}
#[derive(Debug, PartialEq, Eq, UnsizedConstParamTy)]
#[derive(Debug, PartialEq, Eq, ConstParamTy)]
struct Bar<T>(T);
struct Test<const F: Foo>;

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 `UnsizedConstParamTy`, but it does not
= note: `(dyn A + 'static)` must implement `ConstParamTy_`, but it does not
error: aborting due to 1 previous error

View file

@ -1,14 +1,22 @@
error[E0741]: `&'static str` can't be used as a const parameter type
--> $DIR/slice-const-param-mismatch.rs:8:29
error[E0658]: use of unstable library feature `unsized_const_params`
--> $DIR/slice-const-param-mismatch.rs:8:20
|
LL | struct ConstString<const T: &'static str>;
| ^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^^^^^
|
= help: add `#![feature(unsized_const_params)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
= note: required for `&'static str` to implement `ConstParamTy_`
error[E0741]: `&'static [u8]` can't be used as a const parameter type
--> $DIR/slice-const-param-mismatch.rs:11:28
error[E0658]: use of unstable library feature `unsized_const_params`
--> $DIR/slice-const-param-mismatch.rs:11:19
|
LL | struct ConstBytes<const T: &'static [u8]>;
| ^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^^^^^^
|
= help: add `#![feature(unsized_const_params)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
= note: required for `&'static [u8]` to implement `ConstParamTy_`
error[E0308]: mismatched types
--> $DIR/slice-const-param-mismatch.rs:17:35
@ -45,5 +53,5 @@ LL | let _: ConstBytes<b"AAA"> = ConstBytes::<b"BBB">;
error: aborting due to 5 previous errors
Some errors have detailed explanations: E0308, E0741.
Some errors have detailed explanations: E0308, E0658.
For more information about an error, try `rustc --explain E0308`.

View file

@ -12,7 +12,7 @@ pub fn function_with_bytes<const BYTES: &'static [u8]>() -> &'static [u8] {
}
// Also check the codepaths for custom DST
#[derive(std::marker::UnsizedConstParamTy, PartialEq, Eq)]
#[derive(std::marker::ConstParamTy, PartialEq, Eq)]
struct MyStr(str);
fn function_with_my_str<const S: &'static MyStr>() -> &'static MyStr {

View file

@ -1,9 +1,13 @@
error[E0741]: `&'static ()` can't be used as a const parameter type
--> $DIR/transmute-const-param-static-reference.rs:9:23
error[E0658]: use of unstable library feature `unsized_const_params`
--> $DIR/transmute-const-param-static-reference.rs:9:14
|
LL | struct Const<const P: &'static ()>;
| ^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^^^^
|
= help: add `#![feature(unsized_const_params)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
= note: required for `&'static ()` to implement `ConstParamTy_`
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0741`.
For more information about this error, try `rustc --explain E0658`.

View file

@ -8,7 +8,7 @@
struct Const<const P: &'static ()>;
//[min]~^ ERROR `&'static ()` is forbidden as the type of a const generic parameter
//[adt_const_params]~^^ ERROR `&'static ()` can't be used as a const parameter type
//[adt_const_params]~^^ ERROR use of unstable library feature `unsized_const_params`
fn main() {
const A: &'static () = unsafe { std::mem::transmute(10 as *const ()) };

View file

@ -1,13 +1,13 @@
//@ check-pass
//@ compile-flags: -Csymbol-mangling-version=v0
#![allow(incomplete_features)]
#![feature(unsized_const_params)]
#![feature(adt_const_params, unsized_const_params)]
// Regression test for #116303
#[derive(PartialEq, Eq)]
struct MyStr(str);
impl std::marker::UnsizedConstParamTy for MyStr {}
impl std::marker::ConstParamTy_ for MyStr {}
fn function_with_my_str<const S: &'static MyStr>() -> &'static MyStr {
S

View file

@ -1,2 +1,6 @@
struct Foo<const NAME: &'static str>; //~ ERROR `&'static str` is forbidden
struct Bar(u8);
struct Foo<const N: Bar>;
//~^ ERROR: `Bar` is forbidden as the type of a const generic parameter
fn main() {}

View file

@ -1,18 +1,14 @@
error: `&'static str` is forbidden as the type of a const generic parameter
--> $DIR/feature-gate-adt_const_params.rs:1:24
error: `Bar` is forbidden as the type of a const generic parameter
--> $DIR/feature-gate-adt_const_params.rs:3:21
|
LL | struct Foo<const NAME: &'static str>;
| ^^^^^^^^^^^^
LL | struct Foo<const N: Bar>;
| ^^^
|
= 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)]
|
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

@ -9,6 +9,7 @@ mod assert {
where
Dst: TransmuteFrom<Src>,
//~^ ERROR: use of unstable library feature `transmutability`
//~^^ ERROR: use of unstable library feature `transmutability`
{
}
}

View file

@ -1,5 +1,5 @@
error[E0412]: cannot find type `Subset` in this scope
--> $DIR/thaw-transmute-invalid-enum.rs:34:41
--> $DIR/thaw-transmute-invalid-enum.rs:35:41
|
LL | assert::is_transmutable::<Superset, Subset>();
| ^^^^^^ not found in this scope
@ -10,7 +10,7 @@ LL | fn test<Subset>() {
| ++++++++
error[E0517]: attribute should be applied to a struct or union
--> $DIR/thaw-transmute-invalid-enum.rs:21:11
--> $DIR/thaw-transmute-invalid-enum.rs:22:11
|
LL | #[repr(C, packed(2))]
| ^^^^^^^^^
@ -50,8 +50,19 @@ LL | Dst: TransmuteFrom<Src>,
= help: add `#![feature(transmutability)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0658]: use of unstable library feature `transmutability`
--> $DIR/thaw-transmute-invalid-enum.rs:10:14
|
LL | Dst: TransmuteFrom<Src>,
| ^^^^^^^^^^^^^^^^^^
|
= help: add `#![feature(transmutability)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
note: required by a bound in `TransmuteFrom`
--> $SRC_DIR/core/src/mem/transmutability.rs:LL:COL
error[E0740]: field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union
--> $DIR/thaw-transmute-invalid-enum.rs:29:9
--> $DIR/thaw-transmute-invalid-enum.rs:30:9
|
LL | a: Ox00,
| ^^^^^^^
@ -62,7 +73,7 @@ help: wrap the field type in `ManuallyDrop<...>`
LL | a: std::mem::ManuallyDrop<Ox00>,
| +++++++++++++++++++++++ +
error: aborting due to 6 previous errors
error: aborting due to 7 previous errors
Some errors have detailed explanations: E0412, E0517, E0658, E0740.
For more information about an error, try `rustc --explain E0412`.

View file

@ -6,7 +6,7 @@
#![feature(adt_const_params, unsized_const_params, decl_macro, rustc_attrs)]
#![allow(incomplete_features)]
use std::marker::UnsizedConstParamTy;
use std::marker::ConstParamTy;
pub struct RefByte<const RB: &'static u8>;
@ -42,7 +42,7 @@ pub struct TupleByteBool<const TBB: (u8, bool)>;
//~| ERROR demangling-alt(<c::TupleByteBool<{(1, false)}>>)
impl TupleByteBool<{ (1, false) }> {}
#[derive(PartialEq, Eq, UnsizedConstParamTy)]
#[derive(PartialEq, Eq, ConstParamTy)]
pub enum MyOption<T> {
Some(T),
None,
@ -66,7 +66,7 @@ impl OptionUsize<{ MyOption::None }> {}
//~| ERROR demangling-alt(<c::OptionUsize<{c::MyOption::<usize>::Some(0)}>>)
impl OptionUsize<{ MyOption::Some(0) }> {}
#[derive(PartialEq, Eq, UnsizedConstParamTy)]
#[derive(PartialEq, Eq, ConstParamTy)]
pub struct Foo {
s: &'static str,
ch: char,
@ -83,7 +83,7 @@ impl Foo_<{ Foo { s: "abc", ch: 'x', slice: &[1, 2, 3] } }> {}
// NOTE(eddyb) this tests specifically the use of disambiguators in field names,
// using macros 2.0 hygiene to create a `struct` with conflicting field names.
macro duplicate_field_name_test($x:ident) {
#[derive(PartialEq, Eq, UnsizedConstParamTy)]
#[derive(PartialEq, Eq, ConstParamTy)]
pub struct Bar {
$x: u8,
x: u16,