Change const trait bound syntax from ~const to [const]
This commit is contained in:
parent
18f4cb1110
commit
eb7245a864
234 changed files with 1382 additions and 1319 deletions
|
|
@ -323,7 +323,7 @@ impl ParenthesizedArgs {
|
|||
|
||||
pub use crate::node_id::{CRATE_NODE_ID, DUMMY_NODE_ID, NodeId};
|
||||
|
||||
/// Modifiers on a trait bound like `~const`, `?` and `!`.
|
||||
/// Modifiers on a trait bound like `[const]`, `?` and `!`.
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Encodable, Decodable, Debug)]
|
||||
pub struct TraitBoundModifiers {
|
||||
pub constness: BoundConstness,
|
||||
|
|
@ -3111,7 +3111,7 @@ pub enum BoundConstness {
|
|||
Never,
|
||||
/// `Type: const Trait`
|
||||
Always(Span),
|
||||
/// `Type: ~const Trait`
|
||||
/// `Type: [const] Trait`
|
||||
Maybe(Span),
|
||||
}
|
||||
|
||||
|
|
@ -3120,7 +3120,7 @@ impl BoundConstness {
|
|||
match self {
|
||||
Self::Never => "",
|
||||
Self::Always(_) => "const",
|
||||
Self::Maybe(_) => "~const",
|
||||
Self::Maybe(_) => "[const]",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -232,17 +232,17 @@ ast_passes_static_without_body =
|
|||
free static item without body
|
||||
.suggestion = provide a definition for the static
|
||||
|
||||
ast_passes_tilde_const_disallowed = `~const` is not allowed here
|
||||
.closure = closures cannot have `~const` trait bounds
|
||||
.function = this function is not `const`, so it cannot have `~const` trait bounds
|
||||
.trait = this trait is not a `#[const_trait]`, so it cannot have `~const` trait bounds
|
||||
.trait_impl = this impl is not `const`, so it cannot have `~const` trait bounds
|
||||
.impl = inherent impls cannot have `~const` trait bounds
|
||||
.trait_assoc_ty = associated types in non-`#[const_trait]` traits cannot have `~const` trait bounds
|
||||
.trait_impl_assoc_ty = associated types in non-const impls cannot have `~const` trait bounds
|
||||
.inherent_assoc_ty = inherent associated types cannot have `~const` trait bounds
|
||||
.object = trait objects cannot have `~const` trait bounds
|
||||
.item = this item cannot have `~const` trait bounds
|
||||
ast_passes_tilde_const_disallowed = `[const]` is not allowed here
|
||||
.closure = closures cannot have `[const]` trait bounds
|
||||
.function = this function is not `const`, so it cannot have `[const]` trait bounds
|
||||
.trait = this trait is not a `#[const_trait]`, so it cannot have `[const]` trait bounds
|
||||
.trait_impl = this impl is not `const`, so it cannot have `[const]` trait bounds
|
||||
.impl = inherent impls cannot have `[const]` trait bounds
|
||||
.trait_assoc_ty = associated types in non-`#[const_trait]` traits cannot have `[const]` trait bounds
|
||||
.trait_impl_assoc_ty = associated types in non-const impls cannot have `[const]` trait bounds
|
||||
.inherent_assoc_ty = inherent associated types cannot have `[const]` trait bounds
|
||||
.object = trait objects cannot have `[const]` trait bounds
|
||||
.item = this item cannot have `[const]` trait bounds
|
||||
|
||||
ast_passes_trait_fn_const =
|
||||
functions in {$in_impl ->
|
||||
|
|
|
|||
|
|
@ -421,7 +421,7 @@ impl<'mir, 'tcx> Checker<'mir, 'tcx> {
|
|||
Some(ConstConditionsHold::Yes)
|
||||
} else {
|
||||
tcx.dcx()
|
||||
.span_delayed_bug(call_span, "this should have reported a ~const error in HIR");
|
||||
.span_delayed_bug(call_span, "this should have reported a [const] error in HIR");
|
||||
Some(ConstConditionsHold::No)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -149,7 +149,7 @@ impl<'tcx> NonConstOp<'tcx> for FnCallNonConst<'tcx> {
|
|||
debug!(?param_ty);
|
||||
if let Some(generics) = tcx.hir_node_by_def_id(caller).generics() {
|
||||
let constraint = with_no_trimmed_paths!(format!(
|
||||
"~const {}",
|
||||
"[const] {}",
|
||||
trait_ref.print_trait_sugared(),
|
||||
));
|
||||
suggest_constraining_type_param(
|
||||
|
|
|
|||
|
|
@ -170,14 +170,14 @@ impl Qualif for NeedsNonConstDrop {
|
|||
|
||||
#[instrument(level = "trace", skip(cx), ret)]
|
||||
fn in_any_value_of_ty<'tcx>(cx: &ConstCx<'_, 'tcx>, ty: Ty<'tcx>) -> bool {
|
||||
// If this doesn't need drop at all, then don't select `~const Destruct`.
|
||||
// If this doesn't need drop at all, then don't select `[const] Destruct`.
|
||||
if !ty.needs_drop(cx.tcx, cx.typing_env) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// We check that the type is `~const Destruct` since that will verify that
|
||||
// the type is both `~const Drop` (if a drop impl exists for the adt), *and*
|
||||
// that the components of this type are also `~const Destruct`. This
|
||||
// We check that the type is `[const] Destruct` since that will verify that
|
||||
// the type is both `[const] Drop` (if a drop impl exists for the adt), *and*
|
||||
// that the components of this type are also `[const] Destruct`. This
|
||||
// amounts to verifying that there are no values in this ADT that may have
|
||||
// a non-const drop.
|
||||
let destruct_def_id = cx.tcx.require_lang_item(LangItem::Destruct, cx.body.span);
|
||||
|
|
@ -203,9 +203,9 @@ impl Qualif for NeedsNonConstDrop {
|
|||
fn is_structural_in_adt_value<'tcx>(cx: &ConstCx<'_, 'tcx>, adt: AdtDef<'tcx>) -> bool {
|
||||
// As soon as an ADT has a destructor, then the drop becomes non-structural
|
||||
// in its value since:
|
||||
// 1. The destructor may have `~const` bounds which are not present on the type.
|
||||
// 1. The destructor may have `[const]` bounds which are not present on the type.
|
||||
// Someone needs to check that those are satisfied.
|
||||
// While this could be instead satisfied by checking that the `~const Drop`
|
||||
// While this could be instead satisfied by checking that the `[const] Drop`
|
||||
// impl holds (i.e. replicating part of the `in_any_value_of_ty` logic above),
|
||||
// even in this case, we have another problem, which is,
|
||||
// 2. The destructor may *modify* the operand being dropped, so even if we
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ declare_features! (
|
|||
Some("at compile-time, pointers do not have an integer value, so these casts cannot be properly supported"), 87020),
|
||||
/// Allows `T: ?const Trait` syntax in bounds.
|
||||
(removed, const_trait_bound_opt_out, "1.56.0", Some(67794),
|
||||
Some("Removed in favor of `~const` bound in #![feature(const_trait_impl)]"), 88328),
|
||||
Some("Removed in favor of `[const]` bound in #![feature(const_trait_impl)]"), 88328),
|
||||
/// Allows using `crate` as visibility modifier, synonymous with `pub(crate)`.
|
||||
(removed, crate_visibility_modifier, "1.63.0", Some(53120), Some("removed in favor of `pub(crate)`"), 97254),
|
||||
/// Allows using custom attributes (RFC 572).
|
||||
|
|
@ -122,7 +122,7 @@ declare_features! (
|
|||
/// [^1]: Formerly known as "object safe".
|
||||
(removed, dyn_compatible_for_dispatch, "1.87.0", Some(43561),
|
||||
Some("removed, not used heavily and represented additional complexity in dyn compatibility"), 136522),
|
||||
/// Uses generic effect parameters for ~const bounds
|
||||
/// Uses generic effect parameters for [const] bounds
|
||||
(removed, effects, "1.84.0", Some(102090),
|
||||
Some("removed, redundant with `#![feature(const_trait_impl)]`"), 132479),
|
||||
/// Allows defining `existential type`s.
|
||||
|
|
|
|||
|
|
@ -437,7 +437,7 @@ declare_features! (
|
|||
(unstable, const_async_blocks, "1.53.0", Some(85368)),
|
||||
/// Allows `const || {}` closures in const contexts.
|
||||
(incomplete, const_closures, "1.68.0", Some(106003)),
|
||||
/// Allows using `~const Destruct` bounds and calling drop impls in const contexts.
|
||||
/// Allows using `[const] Destruct` bounds and calling drop impls in const contexts.
|
||||
(unstable, const_destruct, "1.85.0", Some(133214)),
|
||||
/// Allows `for _ in _` loops in const contexts.
|
||||
(unstable, const_for, "1.56.0", Some(87575)),
|
||||
|
|
|
|||
|
|
@ -344,7 +344,7 @@ fn check_opaque_meets_bounds<'tcx>(
|
|||
let misc_cause = ObligationCause::misc(span, def_id);
|
||||
// FIXME: We should just register the item bounds here, rather than equating.
|
||||
// FIXME(const_trait_impl): When we do that, please make sure to also register
|
||||
// the `~const` bounds.
|
||||
// the `[const]` bounds.
|
||||
match ocx.eq(&misc_cause, param_env, opaque_ty, hidden_ty) {
|
||||
Ok(()) => {}
|
||||
Err(ty_err) => {
|
||||
|
|
|
|||
|
|
@ -264,9 +264,9 @@ fn compare_method_predicate_entailment<'tcx>(
|
|||
}
|
||||
|
||||
// If we're within a const implementation, we need to make sure that the method
|
||||
// does not assume stronger `~const` bounds than the trait definition.
|
||||
// does not assume stronger `[const]` bounds than the trait definition.
|
||||
//
|
||||
// This registers the `~const` bounds of the impl method, which we will prove
|
||||
// This registers the `[const]` bounds of the impl method, which we will prove
|
||||
// using the hybrid param-env that we earlier augmented with the const conditions
|
||||
// from the impl header and trait method declaration.
|
||||
if is_conditionally_const {
|
||||
|
|
@ -2335,7 +2335,7 @@ pub(super) fn check_type_bounds<'tcx>(
|
|||
)
|
||||
.collect();
|
||||
|
||||
// Only in a const implementation do we need to check that the `~const` item bounds hold.
|
||||
// Only in a const implementation do we need to check that the `[const]` item bounds hold.
|
||||
if tcx.is_conditionally_const(impl_ty_def_id) {
|
||||
obligations.extend(util::elaborate(
|
||||
tcx,
|
||||
|
|
|
|||
|
|
@ -1399,7 +1399,7 @@ fn check_impl<'tcx>(
|
|||
}
|
||||
}
|
||||
|
||||
// Ensure that the `~const` where clauses of the trait hold for the impl.
|
||||
// Ensure that the `[const]` where clauses of the trait hold for the impl.
|
||||
if tcx.is_conditionally_const(item.owner_id.def_id) {
|
||||
for (bound, _) in
|
||||
tcx.const_conditions(trait_ref.def_id).instantiate(tcx, trait_ref.args)
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ fn associated_type_bounds<'tcx>(
|
|||
);
|
||||
icx.lowerer().add_default_traits(&mut bounds, item_ty, hir_bounds, None, span);
|
||||
}
|
||||
// `ConstIfConst` is only interested in `~const` bounds.
|
||||
// `ConstIfConst` is only interested in `[const]` bounds.
|
||||
PredicateFilter::ConstIfConst | PredicateFilter::SelfConstIfConst => {}
|
||||
}
|
||||
|
||||
|
|
@ -351,7 +351,7 @@ fn opaque_type_bounds<'tcx>(
|
|||
);
|
||||
icx.lowerer().add_default_traits(&mut bounds, item_ty, hir_bounds, None, span);
|
||||
}
|
||||
//`ConstIfConst` is only interested in `~const` bounds.
|
||||
//`ConstIfConst` is only interested in `[const]` bounds.
|
||||
PredicateFilter::ConstIfConst | PredicateFilter::SelfConstIfConst => {}
|
||||
}
|
||||
debug!(?bounds);
|
||||
|
|
|
|||
|
|
@ -666,7 +666,7 @@ pub(super) fn implied_predicates_with_filter<'tcx>(
|
|||
item.span,
|
||||
);
|
||||
}
|
||||
//`ConstIfConst` is only interested in `~const` bounds.
|
||||
//`ConstIfConst` is only interested in `[const]` bounds.
|
||||
PredicateFilter::ConstIfConst | PredicateFilter::SelfConstIfConst => {}
|
||||
}
|
||||
|
||||
|
|
@ -821,7 +821,7 @@ pub(super) fn assert_only_contains_predicates_from<'tcx>(
|
|||
assert_eq!(
|
||||
pred.constness,
|
||||
ty::BoundConstness::Maybe,
|
||||
"expected `~const` predicate when computing `{filter:?}` \
|
||||
"expected `[const]` predicate when computing `{filter:?}` \
|
||||
implied bounds: {clause:?}",
|
||||
);
|
||||
assert_eq!(
|
||||
|
|
@ -1009,7 +1009,7 @@ pub(super) fn const_conditions<'tcx>(
|
|||
}
|
||||
_ => bug!("const_conditions called on wrong item: {def_id:?}"),
|
||||
},
|
||||
// While associated types are not really const, we do allow them to have `~const`
|
||||
// While associated types are not really const, we do allow them to have `[const]`
|
||||
// bounds and where clauses. `const_conditions` is responsible for gathering
|
||||
// these up so we can check them in `compare_type_predicate_entailment`, and
|
||||
// in `HostEffect` goal computation.
|
||||
|
|
|
|||
|
|
@ -635,7 +635,7 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {
|
|||
self.suggest_adding_type_and_const_args(err);
|
||||
}
|
||||
ExcessTypesOrConsts { .. } => {
|
||||
// this can happen with `~const T` where T isn't a const_trait.
|
||||
// this can happen with `[const] T` where T isn't a const_trait.
|
||||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -492,7 +492,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
|||
);
|
||||
}
|
||||
hir::GenericBound::Outlives(lifetime) => {
|
||||
// `ConstIfConst` is only interested in `~const` bounds.
|
||||
// `ConstIfConst` is only interested in `[const]` bounds.
|
||||
if matches!(
|
||||
predicate_filter,
|
||||
PredicateFilter::ConstIfConst | PredicateFilter::SelfConstIfConst
|
||||
|
|
@ -708,7 +708,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
|||
}
|
||||
// SelfTraitThatDefines is only interested in trait predicates.
|
||||
PredicateFilter::SelfTraitThatDefines(_) => {}
|
||||
// `ConstIfConst` is only interested in `~const` bounds.
|
||||
// `ConstIfConst` is only interested in `[const]` bounds.
|
||||
PredicateFilter::ConstIfConst | PredicateFilter::SelfConstIfConst => {}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -80,10 +80,10 @@ pub enum PredicateFilter {
|
|||
/// and `<Self as Tr>::A: B`.
|
||||
SelfAndAssociatedTypeBounds,
|
||||
|
||||
/// Filter only the `~const` bounds, which are lowered into `HostEffect` clauses.
|
||||
/// Filter only the `[const]` bounds, which are lowered into `HostEffect` clauses.
|
||||
ConstIfConst,
|
||||
|
||||
/// Filter only the `~const` bounds which are *also* in the supertrait position.
|
||||
/// Filter only the `[const]` bounds which are *also* in the supertrait position.
|
||||
SelfConstIfConst,
|
||||
}
|
||||
|
||||
|
|
@ -885,7 +885,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
|||
}
|
||||
}
|
||||
// On the flip side, when filtering `ConstIfConst` bounds, we only need to convert
|
||||
// `~const` bounds. All other predicates are handled in their respective queries.
|
||||
// `[const]` bounds. All other predicates are handled in their respective queries.
|
||||
//
|
||||
// Note that like `PredicateFilter::SelfOnly`, we don't need to do any filtering
|
||||
// here because we only call this on self bounds, and deal with the recursive case
|
||||
|
|
|
|||
|
|
@ -402,22 +402,22 @@ fn check_predicates<'tcx>(
|
|||
/// as some predicate on the base impl (`predicate2`).
|
||||
///
|
||||
/// This basically just checks syntactic equivalence, but is a little more
|
||||
/// forgiving since we want to equate `T: Tr` with `T: ~const Tr` so this can work:
|
||||
/// forgiving since we want to equate `T: Tr` with `T: [const] Tr` so this can work:
|
||||
///
|
||||
/// ```ignore (illustrative)
|
||||
/// #[rustc_specialization_trait]
|
||||
/// trait Specialize { }
|
||||
///
|
||||
/// impl<T: Bound> Tr for T { }
|
||||
/// impl<T: ~const Bound + Specialize> const Tr for T { }
|
||||
/// impl<T: [const] Bound + Specialize> const Tr for T { }
|
||||
/// ```
|
||||
///
|
||||
/// However, we *don't* want to allow the reverse, i.e., when the bound on the
|
||||
/// specializing impl is not as const as the bound on the base impl:
|
||||
///
|
||||
/// ```ignore (illustrative)
|
||||
/// impl<T: ~const Bound> const Tr for T { }
|
||||
/// impl<T: Bound + Specialize> const Tr for T { } // should be T: ~const Bound
|
||||
/// impl<T: [const] Bound> const Tr for T { }
|
||||
/// impl<T: Bound + Specialize> const Tr for T { } // should be T: [const] Bound
|
||||
/// ```
|
||||
///
|
||||
/// So we make that check in this function and try to raise a helpful error message.
|
||||
|
|
|
|||
|
|
@ -784,7 +784,7 @@ impl<'a> State<'a> {
|
|||
match constness {
|
||||
hir::BoundConstness::Never => {}
|
||||
hir::BoundConstness::Always(_) => self.word("const"),
|
||||
hir::BoundConstness::Maybe(_) => self.word("~const"),
|
||||
hir::BoundConstness::Maybe(_) => self.word("[const]"),
|
||||
}
|
||||
match polarity {
|
||||
hir::BoundPolarity::Positive => {}
|
||||
|
|
|
|||
|
|
@ -903,7 +903,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
return;
|
||||
}
|
||||
|
||||
// If we have `rustc_do_not_const_check`, do not check `~const` bounds.
|
||||
// If we have `rustc_do_not_const_check`, do not check `[const]` bounds.
|
||||
if self.tcx.has_attr(self.body_id, sym::rustc_do_not_const_check) {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -281,7 +281,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
);
|
||||
}
|
||||
Adjust::Deref(None) => {
|
||||
// FIXME(const_trait_impl): We *could* enforce `&T: ~const Deref` here.
|
||||
// FIXME(const_trait_impl): We *could* enforce `&T: [const] Deref` here.
|
||||
}
|
||||
Adjust::Pointer(_pointer_coercion) => {
|
||||
// FIXME(const_trait_impl): We should probably enforce these.
|
||||
|
|
|
|||
|
|
@ -620,7 +620,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
/// instead of regular stability.
|
||||
///
|
||||
/// This enforces *syntactical* const stability of const traits. In other words,
|
||||
/// it enforces the ability to name `~const`/`const` traits in trait bounds in various
|
||||
/// it enforces the ability to name `[const]`/`const` traits in trait bounds in various
|
||||
/// syntax positions in HIR (including in the trait of an impl header).
|
||||
pub fn check_const_stability(self, def_id: DefId, span: Span, const_kw_span: Span) {
|
||||
let is_staged_api = self.lookup_stability(def_id.krate.as_def_id()).is_some();
|
||||
|
|
|
|||
|
|
@ -850,14 +850,14 @@ rustc_queries! {
|
|||
}
|
||||
|
||||
/// Compute the conditions that need to hold for a conditionally-const item to be const.
|
||||
/// That is, compute the set of `~const` where clauses for a given item.
|
||||
/// That is, compute the set of `[const]` where clauses for a given item.
|
||||
///
|
||||
/// This can be thought of as the `~const` equivalent of `predicates_of`. These are the
|
||||
/// This can be thought of as the `[const]` equivalent of `predicates_of`. These are the
|
||||
/// predicates that need to be proven at usage sites, and can be assumed at definition.
|
||||
///
|
||||
/// This query also computes the `~const` where clauses for associated types, which are
|
||||
/// not "const", but which have item bounds which may be `~const`. These must hold for
|
||||
/// the `~const` item bound to hold.
|
||||
/// This query also computes the `[const]` where clauses for associated types, which are
|
||||
/// not "const", but which have item bounds which may be `[const]`. These must hold for
|
||||
/// the `[const]` item bound to hold.
|
||||
query const_conditions(
|
||||
key: DefId
|
||||
) -> ty::ConstConditions<'tcx> {
|
||||
|
|
@ -869,13 +869,13 @@ rustc_queries! {
|
|||
|
||||
/// Compute the const bounds that are implied for a conditionally-const item.
|
||||
///
|
||||
/// This can be though of as the `~const` equivalent of `explicit_item_bounds`. These
|
||||
/// This can be though of as the `[const]` equivalent of `explicit_item_bounds`. These
|
||||
/// are the predicates that need to proven at definition sites, and can be assumed at
|
||||
/// usage sites.
|
||||
query explicit_implied_const_bounds(
|
||||
key: DefId
|
||||
) -> ty::EarlyBinder<'tcx, &'tcx [(ty::PolyTraitRef<'tcx>, Span)]> {
|
||||
desc { |tcx| "computing the implied `~const` bounds for `{}`",
|
||||
desc { |tcx| "computing the implied `[const]` bounds for `{}`",
|
||||
tcx.def_path_str(key)
|
||||
}
|
||||
separate_provide_extern
|
||||
|
|
|
|||
|
|
@ -419,7 +419,7 @@ impl<'tcx> GenericPredicates<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
/// `~const` bounds for a given item. This is represented using a struct much like
|
||||
/// `[const]` bounds for a given item. This is represented using a struct much like
|
||||
/// `GenericPredicates`, where you can either choose to only instantiate the "own"
|
||||
/// bounds or all of the bounds including those from the parent. This distinction
|
||||
/// is necessary for code like `compare_method_predicate_entailment`.
|
||||
|
|
|
|||
|
|
@ -2156,7 +2156,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
},
|
||||
DefKind::Closure => {
|
||||
// Closures and RPITs will eventually have const conditions
|
||||
// for `~const` bounds.
|
||||
// for `[const]` bounds.
|
||||
false
|
||||
}
|
||||
DefKind::Ctor(_, CtorKind::Const)
|
||||
|
|
|
|||
|
|
@ -2077,7 +2077,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
|
|||
p!("const ");
|
||||
}
|
||||
ty::BoundConstness::Maybe => {
|
||||
p!("~const ");
|
||||
p!("[const] ");
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
|
|
@ -3250,7 +3250,7 @@ define_print! {
|
|||
ty::HostEffectPredicate<'tcx> {
|
||||
let constness = match self.constness {
|
||||
ty::BoundConstness::Const => { "const" }
|
||||
ty::BoundConstness::Maybe => { "~const" }
|
||||
ty::BoundConstness::Maybe => { "[const]" }
|
||||
};
|
||||
p!(print(self.trait_ref.self_ty()), ": {constness} ");
|
||||
p!(print(self.trait_ref.print_trait_sugared()))
|
||||
|
|
|
|||
|
|
@ -735,11 +735,11 @@ pub(in crate::solve) fn const_conditions_for_destruct<I: Interner>(
|
|||
let destruct_def_id = cx.require_lang_item(TraitSolverLangItem::Destruct);
|
||||
|
||||
match self_ty.kind() {
|
||||
// `ManuallyDrop` is trivially `~const Destruct` as we do not run any drop glue on it.
|
||||
// `ManuallyDrop` is trivially `[const] Destruct` as we do not run any drop glue on it.
|
||||
ty::Adt(adt_def, _) if adt_def.is_manually_drop() => Ok(vec![]),
|
||||
|
||||
// An ADT is `~const Destruct` only if all of the fields are,
|
||||
// *and* if there is a `Drop` impl, that `Drop` impl is also `~const`.
|
||||
// An ADT is `[const] Destruct` only if all of the fields are,
|
||||
// *and* if there is a `Drop` impl, that `Drop` impl is also `[const]`.
|
||||
ty::Adt(adt_def, args) => {
|
||||
let mut const_conditions: Vec<_> = adt_def
|
||||
.all_field_tys(cx)
|
||||
|
|
@ -747,9 +747,9 @@ pub(in crate::solve) fn const_conditions_for_destruct<I: Interner>(
|
|||
.map(|field_ty| ty::TraitRef::new(cx, destruct_def_id, [field_ty]))
|
||||
.collect();
|
||||
match adt_def.destructor(cx) {
|
||||
// `Drop` impl exists, but it's not const. Type cannot be `~const Destruct`.
|
||||
// `Drop` impl exists, but it's not const. Type cannot be `[const] Destruct`.
|
||||
Some(AdtDestructorKind::NotConst) => return Err(NoSolution),
|
||||
// `Drop` impl exists, and it's const. Require `Ty: ~const Drop` to hold.
|
||||
// `Drop` impl exists, and it's const. Require `Ty: [const] Drop` to hold.
|
||||
Some(AdtDestructorKind::Const) => {
|
||||
let drop_def_id = cx.require_lang_item(TraitSolverLangItem::Drop);
|
||||
let drop_trait_ref = ty::TraitRef::new(cx, drop_def_id, [self_ty]);
|
||||
|
|
@ -770,7 +770,7 @@ pub(in crate::solve) fn const_conditions_for_destruct<I: Interner>(
|
|||
.map(|field_ty| ty::TraitRef::new(cx, destruct_def_id, [field_ty]))
|
||||
.collect()),
|
||||
|
||||
// Trivially implement `~const Destruct`
|
||||
// Trivially implement `[const] Destruct`
|
||||
ty::Bool
|
||||
| ty::Char
|
||||
| ty::Int(..)
|
||||
|
|
@ -785,14 +785,14 @@ pub(in crate::solve) fn const_conditions_for_destruct<I: Interner>(
|
|||
| ty::Infer(ty::InferTy::FloatVar(_) | ty::InferTy::IntVar(_))
|
||||
| ty::Error(_) => Ok(vec![]),
|
||||
|
||||
// Coroutines and closures could implement `~const Drop`,
|
||||
// Coroutines and closures could implement `[const] Drop`,
|
||||
// but they don't really need to right now.
|
||||
ty::Closure(_, _)
|
||||
| ty::CoroutineClosure(_, _)
|
||||
| ty::Coroutine(_, _)
|
||||
| ty::CoroutineWitness(_, _) => Err(NoSolution),
|
||||
|
||||
// FIXME(unsafe_binders): Unsafe binders could implement `~const Drop`
|
||||
// FIXME(unsafe_binders): Unsafe binders could implement `[const] Drop`
|
||||
// if their inner type implements it.
|
||||
ty::UnsafeBinder(_) => Err(NoSolution),
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
//! Dealing with host effect goals, i.e. enforcing the constness in
|
||||
//! `T: const Trait` or `T: ~const Trait`.
|
||||
//! `T: const Trait` or `T: [const] Trait`.
|
||||
|
||||
use rustc_type_ir::fast_reject::DeepRejectCtxt;
|
||||
use rustc_type_ir::inherent::*;
|
||||
|
|
@ -72,7 +72,7 @@ where
|
|||
then(ecx)
|
||||
}
|
||||
|
||||
/// Register additional assumptions for aliases corresponding to `~const` item bounds.
|
||||
/// Register additional assumptions for aliases corresponding to `[const]` item bounds.
|
||||
///
|
||||
/// Unlike item bounds, they are not simply implied by the well-formedness of the alias.
|
||||
/// Instead, they only hold if the const conditons on the alias also hold. This is why
|
||||
|
|
@ -161,7 +161,7 @@ where
|
|||
.map(|pred| goal.with(cx, pred));
|
||||
ecx.add_goals(GoalSource::ImplWhereBound, where_clause_bounds);
|
||||
|
||||
// For this impl to be `const`, we need to check its `~const` bounds too.
|
||||
// For this impl to be `const`, we need to check its `[const]` bounds too.
|
||||
let const_conditions = cx
|
||||
.const_conditions(impl_def_id)
|
||||
.iter_instantiated(cx, impl_args)
|
||||
|
|
|
|||
|
|
@ -885,6 +885,7 @@ impl<'a> Parser<'a> {
|
|||
|| self.check(exp!(Tilde))
|
||||
|| self.check_keyword(exp!(For))
|
||||
|| self.check(exp!(OpenParen))
|
||||
|| self.check(exp!(OpenBracket))
|
||||
|| self.check_keyword(exp!(Const))
|
||||
|| self.check_keyword(exp!(Async))
|
||||
|| self.check_keyword(exp!(Use))
|
||||
|
|
@ -982,12 +983,12 @@ impl<'a> Parser<'a> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Parses the modifiers that may precede a trait in a bound, e.g. `?Trait` or `~const Trait`.
|
||||
/// Parses the modifiers that may precede a trait in a bound, e.g. `?Trait` or `[const] Trait`.
|
||||
///
|
||||
/// If no modifiers are present, this does not consume any tokens.
|
||||
///
|
||||
/// ```ebnf
|
||||
/// CONSTNESS = [["~"] "const"]
|
||||
/// CONSTNESS = [["["] "const" ["]"]]
|
||||
/// ASYNCNESS = ["async"]
|
||||
/// POLARITY = ["?" | "!"]
|
||||
/// ```
|
||||
|
|
@ -1057,13 +1058,26 @@ impl<'a> Parser<'a> {
|
|||
Ok(TraitBoundModifiers { constness, asyncness, polarity })
|
||||
}
|
||||
|
||||
fn parse_bound_constness(&mut self) -> PResult<'a, BoundConstness> {
|
||||
pub fn parse_bound_constness(&mut self) -> PResult<'a, BoundConstness> {
|
||||
// FIXME(const_trait_impl): remove `~const` parser support once bootstrap has the new syntax
|
||||
// in rustfmt
|
||||
Ok(if self.eat(exp!(Tilde)) {
|
||||
let tilde = self.prev_token.span;
|
||||
self.expect_keyword(exp!(Const))?;
|
||||
let span = tilde.to(self.prev_token.span);
|
||||
self.psess.gated_spans.gate(sym::const_trait_impl, span);
|
||||
BoundConstness::Maybe(span)
|
||||
} else if self.check(exp!(OpenBracket))
|
||||
&& self.look_ahead(1, |t| t.is_keyword(kw::Const))
|
||||
&& self.look_ahead(2, |t| *t == token::CloseBracket)
|
||||
{
|
||||
let start = self.prev_token.span;
|
||||
self.bump();
|
||||
self.expect_keyword(exp!(Const)).unwrap();
|
||||
self.bump();
|
||||
let span = start.to(self.prev_token.span);
|
||||
self.psess.gated_spans.gate(sym::const_trait_impl, span);
|
||||
BoundConstness::Maybe(span)
|
||||
} else if self.eat_keyword(exp!(Const)) {
|
||||
self.psess.gated_spans.gate(sym::const_trait_impl, self.prev_token.span);
|
||||
BoundConstness::Always(self.prev_token.span)
|
||||
|
|
@ -1078,7 +1092,7 @@ impl<'a> Parser<'a> {
|
|||
/// TY_BOUND_NOPAREN = [for<GENERIC_PARAMS> CONSTNESS ASYNCNESS | POLARITY] SIMPLE_PATH
|
||||
/// ```
|
||||
///
|
||||
/// For example, this grammar accepts `for<'a: 'b> ~const ?m::Trait<'a>`.
|
||||
/// For example, this grammar accepts `for<'a: 'b> [const] ?m::Trait<'a>`.
|
||||
fn parse_generic_ty_bound(
|
||||
&mut self,
|
||||
lo: Span,
|
||||
|
|
@ -1105,7 +1119,7 @@ impl<'a> Parser<'a> {
|
|||
}
|
||||
|
||||
// Recover erroneous lifetime bound with modifiers or binder.
|
||||
// e.g. `T: for<'a> 'a` or `T: ~const 'a`.
|
||||
// e.g. `T: for<'a> 'a` or `T: [const] 'a`.
|
||||
if self.token.is_lifetime() {
|
||||
let _: ErrorGuaranteed = self.error_lt_bound_with_modifiers(modifiers, binder_span);
|
||||
return self.parse_generic_lt_bound(lo, has_parens);
|
||||
|
|
|
|||
|
|
@ -775,7 +775,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||
param_env: ty::ParamEnv<'tcx>,
|
||||
span: Span,
|
||||
) -> Diag<'a> {
|
||||
// FIXME(const_trait_impl): We should recompute the predicate with `~const`
|
||||
// FIXME(const_trait_impl): We should recompute the predicate with `[const]`
|
||||
// if it's `const`, and if it holds, explain that this bound only
|
||||
// *conditionally* holds. If that fails, we should also do selection
|
||||
// to drill this down to an impl or built-in source, so we can
|
||||
|
|
|
|||
|
|
@ -334,7 +334,7 @@ pub struct OnUnimplementedNote {
|
|||
pub append_const_msg: Option<AppendConstMessage>,
|
||||
}
|
||||
|
||||
/// Append a message for `~const Trait` errors.
|
||||
/// Append a message for `[const] Trait` errors.
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Debug, Default)]
|
||||
pub enum AppendConstMessage {
|
||||
#[default]
|
||||
|
|
|
|||
|
|
@ -593,7 +593,7 @@ fn receiver_is_dispatchable<'tcx>(
|
|||
// will cause ambiguity that the user can't really avoid.
|
||||
//
|
||||
// We leave out certain complexities of the param-env query here. Specifically, we:
|
||||
// 1. Do not add `~const` bounds since there are no `dyn const Trait`s.
|
||||
// 1. Do not add `[const]` bounds since there are no `dyn const Trait`s.
|
||||
// 2. Do not add RPITIT self projection bounds for defaulted methods, since we
|
||||
// are not constructing a param-env for "inside" of the body of the defaulted
|
||||
// method, so we don't really care about projecting to a specific RPIT type,
|
||||
|
|
|
|||
|
|
@ -252,20 +252,20 @@ fn evaluate_host_effect_for_destruct_goal<'tcx>(
|
|||
let self_ty = obligation.predicate.self_ty();
|
||||
|
||||
let const_conditions = match *self_ty.kind() {
|
||||
// `ManuallyDrop` is trivially `~const Destruct` as we do not run any drop glue on it.
|
||||
// `ManuallyDrop` is trivially `[const] Destruct` as we do not run any drop glue on it.
|
||||
ty::Adt(adt_def, _) if adt_def.is_manually_drop() => thin_vec![],
|
||||
|
||||
// An ADT is `~const Destruct` only if all of the fields are,
|
||||
// *and* if there is a `Drop` impl, that `Drop` impl is also `~const`.
|
||||
// An ADT is `[const] Destruct` only if all of the fields are,
|
||||
// *and* if there is a `Drop` impl, that `Drop` impl is also `[const]`.
|
||||
ty::Adt(adt_def, args) => {
|
||||
let mut const_conditions: ThinVec<_> = adt_def
|
||||
.all_fields()
|
||||
.map(|field| ty::TraitRef::new(tcx, destruct_def_id, [field.ty(tcx, args)]))
|
||||
.collect();
|
||||
match adt_def.destructor(tcx).map(|dtor| tcx.constness(dtor.did)) {
|
||||
// `Drop` impl exists, but it's not const. Type cannot be `~const Destruct`.
|
||||
// `Drop` impl exists, but it's not const. Type cannot be `[const] Destruct`.
|
||||
Some(hir::Constness::NotConst) => return Err(EvaluationFailure::NoSolution),
|
||||
// `Drop` impl exists, and it's const. Require `Ty: ~const Drop` to hold.
|
||||
// `Drop` impl exists, and it's const. Require `Ty: [const] Drop` to hold.
|
||||
Some(hir::Constness::Const) => {
|
||||
let drop_def_id = tcx.require_lang_item(LangItem::Drop, obligation.cause.span);
|
||||
let drop_trait_ref = ty::TraitRef::new(tcx, drop_def_id, [self_ty]);
|
||||
|
|
@ -285,7 +285,7 @@ fn evaluate_host_effect_for_destruct_goal<'tcx>(
|
|||
tys.iter().map(|field_ty| ty::TraitRef::new(tcx, destruct_def_id, [field_ty])).collect()
|
||||
}
|
||||
|
||||
// Trivially implement `~const Destruct`
|
||||
// Trivially implement `[const] Destruct`
|
||||
ty::Bool
|
||||
| ty::Char
|
||||
| ty::Int(..)
|
||||
|
|
@ -300,14 +300,14 @@ fn evaluate_host_effect_for_destruct_goal<'tcx>(
|
|||
| ty::Infer(ty::InferTy::FloatVar(_) | ty::InferTy::IntVar(_))
|
||||
| ty::Error(_) => thin_vec![],
|
||||
|
||||
// Coroutines and closures could implement `~const Drop`,
|
||||
// Coroutines and closures could implement `[const] Drop`,
|
||||
// but they don't really need to right now.
|
||||
ty::Closure(_, _)
|
||||
| ty::CoroutineClosure(_, _)
|
||||
| ty::Coroutine(_, _)
|
||||
| ty::CoroutineWitness(_, _) => return Err(EvaluationFailure::NoSolution),
|
||||
|
||||
// FIXME(unsafe_binders): Unsafe binders could implement `~const Drop`
|
||||
// FIXME(unsafe_binders): Unsafe binders could implement `[const] Drop`
|
||||
// if their inner type implements it.
|
||||
ty::UnsafeBinder(_) => return Err(EvaluationFailure::NoSolution),
|
||||
|
||||
|
|
|
|||
|
|
@ -233,7 +233,7 @@ pub(super) fn specialization_enabled_in(tcx: TyCtxt<'_>, _: LocalCrate) -> bool
|
|||
///
|
||||
/// For the purposes of const traits, we also check that the specializing
|
||||
/// impl is not more restrictive than the parent impl. That is, if the
|
||||
/// `parent_impl_def_id` is a const impl (conditionally based off of some `~const`
|
||||
/// `parent_impl_def_id` is a const impl (conditionally based off of some `[const]`
|
||||
/// bounds), then `specializing_impl_def_id` must also be const for the same
|
||||
/// set of types.
|
||||
#[instrument(skip(tcx), level = "debug")]
|
||||
|
|
|
|||
|
|
@ -175,7 +175,7 @@ fn param_env(tcx: TyCtxt<'_>, def_id: DefId) -> ty::ParamEnv<'_> {
|
|||
}
|
||||
|
||||
// We extend the param-env of our item with the const conditions of the item,
|
||||
// since we're allowed to assume `~const` bounds hold within the item itself.
|
||||
// since we're allowed to assume `[const]` bounds hold within the item itself.
|
||||
if tcx.is_conditionally_const(def_id) {
|
||||
predicates.extend(
|
||||
tcx.const_conditions(def_id).instantiate_identity(tcx).into_iter().map(
|
||||
|
|
|
|||
|
|
@ -179,7 +179,7 @@ impl<I: Interner, O: Elaboratable<I>> Elaborator<I, O> {
|
|||
),
|
||||
};
|
||||
}
|
||||
// `T: ~const Trait` implies `T: ~const Supertrait`.
|
||||
// `T: [const] Trait` implies `T: [const] Supertrait`.
|
||||
ty::ClauseKind::HostEffect(data) => self.extend_deduped(
|
||||
cx.explicit_implied_const_bounds(data.def_id()).iter_identity().map(|trait_ref| {
|
||||
elaboratable.child(
|
||||
|
|
|
|||
|
|
@ -911,7 +911,7 @@ pub enum BoundConstness {
|
|||
///
|
||||
/// A bound is required to be unconditionally const, even in a runtime function.
|
||||
Const,
|
||||
/// `Type: ~const Trait`
|
||||
/// `Type: [const] Trait`
|
||||
///
|
||||
/// Requires resolving to const only when we are in a const context.
|
||||
Maybe,
|
||||
|
|
@ -929,7 +929,7 @@ impl BoundConstness {
|
|||
pub fn as_str(self) -> &'static str {
|
||||
match self {
|
||||
Self::Const => "const",
|
||||
Self::Maybe => "~const",
|
||||
Self::Maybe => "[const]",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -938,7 +938,7 @@ impl fmt::Display for BoundConstness {
|
|||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
Self::Const => f.write_str("const"),
|
||||
Self::Maybe => f.write_str("~const"),
|
||||
Self::Maybe => f.write_str("[const]"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ pub enum GoalSource {
|
|||
TypeRelating,
|
||||
/// We're proving a where-bound of an impl.
|
||||
ImplWhereBound,
|
||||
/// Const conditions that need to hold for `~const` alias bounds to hold.
|
||||
/// Const conditions that need to hold for `[const]` alias bounds to hold.
|
||||
AliasBoundConstCondition,
|
||||
/// Instantiating a higher-ranked goal and re-proving it.
|
||||
InstantiateHigherRanked,
|
||||
|
|
|
|||
|
|
@ -227,7 +227,7 @@ fn clean_generic_bound<'tcx>(
|
|||
Some(match bound {
|
||||
hir::GenericBound::Outlives(lt) => GenericBound::Outlives(clean_lifetime(lt, cx)),
|
||||
hir::GenericBound::Trait(t) => {
|
||||
// `T: ~const Destruct` is hidden because `T: Destruct` is a no-op.
|
||||
// `T: [const] Destruct` is hidden because `T: Destruct` is a no-op.
|
||||
if let hir::BoundConstness::Maybe(_) = t.modifiers.constness
|
||||
&& cx.tcx.lang_items().destruct_trait() == Some(t.trait_ref.trait_def_id().unwrap())
|
||||
{
|
||||
|
|
@ -395,7 +395,7 @@ pub(crate) fn clean_predicate<'tcx>(
|
|||
ty::ClauseKind::ConstEvaluatable(..)
|
||||
| ty::ClauseKind::WellFormed(..)
|
||||
| ty::ClauseKind::ConstArgHasType(..)
|
||||
// FIXME(const_trait_impl): We can probably use this `HostEffect` pred to render `~const`.
|
||||
// FIXME(const_trait_impl): We can probably use this `HostEffect` pred to render `[const]`.
|
||||
| ty::ClauseKind::HostEffect(_) => None,
|
||||
}
|
||||
}
|
||||
|
|
@ -404,7 +404,7 @@ fn clean_poly_trait_predicate<'tcx>(
|
|||
pred: ty::PolyTraitPredicate<'tcx>,
|
||||
cx: &mut DocContext<'tcx>,
|
||||
) -> Option<WherePredicate> {
|
||||
// `T: ~const Destruct` is hidden because `T: Destruct` is a no-op.
|
||||
// `T: [const] Destruct` is hidden because `T: Destruct` is a no-op.
|
||||
// FIXME(const_trait_impl) check constness
|
||||
if Some(pred.skip_binder().def_id()) == cx.tcx.lang_items().destruct_trait() {
|
||||
return None;
|
||||
|
|
|
|||
|
|
@ -268,7 +268,7 @@ impl clean::GenericBound {
|
|||
fmt::from_fn(move |f| match self {
|
||||
clean::GenericBound::Outlives(lt) => write!(f, "{}", lt.print()),
|
||||
clean::GenericBound::TraitBound(ty, modifiers) => {
|
||||
// `const` and `~const` trait bounds are experimental; don't render them.
|
||||
// `const` and `[const]` trait bounds are experimental; don't render them.
|
||||
let hir::TraitBoundModifiers { polarity, constness: _ } = modifiers;
|
||||
f.write_str(match polarity {
|
||||
hir::BoundPolarity::Positive => "",
|
||||
|
|
|
|||
|
|
@ -436,7 +436,7 @@ fn is_ty_const_destruct<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, body: &Body<'tcx>
|
|||
// FIXME(const_trait_impl, fee1-dead) revert to const destruct once it works again
|
||||
#[expect(unused)]
|
||||
fn is_ty_const_destruct_unused<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, body: &Body<'tcx>) -> bool {
|
||||
// If this doesn't need drop at all, then don't select `~const Destruct`.
|
||||
// If this doesn't need drop at all, then don't select `[const] Destruct`.
|
||||
if !ty.needs_drop(tcx, body.typing_env(tcx)) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ mod issue14871 {
|
|||
|
||||
impl<T> const NumberConstants for T
|
||||
where
|
||||
T: Number + ~const core::ops::Add,
|
||||
T: Number + [const] core::ops::Add,
|
||||
{
|
||||
fn constant(value: usize) -> Self {
|
||||
let mut res = Self::ZERO;
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ mod issue14871 {
|
|||
|
||||
impl<T> const NumberConstants for T
|
||||
where
|
||||
T: Number + ~const core::ops::Add,
|
||||
T: Number + [const] core::ops::Add,
|
||||
{
|
||||
fn constant(value: usize) -> Self {
|
||||
let mut res = Self::ZERO;
|
||||
|
|
|
|||
|
|
@ -169,9 +169,9 @@ where
|
|||
// #13476
|
||||
#[const_trait]
|
||||
trait ConstTrait {}
|
||||
const fn const_trait_bounds_good<T: ConstTrait + ~const ConstTrait>() {}
|
||||
const fn const_trait_bounds_good<T: ConstTrait + [const] ConstTrait>() {}
|
||||
|
||||
const fn const_trait_bounds_bad<T: ~const ConstTrait>() {}
|
||||
const fn const_trait_bounds_bad<T: [const] ConstTrait>() {}
|
||||
//~^ trait_duplication_in_bounds
|
||||
|
||||
fn projections<T, U, V>()
|
||||
|
|
|
|||
|
|
@ -169,9 +169,9 @@ where
|
|||
// #13476
|
||||
#[const_trait]
|
||||
trait ConstTrait {}
|
||||
const fn const_trait_bounds_good<T: ConstTrait + ~const ConstTrait>() {}
|
||||
const fn const_trait_bounds_good<T: ConstTrait + [const] ConstTrait>() {}
|
||||
|
||||
const fn const_trait_bounds_bad<T: ~const ConstTrait + ~const ConstTrait>() {}
|
||||
const fn const_trait_bounds_bad<T: [const] ConstTrait + [const] ConstTrait>() {}
|
||||
//~^ trait_duplication_in_bounds
|
||||
|
||||
fn projections<T, U, V>()
|
||||
|
|
|
|||
|
|
@ -61,8 +61,8 @@ LL | fn bad_trait_object(arg0: &(dyn Any + Send + Send)) {
|
|||
error: these bounds contain repeated elements
|
||||
--> tests/ui/trait_duplication_in_bounds.rs:174:36
|
||||
|
|
||||
LL | const fn const_trait_bounds_bad<T: ~const ConstTrait + ~const ConstTrait>() {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `~const ConstTrait`
|
||||
LL | const fn const_trait_bounds_bad<T: [const] ConstTrait + [const] ConstTrait>() {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `[const] ConstTrait`
|
||||
|
||||
error: these where clauses contain repeated elements
|
||||
--> tests/ui/trait_duplication_in_bounds.rs:181:8
|
||||
|
|
|
|||
|
|
@ -142,18 +142,18 @@ type MyFn = fn(a: SomeLongComplexType, b: SomeOtherLongComplexType,) -> Box<Futu
|
|||
|
||||
// Const bound
|
||||
|
||||
trait T: ~ const Super {}
|
||||
trait T: [ const ] Super {}
|
||||
|
||||
const fn not_quite_const<S: ~ const T>() -> i32 { <S as T>::CONST }
|
||||
const fn not_quite_const<S: [ const ] T>() -> i32 { <S as T>::CONST }
|
||||
|
||||
impl ~ const T {}
|
||||
impl const T for U {}
|
||||
|
||||
fn apit(_: impl ~ const T) {}
|
||||
fn apit(_: impl [ const ] T) {}
|
||||
|
||||
fn rpit() -> impl ~ const T { S }
|
||||
fn rpit() -> impl [ const] T { S }
|
||||
|
||||
pub struct Foo<T: Trait>(T);
|
||||
impl<T: ~ const Trait> Foo<T> {
|
||||
impl<T: [ const] Trait> Foo<T> {
|
||||
fn new(t: T) -> Self {
|
||||
Self(t)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -147,22 +147,22 @@ type MyFn = fn(
|
|||
|
||||
// Const bound
|
||||
|
||||
trait T: ~const Super {}
|
||||
trait T: [const] Super {}
|
||||
|
||||
const fn not_quite_const<S: ~const T>() -> i32 {
|
||||
const fn not_quite_const<S: [const] T>() -> i32 {
|
||||
<S as T>::CONST
|
||||
}
|
||||
|
||||
impl ~const T {}
|
||||
impl const T for U {}
|
||||
|
||||
fn apit(_: impl ~const T) {}
|
||||
fn apit(_: impl [const] T) {}
|
||||
|
||||
fn rpit() -> impl ~const T {
|
||||
fn rpit() -> impl [const] T {
|
||||
S
|
||||
}
|
||||
|
||||
pub struct Foo<T: Trait>(T);
|
||||
impl<T: ~const Trait> Foo<T> {
|
||||
impl<T: [const] Trait> Foo<T> {
|
||||
fn new(t: T) -> Self {
|
||||
Self(t)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
error: `~const` is not allowed here
|
||||
error: `[const]` is not allowed here
|
||||
--> const-super-trait.rs:7:12
|
||||
|
|
||||
LL | trait Bar: ~const Foo {}
|
||||
| ^^^^^^
|
||||
|
|
||||
note: this trait is not a `#[const_trait]`, so it cannot have `~const` trait bounds
|
||||
note: this trait is not a `#[const_trait]`, so it cannot have `[const]` trait bounds
|
||||
--> const-super-trait.rs:7:1
|
||||
|
|
||||
LL | trait Bar: ~const Foo {}
|
||||
|
|
@ -30,7 +30,7 @@ LL | const fn foo<T: ~const Bar>(x: &T) {
|
|||
= help: add `#![feature(const_trait_impl)]` 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: `~const` can only be applied to `#[const_trait]` traits
|
||||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
--> const-super-trait.rs:7:12
|
||||
|
|
||||
LL | trait Bar: ~const Foo {}
|
||||
|
|
@ -41,7 +41,7 @@ help: enable `#![feature(const_trait_impl)]` in your crate and mark `Foo` as `#[
|
|||
LL | #[const_trait] trait Foo {
|
||||
| ++++++++++++++
|
||||
|
||||
error: `~const` can only be applied to `#[const_trait]` traits
|
||||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
--> const-super-trait.rs:9:17
|
||||
|
|
||||
LL | const fn foo<T: ~const Bar>(x: &T) {
|
||||
|
|
|
|||
|
|
@ -1,16 +1,16 @@
|
|||
error: `~const` is not allowed here
|
||||
error: `[const]` is not allowed here
|
||||
--> const-super-trait.rs:7:12
|
||||
|
|
||||
LL | trait Bar: ~const Foo {}
|
||||
| ^^^^^^
|
||||
|
|
||||
note: this trait is not a `#[const_trait]`, so it cannot have `~const` trait bounds
|
||||
note: this trait is not a `#[const_trait]`, so it cannot have `[const]` trait bounds
|
||||
--> const-super-trait.rs:7:1
|
||||
|
|
||||
LL | trait Bar: ~const Foo {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: `~const` can only be applied to `#[const_trait]` traits
|
||||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
--> const-super-trait.rs:7:12
|
||||
|
|
||||
LL | trait Bar: ~const Foo {}
|
||||
|
|
@ -21,7 +21,7 @@ help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations
|
|||
LL | #[const_trait] trait Foo {
|
||||
| ++++++++++++++
|
||||
|
||||
error: `~const` can only be applied to `#[const_trait]` traits
|
||||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
--> const-super-trait.rs:9:17
|
||||
|
|
||||
LL | const fn foo<T: ~const Bar>(x: &T) {
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
error: `~const` is not allowed here
|
||||
error: `[const]` is not allowed here
|
||||
--> const-super-trait.rs:7:12
|
||||
|
|
||||
7 | trait Bar: ~const Foo {}
|
||||
| ^^^^^^
|
||||
|
|
||||
note: this trait is not a `#[const_trait]`, so it cannot have `~const` trait bounds
|
||||
note: this trait is not a `#[const_trait]`, so it cannot have `[const]` trait bounds
|
||||
--> const-super-trait.rs:7:1
|
||||
|
|
||||
7 | trait Bar: ~const Foo {}
|
||||
|
|
@ -26,25 +26,25 @@ error[E0658]: const trait impls are experimental
|
|||
|
|
||||
= note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information
|
||||
|
||||
error: `~const` can only be applied to `#[const_trait]` traits
|
||||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
--> const-super-trait.rs:7:12
|
||||
|
|
||||
7 | trait Bar: ~const Foo {}
|
||||
| ^^^^^^ can't be applied to `Foo`
|
||||
|
|
||||
note: `Foo` can't be used with `~const` because it isn't annotated with `#[const_trait]`
|
||||
note: `Foo` can't be used with `[const]` because it isn't annotated with `#[const_trait]`
|
||||
--> const-super-trait.rs:3:1
|
||||
|
|
||||
3 | trait Foo {
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: `~const` can only be applied to `#[const_trait]` traits
|
||||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
--> const-super-trait.rs:9:17
|
||||
|
|
||||
9 | const fn foo<T: ~const Bar>(x: &T) {
|
||||
| ^^^^^^ can't be applied to `Bar`
|
||||
|
|
||||
note: `Bar` can't be used with `~const` because it isn't annotated with `#[const_trait]`
|
||||
note: `Bar` can't be used with `[const]` because it isn't annotated with `#[const_trait]`
|
||||
--> const-super-trait.rs:7:1
|
||||
|
|
||||
7 | trait Bar: ~const Foo {}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
error: `~const` is not allowed here
|
||||
error: `[const]` is not allowed here
|
||||
--> const-super-trait.rs:7:12
|
||||
|
|
||||
7 | trait Bar: ~const Foo {}
|
||||
| ^^^^^^
|
||||
|
|
||||
note: this trait is not a `#[const_trait]`, so it cannot have `~const` trait bounds
|
||||
note: this trait is not a `#[const_trait]`, so it cannot have `[const]` trait bounds
|
||||
--> const-super-trait.rs:7:1
|
||||
|
|
||||
7 | trait Bar: ~const Foo {}
|
||||
|
|
@ -16,25 +16,25 @@ error[E0554]: `#![feature]` may not be used on the NIGHTLY release channel
|
|||
1 | #![cfg_attr(feature_enabled, feature(const_trait_impl))]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: `~const` can only be applied to `#[const_trait]` traits
|
||||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
--> const-super-trait.rs:7:12
|
||||
|
|
||||
7 | trait Bar: ~const Foo {}
|
||||
| ^^^^^^ can't be applied to `Foo`
|
||||
|
|
||||
note: `Foo` can't be used with `~const` because it isn't annotated with `#[const_trait]`
|
||||
note: `Foo` can't be used with `[const]` because it isn't annotated with `#[const_trait]`
|
||||
--> const-super-trait.rs:3:1
|
||||
|
|
||||
3 | trait Foo {
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: `~const` can only be applied to `#[const_trait]` traits
|
||||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
--> const-super-trait.rs:9:17
|
||||
|
|
||||
9 | const fn foo<T: ~const Bar>(x: &T) {
|
||||
| ^^^^^^ can't be applied to `Bar`
|
||||
|
|
||||
note: `Bar` can't be used with `~const` because it isn't annotated with `#[const_trait]`
|
||||
note: `Bar` can't be used with `[const]` because it isn't annotated with `#[const_trait]`
|
||||
--> const-super-trait.rs:7:1
|
||||
|
|
||||
7 | trait Bar: ~const Foo {}
|
||||
|
|
|
|||
|
|
@ -11,4 +11,4 @@ pub trait Tr {
|
|||
//@ has foo/fn.g.html
|
||||
//@ has - '//pre[@class="rust item-decl"]' 'pub const fn g<T: Tr>()'
|
||||
/// foo
|
||||
pub const fn g<T: ~const Tr>() {}
|
||||
pub const fn g<T: [const] Tr>() {}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
// Test that we do not currently display `~const` in rustdoc
|
||||
// as that syntax is currently provisional; `~const Destruct` has
|
||||
// Test that we do not currently display `[const]` in rustdoc
|
||||
// as that syntax is currently provisional; `[const] Destruct` has
|
||||
// no effect on stable code so it should be hidden as well.
|
||||
//
|
||||
// To future blessers: make sure that `const_trait_impl` is
|
||||
// stabilized when changing `@!has` to `@has`, and please do
|
||||
// not remove this test.
|
||||
//
|
||||
// FIXME(const_trait_impl) add `const_trait` to `Fn` so we use `~const`
|
||||
// FIXME(const_trait_impl) add `const_trait` to `Fn` so we use `[const]`
|
||||
// FIXME(const_trait_impl) restore `const_trait` to `Destruct`
|
||||
#![feature(const_trait_impl)]
|
||||
#![crate_name = "foo"]
|
||||
|
|
@ -15,58 +15,58 @@ use std::marker::Destruct;
|
|||
|
||||
pub struct S<T>(T);
|
||||
|
||||
//@ !has foo/trait.Tr.html '//pre[@class="rust item-decl"]/code/a[@class="trait"]' '~const'
|
||||
//@ !has foo/trait.Tr.html '//pre[@class="rust item-decl"]/code/a[@class="trait"]' '[const]'
|
||||
//@ has - '//pre[@class="rust item-decl"]/code/a[@class="trait"]' 'Fn'
|
||||
//@ !has - '//pre[@class="rust item-decl"]/code/span[@class="where"]' '~const'
|
||||
//@ !has - '//pre[@class="rust item-decl"]/code/span[@class="where"]' '[const]'
|
||||
//@ has - '//pre[@class="rust item-decl"]/code/span[@class="where"]' ': Fn'
|
||||
#[const_trait]
|
||||
pub trait Tr<T> {
|
||||
//@ !has - '//section[@id="method.a"]/h4[@class="code-header"]' '~const'
|
||||
//@ !has - '//section[@id="method.a"]/h4[@class="code-header"]' '[const]'
|
||||
//@ has - '//section[@id="method.a"]/h4[@class="code-header"]/a[@class="trait"]' 'Fn'
|
||||
//@ !has - '//section[@id="method.a"]/h4[@class="code-header"]/span[@class="where"]' '~const'
|
||||
//@ !has - '//section[@id="method.a"]/h4[@class="code-header"]/span[@class="where"]' '[const]'
|
||||
//@ has - '//section[@id="method.a"]/h4[@class="code-header"]/div[@class="where"]' ': Fn'
|
||||
fn a<A: /* ~const */ Fn() /* + ~const Destruct */>()
|
||||
fn a<A: /* [const] */ Fn() /* + [const] Destruct */>()
|
||||
where
|
||||
Option<A>: /* ~const */ Fn() /* + ~const Destruct */,
|
||||
Option<A>: /* [const] */ Fn() /* + [const] Destruct */,
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
//@ has - '//section[@id="impl-Tr%3CT%3E-for-T"]' ''
|
||||
//@ !has - '//section[@id="impl-Tr%3CT%3E-for-T"]/h3[@class="code-header"]' '~const'
|
||||
//@ !has - '//section[@id="impl-Tr%3CT%3E-for-T"]/h3[@class="code-header"]' '[const]'
|
||||
//@ has - '//section[@id="impl-Tr%3CT%3E-for-T"]/h3[@class="code-header"]/a[@class="trait"]' 'Fn'
|
||||
//@ !has - '//section[@id="impl-Tr%3CT%3E-for-T"]/h3[@class="code-header"]/span[@class="where"]' '~const'
|
||||
//@ !has - '//section[@id="impl-Tr%3CT%3E-for-T"]/h3[@class="code-header"]/span[@class="where"]' '[const]'
|
||||
//@ has - '//section[@id="impl-Tr%3CT%3E-for-T"]/h3[@class="code-header"]/div[@class="where"]' ': Fn'
|
||||
impl<T: /* ~const */ Fn() /* + ~const Destruct */> const Tr<T> for T
|
||||
impl<T: /* [const] */ Fn() /* + [const] Destruct */> const Tr<T> for T
|
||||
where
|
||||
Option<T>: /* ~const */ Fn() /* + ~const Destruct */,
|
||||
Option<T>: /* [const] */ Fn() /* + [const] Destruct */,
|
||||
{
|
||||
fn a<A: /* ~const */ Fn() /* + ~const Destruct */>()
|
||||
fn a<A: /* [const] */ Fn() /* + [const] Destruct */>()
|
||||
where
|
||||
Option<A>: /* ~const */ Fn() /* + ~const Destruct */,
|
||||
Option<A>: /* [const] */ Fn() /* + [const] Destruct */,
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
//@ !has foo/fn.foo.html '//pre[@class="rust item-decl"]/code/a[@class="trait"]' '~const'
|
||||
//@ !has foo/fn.foo.html '//pre[@class="rust item-decl"]/code/a[@class="trait"]' '[const]'
|
||||
//@ has - '//pre[@class="rust item-decl"]/code/a[@class="trait"]' 'Fn'
|
||||
//@ !has - '//pre[@class="rust item-decl"]/code/div[@class="where"]' '~const'
|
||||
//@ !has - '//pre[@class="rust item-decl"]/code/div[@class="where"]' '[const]'
|
||||
//@ has - '//pre[@class="rust item-decl"]/code/div[@class="where"]' ': Fn'
|
||||
pub const fn foo<F: /* ~const */ Fn() /* + ~const Destruct */>()
|
||||
pub const fn foo<F: /* [const] */ Fn() /* + [const] Destruct */>()
|
||||
where
|
||||
Option<F>: /* ~const */ Fn() /* + ~const Destruct */,
|
||||
Option<F>: /* [const] */ Fn() /* + [const] Destruct */,
|
||||
{
|
||||
F::a()
|
||||
}
|
||||
|
||||
impl<T> S<T> {
|
||||
//@ !has foo/struct.S.html '//section[@id="method.foo"]/h4[@class="code-header"]' '~const'
|
||||
//@ !has foo/struct.S.html '//section[@id="method.foo"]/h4[@class="code-header"]' '[const]'
|
||||
//@ has - '//section[@id="method.foo"]/h4[@class="code-header"]/a[@class="trait"]' 'Fn'
|
||||
//@ !has - '//section[@id="method.foo"]/h4[@class="code-header"]/span[@class="where"]' '~const'
|
||||
//@ !has - '//section[@id="method.foo"]/h4[@class="code-header"]/span[@class="where"]' '[const]'
|
||||
//@ has - '//section[@id="method.foo"]/h4[@class="code-header"]/div[@class="where"]' ': Fn'
|
||||
pub const fn foo<B, C: /* ~const */ Fn() /* + ~const Destruct */>()
|
||||
pub const fn foo<B, C: /* [const] */ Fn() /* + [const] Destruct */>()
|
||||
where
|
||||
B: /* ~const */ Fn() /* + ~const Destruct */,
|
||||
B: /* [const] */ Fn() /* + [const] Destruct */,
|
||||
{
|
||||
B::a()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
#[const_trait]
|
||||
pub trait Resource {}
|
||||
|
||||
pub const fn load<R: ~const Resource>() -> i32 {
|
||||
pub const fn load<R: [const] Resource>() -> i32 {
|
||||
0
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ trait Func<T> {
|
|||
fn call_once(self, arg: T) -> Self::Output;
|
||||
}
|
||||
|
||||
|
||||
struct Closure;
|
||||
|
||||
impl const Func<&usize> for Closure {
|
||||
|
|
@ -21,7 +20,7 @@ impl const Func<&usize> for Closure {
|
|||
}
|
||||
}
|
||||
|
||||
enum Bug<T = [(); Closure.call_once(&0) ]> {
|
||||
enum Bug<T = [(); Closure.call_once(&0)]> {
|
||||
V(T),
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ LL | #![feature(const_trait_impl, generic_const_exprs)]
|
|||
|
|
||||
= help: remove one of these features
|
||||
|
||||
error[E0275]: overflow evaluating the requirement `&T: ~const ConstName`
|
||||
error[E0275]: overflow evaluating the requirement `&T: [const] ConstName`
|
||||
--> $DIR/issue-88119.rs:19:49
|
||||
|
|
||||
LL | impl<T: ?Sized + ConstName> const ConstName for &T
|
||||
|
|
@ -42,7 +42,7 @@ note: required by a bound in `<&T as ConstName>`
|
|||
LL | [(); name_len::<T>()]:,
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ required by this bound in `<&T as ConstName>`
|
||||
|
||||
error[E0275]: overflow evaluating the requirement `&mut T: ~const ConstName`
|
||||
error[E0275]: overflow evaluating the requirement `&mut T: [const] ConstName`
|
||||
--> $DIR/issue-88119.rs:26:49
|
||||
|
|
||||
LL | impl<T: ?Sized + ConstName> const ConstName for &mut T
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
use std::marker::Destruct;
|
||||
|
||||
const fn f<T: ~const Destruct>(x: T) {}
|
||||
const fn f<T: [const] Destruct>(x: T) {}
|
||||
|
||||
struct UnconstDrop;
|
||||
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@ LL | f(UnconstDrop);
|
|||
note: required by a bound in `f`
|
||||
--> $DIR/const-block-const-bound.rs:6:15
|
||||
|
|
||||
LL | const fn f<T: ~const Destruct>(x: T) {}
|
||||
| ^^^^^^^^^^^^^^^ required by this bound in `f`
|
||||
LL | const fn f<T: [const] Destruct>(x: T) {}
|
||||
| ^^^^^^^^^^^^^^^^ required by this bound in `f`
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ impl Tr for () {
|
|||
}
|
||||
}
|
||||
|
||||
const fn foo<T: ~const Tr>() -> [u8; T::a()] {
|
||||
const fn foo<T: [const] Tr>() -> [u8; T::a()] {
|
||||
[0; T::a()]
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
error[E0277]: the trait bound `T: const Tr` is not satisfied
|
||||
--> $DIR/constifconst-call-in-const-position.rs:17:38
|
||||
--> $DIR/constifconst-call-in-const-position.rs:17:39
|
||||
|
|
||||
LL | const fn foo<T: ~const Tr>() -> [u8; T::a()] {
|
||||
| ^
|
||||
LL | const fn foo<T: [const] Tr>() -> [u8; T::a()] {
|
||||
| ^
|
||||
|
||||
error[E0277]: the trait bound `T: const Tr` is not satisfied
|
||||
--> $DIR/constifconst-call-in-const-position.rs:18:9
|
||||
|
|
|
|||
|
|
@ -11,47 +11,47 @@ use std::marker::Destruct;
|
|||
|
||||
const fn tester_fn<T>(f: T) -> T::Output
|
||||
where
|
||||
T: ~const Fn<()> + ~const Destruct,
|
||||
T: [const] Fn<()> + [const] Destruct,
|
||||
{
|
||||
f()
|
||||
}
|
||||
|
||||
const fn tester_fn_mut<T>(mut f: T) -> T::Output
|
||||
where
|
||||
T: ~const FnMut<()> + ~const Destruct,
|
||||
T: [const] FnMut<()> + [const] Destruct,
|
||||
{
|
||||
f()
|
||||
}
|
||||
|
||||
const fn tester_fn_once<T>(f: T) -> T::Output
|
||||
where
|
||||
T: ~const FnOnce<()>,
|
||||
T: [const] FnOnce<()>,
|
||||
{
|
||||
f()
|
||||
}
|
||||
|
||||
const fn test_fn<T>(mut f: T) -> (T::Output, T::Output, T::Output)
|
||||
where
|
||||
T: ~const Fn<()> + ~const Destruct,
|
||||
T: [const] Fn<()> + [const] Destruct,
|
||||
{
|
||||
(
|
||||
// impl<A: Tuple, F: ~const Fn + ?Sized> const Fn<A> for &F
|
||||
// impl<A: Tuple, F: [const] Fn + ?Sized> const Fn<A> for &F
|
||||
tester_fn(&f),
|
||||
// impl<A: Tuple, F: ~const Fn + ?Sized> const FnMut<A> for &F
|
||||
// impl<A: Tuple, F: [const] Fn + ?Sized> const FnMut<A> for &F
|
||||
tester_fn_mut(&f),
|
||||
// impl<A: Tuple, F: ~const Fn + ?Sized> const FnOnce<A> for &F
|
||||
// impl<A: Tuple, F: [const] Fn + ?Sized> const FnOnce<A> for &F
|
||||
tester_fn_once(&f),
|
||||
)
|
||||
}
|
||||
|
||||
const fn test_fn_mut<T>(mut f: T) -> (T::Output, T::Output)
|
||||
where
|
||||
T: ~const FnMut<()> + ~const Destruct,
|
||||
T: [const] FnMut<()> + [const] Destruct,
|
||||
{
|
||||
(
|
||||
// impl<A: Tuple, F: ~const FnMut + ?Sized> const FnMut<A> for &mut F
|
||||
// impl<A: Tuple, F: [const] FnMut + ?Sized> const FnMut<A> for &mut F
|
||||
tester_fn_mut(&mut f),
|
||||
// impl<A: Tuple, F: ~const FnMut + ?Sized> const FnOnce<A> for &mut F
|
||||
// impl<A: Tuple, F: [const] FnMut + ?Sized> const FnOnce<A> for &mut F
|
||||
tester_fn_once(&mut f),
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,148 +4,148 @@ error[E0635]: unknown feature `const_fn_trait_ref_impls`
|
|||
LL | #![feature(const_fn_trait_ref_impls)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: `~const` can only be applied to `#[const_trait]` traits
|
||||
--> $DIR/fn_trait_refs.rs:14:8
|
||||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
--> $DIR/fn_trait_refs.rs:14:6
|
||||
|
|
||||
LL | T: ~const Fn<()> + ~const Destruct,
|
||||
| ^^^^^^ can't be applied to `Fn`
|
||||
LL | T: [const] Fn<()> + [const] Destruct,
|
||||
| ^^^^^^^^^ can't be applied to `Fn`
|
||||
|
|
||||
note: `Fn` can't be used with `~const` because it isn't annotated with `#[const_trait]`
|
||||
note: `Fn` can't be used with `[const]` because it isn't annotated with `#[const_trait]`
|
||||
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
|
||||
|
||||
error: `~const` can only be applied to `#[const_trait]` traits
|
||||
--> $DIR/fn_trait_refs.rs:14:8
|
||||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
--> $DIR/fn_trait_refs.rs:14:6
|
||||
|
|
||||
LL | T: ~const Fn<()> + ~const Destruct,
|
||||
| ^^^^^^ can't be applied to `Fn`
|
||||
LL | T: [const] Fn<()> + [const] Destruct,
|
||||
| ^^^^^^^^^ can't be applied to `Fn`
|
||||
|
|
||||
note: `Fn` can't be used with `~const` because it isn't annotated with `#[const_trait]`
|
||||
note: `Fn` can't be used with `[const]` because it isn't annotated with `#[const_trait]`
|
||||
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
|
||||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||
|
||||
error: `~const` can only be applied to `#[const_trait]` traits
|
||||
--> $DIR/fn_trait_refs.rs:14:8
|
||||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
--> $DIR/fn_trait_refs.rs:14:6
|
||||
|
|
||||
LL | T: ~const Fn<()> + ~const Destruct,
|
||||
| ^^^^^^ can't be applied to `Fn`
|
||||
LL | T: [const] Fn<()> + [const] Destruct,
|
||||
| ^^^^^^^^^ can't be applied to `Fn`
|
||||
|
|
||||
note: `Fn` can't be used with `~const` because it isn't annotated with `#[const_trait]`
|
||||
note: `Fn` can't be used with `[const]` because it isn't annotated with `#[const_trait]`
|
||||
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
|
||||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||
|
||||
error: `~const` can only be applied to `#[const_trait]` traits
|
||||
--> $DIR/fn_trait_refs.rs:21:8
|
||||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
--> $DIR/fn_trait_refs.rs:21:6
|
||||
|
|
||||
LL | T: ~const FnMut<()> + ~const Destruct,
|
||||
| ^^^^^^ can't be applied to `FnMut`
|
||||
LL | T: [const] FnMut<()> + [const] Destruct,
|
||||
| ^^^^^^^^^ can't be applied to `FnMut`
|
||||
|
|
||||
note: `FnMut` can't be used with `~const` because it isn't annotated with `#[const_trait]`
|
||||
note: `FnMut` can't be used with `[const]` because it isn't annotated with `#[const_trait]`
|
||||
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
|
||||
|
||||
error: `~const` can only be applied to `#[const_trait]` traits
|
||||
--> $DIR/fn_trait_refs.rs:21:8
|
||||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
--> $DIR/fn_trait_refs.rs:21:6
|
||||
|
|
||||
LL | T: ~const FnMut<()> + ~const Destruct,
|
||||
| ^^^^^^ can't be applied to `FnMut`
|
||||
LL | T: [const] FnMut<()> + [const] Destruct,
|
||||
| ^^^^^^^^^ can't be applied to `FnMut`
|
||||
|
|
||||
note: `FnMut` can't be used with `~const` because it isn't annotated with `#[const_trait]`
|
||||
note: `FnMut` can't be used with `[const]` because it isn't annotated with `#[const_trait]`
|
||||
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
|
||||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||
|
||||
error: `~const` can only be applied to `#[const_trait]` traits
|
||||
--> $DIR/fn_trait_refs.rs:21:8
|
||||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
--> $DIR/fn_trait_refs.rs:21:6
|
||||
|
|
||||
LL | T: ~const FnMut<()> + ~const Destruct,
|
||||
| ^^^^^^ can't be applied to `FnMut`
|
||||
LL | T: [const] FnMut<()> + [const] Destruct,
|
||||
| ^^^^^^^^^ can't be applied to `FnMut`
|
||||
|
|
||||
note: `FnMut` can't be used with `~const` because it isn't annotated with `#[const_trait]`
|
||||
note: `FnMut` can't be used with `[const]` because it isn't annotated with `#[const_trait]`
|
||||
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
|
||||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||
|
||||
error: `~const` can only be applied to `#[const_trait]` traits
|
||||
--> $DIR/fn_trait_refs.rs:28:8
|
||||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
--> $DIR/fn_trait_refs.rs:28:6
|
||||
|
|
||||
LL | T: ~const FnOnce<()>,
|
||||
| ^^^^^^ can't be applied to `FnOnce`
|
||||
LL | T: [const] FnOnce<()>,
|
||||
| ^^^^^^^^^ can't be applied to `FnOnce`
|
||||
|
|
||||
note: `FnOnce` can't be used with `~const` because it isn't annotated with `#[const_trait]`
|
||||
note: `FnOnce` can't be used with `[const]` because it isn't annotated with `#[const_trait]`
|
||||
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
|
||||
|
||||
error: `~const` can only be applied to `#[const_trait]` traits
|
||||
--> $DIR/fn_trait_refs.rs:28:8
|
||||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
--> $DIR/fn_trait_refs.rs:28:6
|
||||
|
|
||||
LL | T: ~const FnOnce<()>,
|
||||
| ^^^^^^ can't be applied to `FnOnce`
|
||||
LL | T: [const] FnOnce<()>,
|
||||
| ^^^^^^^^^ can't be applied to `FnOnce`
|
||||
|
|
||||
note: `FnOnce` can't be used with `~const` because it isn't annotated with `#[const_trait]`
|
||||
note: `FnOnce` can't be used with `[const]` because it isn't annotated with `#[const_trait]`
|
||||
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
|
||||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||
|
||||
error: `~const` can only be applied to `#[const_trait]` traits
|
||||
--> $DIR/fn_trait_refs.rs:28:8
|
||||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
--> $DIR/fn_trait_refs.rs:28:6
|
||||
|
|
||||
LL | T: ~const FnOnce<()>,
|
||||
| ^^^^^^ can't be applied to `FnOnce`
|
||||
LL | T: [const] FnOnce<()>,
|
||||
| ^^^^^^^^^ can't be applied to `FnOnce`
|
||||
|
|
||||
note: `FnOnce` can't be used with `~const` because it isn't annotated with `#[const_trait]`
|
||||
note: `FnOnce` can't be used with `[const]` because it isn't annotated with `#[const_trait]`
|
||||
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
|
||||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||
|
||||
error: `~const` can only be applied to `#[const_trait]` traits
|
||||
--> $DIR/fn_trait_refs.rs:35:8
|
||||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
--> $DIR/fn_trait_refs.rs:35:6
|
||||
|
|
||||
LL | T: ~const Fn<()> + ~const Destruct,
|
||||
| ^^^^^^ can't be applied to `Fn`
|
||||
LL | T: [const] Fn<()> + [const] Destruct,
|
||||
| ^^^^^^^^^ can't be applied to `Fn`
|
||||
|
|
||||
note: `Fn` can't be used with `~const` because it isn't annotated with `#[const_trait]`
|
||||
note: `Fn` can't be used with `[const]` because it isn't annotated with `#[const_trait]`
|
||||
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
|
||||
|
||||
error: `~const` can only be applied to `#[const_trait]` traits
|
||||
--> $DIR/fn_trait_refs.rs:35:8
|
||||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
--> $DIR/fn_trait_refs.rs:35:6
|
||||
|
|
||||
LL | T: ~const Fn<()> + ~const Destruct,
|
||||
| ^^^^^^ can't be applied to `Fn`
|
||||
LL | T: [const] Fn<()> + [const] Destruct,
|
||||
| ^^^^^^^^^ can't be applied to `Fn`
|
||||
|
|
||||
note: `Fn` can't be used with `~const` because it isn't annotated with `#[const_trait]`
|
||||
note: `Fn` can't be used with `[const]` because it isn't annotated with `#[const_trait]`
|
||||
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
|
||||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||
|
||||
error: `~const` can only be applied to `#[const_trait]` traits
|
||||
--> $DIR/fn_trait_refs.rs:35:8
|
||||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
--> $DIR/fn_trait_refs.rs:35:6
|
||||
|
|
||||
LL | T: ~const Fn<()> + ~const Destruct,
|
||||
| ^^^^^^ can't be applied to `Fn`
|
||||
LL | T: [const] Fn<()> + [const] Destruct,
|
||||
| ^^^^^^^^^ can't be applied to `Fn`
|
||||
|
|
||||
note: `Fn` can't be used with `~const` because it isn't annotated with `#[const_trait]`
|
||||
note: `Fn` can't be used with `[const]` because it isn't annotated with `#[const_trait]`
|
||||
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
|
||||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||
|
||||
error: `~const` can only be applied to `#[const_trait]` traits
|
||||
--> $DIR/fn_trait_refs.rs:49:8
|
||||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
--> $DIR/fn_trait_refs.rs:49:6
|
||||
|
|
||||
LL | T: ~const FnMut<()> + ~const Destruct,
|
||||
| ^^^^^^ can't be applied to `FnMut`
|
||||
LL | T: [const] FnMut<()> + [const] Destruct,
|
||||
| ^^^^^^^^^ can't be applied to `FnMut`
|
||||
|
|
||||
note: `FnMut` can't be used with `~const` because it isn't annotated with `#[const_trait]`
|
||||
note: `FnMut` can't be used with `[const]` because it isn't annotated with `#[const_trait]`
|
||||
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
|
||||
|
||||
error: `~const` can only be applied to `#[const_trait]` traits
|
||||
--> $DIR/fn_trait_refs.rs:49:8
|
||||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
--> $DIR/fn_trait_refs.rs:49:6
|
||||
|
|
||||
LL | T: ~const FnMut<()> + ~const Destruct,
|
||||
| ^^^^^^ can't be applied to `FnMut`
|
||||
LL | T: [const] FnMut<()> + [const] Destruct,
|
||||
| ^^^^^^^^^ can't be applied to `FnMut`
|
||||
|
|
||||
note: `FnMut` can't be used with `~const` because it isn't annotated with `#[const_trait]`
|
||||
note: `FnMut` can't be used with `[const]` because it isn't annotated with `#[const_trait]`
|
||||
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
|
||||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||
|
||||
error: `~const` can only be applied to `#[const_trait]` traits
|
||||
--> $DIR/fn_trait_refs.rs:49:8
|
||||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
--> $DIR/fn_trait_refs.rs:49:6
|
||||
|
|
||||
LL | T: ~const FnMut<()> + ~const Destruct,
|
||||
| ^^^^^^ can't be applied to `FnMut`
|
||||
LL | T: [const] FnMut<()> + [const] Destruct,
|
||||
| ^^^^^^^^^ can't be applied to `FnMut`
|
||||
|
|
||||
note: `FnMut` can't be used with `~const` because it isn't annotated with `#[const_trait]`
|
||||
note: `FnMut` can't be used with `[const]` because it isn't annotated with `#[const_trait]`
|
||||
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
|
||||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error[E0277]: the trait bound `TypeId: ~const PartialEq` is not satisfied
|
||||
error[E0277]: the trait bound `TypeId: [const] PartialEq` is not satisfied
|
||||
--> $DIR/issue-73976-monomorphic.rs:21:5
|
||||
|
|
||||
LL | GetTypeId::<T>::VALUE == GetTypeId::<usize>::VALUE
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ enum Opt<T> {
|
|||
impl<T> Opt<T> {
|
||||
#[rustc_const_unstable(feature = "foo", issue = "none")]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
const fn unwrap_or_else<F: ~const FnOnce() -> T>(self, f: F) -> T {
|
||||
const fn unwrap_or_else<F: [const] FnOnce() -> T>(self, f: F) -> T {
|
||||
//FIXME ~^ ERROR destructor of
|
||||
//FIXME ~| ERROR destructor of
|
||||
match self {
|
||||
|
|
|
|||
|
|
@ -1,19 +1,19 @@
|
|||
error: `~const` can only be applied to `#[const_trait]` traits
|
||||
--> $DIR/unstable-const-fn-in-libcore.rs:19:32
|
||||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
--> $DIR/unstable-const-fn-in-libcore.rs:19:30
|
||||
|
|
||||
LL | const fn unwrap_or_else<F: ~const FnOnce() -> T>(self, f: F) -> T {
|
||||
| ^^^^^^ can't be applied to `FnOnce`
|
||||
LL | const fn unwrap_or_else<F: [const] FnOnce() -> T>(self, f: F) -> T {
|
||||
| ^^^^^^^^^ can't be applied to `FnOnce`
|
||||
|
|
||||
note: `FnOnce` can't be used with `~const` because it isn't annotated with `#[const_trait]`
|
||||
note: `FnOnce` can't be used with `[const]` because it isn't annotated with `#[const_trait]`
|
||||
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
|
||||
|
||||
error: `~const` can only be applied to `#[const_trait]` traits
|
||||
--> $DIR/unstable-const-fn-in-libcore.rs:19:32
|
||||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
--> $DIR/unstable-const-fn-in-libcore.rs:19:30
|
||||
|
|
||||
LL | const fn unwrap_or_else<F: ~const FnOnce() -> T>(self, f: F) -> T {
|
||||
| ^^^^^^ can't be applied to `FnOnce`
|
||||
LL | const fn unwrap_or_else<F: [const] FnOnce() -> T>(self, f: F) -> T {
|
||||
| ^^^^^^^^^ can't be applied to `FnOnce`
|
||||
|
|
||||
note: `FnOnce` can't be used with `~const` because it isn't annotated with `#[const_trait]`
|
||||
note: `FnOnce` can't be used with `[const]` because it isn't annotated with `#[const_trait]`
|
||||
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
|
||||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||
|
||||
|
|
@ -26,19 +26,19 @@ LL | Opt::None => f(),
|
|||
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
|
||||
|
||||
error[E0493]: destructor of `F` cannot be evaluated at compile-time
|
||||
--> $DIR/unstable-const-fn-in-libcore.rs:19:60
|
||||
--> $DIR/unstable-const-fn-in-libcore.rs:19:61
|
||||
|
|
||||
LL | const fn unwrap_or_else<F: ~const FnOnce() -> T>(self, f: F) -> T {
|
||||
| ^ the destructor for this type cannot be evaluated in constant functions
|
||||
LL | const fn unwrap_or_else<F: [const] FnOnce() -> T>(self, f: F) -> T {
|
||||
| ^ the destructor for this type cannot be evaluated in constant functions
|
||||
...
|
||||
LL | }
|
||||
| - value is dropped here
|
||||
|
||||
error[E0493]: destructor of `Opt<T>` cannot be evaluated at compile-time
|
||||
--> $DIR/unstable-const-fn-in-libcore.rs:19:54
|
||||
--> $DIR/unstable-const-fn-in-libcore.rs:19:55
|
||||
|
|
||||
LL | const fn unwrap_or_else<F: ~const FnOnce() -> T>(self, f: F) -> T {
|
||||
| ^^^^ the destructor for this type cannot be evaluated in constant functions
|
||||
LL | const fn unwrap_or_else<F: [const] FnOnce() -> T>(self, f: F) -> T {
|
||||
| ^^^^ the destructor for this type cannot be evaluated in constant functions
|
||||
...
|
||||
LL | }
|
||||
| - value is dropped here
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ mod foo {
|
|||
}
|
||||
use foo::*;
|
||||
|
||||
const fn with_positive<F: for<'a> ~const Fn(&'a Alias<'a>) + ~const Destruct>(fun: F) {
|
||||
const fn with_positive<F: for<'a> [const] Fn(&'a Alias<'a>) + [const] Destruct>(fun: F) {
|
||||
fun(filter_positive());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,19 +1,19 @@
|
|||
error: `~const` can only be applied to `#[const_trait]` traits
|
||||
--> $DIR/normalize-tait-in-const.rs:27:35
|
||||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
--> $DIR/normalize-tait-in-const.rs:27:33
|
||||
|
|
||||
LL | const fn with_positive<F: for<'a> ~const Fn(&'a Alias<'a>) + ~const Destruct>(fun: F) {
|
||||
| ^^^^^^ can't be applied to `Fn`
|
||||
LL | const fn with_positive<F: for<'a> [const] Fn(&'a Alias<'a>) + [const] Destruct>(fun: F) {
|
||||
| ^^^^^^^^^ can't be applied to `Fn`
|
||||
|
|
||||
note: `Fn` can't be used with `~const` because it isn't annotated with `#[const_trait]`
|
||||
note: `Fn` can't be used with `[const]` because it isn't annotated with `#[const_trait]`
|
||||
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
|
||||
|
||||
error: `~const` can only be applied to `#[const_trait]` traits
|
||||
--> $DIR/normalize-tait-in-const.rs:27:35
|
||||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
--> $DIR/normalize-tait-in-const.rs:27:33
|
||||
|
|
||||
LL | const fn with_positive<F: for<'a> ~const Fn(&'a Alias<'a>) + ~const Destruct>(fun: F) {
|
||||
| ^^^^^^ can't be applied to `Fn`
|
||||
LL | const fn with_positive<F: for<'a> [const] Fn(&'a Alias<'a>) + [const] Destruct>(fun: F) {
|
||||
| ^^^^^^^^^ can't be applied to `Fn`
|
||||
|
|
||||
note: `Fn` can't be used with `~const` because it isn't annotated with `#[const_trait]`
|
||||
note: `Fn` can't be used with `[const]` because it isn't annotated with `#[const_trait]`
|
||||
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
|
||||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||
|
||||
|
|
|
|||
|
|
@ -483,7 +483,6 @@ fn test_item() {
|
|||
c1!(item, [ impl<T> Struct<T> {} ], "impl<T> Struct<T> {}");
|
||||
c1!(item, [ pub impl Trait for Struct {} ], "pub impl Trait for Struct {}");
|
||||
c1!(item, [ impl<T> const Trait for T {} ], "impl<T> const Trait for T {}");
|
||||
c1!(item, [ impl ~const Struct {} ], "impl ~const Struct {}");
|
||||
|
||||
// ItemKind::MacCall
|
||||
c1!(item, [ mac!(); ], "mac!();");
|
||||
|
|
@ -730,7 +729,7 @@ fn test_ty() {
|
|||
c1!(ty, [ dyn Send + 'a ], "dyn Send + 'a");
|
||||
c1!(ty, [ dyn 'a + Send ], "dyn 'a + Send");
|
||||
c1!(ty, [ dyn ?Sized ], "dyn ?Sized");
|
||||
c1!(ty, [ dyn ~const Clone ], "dyn ~const Clone");
|
||||
c1!(ty, [ dyn [const] Clone ], "dyn [const] Clone");
|
||||
c1!(ty, [ dyn for<'a> Send ], "dyn for<'a> Send");
|
||||
|
||||
// TyKind::ImplTrait
|
||||
|
|
@ -738,7 +737,7 @@ fn test_ty() {
|
|||
c1!(ty, [ impl Send + 'a ], "impl Send + 'a");
|
||||
c1!(ty, [ impl 'a + Send ], "impl 'a + Send");
|
||||
c1!(ty, [ impl ?Sized ], "impl ?Sized");
|
||||
c1!(ty, [ impl ~const Clone ], "impl ~const Clone");
|
||||
c1!(ty, [ impl [const] Clone ], "impl [const] Clone");
|
||||
c1!(ty, [ impl for<'a> Send ], "impl for<'a> Send");
|
||||
|
||||
// TyKind::Paren
|
||||
|
|
|
|||
|
|
@ -10,10 +10,10 @@ struct S<
|
|||
T: Tr +, // OK
|
||||
T: ?'a, //~ ERROR `?` may only modify trait bounds, not lifetime bounds
|
||||
|
||||
T: ~const Tr, // OK
|
||||
T: ~const ?Tr, //~ ERROR `~const` trait not allowed with `?` trait polarity modifier
|
||||
T: ~const Tr + 'a, // OK
|
||||
T: ~const 'a, //~ ERROR `~const` may only modify trait bounds, not lifetime bounds
|
||||
T: [const] Tr, // OK
|
||||
T: [const] ?Tr, //~ ERROR `[const]` trait not allowed with `?` trait polarity modifier
|
||||
T: [const] Tr + 'a, // OK
|
||||
T: [const] 'a, //~ ERROR `[const]` may only modify trait bounds, not lifetime bounds
|
||||
T: const 'a, //~ ERROR `const` may only modify trait bounds, not lifetime bounds
|
||||
|
||||
T: async Tr, // OK
|
||||
|
|
|
|||
|
|
@ -12,19 +12,19 @@ error: `?` may only modify trait bounds, not lifetime bounds
|
|||
LL | T: ?'a,
|
||||
| ^
|
||||
|
||||
error: `~const` trait not allowed with `?` trait polarity modifier
|
||||
--> $DIR/bounds-type.rs:14:15
|
||||
error: `[const]` trait not allowed with `?` trait polarity modifier
|
||||
--> $DIR/bounds-type.rs:14:16
|
||||
|
|
||||
LL | T: ~const ?Tr,
|
||||
| ------ ^
|
||||
LL | T: [const] ?Tr,
|
||||
| ------- ^
|
||||
| |
|
||||
| there is not a well-defined meaning for a `~const ?` trait
|
||||
| there is not a well-defined meaning for a `[const] ?` trait
|
||||
|
||||
error: `~const` may only modify trait bounds, not lifetime bounds
|
||||
--> $DIR/bounds-type.rs:16:8
|
||||
error: `[const]` may only modify trait bounds, not lifetime bounds
|
||||
--> $DIR/bounds-type.rs:16:6
|
||||
|
|
||||
LL | T: ~const 'a,
|
||||
| ^^^^^^
|
||||
LL | T: [const] 'a,
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: `const` may only modify trait bounds, not lifetime bounds
|
||||
--> $DIR/bounds-type.rs:17:8
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ fn foo2(_: &dyn (Drop + AsRef<str>)) {} //~ ERROR incorrect parentheses around t
|
|||
fn foo2_no_space(_: &dyn(Drop + AsRef<str>)) {} //~ ERROR incorrect parentheses around trait bounds
|
||||
|
||||
fn foo3(_: &dyn {Drop + AsRef<str>}) {} //~ ERROR expected parameter name, found `{`
|
||||
//~^ ERROR expected one of `!`, `(`, `)`, `*`, `,`, `?`, `async`, `const`, `for`, `use`, `~`, lifetime, or path, found `{`
|
||||
//~^ ERROR expected one of `!`, `(`, `)`, `*`, `,`, `?`, `[`, `async`, `const`, `for`, `use`, `~`, lifetime, or path, found `{`
|
||||
//~| ERROR at least one trait is required for an object type
|
||||
|
||||
fn foo4(_: &dyn <Drop + AsRef<str>>) {} //~ ERROR expected identifier, found `<`
|
||||
|
|
|
|||
|
|
@ -39,11 +39,11 @@ error: expected parameter name, found `{`
|
|||
LL | fn foo3(_: &dyn {Drop + AsRef<str>}) {}
|
||||
| ^ expected parameter name
|
||||
|
||||
error: expected one of `!`, `(`, `)`, `*`, `,`, `?`, `async`, `const`, `for`, `use`, `~`, lifetime, or path, found `{`
|
||||
error: expected one of `!`, `(`, `)`, `*`, `,`, `?`, `[`, `async`, `const`, `for`, `use`, `~`, lifetime, or path, found `{`
|
||||
--> $DIR/trait-object-delimiters.rs:10:17
|
||||
|
|
||||
LL | fn foo3(_: &dyn {Drop + AsRef<str>}) {}
|
||||
| -^ expected one of 13 possible tokens
|
||||
| -^ expected one of 14 possible tokens
|
||||
| |
|
||||
| help: missing `,`
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ pub unsafe trait Sup {
|
|||
|
||||
#[rustc_specialization_trait]
|
||||
#[const_trait]
|
||||
pub unsafe trait Sub: ~const Sup {}
|
||||
pub unsafe trait Sub: [const] Sup {}
|
||||
|
||||
unsafe impl const Sup for u8 {
|
||||
default fn foo() -> u32 {
|
||||
|
|
@ -31,19 +31,19 @@ pub trait A {
|
|||
fn a() -> u32;
|
||||
}
|
||||
|
||||
impl<T: ~const Default> const A for T {
|
||||
impl<T: [const] Default> const A for T {
|
||||
default fn a() -> u32 {
|
||||
2
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: ~const Default + ~const Sup> const A for T {
|
||||
impl<T: [const] Default + [const] Sup> const A for T {
|
||||
default fn a() -> u32 {
|
||||
3
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: ~const Default + ~const Sub> const A for T {
|
||||
impl<T: [const] Default + [const] Sub> const A for T {
|
||||
fn a() -> u32 {
|
||||
T::foo()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,57 +1,57 @@
|
|||
error: `~const` can only be applied to `#[const_trait]` traits
|
||||
--> $DIR/const_trait_impl.rs:34:9
|
||||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
--> $DIR/const_trait_impl.rs:34:7
|
||||
|
|
||||
LL | impl<T: ~const Default> const A for T {
|
||||
| ^^^^^^ can't be applied to `Default`
|
||||
LL | impl<T: [const] Default> const A for T {
|
||||
| ^^^^^^^^^ can't be applied to `Default`
|
||||
|
|
||||
note: `Default` can't be used with `~const` because it isn't annotated with `#[const_trait]`
|
||||
note: `Default` can't be used with `[const]` because it isn't annotated with `#[const_trait]`
|
||||
--> $SRC_DIR/core/src/default.rs:LL:COL
|
||||
|
||||
error: `~const` can only be applied to `#[const_trait]` traits
|
||||
--> $DIR/const_trait_impl.rs:40:9
|
||||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
--> $DIR/const_trait_impl.rs:40:7
|
||||
|
|
||||
LL | impl<T: ~const Default + ~const Sup> const A for T {
|
||||
| ^^^^^^ can't be applied to `Default`
|
||||
LL | impl<T: [const] Default + [const] Sup> const A for T {
|
||||
| ^^^^^^^^^ can't be applied to `Default`
|
||||
|
|
||||
note: `Default` can't be used with `~const` because it isn't annotated with `#[const_trait]`
|
||||
note: `Default` can't be used with `[const]` because it isn't annotated with `#[const_trait]`
|
||||
--> $SRC_DIR/core/src/default.rs:LL:COL
|
||||
|
||||
error: `~const` can only be applied to `#[const_trait]` traits
|
||||
--> $DIR/const_trait_impl.rs:46:9
|
||||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
--> $DIR/const_trait_impl.rs:46:7
|
||||
|
|
||||
LL | impl<T: ~const Default + ~const Sub> const A for T {
|
||||
| ^^^^^^ can't be applied to `Default`
|
||||
LL | impl<T: [const] Default + [const] Sub> const A for T {
|
||||
| ^^^^^^^^^ can't be applied to `Default`
|
||||
|
|
||||
note: `Default` can't be used with `~const` because it isn't annotated with `#[const_trait]`
|
||||
note: `Default` can't be used with `[const]` because it isn't annotated with `#[const_trait]`
|
||||
--> $SRC_DIR/core/src/default.rs:LL:COL
|
||||
|
||||
error: `~const` can only be applied to `#[const_trait]` traits
|
||||
--> $DIR/const_trait_impl.rs:40:9
|
||||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
--> $DIR/const_trait_impl.rs:40:7
|
||||
|
|
||||
LL | impl<T: ~const Default + ~const Sup> const A for T {
|
||||
| ^^^^^^ can't be applied to `Default`
|
||||
LL | impl<T: [const] Default + [const] Sup> const A for T {
|
||||
| ^^^^^^^^^ can't be applied to `Default`
|
||||
|
|
||||
note: `Default` can't be used with `~const` because it isn't annotated with `#[const_trait]`
|
||||
note: `Default` can't be used with `[const]` because it isn't annotated with `#[const_trait]`
|
||||
--> $SRC_DIR/core/src/default.rs:LL:COL
|
||||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||
|
||||
error: `~const` can only be applied to `#[const_trait]` traits
|
||||
--> $DIR/const_trait_impl.rs:34:9
|
||||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
--> $DIR/const_trait_impl.rs:34:7
|
||||
|
|
||||
LL | impl<T: ~const Default> const A for T {
|
||||
| ^^^^^^ can't be applied to `Default`
|
||||
LL | impl<T: [const] Default> const A for T {
|
||||
| ^^^^^^^^^ can't be applied to `Default`
|
||||
|
|
||||
note: `Default` can't be used with `~const` because it isn't annotated with `#[const_trait]`
|
||||
note: `Default` can't be used with `[const]` because it isn't annotated with `#[const_trait]`
|
||||
--> $SRC_DIR/core/src/default.rs:LL:COL
|
||||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||
|
||||
error: `~const` can only be applied to `#[const_trait]` traits
|
||||
--> $DIR/const_trait_impl.rs:46:9
|
||||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
--> $DIR/const_trait_impl.rs:46:7
|
||||
|
|
||||
LL | impl<T: ~const Default + ~const Sub> const A for T {
|
||||
| ^^^^^^ can't be applied to `Default`
|
||||
LL | impl<T: [const] Default + [const] Sub> const A for T {
|
||||
| ^^^^^^^^^ can't be applied to `Default`
|
||||
|
|
||||
note: `Default` can't be used with `~const` because it isn't annotated with `#[const_trait]`
|
||||
note: `Default` can't be used with `[const]` because it isn't annotated with `#[const_trait]`
|
||||
--> $SRC_DIR/core/src/default.rs:LL:COL
|
||||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||
|
||||
|
|
|
|||
|
|
@ -6,15 +6,15 @@
|
|||
|
||||
#[const_trait]
|
||||
trait Trait {
|
||||
type Assoc: ~const Trait;
|
||||
type Assoc: [const] Trait;
|
||||
fn func() -> i32;
|
||||
}
|
||||
|
||||
const fn unqualified<T: ~const Trait>() -> i32 {
|
||||
const fn unqualified<T: [const] Trait>() -> i32 {
|
||||
T::Assoc::func()
|
||||
}
|
||||
|
||||
const fn qualified<T: ~const Trait>() -> i32 {
|
||||
const fn qualified<T: [const] Trait>() -> i32 {
|
||||
<T as Trait>::Assoc::func()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
#[const_trait]
|
||||
trait Trait {
|
||||
type Assoc: ~const Trait;
|
||||
type Assoc: [const] Trait;
|
||||
fn func() -> i32;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
error[E0277]: the trait bound `U: ~const Other` is not satisfied
|
||||
error[E0277]: the trait bound `U: [const] Other` is not satisfied
|
||||
--> $DIR/assoc-type-const-bound-usage-fail-2.rs:24:5
|
||||
|
|
||||
LL | T::Assoc::<U>::func();
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error[E0277]: the trait bound `U: ~const Other` is not satisfied
|
||||
error[E0277]: the trait bound `U: [const] Other` is not satisfied
|
||||
--> $DIR/assoc-type-const-bound-usage-fail-2.rs:26:5
|
||||
|
|
||||
LL | <T as Trait>::Assoc::<U>::func();
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
error[E0277]: the trait bound `U: ~const Other` is not satisfied
|
||||
error[E0277]: the trait bound `U: [const] Other` is not satisfied
|
||||
--> $DIR/assoc-type-const-bound-usage-fail-2.rs:24:5
|
||||
|
|
||||
LL | T::Assoc::<U>::func();
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error[E0277]: the trait bound `U: ~const Other` is not satisfied
|
||||
error[E0277]: the trait bound `U: [const] Other` is not satisfied
|
||||
--> $DIR/assoc-type-const-bound-usage-fail-2.rs:26:5
|
||||
|
|
||||
LL | <T as Trait>::Assoc::<U>::func();
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
//@ revisions: current next
|
||||
//@[next] compile-flags: -Znext-solver
|
||||
|
||||
// Check that `~const` item bounds only hold if the where clauses on the
|
||||
// Check that `[const]` item bounds only hold if the where clauses on the
|
||||
// associated type are also const.
|
||||
// i.e. check that we validate the const conditions for the associated type
|
||||
// when considering one of implied const bounds.
|
||||
|
|
@ -10,9 +10,9 @@
|
|||
|
||||
#[const_trait]
|
||||
trait Trait {
|
||||
type Assoc<U>: ~const Trait
|
||||
type Assoc<U>: [const] Trait
|
||||
where
|
||||
U: ~const Other;
|
||||
U: [const] Other;
|
||||
|
||||
fn func();
|
||||
}
|
||||
|
|
@ -20,14 +20,14 @@ trait Trait {
|
|||
#[const_trait]
|
||||
trait Other {}
|
||||
|
||||
const fn fails<T: ~const Trait, U: Other>() {
|
||||
const fn fails<T: [const] Trait, U: Other>() {
|
||||
T::Assoc::<U>::func();
|
||||
//~^ ERROR the trait bound `U: ~const Other` is not satisfied
|
||||
//~^ ERROR the trait bound `U: [const] Other` is not satisfied
|
||||
<T as Trait>::Assoc::<U>::func();
|
||||
//~^ ERROR the trait bound `U: ~const Other` is not satisfied
|
||||
//~^ ERROR the trait bound `U: [const] Other` is not satisfied
|
||||
}
|
||||
|
||||
const fn works<T: ~const Trait, U: ~const Other>() {
|
||||
const fn works<T: [const] Trait, U: [const] Other>() {
|
||||
T::Assoc::<U>::func();
|
||||
<T as Trait>::Assoc::<U>::func();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
error[E0277]: the trait bound `T: ~const Trait` is not satisfied
|
||||
error[E0277]: the trait bound `T: [const] Trait` is not satisfied
|
||||
--> $DIR/assoc-type-const-bound-usage-fail.rs:17:5
|
||||
|
|
||||
LL | T::Assoc::func();
|
||||
| ^^^^^^^^
|
||||
|
||||
error[E0277]: the trait bound `T: ~const Trait` is not satisfied
|
||||
error[E0277]: the trait bound `T: [const] Trait` is not satisfied
|
||||
--> $DIR/assoc-type-const-bound-usage-fail.rs:19:5
|
||||
|
|
||||
LL | <T as Trait>::Assoc::func();
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
error[E0277]: the trait bound `T: ~const Trait` is not satisfied
|
||||
error[E0277]: the trait bound `T: [const] Trait` is not satisfied
|
||||
--> $DIR/assoc-type-const-bound-usage-fail.rs:17:5
|
||||
|
|
||||
LL | T::Assoc::func();
|
||||
| ^^^^^^^^
|
||||
|
||||
error[E0277]: the trait bound `T: ~const Trait` is not satisfied
|
||||
error[E0277]: the trait bound `T: [const] Trait` is not satisfied
|
||||
--> $DIR/assoc-type-const-bound-usage-fail.rs:19:5
|
||||
|
|
||||
LL | <T as Trait>::Assoc::func();
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
//@ revisions: current next
|
||||
//@[next] compile-flags: -Znext-solver
|
||||
|
||||
// Check that `~const` item bounds only hold if the parent trait is `~const`.
|
||||
// Check that `[const]` item bounds only hold if the parent trait is `[const]`.
|
||||
// i.e. check that we validate the const conditions for the associated type
|
||||
// when considering one of implied const bounds.
|
||||
|
||||
|
|
@ -9,18 +9,18 @@
|
|||
|
||||
#[const_trait]
|
||||
trait Trait {
|
||||
type Assoc: ~const Trait;
|
||||
type Assoc: [const] Trait;
|
||||
fn func();
|
||||
}
|
||||
|
||||
const fn unqualified<T: Trait>() {
|
||||
T::Assoc::func();
|
||||
//~^ ERROR the trait bound `T: ~const Trait` is not satisfied
|
||||
//~^ ERROR the trait bound `T: [const] Trait` is not satisfied
|
||||
<T as Trait>::Assoc::func();
|
||||
//~^ ERROR the trait bound `T: ~const Trait` is not satisfied
|
||||
//~^ ERROR the trait bound `T: [const] Trait` is not satisfied
|
||||
}
|
||||
|
||||
const fn works<T: ~const Trait>() {
|
||||
const fn works<T: [const] Trait>() {
|
||||
T::Assoc::func();
|
||||
<T as Trait>::Assoc::func();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error[E0277]: the trait bound `NonConstAdd: ~const Add` is not satisfied
|
||||
error[E0277]: the trait bound `NonConstAdd: [const] Add` is not satisfied
|
||||
--> $DIR/assoc-type.rs:37:16
|
||||
|
|
||||
LL | type Bar = NonConstAdd;
|
||||
|
|
@ -7,8 +7,8 @@ LL | type Bar = NonConstAdd;
|
|||
note: required by a bound in `Foo::Bar`
|
||||
--> $DIR/assoc-type.rs:33:15
|
||||
|
|
||||
LL | type Bar: ~const Add;
|
||||
| ^^^^^^^^^^ required by this bound in `Foo::Bar`
|
||||
LL | type Bar: [const] Add;
|
||||
| ^^^^^^^^^^^ required by this bound in `Foo::Bar`
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error[E0277]: the trait bound `NonConstAdd: ~const Add` is not satisfied
|
||||
error[E0277]: the trait bound `NonConstAdd: [const] Add` is not satisfied
|
||||
--> $DIR/assoc-type.rs:37:16
|
||||
|
|
||||
LL | type Bar = NonConstAdd;
|
||||
|
|
@ -7,8 +7,8 @@ LL | type Bar = NonConstAdd;
|
|||
note: required by a bound in `Foo::Bar`
|
||||
--> $DIR/assoc-type.rs:33:15
|
||||
|
|
||||
LL | type Bar: ~const Add;
|
||||
| ^^^^^^^^^^ required by this bound in `Foo::Bar`
|
||||
LL | type Bar: [const] Add;
|
||||
| ^^^^^^^^^^^ required by this bound in `Foo::Bar`
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -30,12 +30,12 @@ impl Add for NonConstAdd {
|
|||
|
||||
#[const_trait]
|
||||
trait Foo {
|
||||
type Bar: ~const Add;
|
||||
type Bar: [const] Add;
|
||||
}
|
||||
|
||||
impl const Foo for NonConstAdd {
|
||||
type Bar = NonConstAdd;
|
||||
//~^ ERROR the trait bound `NonConstAdd: ~const Add` is not satisfied
|
||||
//~^ ERROR the trait bound `NonConstAdd: [const] Add` is not satisfied
|
||||
}
|
||||
|
||||
#[const_trait]
|
||||
|
|
|
|||
|
|
@ -86,14 +86,14 @@ enum ControlFlow<B, C = ()> {
|
|||
#[const_trait]
|
||||
#[lang = "fn"]
|
||||
#[rustc_paren_sugar]
|
||||
pub trait Fn<Args: Tuple>: ~const FnMut<Args> {
|
||||
pub trait Fn<Args: Tuple>: [const] FnMut<Args> {
|
||||
extern "rust-call" fn call(&self, args: Args) -> Self::Output;
|
||||
}
|
||||
|
||||
#[const_trait]
|
||||
#[lang = "fn_mut"]
|
||||
#[rustc_paren_sugar]
|
||||
pub trait FnMut<Args: Tuple>: ~const FnOnce<Args> {
|
||||
pub trait FnMut<Args: Tuple>: [const] FnOnce<Args> {
|
||||
extern "rust-call" fn call_mut(&mut self, args: Args) -> Self::Output;
|
||||
}
|
||||
|
||||
|
|
@ -142,7 +142,7 @@ pub trait Drop {
|
|||
|
||||
#[const_trait]
|
||||
pub trait Residual<O> {
|
||||
type TryType: ~const Try<Output = O, Residual = Self> + Try<Output = O, Residual = Self>;
|
||||
type TryType: [const] Try<Output = O, Residual = Self> + Try<Output = O, Residual = Self>;
|
||||
}
|
||||
|
||||
const fn size_of<T>() -> usize {
|
||||
|
|
@ -183,7 +183,7 @@ pub unsafe trait SliceIndex<T: PointeeSized> {
|
|||
|
||||
impl<T, I> const Index<I> for [T]
|
||||
where
|
||||
I: ~const SliceIndex<[T]>,
|
||||
I: [const] SliceIndex<[T]>,
|
||||
{
|
||||
type Output = I::Output;
|
||||
|
||||
|
|
@ -195,7 +195,7 @@ where
|
|||
|
||||
impl<T, I, const N: usize> const Index<I> for [T; N]
|
||||
where
|
||||
[T]: ~const Index<I>,
|
||||
[T]: [const] Index<I>,
|
||||
{
|
||||
type Output = <[T] as Index<I>>::Output;
|
||||
|
||||
|
|
@ -265,7 +265,7 @@ use Option::*;
|
|||
|
||||
const fn as_deref<T>(opt: &Option<T>) -> Option<&T::Target>
|
||||
where
|
||||
T: ~const Deref,
|
||||
T: [const] Deref,
|
||||
{
|
||||
match opt {
|
||||
Option::Some(t) => Option::Some(t.deref()),
|
||||
|
|
@ -285,7 +285,7 @@ pub trait From<T>: Sized {
|
|||
|
||||
impl<T, U> const Into<U> for T
|
||||
where
|
||||
U: ~const From<T>,
|
||||
U: [const] From<T>,
|
||||
{
|
||||
fn into(self) -> U {
|
||||
U::from(self)
|
||||
|
|
@ -323,7 +323,7 @@ pub trait PartialEq<Rhs: PointeeSized = Self>: PointeeSized {
|
|||
|
||||
impl<A: PointeeSized, B: PointeeSized> const PartialEq<&B> for &A
|
||||
where
|
||||
A: ~const PartialEq<B>,
|
||||
A: [const] PartialEq<B>,
|
||||
{
|
||||
fn eq(&self, other: &&B) -> bool {
|
||||
PartialEq::eq(*self, *other)
|
||||
|
|
@ -373,7 +373,7 @@ impl<'a, T: PointeeSized> Pin<&'a T> {
|
|||
impl<P: Deref> Pin<P> {
|
||||
const fn as_ref(&self) -> Pin<&P::Target>
|
||||
where
|
||||
P: ~const Deref,
|
||||
P: [const] Deref,
|
||||
{
|
||||
unsafe { Pin::new_unchecked(&*self.pointer) }
|
||||
}
|
||||
|
|
@ -403,7 +403,7 @@ impl<T> Option<T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<P: ~const Deref> const Deref for Pin<P> {
|
||||
impl<P: [const] Deref> const Deref for Pin<P> {
|
||||
type Target = P::Target;
|
||||
fn deref(&self) -> &P::Target {
|
||||
Pin::get_ref(Pin::as_ref(self))
|
||||
|
|
@ -467,7 +467,7 @@ pub trait Clone: Sized {
|
|||
fn clone(&self) -> Self;
|
||||
fn clone_from(&mut self, source: &Self)
|
||||
where
|
||||
Self: ~const Destruct,
|
||||
Self: [const] Destruct,
|
||||
{
|
||||
*self = source.clone()
|
||||
}
|
||||
|
|
@ -476,7 +476,7 @@ pub trait Clone: Sized {
|
|||
#[lang = "structural_peq"]
|
||||
pub trait StructuralPartialEq {}
|
||||
|
||||
pub const fn drop<T: ~const Destruct>(_: T) {}
|
||||
pub const fn drop<T: [const] Destruct>(_: T) {}
|
||||
|
||||
#[rustc_intrinsic]
|
||||
const fn const_eval_select<ARG: Tuple, F, G, RET>(
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ impl Bar for () {
|
|||
|
||||
const FOO: () = {
|
||||
(const || ().foo())();
|
||||
//~^ ERROR the trait bound `(): ~const Bar` is not satisfied
|
||||
//~^ ERROR the trait bound `(): [const] Bar` is not satisfied
|
||||
// FIXME(const_trait_impl): The constness environment for const closures is wrong.
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error[E0277]: the trait bound `(): ~const Bar` is not satisfied
|
||||
error[E0277]: the trait bound `(): [const] Bar` is not satisfied
|
||||
--> $DIR/call-const-closure.rs:17:18
|
||||
|
|
||||
LL | (const || ().foo())();
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
fn foo();
|
||||
}
|
||||
|
||||
const fn foo<T: ~const Foo>() {
|
||||
const fn foo<T: [const] Foo>() {
|
||||
const { T::foo() }
|
||||
//~^ ERROR the trait bound `T: const Foo` is not satisfied
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ pub const fn add_i32(a: i32, b: i32) -> i32 {
|
|||
|
||||
pub const fn add_u32(a: u32, b: u32) -> u32 {
|
||||
a.plus(b)
|
||||
//~^ ERROR the trait bound `u32: ~const Plus`
|
||||
//~^ ERROR the trait bound `u32: [const] Plus`
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error[E0277]: the trait bound `u32: ~const Plus` is not satisfied
|
||||
error[E0277]: the trait bound `u32: [const] Plus` is not satisfied
|
||||
--> $DIR/call-const-trait-method-fail.rs:26:5
|
||||
|
|
||||
LL | a.plus(b)
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ trait MyPartialEq {
|
|||
fn eq(&self, other: &Self) -> bool;
|
||||
}
|
||||
|
||||
impl<T: ~const PartialEq> const MyPartialEq for T {
|
||||
impl<T: [const] PartialEq> const MyPartialEq for T {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
PartialEq::eq(self, other)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,11 +16,11 @@ impl const PartialEq for S {
|
|||
}
|
||||
}
|
||||
|
||||
const fn equals_self<T: ~const PartialEq>(t: &T) -> bool {
|
||||
const fn equals_self<T: [const] PartialEq>(t: &T) -> bool {
|
||||
*t == *t
|
||||
}
|
||||
|
||||
const fn equals_self_wrapper<T: ~const PartialEq>(t: &T) -> bool {
|
||||
const fn equals_self_wrapper<T: [const] PartialEq>(t: &T) -> bool {
|
||||
equals_self(t)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,16 +14,16 @@ impl const PartialEq for S {
|
|||
}
|
||||
}
|
||||
|
||||
// This duplicate bound should not result in ambiguities. It should be equivalent to a single ~const
|
||||
// bound.
|
||||
const fn equals_self<T: PartialEq + ~const PartialEq>(t: &T) -> bool {
|
||||
// This duplicate bound should not result in ambiguities.
|
||||
// It should be equivalent to a single [const] bound.
|
||||
const fn equals_self<T: PartialEq + [const] PartialEq>(t: &T) -> bool {
|
||||
*t == *t
|
||||
}
|
||||
|
||||
trait A: PartialEq {}
|
||||
impl<T: PartialEq> A for T {}
|
||||
|
||||
const fn equals_self2<T: A + ~const PartialEq>(t: &T) -> bool {
|
||||
const fn equals_self2<T: A + [const] PartialEq>(t: &T) -> bool {
|
||||
*t == *t
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
pub const fn equals_self<T: PartialEq>(t: &T) -> bool {
|
||||
*t == *t
|
||||
//~^ ERROR the trait bound `T: ~const PartialEq` is not satisfied
|
||||
//~^ ERROR the trait bound `T: [const] PartialEq` is not satisfied
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error[E0277]: the trait bound `T: ~const PartialEq` is not satisfied
|
||||
error[E0277]: the trait bound `T: [const] PartialEq` is not satisfied
|
||||
--> $DIR/call-generic-method-fail.rs:5:5
|
||||
|
|
||||
LL | *t == *t
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ impl Foo for S {
|
|||
}
|
||||
}
|
||||
|
||||
const fn equals_self<T: ~const Foo>(t: &T) -> bool {
|
||||
const fn equals_self<T: [const] Foo>(t: &T) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@ LL | pub const EQ: bool = equals_self(&S);
|
|||
note: required by a bound in `equals_self`
|
||||
--> $DIR/call-generic-method-nonconst.rs:17:25
|
||||
|
|
||||
LL | const fn equals_self<T: ~const Foo>(t: &T) -> bool {
|
||||
| ^^^^^^^^^^ required by this bound in `equals_self`
|
||||
LL | const fn equals_self<T: [const] Foo>(t: &T) -> bool {
|
||||
| ^^^^^^^^^^^ required by this bound in `equals_self`
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ impl const PartialEq for S {
|
|||
}
|
||||
}
|
||||
|
||||
const fn equals_self<T: ~const PartialEq>(t: &T) -> bool {
|
||||
const fn equals_self<T: [const] PartialEq>(t: &T) -> bool {
|
||||
*t == *t
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ trait MyTrait {
|
|||
}
|
||||
|
||||
trait OtherTrait {
|
||||
fn do_something_else() where Self: ~const MyTrait;
|
||||
//~^ ERROR `~const` is not allowed here
|
||||
fn do_something_else() where Self: [const] MyTrait;
|
||||
//~^ ERROR `[const]` is not allowed here
|
||||
}
|
||||
|
||||
struct MyStruct<T>(T);
|
||||
|
|
@ -19,8 +19,8 @@ impl const MyTrait for u32 {
|
|||
}
|
||||
|
||||
impl<T> MyStruct<T> {
|
||||
pub fn foo(&self) where T: ~const MyTrait {
|
||||
//~^ ERROR `~const` is not allowed here
|
||||
pub fn foo(&self) where T: [const] MyTrait {
|
||||
//~^ ERROR `[const]` is not allowed here
|
||||
self.0.do_something();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,25 +1,25 @@
|
|||
error: `~const` is not allowed here
|
||||
--> $DIR/const-bound-on-not-const-associated-fn.rs:11:40
|
||||
error: `[const]` is not allowed here
|
||||
--> $DIR/const-bound-on-not-const-associated-fn.rs:11:38
|
||||
|
|
||||
LL | fn do_something_else() where Self: ~const MyTrait;
|
||||
| ^^^^^^
|
||||
LL | fn do_something_else() where Self: [const] MyTrait;
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
note: this function is not `const`, so it cannot have `~const` trait bounds
|
||||
note: this function is not `const`, so it cannot have `[const]` trait bounds
|
||||
--> $DIR/const-bound-on-not-const-associated-fn.rs:11:8
|
||||
|
|
||||
LL | fn do_something_else() where Self: ~const MyTrait;
|
||||
LL | fn do_something_else() where Self: [const] MyTrait;
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: `~const` is not allowed here
|
||||
--> $DIR/const-bound-on-not-const-associated-fn.rs:22:32
|
||||
error: `[const]` is not allowed here
|
||||
--> $DIR/const-bound-on-not-const-associated-fn.rs:22:30
|
||||
|
|
||||
LL | pub fn foo(&self) where T: ~const MyTrait {
|
||||
| ^^^^^^
|
||||
LL | pub fn foo(&self) where T: [const] MyTrait {
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
note: this function is not `const`, so it cannot have `~const` trait bounds
|
||||
note: this function is not `const`, so it cannot have `[const]` trait bounds
|
||||
--> $DIR/const-bound-on-not-const-associated-fn.rs:22:12
|
||||
|
|
||||
LL | pub fn foo(&self) where T: ~const MyTrait {
|
||||
LL | pub fn foo(&self) where T: [const] MyTrait {
|
||||
| ^^^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue