diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs index 11afd359e5ad3..87fe54dc31d46 100644 --- a/compiler/rustc_ast/src/ast.rs +++ b/compiler/rustc_ast/src/ast.rs @@ -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]", } } } diff --git a/compiler/rustc_ast_passes/messages.ftl b/compiler/rustc_ast_passes/messages.ftl index 9a267501230fe..37bb35c97ef7f 100644 --- a/compiler/rustc_ast_passes/messages.ftl +++ b/compiler/rustc_ast_passes/messages.ftl @@ -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 -> diff --git a/compiler/rustc_const_eval/src/check_consts/check.rs b/compiler/rustc_const_eval/src/check_consts/check.rs index 576b174369d46..29274a12f441b 100644 --- a/compiler/rustc_const_eval/src/check_consts/check.rs +++ b/compiler/rustc_const_eval/src/check_consts/check.rs @@ -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) } } diff --git a/compiler/rustc_const_eval/src/check_consts/ops.rs b/compiler/rustc_const_eval/src/check_consts/ops.rs index 887275e7294d2..4295f4a413205 100644 --- a/compiler/rustc_const_eval/src/check_consts/ops.rs +++ b/compiler/rustc_const_eval/src/check_consts/ops.rs @@ -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( diff --git a/compiler/rustc_const_eval/src/check_consts/qualifs.rs b/compiler/rustc_const_eval/src/check_consts/qualifs.rs index c1a37ab6a83f3..166491b47a1fd 100644 --- a/compiler/rustc_const_eval/src/check_consts/qualifs.rs +++ b/compiler/rustc_const_eval/src/check_consts/qualifs.rs @@ -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 diff --git a/compiler/rustc_feature/src/removed.rs b/compiler/rustc_feature/src/removed.rs index 0cd090b25a4f8..df9f85fa7e21b 100644 --- a/compiler/rustc_feature/src/removed.rs +++ b/compiler/rustc_feature/src/removed.rs @@ -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. diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs index 91715851226bb..14d494f8d7aa0 100644 --- a/compiler/rustc_feature/src/unstable.rs +++ b/compiler/rustc_feature/src/unstable.rs @@ -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)), diff --git a/compiler/rustc_hir_analysis/src/check/check.rs b/compiler/rustc_hir_analysis/src/check/check.rs index 485dd1d220441..b2cfd5b9dab8d 100644 --- a/compiler/rustc_hir_analysis/src/check/check.rs +++ b/compiler/rustc_hir_analysis/src/check/check.rs @@ -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) => { diff --git a/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs b/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs index 47681a78ecca8..dab4d7e5db1b0 100644 --- a/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs +++ b/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs @@ -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, diff --git a/compiler/rustc_hir_analysis/src/check/wfcheck.rs b/compiler/rustc_hir_analysis/src/check/wfcheck.rs index d05e381f8c86b..f0b550398b69c 100644 --- a/compiler/rustc_hir_analysis/src/check/wfcheck.rs +++ b/compiler/rustc_hir_analysis/src/check/wfcheck.rs @@ -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) diff --git a/compiler/rustc_hir_analysis/src/collect/item_bounds.rs b/compiler/rustc_hir_analysis/src/collect/item_bounds.rs index 53c44cdc4115d..e51ef46afb72f 100644 --- a/compiler/rustc_hir_analysis/src/collect/item_bounds.rs +++ b/compiler/rustc_hir_analysis/src/collect/item_bounds.rs @@ -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); diff --git a/compiler/rustc_hir_analysis/src/collect/predicates_of.rs b/compiler/rustc_hir_analysis/src/collect/predicates_of.rs index c337765c5fec3..2813d4204a70f 100644 --- a/compiler/rustc_hir_analysis/src/collect/predicates_of.rs +++ b/compiler/rustc_hir_analysis/src/collect/predicates_of.rs @@ -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. diff --git a/compiler/rustc_hir_analysis/src/errors/wrong_number_of_generic_args.rs b/compiler/rustc_hir_analysis/src/errors/wrong_number_of_generic_args.rs index a3c8ce620b366..ef789743e06f7 100644 --- a/compiler/rustc_hir_analysis/src/errors/wrong_number_of_generic_args.rs +++ b/compiler/rustc_hir_analysis/src/errors/wrong_number_of_generic_args.rs @@ -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!(), } diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/bounds.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/bounds.rs index ea1dfdfd80619..7aab8ecc74ee3 100644 --- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/bounds.rs +++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/bounds.rs @@ -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 => {} } } diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs index baf3b9b5bc9e0..74739355e1fcb 100644 --- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs +++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs @@ -80,10 +80,10 @@ pub enum PredicateFilter { /// and `::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 diff --git a/compiler/rustc_hir_analysis/src/impl_wf_check/min_specialization.rs b/compiler/rustc_hir_analysis/src/impl_wf_check/min_specialization.rs index 309221f9a127a..574d19a5aa5a4 100644 --- a/compiler/rustc_hir_analysis/src/impl_wf_check/min_specialization.rs +++ b/compiler/rustc_hir_analysis/src/impl_wf_check/min_specialization.rs @@ -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 Tr for T { } -/// impl const Tr for T { } +/// impl 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 const Tr for T { } -/// impl const Tr for T { } // should be T: ~const Bound +/// impl const Tr for T { } +/// impl 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. diff --git a/compiler/rustc_hir_pretty/src/lib.rs b/compiler/rustc_hir_pretty/src/lib.rs index d3289e4cc6d0f..b295a21381147 100644 --- a/compiler/rustc_hir_pretty/src/lib.rs +++ b/compiler/rustc_hir_pretty/src/lib.rs @@ -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 => {} diff --git a/compiler/rustc_hir_typeck/src/callee.rs b/compiler/rustc_hir_typeck/src/callee.rs index 7a3647df0c405..80d504f0dc690 100644 --- a/compiler/rustc_hir_typeck/src/callee.rs +++ b/compiler/rustc_hir_typeck/src/callee.rs @@ -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; } diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs index 2df19cb21d583..58751f232d032 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs @@ -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. diff --git a/compiler/rustc_middle/src/middle/stability.rs b/compiler/rustc_middle/src/middle/stability.rs index ab6a65ed52634..99faba7b2c0ae 100644 --- a/compiler/rustc_middle/src/middle/stability.rs +++ b/compiler/rustc_middle/src/middle/stability.rs @@ -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(); diff --git a/compiler/rustc_middle/src/query/mod.rs b/compiler/rustc_middle/src/query/mod.rs index 3668f4e12f5d9..3dd8ccbc8550c 100644 --- a/compiler/rustc_middle/src/query/mod.rs +++ b/compiler/rustc_middle/src/query/mod.rs @@ -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 diff --git a/compiler/rustc_middle/src/ty/generics.rs b/compiler/rustc_middle/src/ty/generics.rs index d4cc562e70cc7..c7b3b5415492b 100644 --- a/compiler/rustc_middle/src/ty/generics.rs +++ b/compiler/rustc_middle/src/ty/generics.rs @@ -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`. diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index 97408e31854ae..f7e569654bd48 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -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) diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index c10277c75a79b..1392d1d08fcb5 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -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())) diff --git a/compiler/rustc_next_trait_solver/src/solve/assembly/structural_traits.rs b/compiler/rustc_next_trait_solver/src/solve/assembly/structural_traits.rs index f39d32260093c..a7b8a9ed9a862 100644 --- a/compiler/rustc_next_trait_solver/src/solve/assembly/structural_traits.rs +++ b/compiler/rustc_next_trait_solver/src/solve/assembly/structural_traits.rs @@ -735,11 +735,11 @@ pub(in crate::solve) fn const_conditions_for_destruct( 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( .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( .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( | 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), diff --git a/compiler/rustc_next_trait_solver/src/solve/effect_goals.rs b/compiler/rustc_next_trait_solver/src/solve/effect_goals.rs index 1690c908d123b..0547eb77f8d83 100644 --- a/compiler/rustc_next_trait_solver/src/solve/effect_goals.rs +++ b/compiler/rustc_next_trait_solver/src/solve/effect_goals.rs @@ -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) diff --git a/compiler/rustc_parse/src/parser/ty.rs b/compiler/rustc_parse/src/parser/ty.rs index 620a34044d12e..f181097813dba 100644 --- a/compiler/rustc_parse/src/parser/ty.rs +++ b/compiler/rustc_parse/src/parser/ty.rs @@ -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 = ["?" | "!"] /// ``` @@ -995,18 +996,7 @@ impl<'a> Parser<'a> { /// See `parse_generic_ty_bound` for the complete grammar of trait bound modifiers. fn parse_trait_bound_modifiers(&mut self) -> PResult<'a, TraitBoundModifiers> { let modifier_lo = self.token.span; - let constness = 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.eat_keyword(exp!(Const)) { - self.psess.gated_spans.gate(sym::const_trait_impl, self.prev_token.span); - BoundConstness::Always(self.prev_token.span) - } else { - BoundConstness::Never - }; + let constness = self.parse_bound_constness()?; let asyncness = if self.token_uninterpolated_span().at_least_rust_2018() && self.eat_keyword(exp!(Async)) @@ -1068,13 +1058,41 @@ impl<'a> Parser<'a> { Ok(TraitBoundModifiers { constness, asyncness, polarity }) } + 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) + } else { + BoundConstness::Never + }) + } + /// Parses a type bound according to: /// ```ebnf /// TY_BOUND = TY_BOUND_NOPAREN | (TY_BOUND_NOPAREN) /// TY_BOUND_NOPAREN = [for 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, @@ -1101,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); diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs index 0c88bd3dcbc54..f643e61a98928 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs @@ -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 diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/on_unimplemented.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/on_unimplemented.rs index 89dab90dc681c..a52dbedfe1eb2 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/on_unimplemented.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/on_unimplemented.rs @@ -334,7 +334,7 @@ pub struct OnUnimplementedNote { pub append_const_msg: Option, } -/// 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] diff --git a/compiler/rustc_trait_selection/src/traits/dyn_compatibility.rs b/compiler/rustc_trait_selection/src/traits/dyn_compatibility.rs index bdfe48a3928eb..8d049fedf230d 100644 --- a/compiler/rustc_trait_selection/src/traits/dyn_compatibility.rs +++ b/compiler/rustc_trait_selection/src/traits/dyn_compatibility.rs @@ -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, diff --git a/compiler/rustc_trait_selection/src/traits/effects.rs b/compiler/rustc_trait_selection/src/traits/effects.rs index e77d9e32cb98c..fc95e42d67fc4 100644 --- a/compiler/rustc_trait_selection/src/traits/effects.rs +++ b/compiler/rustc_trait_selection/src/traits/effects.rs @@ -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), diff --git a/compiler/rustc_trait_selection/src/traits/specialize/mod.rs b/compiler/rustc_trait_selection/src/traits/specialize/mod.rs index b30fadd3e5b7d..4bb12694c478a 100644 --- a/compiler/rustc_trait_selection/src/traits/specialize/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/specialize/mod.rs @@ -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")] diff --git a/compiler/rustc_ty_utils/src/ty.rs b/compiler/rustc_ty_utils/src/ty.rs index d996ee2b60aa4..553f5e0e1b5d9 100644 --- a/compiler/rustc_ty_utils/src/ty.rs +++ b/compiler/rustc_ty_utils/src/ty.rs @@ -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( diff --git a/compiler/rustc_type_ir/src/elaborate.rs b/compiler/rustc_type_ir/src/elaborate.rs index 852949d707bff..177bad96595e0 100644 --- a/compiler/rustc_type_ir/src/elaborate.rs +++ b/compiler/rustc_type_ir/src/elaborate.rs @@ -179,7 +179,7 @@ impl> Elaborator { ), }; } - // `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( diff --git a/compiler/rustc_type_ir/src/predicate.rs b/compiler/rustc_type_ir/src/predicate.rs index f02d9c988c8de..4643cd0ab850f 100644 --- a/compiler/rustc_type_ir/src/predicate.rs +++ b/compiler/rustc_type_ir/src/predicate.rs @@ -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]"), } } } diff --git a/compiler/rustc_type_ir/src/solve/mod.rs b/compiler/rustc_type_ir/src/solve/mod.rs index bbbeaa29f84aa..a6571ef261a16 100644 --- a/compiler/rustc_type_ir/src/solve/mod.rs +++ b/compiler/rustc_type_ir/src/solve/mod.rs @@ -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, diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index d77bdf09d010a..3d027db2622df 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -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 { - // `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; diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index 6ab1520386d8e..bcb3e57c84428 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -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 => "", diff --git a/src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs b/src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs index e629012b187cd..328fe3d428b8a 100644 --- a/src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs +++ b/src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs @@ -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; } diff --git a/src/tools/clippy/tests/ui/assign_ops.fixed b/src/tools/clippy/tests/ui/assign_ops.fixed index 3bc6885d7c3e6..99beea850a258 100644 --- a/src/tools/clippy/tests/ui/assign_ops.fixed +++ b/src/tools/clippy/tests/ui/assign_ops.fixed @@ -91,7 +91,7 @@ mod issue14871 { impl 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; diff --git a/src/tools/clippy/tests/ui/assign_ops.rs b/src/tools/clippy/tests/ui/assign_ops.rs index f1f8f9daff95e..900d5ad38e03b 100644 --- a/src/tools/clippy/tests/ui/assign_ops.rs +++ b/src/tools/clippy/tests/ui/assign_ops.rs @@ -91,7 +91,7 @@ mod issue14871 { impl 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; diff --git a/src/tools/clippy/tests/ui/trait_duplication_in_bounds.fixed b/src/tools/clippy/tests/ui/trait_duplication_in_bounds.fixed index 666ff78b21897..cf52ecf2f0326 100644 --- a/src/tools/clippy/tests/ui/trait_duplication_in_bounds.fixed +++ b/src/tools/clippy/tests/ui/trait_duplication_in_bounds.fixed @@ -169,9 +169,9 @@ where // #13476 #[const_trait] trait ConstTrait {} -const fn const_trait_bounds_good() {} +const fn const_trait_bounds_good() {} -const fn const_trait_bounds_bad() {} +const fn const_trait_bounds_bad() {} //~^ trait_duplication_in_bounds fn projections() diff --git a/src/tools/clippy/tests/ui/trait_duplication_in_bounds.rs b/src/tools/clippy/tests/ui/trait_duplication_in_bounds.rs index a1a86fe058e63..955562f08dc32 100644 --- a/src/tools/clippy/tests/ui/trait_duplication_in_bounds.rs +++ b/src/tools/clippy/tests/ui/trait_duplication_in_bounds.rs @@ -169,9 +169,9 @@ where // #13476 #[const_trait] trait ConstTrait {} -const fn const_trait_bounds_good() {} +const fn const_trait_bounds_good() {} -const fn const_trait_bounds_bad() {} +const fn const_trait_bounds_bad() {} //~^ trait_duplication_in_bounds fn projections() diff --git a/src/tools/clippy/tests/ui/trait_duplication_in_bounds.stderr b/src/tools/clippy/tests/ui/trait_duplication_in_bounds.stderr index d76b4e458480f..ab31721ef5157 100644 --- a/src/tools/clippy/tests/ui/trait_duplication_in_bounds.stderr +++ b/src/tools/clippy/tests/ui/trait_duplication_in_bounds.stderr @@ -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() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `~const ConstTrait` +LL | const fn const_trait_bounds_bad() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `[const] ConstTrait` error: these where clauses contain repeated elements --> tests/ui/trait_duplication_in_bounds.rs:181:8 diff --git a/src/tools/rustfmt/tests/source/type.rs b/src/tools/rustfmt/tests/source/type.rs index 7a232f85198a8..213fad7cb16b7 100644 --- a/src/tools/rustfmt/tests/source/type.rs +++ b/src/tools/rustfmt/tests/source/type.rs @@ -142,18 +142,18 @@ type MyFn = fn(a: SomeLongComplexType, b: SomeOtherLongComplexType,) -> Box() -> i32 { ::CONST } +const fn not_quite_const() -> i32 { ::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); -impl Foo { +impl Foo { fn new(t: T) -> Self { Self(t) } diff --git a/src/tools/rustfmt/tests/target/type.rs b/src/tools/rustfmt/tests/target/type.rs index 325adb52f3f99..93479f8b484cb 100644 --- a/src/tools/rustfmt/tests/target/type.rs +++ b/src/tools/rustfmt/tests/target/type.rs @@ -147,22 +147,22 @@ type MyFn = fn( // Const bound -trait T: ~const Super {} +trait T: [const] Super {} -const fn not_quite_const() -> i32 { +const fn not_quite_const() -> i32 { ::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); -impl Foo { +impl Foo { fn new(t: T) -> Self { Self(t) } diff --git a/src/tools/tidy/src/issues.txt b/src/tools/tidy/src/issues.txt index b3517b2e9da08..bad943441b321 100644 --- a/src/tools/tidy/src/issues.txt +++ b/src/tools/tidy/src/issues.txt @@ -3921,7 +3921,6 @@ ui/traits/const-traits/issue-79450.rs ui/traits/const-traits/issue-88155.rs ui/traits/const-traits/issue-92111.rs ui/traits/const-traits/issue-92230-wf-super-trait-env.rs -ui/traits/const-traits/specialization/issue-95186-specialize-on-tilde-const.rs ui/traits/const-traits/specialization/issue-95187-same-trait-bound-different-constness.rs ui/traits/issue-103563.rs ui/traits/issue-104322.rs diff --git a/tests/run-make/const-trait-stable-toolchain/const-super-trait-nightly-disabled.stderr b/tests/run-make/const-trait-stable-toolchain/const-super-trait-nightly-disabled.stderr index 82f57864d859e..be3de58098325 100644 --- a/tests/run-make/const-trait-stable-toolchain/const-super-trait-nightly-disabled.stderr +++ b/tests/run-make/const-trait-stable-toolchain/const-super-trait-nightly-disabled.stderr @@ -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(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(x: &T) { diff --git a/tests/run-make/const-trait-stable-toolchain/const-super-trait-nightly-enabled.stderr b/tests/run-make/const-trait-stable-toolchain/const-super-trait-nightly-enabled.stderr index 8f4c78ccfa4c2..ef764a62b0667 100644 --- a/tests/run-make/const-trait-stable-toolchain/const-super-trait-nightly-enabled.stderr +++ b/tests/run-make/const-trait-stable-toolchain/const-super-trait-nightly-enabled.stderr @@ -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(x: &T) { diff --git a/tests/run-make/const-trait-stable-toolchain/const-super-trait-stable-disabled.stderr b/tests/run-make/const-trait-stable-toolchain/const-super-trait-stable-disabled.stderr index b7cd7097f4447..a23793580f7a8 100644 --- a/tests/run-make/const-trait-stable-toolchain/const-super-trait-stable-disabled.stderr +++ b/tests/run-make/const-trait-stable-toolchain/const-super-trait-stable-disabled.stderr @@ -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 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(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 {} diff --git a/tests/run-make/const-trait-stable-toolchain/const-super-trait-stable-enabled.stderr b/tests/run-make/const-trait-stable-toolchain/const-super-trait-stable-enabled.stderr index 4c59d870671d0..2cdeb277ca4a6 100644 --- a/tests/run-make/const-trait-stable-toolchain/const-super-trait-stable-enabled.stderr +++ b/tests/run-make/const-trait-stable-toolchain/const-super-trait-stable-enabled.stderr @@ -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(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 {} diff --git a/tests/rustdoc/constant/const-effect-param.rs b/tests/rustdoc/constant/const-effect-param.rs index cceb0adac3096..3dc63fb3d30f6 100644 --- a/tests/rustdoc/constant/const-effect-param.rs +++ b/tests/rustdoc/constant/const-effect-param.rs @@ -11,4 +11,4 @@ pub trait Tr { //@ has foo/fn.g.html //@ has - '//pre[@class="rust item-decl"]' 'pub const fn g()' /// foo -pub const fn g() {} +pub const fn g() {} diff --git a/tests/rustdoc/constant/rfc-2632-const-trait-impl.rs b/tests/rustdoc/constant/rfc-2632-const-trait-impl.rs index 8a86e3e5e9782..e304eff14e8cb 100644 --- a/tests/rustdoc/constant/rfc-2632-const-trait-impl.rs +++ b/tests/rustdoc/constant/rfc-2632-const-trait-impl.rs @@ -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); -//@ !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 { - //@ !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() + fn a() where - Option: /* ~const */ Fn() /* + ~const Destruct */, + Option: /* [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 const Tr for T +impl const Tr for T where - Option: /* ~const */ Fn() /* + ~const Destruct */, + Option: /* [const] */ Fn() /* + [const] Destruct */, { - fn a() + fn a() where - Option: /* ~const */ Fn() /* + ~const Destruct */, + Option: /* [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() +pub const fn foo() where - Option: /* ~const */ Fn() /* + ~const Destruct */, + Option: /* [const] */ Fn() /* + [const] Destruct */, { F::a() } impl S { - //@ !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() + pub const fn foo() where - B: /* ~const */ Fn() /* + ~const Destruct */, + B: /* [const] */ Fn() /* + [const] Destruct */, { B::a() } diff --git a/tests/rustdoc/inline_cross/auxiliary/const-effect-param.rs b/tests/rustdoc/inline_cross/auxiliary/const-effect-param.rs index db198e0fce993..d7d7b32e2b8b7 100644 --- a/tests/rustdoc/inline_cross/auxiliary/const-effect-param.rs +++ b/tests/rustdoc/inline_cross/auxiliary/const-effect-param.rs @@ -4,7 +4,7 @@ #[const_trait] pub trait Resource {} -pub const fn load() -> i32 { +pub const fn load() -> i32 { 0 } diff --git a/tests/ui/const-generics/const_trait_fn-issue-88433.rs b/tests/ui/const-generics/const_trait_fn-issue-88433.rs index bc91fc1700eaf..2f92a528bf728 100644 --- a/tests/ui/const-generics/const_trait_fn-issue-88433.rs +++ b/tests/ui/const-generics/const_trait_fn-issue-88433.rs @@ -10,7 +10,6 @@ trait Func { 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 { +enum Bug { V(T), } diff --git a/tests/ui/const-generics/issues/issue-88119.stderr b/tests/ui/const-generics/issues/issue-88119.stderr index 94f06bbbbc45a..0aabf48011dcd 100644 --- a/tests/ui/const-generics/issues/issue-88119.stderr +++ b/tests/ui/const-generics/issues/issue-88119.stderr @@ -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 const ConstName for &T @@ -42,7 +42,7 @@ note: required by a bound in `<&T as ConstName>` LL | [(); name_len::()]:, | ^^^^^^^^^^^^^^^^^^^^^ 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 const ConstName for &mut T diff --git a/tests/ui/consts/const-block-const-bound.rs b/tests/ui/consts/const-block-const-bound.rs index b4b89a93e759f..1847c880a3915 100644 --- a/tests/ui/consts/const-block-const-bound.rs +++ b/tests/ui/consts/const-block-const-bound.rs @@ -3,7 +3,7 @@ use std::marker::Destruct; -const fn f(x: T) {} +const fn f(x: T) {} struct UnconstDrop; diff --git a/tests/ui/consts/const-block-const-bound.stderr b/tests/ui/consts/const-block-const-bound.stderr index 624772f5aedc6..b6c8027918ff0 100644 --- a/tests/ui/consts/const-block-const-bound.stderr +++ b/tests/ui/consts/const-block-const-bound.stderr @@ -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(x: T) {} - | ^^^^^^^^^^^^^^^ required by this bound in `f` +LL | const fn f(x: T) {} + | ^^^^^^^^^^^^^^^^ required by this bound in `f` error: aborting due to 1 previous error diff --git a/tests/ui/consts/constifconst-call-in-const-position.rs b/tests/ui/consts/constifconst-call-in-const-position.rs index 80e47c2230f22..da29030dbc746 100644 --- a/tests/ui/consts/constifconst-call-in-const-position.rs +++ b/tests/ui/consts/constifconst-call-in-const-position.rs @@ -14,7 +14,7 @@ impl Tr for () { } } -const fn foo() -> [u8; T::a()] { +const fn foo() -> [u8; T::a()] { [0; T::a()] } diff --git a/tests/ui/consts/constifconst-call-in-const-position.stderr b/tests/ui/consts/constifconst-call-in-const-position.stderr index c778299560fab..e84e686251a5b 100644 --- a/tests/ui/consts/constifconst-call-in-const-position.stderr +++ b/tests/ui/consts/constifconst-call-in-const-position.stderr @@ -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() -> [u8; T::a()] { - | ^ +LL | const fn foo() -> [u8; T::a()] { + | ^ error[E0277]: the trait bound `T: const Tr` is not satisfied --> $DIR/constifconst-call-in-const-position.rs:18:9 diff --git a/tests/ui/consts/fn_trait_refs.rs b/tests/ui/consts/fn_trait_refs.rs index af233efd738a2..e475c0a1b6fd1 100644 --- a/tests/ui/consts/fn_trait_refs.rs +++ b/tests/ui/consts/fn_trait_refs.rs @@ -11,47 +11,47 @@ use std::marker::Destruct; const fn tester_fn(f: T) -> T::Output where - T: ~const Fn<()> + ~const Destruct, + T: [const] Fn<()> + [const] Destruct, { f() } const fn tester_fn_mut(mut f: T) -> T::Output where - T: ~const FnMut<()> + ~const Destruct, + T: [const] FnMut<()> + [const] Destruct, { f() } const fn tester_fn_once(f: T) -> T::Output where - T: ~const FnOnce<()>, + T: [const] FnOnce<()>, { f() } const fn test_fn(mut f: T) -> (T::Output, T::Output, T::Output) where - T: ~const Fn<()> + ~const Destruct, + T: [const] Fn<()> + [const] Destruct, { ( - // impl const Fn for &F + // impl const Fn for &F tester_fn(&f), - // impl const FnMut for &F + // impl const FnMut for &F tester_fn_mut(&f), - // impl const FnOnce for &F + // impl const FnOnce for &F tester_fn_once(&f), ) } const fn test_fn_mut(mut f: T) -> (T::Output, T::Output) where - T: ~const FnMut<()> + ~const Destruct, + T: [const] FnMut<()> + [const] Destruct, { ( - // impl const FnMut for &mut F + // impl const FnMut for &mut F tester_fn_mut(&mut f), - // impl const FnOnce for &mut F + // impl const FnOnce for &mut F tester_fn_once(&mut f), ) } diff --git a/tests/ui/consts/fn_trait_refs.stderr b/tests/ui/consts/fn_trait_refs.stderr index 7dc0804988963..ee716c932e832 100644 --- a/tests/ui/consts/fn_trait_refs.stderr +++ b/tests/ui/consts/fn_trait_refs.stderr @@ -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` diff --git a/tests/ui/consts/issue-73976-monomorphic.stderr b/tests/ui/consts/issue-73976-monomorphic.stderr index e5b32e0c4adff..367d5be09da4e 100644 --- a/tests/ui/consts/issue-73976-monomorphic.stderr +++ b/tests/ui/consts/issue-73976-monomorphic.stderr @@ -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::::VALUE == GetTypeId::::VALUE diff --git a/tests/ui/consts/unstable-const-fn-in-libcore.rs b/tests/ui/consts/unstable-const-fn-in-libcore.rs index baeece40a52bb..f4b4c687bd2ea 100644 --- a/tests/ui/consts/unstable-const-fn-in-libcore.rs +++ b/tests/ui/consts/unstable-const-fn-in-libcore.rs @@ -16,7 +16,7 @@ enum Opt { impl Opt { #[rustc_const_unstable(feature = "foo", issue = "none")] #[stable(feature = "rust1", since = "1.0.0")] - const fn unwrap_or_else T>(self, f: F) -> T { + const fn unwrap_or_else T>(self, f: F) -> T { //FIXME ~^ ERROR destructor of //FIXME ~| ERROR destructor of match self { diff --git a/tests/ui/consts/unstable-const-fn-in-libcore.stderr b/tests/ui/consts/unstable-const-fn-in-libcore.stderr index 32693edbfcbda..b43fa1f7e6c35 100644 --- a/tests/ui/consts/unstable-const-fn-in-libcore.stderr +++ b/tests/ui/consts/unstable-const-fn-in-libcore.stderr @@ -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 T>(self, f: F) -> T { - | ^^^^^^ can't be applied to `FnOnce` +LL | const fn unwrap_or_else 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 T>(self, f: F) -> T { - | ^^^^^^ can't be applied to `FnOnce` +LL | const fn unwrap_or_else 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 T>(self, f: F) -> T { - | ^ the destructor for this type cannot be evaluated in constant functions +LL | const fn unwrap_or_else 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` 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 T>(self, f: F) -> T { - | ^^^^ the destructor for this type cannot be evaluated in constant functions +LL | const fn unwrap_or_else T>(self, f: F) -> T { + | ^^^^ the destructor for this type cannot be evaluated in constant functions ... LL | } | - value is dropped here diff --git a/tests/ui/impl-trait/normalize-tait-in-const.rs b/tests/ui/impl-trait/normalize-tait-in-const.rs index a735ef766737b..0c7969c0e9ed8 100644 --- a/tests/ui/impl-trait/normalize-tait-in-const.rs +++ b/tests/ui/impl-trait/normalize-tait-in-const.rs @@ -24,7 +24,7 @@ mod foo { } use foo::*; -const fn with_positive ~const Fn(&'a Alias<'a>) + ~const Destruct>(fun: F) { +const fn with_positive [const] Fn(&'a Alias<'a>) + [const] Destruct>(fun: F) { fun(filter_positive()); } diff --git a/tests/ui/impl-trait/normalize-tait-in-const.stderr b/tests/ui/impl-trait/normalize-tait-in-const.stderr index 2b6825b1ac672..01427c78dd982 100644 --- a/tests/ui/impl-trait/normalize-tait-in-const.stderr +++ b/tests/ui/impl-trait/normalize-tait-in-const.stderr @@ -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 ~const Fn(&'a Alias<'a>) + ~const Destruct>(fun: F) { - | ^^^^^^ can't be applied to `Fn` +LL | const fn with_positive [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 ~const Fn(&'a Alias<'a>) + ~const Destruct>(fun: F) { - | ^^^^^^ can't be applied to `Fn` +LL | const fn with_positive [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` diff --git a/tests/ui/macros/stringify.rs b/tests/ui/macros/stringify.rs index 3f3d9252adbe8..c858051a7ebfa 100644 --- a/tests/ui/macros/stringify.rs +++ b/tests/ui/macros/stringify.rs @@ -483,7 +483,6 @@ fn test_item() { c1!(item, [ impl Struct {} ], "impl Struct {}"); c1!(item, [ pub impl Trait for Struct {} ], "pub impl Trait for Struct {}"); c1!(item, [ impl const Trait for T {} ], "impl 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 diff --git a/tests/ui/parser/bounds-type.rs b/tests/ui/parser/bounds-type.rs index ec0e83c314e1d..1bd67bbba6b0a 100644 --- a/tests/ui/parser/bounds-type.rs +++ b/tests/ui/parser/bounds-type.rs @@ -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 diff --git a/tests/ui/parser/bounds-type.stderr b/tests/ui/parser/bounds-type.stderr index 09c35c12b000a..0d929c76f0276 100644 --- a/tests/ui/parser/bounds-type.stderr +++ b/tests/ui/parser/bounds-type.stderr @@ -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 diff --git a/tests/ui/parser/trait-object-delimiters.rs b/tests/ui/parser/trait-object-delimiters.rs index 8f6221c1b9434..1cbd2ff1bdfb6 100644 --- a/tests/ui/parser/trait-object-delimiters.rs +++ b/tests/ui/parser/trait-object-delimiters.rs @@ -8,7 +8,7 @@ fn foo2(_: &dyn (Drop + AsRef)) {} //~ ERROR incorrect parentheses around t fn foo2_no_space(_: &dyn(Drop + AsRef)) {} //~ ERROR incorrect parentheses around trait bounds fn foo3(_: &dyn {Drop + AsRef}) {} //~ 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 >) {} //~ ERROR expected identifier, found `<` diff --git a/tests/ui/parser/trait-object-delimiters.stderr b/tests/ui/parser/trait-object-delimiters.stderr index be130ac7ab231..16d5392eec84a 100644 --- a/tests/ui/parser/trait-object-delimiters.stderr +++ b/tests/ui/parser/trait-object-delimiters.stderr @@ -39,11 +39,11 @@ error: expected parameter name, found `{` LL | fn foo3(_: &dyn {Drop + AsRef}) {} | ^ 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}) {} - | -^ expected one of 13 possible tokens + | -^ expected one of 14 possible tokens | | | help: missing `,` diff --git a/tests/ui/specialization/const_trait_impl.rs b/tests/ui/specialization/const_trait_impl.rs index d842601a6b7b9..2df92dfad3be5 100644 --- a/tests/ui/specialization/const_trait_impl.rs +++ b/tests/ui/specialization/const_trait_impl.rs @@ -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 const A for T { +impl const A for T { default fn a() -> u32 { 2 } } -impl const A for T { +impl const A for T { default fn a() -> u32 { 3 } } -impl const A for T { +impl const A for T { fn a() -> u32 { T::foo() } diff --git a/tests/ui/specialization/const_trait_impl.stderr b/tests/ui/specialization/const_trait_impl.stderr index 3e1260ff09c92..d36a0a1c2dc8f 100644 --- a/tests/ui/specialization/const_trait_impl.stderr +++ b/tests/ui/specialization/const_trait_impl.stderr @@ -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 const A for T { - | ^^^^^^ can't be applied to `Default` +LL | impl 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 const A for T { - | ^^^^^^ can't be applied to `Default` +LL | impl 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 const A for T { - | ^^^^^^ can't be applied to `Default` +LL | impl 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 const A for T { - | ^^^^^^ can't be applied to `Default` +LL | impl 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 const A for T { - | ^^^^^^ can't be applied to `Default` +LL | impl 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 const A for T { - | ^^^^^^ can't be applied to `Default` +LL | impl 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` diff --git a/tests/ui/traits/const-traits/assoc-type-const-bound-usage-0.rs b/tests/ui/traits/const-traits/assoc-type-const-bound-usage-0.rs index 9141d327aee87..ff1ce949f097d 100644 --- a/tests/ui/traits/const-traits/assoc-type-const-bound-usage-0.rs +++ b/tests/ui/traits/const-traits/assoc-type-const-bound-usage-0.rs @@ -6,15 +6,15 @@ #[const_trait] trait Trait { - type Assoc: ~const Trait; + type Assoc: [const] Trait; fn func() -> i32; } -const fn unqualified() -> i32 { +const fn unqualified() -> i32 { T::Assoc::func() } -const fn qualified() -> i32 { +const fn qualified() -> i32 { ::Assoc::func() } diff --git a/tests/ui/traits/const-traits/assoc-type-const-bound-usage-1.rs b/tests/ui/traits/const-traits/assoc-type-const-bound-usage-1.rs index 19e86b50d3321..5773f2281c390 100644 --- a/tests/ui/traits/const-traits/assoc-type-const-bound-usage-1.rs +++ b/tests/ui/traits/const-traits/assoc-type-const-bound-usage-1.rs @@ -5,7 +5,7 @@ #[const_trait] trait Trait { - type Assoc: ~const Trait; + type Assoc: [const] Trait; fn func() -> i32; } diff --git a/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail-2.current.stderr b/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail-2.current.stderr index 4cd87002e4910..a0474e65efeba 100644 --- a/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail-2.current.stderr +++ b/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail-2.current.stderr @@ -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::::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 | ::Assoc::::func(); diff --git a/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail-2.next.stderr b/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail-2.next.stderr index 4cd87002e4910..a0474e65efeba 100644 --- a/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail-2.next.stderr +++ b/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail-2.next.stderr @@ -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::::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 | ::Assoc::::func(); diff --git a/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail-2.rs b/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail-2.rs index e1c30b5361124..5338c27bedca5 100644 --- a/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail-2.rs +++ b/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail-2.rs @@ -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: ~const Trait + type Assoc: [const] Trait where - U: ~const Other; + U: [const] Other; fn func(); } @@ -20,14 +20,14 @@ trait Trait { #[const_trait] trait Other {} -const fn fails() { +const fn fails() { T::Assoc::::func(); - //~^ ERROR the trait bound `U: ~const Other` is not satisfied + //~^ ERROR the trait bound `U: [const] Other` is not satisfied ::Assoc::::func(); - //~^ ERROR the trait bound `U: ~const Other` is not satisfied + //~^ ERROR the trait bound `U: [const] Other` is not satisfied } -const fn works() { +const fn works() { T::Assoc::::func(); ::Assoc::::func(); } diff --git a/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail.current.stderr b/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail.current.stderr index 9c29a894749e9..20b01d06e8d5e 100644 --- a/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail.current.stderr +++ b/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail.current.stderr @@ -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 | ::Assoc::func(); diff --git a/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail.next.stderr b/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail.next.stderr index 9c29a894749e9..20b01d06e8d5e 100644 --- a/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail.next.stderr +++ b/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail.next.stderr @@ -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 | ::Assoc::func(); diff --git a/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail.rs b/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail.rs index 3761fea19684d..4940b3a1aa6ce 100644 --- a/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail.rs +++ b/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail.rs @@ -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::Assoc::func(); - //~^ ERROR the trait bound `T: ~const Trait` is not satisfied + //~^ ERROR the trait bound `T: [const] Trait` is not satisfied ::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() { +const fn works() { T::Assoc::func(); ::Assoc::func(); } diff --git a/tests/ui/traits/const-traits/assoc-type.current.stderr b/tests/ui/traits/const-traits/assoc-type.current.stderr index 7526369194b4e..1e58efeedeea1 100644 --- a/tests/ui/traits/const-traits/assoc-type.current.stderr +++ b/tests/ui/traits/const-traits/assoc-type.current.stderr @@ -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 diff --git a/tests/ui/traits/const-traits/assoc-type.next.stderr b/tests/ui/traits/const-traits/assoc-type.next.stderr index 7526369194b4e..1e58efeedeea1 100644 --- a/tests/ui/traits/const-traits/assoc-type.next.stderr +++ b/tests/ui/traits/const-traits/assoc-type.next.stderr @@ -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 diff --git a/tests/ui/traits/const-traits/assoc-type.rs b/tests/ui/traits/const-traits/assoc-type.rs index a169b61994cbf..1faef1b0a3251 100644 --- a/tests/ui/traits/const-traits/assoc-type.rs +++ b/tests/ui/traits/const-traits/assoc-type.rs @@ -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] diff --git a/tests/ui/traits/const-traits/auxiliary/minicore.rs b/tests/ui/traits/const-traits/auxiliary/minicore.rs index 073337b2ac6db..d2133bbbcaea4 100644 --- a/tests/ui/traits/const-traits/auxiliary/minicore.rs +++ b/tests/ui/traits/const-traits/auxiliary/minicore.rs @@ -86,14 +86,14 @@ enum ControlFlow { #[const_trait] #[lang = "fn"] #[rustc_paren_sugar] -pub trait Fn: ~const FnMut { +pub trait Fn: [const] FnMut { extern "rust-call" fn call(&self, args: Args) -> Self::Output; } #[const_trait] #[lang = "fn_mut"] #[rustc_paren_sugar] -pub trait FnMut: ~const FnOnce { +pub trait FnMut: [const] FnOnce { extern "rust-call" fn call_mut(&mut self, args: Args) -> Self::Output; } @@ -142,7 +142,7 @@ pub trait Drop { #[const_trait] pub trait Residual { - type TryType: ~const Try + Try; + type TryType: [const] Try + Try; } const fn size_of() -> usize { @@ -183,7 +183,7 @@ pub unsafe trait SliceIndex { impl const Index for [T] where - I: ~const SliceIndex<[T]>, + I: [const] SliceIndex<[T]>, { type Output = I::Output; @@ -195,7 +195,7 @@ where impl const Index for [T; N] where - [T]: ~const Index, + [T]: [const] Index, { type Output = <[T] as Index>::Output; @@ -265,7 +265,7 @@ use Option::*; const fn as_deref(opt: &Option) -> 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: Sized { impl const Into for T where - U: ~const From, + U: [const] From, { fn into(self) -> U { U::from(self) @@ -323,7 +323,7 @@ pub trait PartialEq: PointeeSized { impl const PartialEq<&B> for &A where - A: ~const PartialEq, + A: [const] PartialEq, { fn eq(&self, other: &&B) -> bool { PartialEq::eq(*self, *other) @@ -373,7 +373,7 @@ impl<'a, T: PointeeSized> Pin<&'a T> { impl Pin

{ 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 Option { } } -impl const Deref for Pin

{ +impl const Deref for Pin

{ 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) {} +pub const fn drop(_: T) {} #[rustc_intrinsic] const fn const_eval_select( diff --git a/tests/ui/traits/const-traits/call-const-closure.rs b/tests/ui/traits/const-traits/call-const-closure.rs index 21f4374b8d530..70dfaf724c9bd 100644 --- a/tests/ui/traits/const-traits/call-const-closure.rs +++ b/tests/ui/traits/const-traits/call-const-closure.rs @@ -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. }; diff --git a/tests/ui/traits/const-traits/call-const-closure.stderr b/tests/ui/traits/const-traits/call-const-closure.stderr index fe7c115aaab44..4bb8b2e9777e6 100644 --- a/tests/ui/traits/const-traits/call-const-closure.stderr +++ b/tests/ui/traits/const-traits/call-const-closure.stderr @@ -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())(); diff --git a/tests/ui/traits/const-traits/call-const-in-tilde-const.rs b/tests/ui/traits/const-traits/call-const-in-conditionally-const.rs similarity index 86% rename from tests/ui/traits/const-traits/call-const-in-tilde-const.rs rename to tests/ui/traits/const-traits/call-const-in-conditionally-const.rs index b6d1517499d6e..4e8c2cd171e6c 100644 --- a/tests/ui/traits/const-traits/call-const-in-tilde-const.rs +++ b/tests/ui/traits/const-traits/call-const-in-conditionally-const.rs @@ -5,7 +5,7 @@ fn foo(); } -const fn foo() { +const fn foo() { const { T::foo() } //~^ ERROR the trait bound `T: const Foo` is not satisfied } diff --git a/tests/ui/traits/const-traits/call-const-in-tilde-const.stderr b/tests/ui/traits/const-traits/call-const-in-conditionally-const.stderr similarity index 80% rename from tests/ui/traits/const-traits/call-const-in-tilde-const.stderr rename to tests/ui/traits/const-traits/call-const-in-conditionally-const.stderr index b9dabceb5de47..f14b640ca315a 100644 --- a/tests/ui/traits/const-traits/call-const-in-tilde-const.stderr +++ b/tests/ui/traits/const-traits/call-const-in-conditionally-const.stderr @@ -1,5 +1,5 @@ error[E0277]: the trait bound `T: const Foo` is not satisfied - --> $DIR/call-const-in-tilde-const.rs:9:13 + --> $DIR/call-const-in-conditionally-const.rs:9:13 | LL | const { T::foo() } | ^ diff --git a/tests/ui/traits/const-traits/call-const-trait-method-fail.rs b/tests/ui/traits/const-traits/call-const-trait-method-fail.rs index e06d04db80409..c03d3e950b0b4 100644 --- a/tests/ui/traits/const-traits/call-const-trait-method-fail.rs +++ b/tests/ui/traits/const-traits/call-const-trait-method-fail.rs @@ -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() {} diff --git a/tests/ui/traits/const-traits/call-const-trait-method-fail.stderr b/tests/ui/traits/const-traits/call-const-trait-method-fail.stderr index 64850335c2ab6..4aaf53344c90a 100644 --- a/tests/ui/traits/const-traits/call-const-trait-method-fail.stderr +++ b/tests/ui/traits/const-traits/call-const-trait-method-fail.stderr @@ -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) diff --git a/tests/ui/traits/const-traits/call-generic-in-impl.rs b/tests/ui/traits/const-traits/call-generic-in-impl.rs index b63458b39e95d..f38590fa3c012 100644 --- a/tests/ui/traits/const-traits/call-generic-in-impl.rs +++ b/tests/ui/traits/const-traits/call-generic-in-impl.rs @@ -6,7 +6,7 @@ trait MyPartialEq { fn eq(&self, other: &Self) -> bool; } -impl const MyPartialEq for T { +impl const MyPartialEq for T { fn eq(&self, other: &Self) -> bool { PartialEq::eq(self, other) } diff --git a/tests/ui/traits/const-traits/call-generic-method-chain.rs b/tests/ui/traits/const-traits/call-generic-method-chain.rs index b515c0e711da4..1ad71c424a3bd 100644 --- a/tests/ui/traits/const-traits/call-generic-method-chain.rs +++ b/tests/ui/traits/const-traits/call-generic-method-chain.rs @@ -16,11 +16,11 @@ impl const PartialEq for S { } } -const fn equals_self(t: &T) -> bool { +const fn equals_self(t: &T) -> bool { *t == *t } -const fn equals_self_wrapper(t: &T) -> bool { +const fn equals_self_wrapper(t: &T) -> bool { equals_self(t) } diff --git a/tests/ui/traits/const-traits/call-generic-method-dup-bound.rs b/tests/ui/traits/const-traits/call-generic-method-dup-bound.rs index fdc439845ace7..58f293b5ac5cd 100644 --- a/tests/ui/traits/const-traits/call-generic-method-dup-bound.rs +++ b/tests/ui/traits/const-traits/call-generic-method-dup-bound.rs @@ -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: &T) -> bool { +// This duplicate bound should not result in ambiguities. +// It should be equivalent to a single [const] bound. +const fn equals_self(t: &T) -> bool { *t == *t } trait A: PartialEq {} impl A for T {} -const fn equals_self2(t: &T) -> bool { +const fn equals_self2(t: &T) -> bool { *t == *t } diff --git a/tests/ui/traits/const-traits/call-generic-method-fail.rs b/tests/ui/traits/const-traits/call-generic-method-fail.rs index 3ab5cc58ce3ca..4528f3b122f97 100644 --- a/tests/ui/traits/const-traits/call-generic-method-fail.rs +++ b/tests/ui/traits/const-traits/call-generic-method-fail.rs @@ -3,7 +3,7 @@ pub const fn equals_self(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() {} diff --git a/tests/ui/traits/const-traits/call-generic-method-fail.stderr b/tests/ui/traits/const-traits/call-generic-method-fail.stderr index 9facf80ee8761..a2fba141f7b89 100644 --- a/tests/ui/traits/const-traits/call-generic-method-fail.stderr +++ b/tests/ui/traits/const-traits/call-generic-method-fail.stderr @@ -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 diff --git a/tests/ui/traits/const-traits/call-generic-method-nonconst.rs b/tests/ui/traits/const-traits/call-generic-method-nonconst.rs index 446a74eb7b7d4..0efc8a954dedb 100644 --- a/tests/ui/traits/const-traits/call-generic-method-nonconst.rs +++ b/tests/ui/traits/const-traits/call-generic-method-nonconst.rs @@ -14,7 +14,7 @@ impl Foo for S { } } -const fn equals_self(t: &T) -> bool { +const fn equals_self(t: &T) -> bool { true } diff --git a/tests/ui/traits/const-traits/call-generic-method-nonconst.stderr b/tests/ui/traits/const-traits/call-generic-method-nonconst.stderr index 11bbe8bbb408b..9c1e0fee9e711 100644 --- a/tests/ui/traits/const-traits/call-generic-method-nonconst.stderr +++ b/tests/ui/traits/const-traits/call-generic-method-nonconst.stderr @@ -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: &T) -> bool { - | ^^^^^^^^^^ required by this bound in `equals_self` +LL | const fn equals_self(t: &T) -> bool { + | ^^^^^^^^^^^ required by this bound in `equals_self` error: aborting due to 1 previous error diff --git a/tests/ui/traits/const-traits/call-generic-method-pass.rs b/tests/ui/traits/const-traits/call-generic-method-pass.rs index bc671c897f075..aa52a7b9e473e 100644 --- a/tests/ui/traits/const-traits/call-generic-method-pass.rs +++ b/tests/ui/traits/const-traits/call-generic-method-pass.rs @@ -16,7 +16,7 @@ impl const PartialEq for S { } } -const fn equals_self(t: &T) -> bool { +const fn equals_self(t: &T) -> bool { *t == *t } diff --git a/tests/ui/traits/const-traits/tilde-const-and-const-params.rs b/tests/ui/traits/const-traits/conditionally-const-and-const-params.rs similarity index 71% rename from tests/ui/traits/const-traits/tilde-const-and-const-params.rs rename to tests/ui/traits/const-traits/conditionally-const-and-const-params.rs index 428223d92c01e..29553884b21c2 100644 --- a/tests/ui/traits/const-traits/tilde-const-and-const-params.rs +++ b/tests/ui/traits/const-traits/conditionally-const-and-const-params.rs @@ -5,8 +5,8 @@ struct Foo; impl Foo { - fn add(self) -> Foo<{ A::add(N) }> { - //~^ ERROR `~const` is not allowed here + fn add(self) -> Foo<{ A::add(N) }> { + //~^ ERROR `[const]` is not allowed here //~| ERROR the trait bound `A: const Add42` is not satisfied Foo } @@ -23,8 +23,8 @@ impl const Add42 for () { } } -fn bar(_: Foo) -> Foo<{ A::add(N) }> { - //~^ ERROR `~const` is not allowed here +fn bar(_: Foo) -> Foo<{ A::add(N) }> { + //~^ ERROR `[const]` is not allowed here //~| ERROR the trait bound `A: const Add42` is not satisfied Foo } diff --git a/tests/ui/traits/const-traits/conditionally-const-and-const-params.stderr b/tests/ui/traits/const-traits/conditionally-const-and-const-params.stderr new file mode 100644 index 0000000000000..f450bc6c9ab6f --- /dev/null +++ b/tests/ui/traits/const-traits/conditionally-const-and-const-params.stderr @@ -0,0 +1,39 @@ +error: `[const]` is not allowed here + --> $DIR/conditionally-const-and-const-params.rs:8:13 + | +LL | fn add(self) -> Foo<{ A::add(N) }> { + | ^^^^^^^^^ + | +note: this function is not `const`, so it cannot have `[const]` trait bounds + --> $DIR/conditionally-const-and-const-params.rs:8:8 + | +LL | fn add(self) -> Foo<{ A::add(N) }> { + | ^^^ + +error: `[const]` is not allowed here + --> $DIR/conditionally-const-and-const-params.rs:26:9 + | +LL | fn bar(_: Foo) -> Foo<{ A::add(N) }> { + | ^^^^^^^^^ + | +note: this function is not `const`, so it cannot have `[const]` trait bounds + --> $DIR/conditionally-const-and-const-params.rs:26:4 + | +LL | fn bar(_: Foo) -> Foo<{ A::add(N) }> { + | ^^^ + +error[E0277]: the trait bound `A: const Add42` is not satisfied + --> $DIR/conditionally-const-and-const-params.rs:26:62 + | +LL | fn bar(_: Foo) -> Foo<{ A::add(N) }> { + | ^ + +error[E0277]: the trait bound `A: const Add42` is not satisfied + --> $DIR/conditionally-const-and-const-params.rs:8:45 + | +LL | fn add(self) -> Foo<{ A::add(N) }> { + | ^ + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/const-traits/tilde-const-assoc-fn-in-trait-impl.rs b/tests/ui/traits/const-traits/conditionally-const-assoc-fn-in-trait-impl.rs similarity index 83% rename from tests/ui/traits/const-traits/tilde-const-assoc-fn-in-trait-impl.rs rename to tests/ui/traits/const-traits/conditionally-const-assoc-fn-in-trait-impl.rs index 73b2bdc4e3f86..7f01c0b7a5c96 100644 --- a/tests/ui/traits/const-traits/tilde-const-assoc-fn-in-trait-impl.rs +++ b/tests/ui/traits/const-traits/conditionally-const-assoc-fn-in-trait-impl.rs @@ -5,11 +5,11 @@ #[const_trait] trait Main { - fn compute() -> u32; + fn compute() -> u32; } impl const Main for () { - fn compute() -> u32 { + fn compute() -> u32 { T::generate() } } diff --git a/tests/ui/traits/const-traits/tilde-const-in-struct-args.rs b/tests/ui/traits/const-traits/conditionally-const-in-struct-args.rs similarity index 84% rename from tests/ui/traits/const-traits/tilde-const-in-struct-args.rs rename to tests/ui/traits/const-traits/conditionally-const-in-struct-args.rs index e7ec3d31eb91f..0c644694585a6 100644 --- a/tests/ui/traits/const-traits/tilde-const-in-struct-args.rs +++ b/tests/ui/traits/const-traits/conditionally-const-in-struct-args.rs @@ -11,7 +11,7 @@ trait Trait {} const fn f< T: Trait< { - struct I>(U); + struct I>(U); 0 }, >, diff --git a/tests/ui/traits/const-traits/tilde-const-inherent-assoc-const-fn.rs b/tests/ui/traits/const-traits/conditionally-const-inherent-assoc-const-fn.rs similarity index 81% rename from tests/ui/traits/const-traits/tilde-const-inherent-assoc-const-fn.rs rename to tests/ui/traits/const-traits/conditionally-const-inherent-assoc-const-fn.rs index 0e010695587f4..56478a6674b0e 100644 --- a/tests/ui/traits/const-traits/tilde-const-inherent-assoc-const-fn.rs +++ b/tests/ui/traits/const-traits/conditionally-const-inherent-assoc-const-fn.rs @@ -10,7 +10,7 @@ trait Foo { struct Bar(T); impl Bar { - const fn foo(&self) where T: ~const Foo { + const fn foo(&self) where T: [const] Foo { self.0.foo() } } diff --git a/tests/ui/traits/const-traits/conditionally-const-invalid-places.rs b/tests/ui/traits/const-traits/conditionally-const-invalid-places.rs new file mode 100644 index 0000000000000..52627004fb246 --- /dev/null +++ b/tests/ui/traits/const-traits/conditionally-const-invalid-places.rs @@ -0,0 +1,61 @@ +#![feature(const_trait_impl)] + +#[const_trait] +trait Trait {} + +// Regression test for issue #90052. +fn non_const_function() {} //~ ERROR `[const]` is not allowed + +struct Struct { field: T } //~ ERROR `[const]` is not allowed here +struct TupleStruct(T); //~ ERROR `[const]` is not allowed here +struct UnitStruct; //~ ERROR `[const]` is not allowed here +//~^ ERROR parameter `T` is never used + +enum Enum { Variant(T) } //~ ERROR `[const]` is not allowed here + +union Union { field: T } //~ ERROR `[const]` is not allowed here +//~^ ERROR field must implement `Copy` + +type Type = T; //~ ERROR `[const]` is not allowed here + +const CONSTANT: () = (); //~ ERROR `[const]` is not allowed here +//~^ ERROR generic const items are experimental + +trait NonConstTrait { + type Type: [const] Trait; + //~^ ERROR `[const]` is not allowed + //~| ERROR `[const]` is not allowed + fn non_const_function(); //~ ERROR `[const]` is not allowed + const CONSTANT: (); //~ ERROR `[const]` is not allowed + //~^ ERROR generic const items are experimental +} + +impl NonConstTrait for () { + type Type = (); //~ ERROR `[const]` is not allowed + //~^ ERROR overflow evaluating the requirement `(): Trait` + fn non_const_function() {} //~ ERROR `[const]` is not allowed + const CONSTANT: () = (); //~ ERROR `[const]` is not allowed + //~^ ERROR generic const items are experimental +} + +struct Implementor; + +impl Implementor { + type Type = (); //~ ERROR `[const]` is not allowed + //~^ ERROR inherent associated types are unstable + fn non_const_function() {} //~ ERROR `[const]` is not allowed + const CONSTANT: () = (); //~ ERROR `[const]` is not allowed + //~^ ERROR generic const items are experimental +} + +// non-const traits +trait Child0: [const] Trait {} //~ ERROR `[const]` is not allowed +trait Child1 where Self: [const] Trait {} //~ ERROR `[const]` is not allowed + +// non-const impl +impl Trait for T {} //~ ERROR `[const]` is not allowed + +// inherent impl (regression test for issue #117004) +impl Struct {} //~ ERROR `[const]` is not allowed + +fn main() {} diff --git a/tests/ui/traits/const-traits/conditionally-const-invalid-places.stderr b/tests/ui/traits/const-traits/conditionally-const-invalid-places.stderr new file mode 100644 index 0000000000000..62319689861b9 --- /dev/null +++ b/tests/ui/traits/const-traits/conditionally-const-invalid-places.stderr @@ -0,0 +1,310 @@ +error: `[const]` is not allowed here + --> $DIR/conditionally-const-invalid-places.rs:7:24 + | +LL | fn non_const_function() {} + | ^^^^^^^^^ + | +note: this function is not `const`, so it cannot have `[const]` trait bounds + --> $DIR/conditionally-const-invalid-places.rs:7:4 + | +LL | fn non_const_function() {} + | ^^^^^^^^^^^^^^^^^^ + +error: `[const]` is not allowed here + --> $DIR/conditionally-const-invalid-places.rs:9:16 + | +LL | struct Struct { field: T } + | ^^^^^^^^^ + | + = note: this item cannot have `[const]` trait bounds + +error: `[const]` is not allowed here + --> $DIR/conditionally-const-invalid-places.rs:10:21 + | +LL | struct TupleStruct(T); + | ^^^^^^^^^ + | + = note: this item cannot have `[const]` trait bounds + +error: `[const]` is not allowed here + --> $DIR/conditionally-const-invalid-places.rs:11:20 + | +LL | struct UnitStruct; + | ^^^^^^^^^ + | + = note: this item cannot have `[const]` trait bounds + +error: `[const]` is not allowed here + --> $DIR/conditionally-const-invalid-places.rs:14:12 + | +LL | enum Enum { Variant(T) } + | ^^^^^^^^^ + | + = note: this item cannot have `[const]` trait bounds + +error: `[const]` is not allowed here + --> $DIR/conditionally-const-invalid-places.rs:16:14 + | +LL | union Union { field: T } + | ^^^^^^^^^ + | + = note: this item cannot have `[const]` trait bounds + +error: `[const]` is not allowed here + --> $DIR/conditionally-const-invalid-places.rs:19:12 + | +LL | type Type = T; + | ^^^^^^^^^ + | + = note: this item cannot have `[const]` trait bounds + +error: `[const]` is not allowed here + --> $DIR/conditionally-const-invalid-places.rs:21:17 + | +LL | const CONSTANT: () = (); + | ^^^^^^^^^ + | + = note: this item cannot have `[const]` trait bounds + +error: `[const]` is not allowed here + --> $DIR/conditionally-const-invalid-places.rs:25:16 + | +LL | type Type: [const] Trait; + | ^^^^^^^^^ + | +note: associated types in non-`#[const_trait]` traits cannot have `[const]` trait bounds + --> $DIR/conditionally-const-invalid-places.rs:25:5 + | +LL | type Type: [const] Trait; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: `[const]` is not allowed here + --> $DIR/conditionally-const-invalid-places.rs:25:32 + | +LL | type Type: [const] Trait; + | ^^^^^^^^^ + | +note: associated types in non-`#[const_trait]` traits cannot have `[const]` trait bounds + --> $DIR/conditionally-const-invalid-places.rs:25:5 + | +LL | type Type: [const] Trait; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: `[const]` is not allowed here + --> $DIR/conditionally-const-invalid-places.rs:28:28 + | +LL | fn non_const_function(); + | ^^^^^^^^^ + | +note: this function is not `const`, so it cannot have `[const]` trait bounds + --> $DIR/conditionally-const-invalid-places.rs:28:8 + | +LL | fn non_const_function(); + | ^^^^^^^^^^^^^^^^^^ + +error: `[const]` is not allowed here + --> $DIR/conditionally-const-invalid-places.rs:29:21 + | +LL | const CONSTANT: (); + | ^^^^^^^^^ + | + = note: this item cannot have `[const]` trait bounds + +error: `[const]` is not allowed here + --> $DIR/conditionally-const-invalid-places.rs:34:16 + | +LL | type Type = (); + | ^^^^^^^^^ + | +note: associated types in non-const impls cannot have `[const]` trait bounds + --> $DIR/conditionally-const-invalid-places.rs:34:5 + | +LL | type Type = (); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: `[const]` is not allowed here + --> $DIR/conditionally-const-invalid-places.rs:36:28 + | +LL | fn non_const_function() {} + | ^^^^^^^^^ + | +note: this function is not `const`, so it cannot have `[const]` trait bounds + --> $DIR/conditionally-const-invalid-places.rs:36:8 + | +LL | fn non_const_function() {} + | ^^^^^^^^^^^^^^^^^^ + +error: `[const]` is not allowed here + --> $DIR/conditionally-const-invalid-places.rs:37:21 + | +LL | const CONSTANT: () = (); + | ^^^^^^^^^ + | + = note: this item cannot have `[const]` trait bounds + +error: `[const]` is not allowed here + --> $DIR/conditionally-const-invalid-places.rs:44:16 + | +LL | type Type = (); + | ^^^^^^^^^ + | +note: inherent associated types cannot have `[const]` trait bounds + --> $DIR/conditionally-const-invalid-places.rs:44:5 + | +LL | type Type = (); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: `[const]` is not allowed here + --> $DIR/conditionally-const-invalid-places.rs:46:28 + | +LL | fn non_const_function() {} + | ^^^^^^^^^ + | +note: this function is not `const`, so it cannot have `[const]` trait bounds + --> $DIR/conditionally-const-invalid-places.rs:46:8 + | +LL | fn non_const_function() {} + | ^^^^^^^^^^^^^^^^^^ + +error: `[const]` is not allowed here + --> $DIR/conditionally-const-invalid-places.rs:47:21 + | +LL | const CONSTANT: () = (); + | ^^^^^^^^^ + | + = note: this item cannot have `[const]` trait bounds + +error: `[const]` is not allowed here + --> $DIR/conditionally-const-invalid-places.rs:52:13 + | +LL | trait Child0: [const] Trait {} + | ^^^^^^^^^ + | +note: this trait is not a `#[const_trait]`, so it cannot have `[const]` trait bounds + --> $DIR/conditionally-const-invalid-places.rs:52:1 + | +LL | trait Child0: [const] Trait {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: `[const]` is not allowed here + --> $DIR/conditionally-const-invalid-places.rs:53:24 + | +LL | trait Child1 where Self: [const] Trait {} + | ^^^^^^^^^ + | +note: this trait is not a `#[const_trait]`, so it cannot have `[const]` trait bounds + --> $DIR/conditionally-const-invalid-places.rs:53:1 + | +LL | trait Child1 where Self: [const] Trait {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: `[const]` is not allowed here + --> $DIR/conditionally-const-invalid-places.rs:56:7 + | +LL | impl Trait for T {} + | ^^^^^^^^^ + | +note: this impl is not `const`, so it cannot have `[const]` trait bounds + --> $DIR/conditionally-const-invalid-places.rs:56:1 + | +LL | impl Trait for T {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: `[const]` is not allowed here + --> $DIR/conditionally-const-invalid-places.rs:59:7 + | +LL | impl Struct {} + | ^^^^^^^^^ + | +note: inherent impls cannot have `[const]` trait bounds + --> $DIR/conditionally-const-invalid-places.rs:59:1 + | +LL | impl Struct {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0658]: generic const items are experimental + --> $DIR/conditionally-const-invalid-places.rs:21:15 + | +LL | const CONSTANT: () = (); + | ^^^^^^^^^^^^^^^^^^ + | + = note: see issue #113521 for more information + = help: add `#![feature(generic_const_items)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error[E0658]: generic const items are experimental + --> $DIR/conditionally-const-invalid-places.rs:29:19 + | +LL | const CONSTANT: (); + | ^^^^^^^^^^^^^^^^^^ + | + = note: see issue #113521 for more information + = help: add `#![feature(generic_const_items)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error[E0658]: generic const items are experimental + --> $DIR/conditionally-const-invalid-places.rs:37:19 + | +LL | const CONSTANT: () = (); + | ^^^^^^^^^^^^^^^^^^ + | + = note: see issue #113521 for more information + = help: add `#![feature(generic_const_items)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error[E0658]: generic const items are experimental + --> $DIR/conditionally-const-invalid-places.rs:47:19 + | +LL | const CONSTANT: () = (); + | ^^^^^^^^^^^^^^^^^^ + | + = note: see issue #113521 for more information + = help: add `#![feature(generic_const_items)]` 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[E0392]: type parameter `T` is never used + --> $DIR/conditionally-const-invalid-places.rs:11:19 + | +LL | struct UnitStruct; + | ^ unused type parameter + | + = help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData` + +error[E0740]: field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union + --> $DIR/conditionally-const-invalid-places.rs:16:33 + | +LL | union Union { field: T } + | ^^^^^^^^ + | + = note: union fields must not have drop side-effects, which is currently enforced via either `Copy` or `ManuallyDrop<...>` +help: wrap the field type in `ManuallyDrop<...>` + | +LL | union Union { field: std::mem::ManuallyDrop } + | +++++++++++++++++++++++ + + +error[E0275]: overflow evaluating the requirement `(): Trait` + --> $DIR/conditionally-const-invalid-places.rs:34:35 + | +LL | type Type = (); + | ^^ + | +note: required by a bound in `NonConstTrait::Type` + --> $DIR/conditionally-const-invalid-places.rs:25:34 + | +LL | type Type: [const] Trait; + | ^^^^^^^^^^^^^ required by this bound in `NonConstTrait::Type` + +error[E0658]: inherent associated types are unstable + --> $DIR/conditionally-const-invalid-places.rs:44:5 + | +LL | type Type = (); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #8995 for more information + = help: add `#![feature(inherent_associated_types)]` 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: aborting due to 30 previous errors + +Some errors have detailed explanations: E0275, E0392, E0658, E0740. +For more information about an error, try `rustc --explain E0275`. diff --git a/tests/ui/traits/const-traits/tilde-const-trait-assoc-tys.rs b/tests/ui/traits/const-traits/conditionally-const-trait-bound-assoc-tys.rs similarity index 71% rename from tests/ui/traits/const-traits/tilde-const-trait-assoc-tys.rs rename to tests/ui/traits/const-traits/conditionally-const-trait-bound-assoc-tys.rs index 53ddb5c0cdfc8..b0bd8466f66b9 100644 --- a/tests/ui/traits/const-traits/tilde-const-trait-assoc-tys.rs +++ b/tests/ui/traits/const-traits/conditionally-const-trait-bound-assoc-tys.rs @@ -4,11 +4,11 @@ #[const_trait] trait Trait { - type Assoc; + type Assoc; } impl const Trait for () { - type Assoc = T; + type Assoc = T; } #[const_trait] diff --git a/tests/ui/traits/const-traits/conditionally-const-trait-bound-syntax.rs b/tests/ui/traits/const-traits/conditionally-const-trait-bound-syntax.rs new file mode 100644 index 0000000000000..89950c65ef642 --- /dev/null +++ b/tests/ui/traits/const-traits/conditionally-const-trait-bound-syntax.rs @@ -0,0 +1,9 @@ +//@ compile-flags: -Z parse-crate-root-only +//@ check-pass + +#![feature(const_trait_impl)] + +struct S< + T: for<'a> [const] Tr<'a> + 'static + [const] std::ops::Add, + T: for<'a: 'b> [const] m::Trait<'a>, +>; diff --git a/tests/ui/traits/const-traits/const-bound-on-not-const-associated-fn.rs b/tests/ui/traits/const-traits/const-bound-on-not-const-associated-fn.rs index c735f855bcea7..9411127270833 100644 --- a/tests/ui/traits/const-traits/const-bound-on-not-const-associated-fn.rs +++ b/tests/ui/traits/const-traits/const-bound-on-not-const-associated-fn.rs @@ -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); @@ -19,8 +19,8 @@ impl const MyTrait for u32 { } impl MyStruct { - 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(); } } diff --git a/tests/ui/traits/const-traits/const-bound-on-not-const-associated-fn.stderr b/tests/ui/traits/const-traits/const-bound-on-not-const-associated-fn.stderr index 50ab52ade49c7..c0af644d3deb0 100644 --- a/tests/ui/traits/const-traits/const-bound-on-not-const-associated-fn.stderr +++ b/tests/ui/traits/const-traits/const-bound-on-not-const-associated-fn.stderr @@ -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 diff --git a/tests/ui/traits/const-traits/const-bounds-non-const-trait.rs b/tests/ui/traits/const-traits/const-bounds-non-const-trait.rs index e446eb154814f..ae31d9ae0ac0e 100644 --- a/tests/ui/traits/const-traits/const-bounds-non-const-trait.rs +++ b/tests/ui/traits/const-traits/const-bounds-non-const-trait.rs @@ -3,9 +3,9 @@ trait NonConst {} -const fn perform() {} -//~^ ERROR `~const` can only be applied to `#[const_trait]` traits -//~| ERROR `~const` can only be applied to `#[const_trait]` traits +const fn perform() {} +//~^ ERROR `[const]` can only be applied to `#[const_trait]` traits +//~| ERROR `[const]` can only be applied to `#[const_trait]` traits fn operate() {} //~^ ERROR `const` can only be applied to `#[const_trait]` traits diff --git a/tests/ui/traits/const-traits/const-bounds-non-const-trait.stderr b/tests/ui/traits/const-traits/const-bounds-non-const-trait.stderr index f97d3a9181e06..2ff5fb74031b1 100644 --- a/tests/ui/traits/const-traits/const-bounds-non-const-trait.stderr +++ b/tests/ui/traits/const-traits/const-bounds-non-const-trait.stderr @@ -1,19 +1,19 @@ -error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/const-bounds-non-const-trait.rs:6:21 +error: `[const]` can only be applied to `#[const_trait]` traits + --> $DIR/const-bounds-non-const-trait.rs:6:19 | -LL | const fn perform() {} - | ^^^^^^ can't be applied to `NonConst` +LL | const fn perform() {} + | ^^^^^^^^^ can't be applied to `NonConst` | help: mark `NonConst` as `#[const_trait]` to allow it to have `const` implementations | LL | #[const_trait] trait NonConst {} | ++++++++++++++ -error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/const-bounds-non-const-trait.rs:6:21 +error: `[const]` can only be applied to `#[const_trait]` traits + --> $DIR/const-bounds-non-const-trait.rs:6:19 | -LL | const fn perform() {} - | ^^^^^^ can't be applied to `NonConst` +LL | const fn perform() {} + | ^^^^^^^^^ can't be applied to `NonConst` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: mark `NonConst` as `#[const_trait]` to allow it to have `const` implementations diff --git a/tests/ui/traits/const-traits/const-closure-parse-not-item.rs b/tests/ui/traits/const-traits/const-closure-parse-not-item.rs index b1b0e68b90db7..35127eda5c039 100644 --- a/tests/ui/traits/const-traits/const-closure-parse-not-item.rs +++ b/tests/ui/traits/const-traits/const-closure-parse-not-item.rs @@ -4,7 +4,7 @@ #![feature(const_trait_impl, const_closures)] #![allow(incomplete_features)] -const fn test() -> impl ~const Fn() { +const fn test() -> impl [const] Fn() { const move || {} } diff --git a/tests/ui/traits/const-traits/const-closure-parse-not-item.stderr b/tests/ui/traits/const-traits/const-closure-parse-not-item.stderr index 57afa2257b7d4..cc9d9bd602294 100644 --- a/tests/ui/traits/const-traits/const-closure-parse-not-item.stderr +++ b/tests/ui/traits/const-traits/const-closure-parse-not-item.stderr @@ -1,29 +1,29 @@ -error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/const-closure-parse-not-item.rs:7:25 +error: `[const]` can only be applied to `#[const_trait]` traits + --> $DIR/const-closure-parse-not-item.rs:7:20 | -LL | const fn test() -> impl ~const Fn() { - | ^^^^^^ can't be applied to `Fn` +LL | const fn test() -> impl [const] Fn() { + | ^^^^^^^^^^^^ 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/const-closure-parse-not-item.rs:7:25 +error: `[const]` can only be applied to `#[const_trait]` traits + --> $DIR/const-closure-parse-not-item.rs:7:20 | -LL | const fn test() -> impl ~const Fn() { - | ^^^^^^ can't be applied to `Fn` +LL | const fn test() -> impl [const] Fn() { + | ^^^^^^^^^^^^ 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/const-closure-parse-not-item.rs:7:25 +error: `[const]` can only be applied to `#[const_trait]` traits + --> $DIR/const-closure-parse-not-item.rs:7:20 | -LL | const fn test() -> impl ~const Fn() { - | ^^^^^^ can't be applied to `Fn` +LL | const fn test() -> impl [const] Fn() { + | ^^^^^^^^^^^^ 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` diff --git a/tests/ui/traits/const-traits/const-closure-trait-method-fail.rs b/tests/ui/traits/const-traits/const-closure-trait-method-fail.rs index 8c6286426d324..cbcc4aa7c3cdb 100644 --- a/tests/ui/traits/const-traits/const-closure-trait-method-fail.rs +++ b/tests/ui/traits/const-traits/const-closure-trait-method-fail.rs @@ -11,7 +11,7 @@ impl Tr for () { fn a(self) -> i32 { 42 } } -const fn need_const_closure i32>(x: T) -> i32 { +const fn need_const_closure i32>(x: T) -> i32 { x(()) } diff --git a/tests/ui/traits/const-traits/const-closure-trait-method-fail.stderr b/tests/ui/traits/const-traits/const-closure-trait-method-fail.stderr index 2a97846ccb448..7a146b9d8a112 100644 --- a/tests/ui/traits/const-traits/const-closure-trait-method-fail.stderr +++ b/tests/ui/traits/const-traits/const-closure-trait-method-fail.stderr @@ -1,19 +1,19 @@ -error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/const-closure-trait-method-fail.rs:14:32 +error: `[const]` can only be applied to `#[const_trait]` traits + --> $DIR/const-closure-trait-method-fail.rs:14:30 | -LL | const fn need_const_closure i32>(x: T) -> i32 { - | ^^^^^^ can't be applied to `FnOnce` +LL | const fn need_const_closure i32>(x: T) -> i32 { + | ^^^^^^^^^ 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/const-closure-trait-method-fail.rs:14:32 +error: `[const]` can only be applied to `#[const_trait]` traits + --> $DIR/const-closure-trait-method-fail.rs:14:30 | -LL | const fn need_const_closure i32>(x: T) -> i32 { - | ^^^^^^ can't be applied to `FnOnce` +LL | const fn need_const_closure i32>(x: T) -> i32 { + | ^^^^^^^^^ 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` diff --git a/tests/ui/traits/const-traits/const-closure-trait-method.rs b/tests/ui/traits/const-traits/const-closure-trait-method.rs index ebee4daefbea3..831d6e27946d1 100644 --- a/tests/ui/traits/const-traits/const-closure-trait-method.rs +++ b/tests/ui/traits/const-traits/const-closure-trait-method.rs @@ -11,7 +11,7 @@ impl const Tr for () { fn a(self) -> i32 { 42 } } -const fn need_const_closure i32>(x: T) -> i32 { +const fn need_const_closure i32>(x: T) -> i32 { x(()) } diff --git a/tests/ui/traits/const-traits/const-closure-trait-method.stderr b/tests/ui/traits/const-traits/const-closure-trait-method.stderr index 9c63b7e63a65d..6c003f87ada6a 100644 --- a/tests/ui/traits/const-traits/const-closure-trait-method.stderr +++ b/tests/ui/traits/const-traits/const-closure-trait-method.stderr @@ -1,19 +1,19 @@ -error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/const-closure-trait-method.rs:14:32 +error: `[const]` can only be applied to `#[const_trait]` traits + --> $DIR/const-closure-trait-method.rs:14:30 | -LL | const fn need_const_closure i32>(x: T) -> i32 { - | ^^^^^^ can't be applied to `FnOnce` +LL | const fn need_const_closure i32>(x: T) -> i32 { + | ^^^^^^^^^ 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/const-closure-trait-method.rs:14:32 +error: `[const]` can only be applied to `#[const_trait]` traits + --> $DIR/const-closure-trait-method.rs:14:30 | -LL | const fn need_const_closure i32>(x: T) -> i32 { - | ^^^^^^ can't be applied to `FnOnce` +LL | const fn need_const_closure i32>(x: T) -> i32 { + | ^^^^^^^^^ 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` diff --git a/tests/ui/traits/const-traits/const-closures.rs b/tests/ui/traits/const-traits/const-closures.rs index 98f8d039cd643..2f6f4dc4ba335 100644 --- a/tests/ui/traits/const-traits/const-closures.rs +++ b/tests/ui/traits/const-traits/const-closures.rs @@ -5,9 +5,9 @@ const fn answer_p1(f: &F) -> u8 where - F: ~const FnOnce() -> u8, - F: ~const FnMut() -> u8, - F: ~const Fn() -> u8, + F: [const] FnOnce() -> u8, + F: [const] FnMut() -> u8, + F: [const] Fn() -> u8, { f() * 7 } @@ -20,7 +20,7 @@ const fn answer_p2() -> u8 { answer_p1(&three) } -const fn answer u8>(f: &F) -> u8 { +const fn answer u8>(f: &F) -> u8 { f() + f() } diff --git a/tests/ui/traits/const-traits/const-closures.stderr b/tests/ui/traits/const-traits/const-closures.stderr index 92f3ba2082072..c76a73418a533 100644 --- a/tests/ui/traits/const-traits/const-closures.stderr +++ b/tests/ui/traits/const-traits/const-closures.stderr @@ -1,76 +1,76 @@ -error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/const-closures.rs:8:12 +error: `[const]` can only be applied to `#[const_trait]` traits + --> $DIR/const-closures.rs:8:10 | -LL | F: ~const FnOnce() -> u8, - | ^^^^^^ can't be applied to `FnOnce` +LL | F: [const] FnOnce() -> u8, + | ^^^^^^^^^ 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/const-closures.rs:9:12 +error: `[const]` can only be applied to `#[const_trait]` traits + --> $DIR/const-closures.rs:9:10 | -LL | F: ~const FnMut() -> u8, - | ^^^^^^ can't be applied to `FnMut` +LL | F: [const] FnMut() -> u8, + | ^^^^^^^^^ 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/const-closures.rs:10:12 +error: `[const]` can only be applied to `#[const_trait]` traits + --> $DIR/const-closures.rs:10:10 | -LL | F: ~const Fn() -> u8, - | ^^^^^^ can't be applied to `Fn` +LL | F: [const] Fn() -> u8, + | ^^^^^^^^^ 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/const-closures.rs:8:12 +error: `[const]` can only be applied to `#[const_trait]` traits + --> $DIR/const-closures.rs:8:10 | -LL | F: ~const FnOnce() -> u8, - | ^^^^^^ can't be applied to `FnOnce` +LL | F: [const] FnOnce() -> u8, + | ^^^^^^^^^ 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/const-closures.rs:9:12 +error: `[const]` can only be applied to `#[const_trait]` traits + --> $DIR/const-closures.rs:9:10 | -LL | F: ~const FnMut() -> u8, - | ^^^^^^ can't be applied to `FnMut` +LL | F: [const] FnMut() -> u8, + | ^^^^^^^^^ 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/const-closures.rs:10:12 +error: `[const]` can only be applied to `#[const_trait]` traits + --> $DIR/const-closures.rs:10:10 | -LL | F: ~const Fn() -> u8, - | ^^^^^^ can't be applied to `Fn` +LL | F: [const] Fn() -> u8, + | ^^^^^^^^^ 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/const-closures.rs:23:20 +error: `[const]` can only be applied to `#[const_trait]` traits + --> $DIR/const-closures.rs:23:18 | -LL | const fn answer u8>(f: &F) -> u8 { - | ^^^^^^ can't be applied to `Fn` +LL | const fn answer u8>(f: &F) -> u8 { + | ^^^^^^^^^ 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/const-closures.rs:23:20 +error: `[const]` can only be applied to `#[const_trait]` traits + --> $DIR/const-closures.rs:23:18 | -LL | const fn answer u8>(f: &F) -> u8 { - | ^^^^^^ can't be applied to `Fn` +LL | const fn answer u8>(f: &F) -> u8 { + | ^^^^^^^^^ 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` diff --git a/tests/ui/traits/const-traits/const-cond-for-rpitit.rs b/tests/ui/traits/const-traits/const-cond-for-rpitit.rs index 50bf93f9a0328..da83e054dd9bb 100644 --- a/tests/ui/traits/const-traits/const-cond-for-rpitit.rs +++ b/tests/ui/traits/const-traits/const-cond-for-rpitit.rs @@ -6,15 +6,15 @@ #[const_trait] pub trait Foo { - fn method(self) -> impl ~const Bar; + fn method(self) -> impl [const] Bar; } #[const_trait] pub trait Bar {} struct A(T); -impl const Foo for A where A: ~const Bar { - fn method(self) -> impl ~const Bar { +impl const Foo for A where A: [const] Bar { + fn method(self) -> impl [const] Bar { self } } diff --git a/tests/ui/traits/const-traits/const-default-method-bodies.rs b/tests/ui/traits/const-traits/const-default-method-bodies.rs index 0ef11a7f0c933..27e828c7ab91a 100644 --- a/tests/ui/traits/const-traits/const-default-method-bodies.rs +++ b/tests/ui/traits/const-traits/const-default-method-bodies.rs @@ -23,7 +23,7 @@ impl const ConstDefaultFn for ConstImpl { const fn test() { NonConstImpl.a(); - //~^ ERROR the trait bound `NonConstImpl: ~const ConstDefaultFn` is not satisfied + //~^ ERROR the trait bound `NonConstImpl: [const] ConstDefaultFn` is not satisfied ConstImpl.a(); } diff --git a/tests/ui/traits/const-traits/const-default-method-bodies.stderr b/tests/ui/traits/const-traits/const-default-method-bodies.stderr index 903f7d37f9d8e..03ca6f1d51155 100644 --- a/tests/ui/traits/const-traits/const-default-method-bodies.stderr +++ b/tests/ui/traits/const-traits/const-default-method-bodies.stderr @@ -1,4 +1,4 @@ -error[E0277]: the trait bound `NonConstImpl: ~const ConstDefaultFn` is not satisfied +error[E0277]: the trait bound `NonConstImpl: [const] ConstDefaultFn` is not satisfied --> $DIR/const-default-method-bodies.rs:25:18 | LL | NonConstImpl.a(); diff --git a/tests/ui/traits/const-traits/const-drop-bound.rs b/tests/ui/traits/const-traits/const-drop-bound.rs index 4819da7c3a403..7fa9b10fa0405 100644 --- a/tests/ui/traits/const-traits/const-drop-bound.rs +++ b/tests/ui/traits/const-traits/const-drop-bound.rs @@ -5,7 +5,7 @@ use std::marker::Destruct; -const fn foo(res: Result) -> Option where E: ~const Destruct { +const fn foo(res: Result) -> Option where E: [const] Destruct { match res { Ok(t) => Some(t), Err(_e) => None, @@ -16,8 +16,8 @@ pub struct Foo(T); const fn baz(res: Result, Foo>) -> Option> where - T: ~const Destruct, - E: ~const Destruct, + T: [const] Destruct, + E: [const] Destruct, { foo(res) } diff --git a/tests/ui/traits/const-traits/const-drop-fail-2.precise.stderr b/tests/ui/traits/const-traits/const-drop-fail-2.precise.stderr index 76207ea0939b3..c2309ea6e122e 100644 --- a/tests/ui/traits/const-traits/const-drop-fail-2.precise.stderr +++ b/tests/ui/traits/const-traits/const-drop-fail-2.precise.stderr @@ -5,17 +5,17 @@ LL | const _: () = check::>( | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: required for `ConstDropImplWithBounds` to implement `const Drop` - --> $DIR/const-drop-fail-2.rs:25:25 + --> $DIR/const-drop-fail-2.rs:25:26 | -LL | impl const Drop for ConstDropImplWithBounds { - | -------- ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | impl const Drop for ConstDropImplWithBounds { + | --------- ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ | | | unsatisfied trait bound introduced here note: required by a bound in `check` --> $DIR/const-drop-fail-2.rs:21:19 | -LL | const fn check(_: T) {} - | ^^^^^^^^^^^^^^^ required by this bound in `check` +LL | const fn check(_: T) {} + | ^^^^^^^^^^^^^^^^ required by this bound in `check` error: aborting due to 1 previous error diff --git a/tests/ui/traits/const-traits/const-drop-fail-2.rs b/tests/ui/traits/const-traits/const-drop-fail-2.rs index 1bcc87e907037..3f98a9f715e8b 100644 --- a/tests/ui/traits/const-traits/const-drop-fail-2.rs +++ b/tests/ui/traits/const-traits/const-drop-fail-2.rs @@ -18,11 +18,11 @@ trait A { fn a() { } } impl A for NonTrivialDrop {} -const fn check(_: T) {} +const fn check(_: T) {} struct ConstDropImplWithBounds(PhantomData); -impl const Drop for ConstDropImplWithBounds { +impl const Drop for ConstDropImplWithBounds { fn drop(&mut self) { T::a(); } @@ -35,7 +35,7 @@ const _: () = check::>( struct ConstDropImplWithNonConstBounds(PhantomData); -impl const Drop for ConstDropImplWithNonConstBounds { +impl const Drop for ConstDropImplWithNonConstBounds { fn drop(&mut self) { T::a(); } diff --git a/tests/ui/traits/const-traits/const-drop-fail-2.stock.stderr b/tests/ui/traits/const-traits/const-drop-fail-2.stock.stderr index 76207ea0939b3..c2309ea6e122e 100644 --- a/tests/ui/traits/const-traits/const-drop-fail-2.stock.stderr +++ b/tests/ui/traits/const-traits/const-drop-fail-2.stock.stderr @@ -5,17 +5,17 @@ LL | const _: () = check::>( | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: required for `ConstDropImplWithBounds` to implement `const Drop` - --> $DIR/const-drop-fail-2.rs:25:25 + --> $DIR/const-drop-fail-2.rs:25:26 | -LL | impl const Drop for ConstDropImplWithBounds { - | -------- ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | impl const Drop for ConstDropImplWithBounds { + | --------- ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ | | | unsatisfied trait bound introduced here note: required by a bound in `check` --> $DIR/const-drop-fail-2.rs:21:19 | -LL | const fn check(_: T) {} - | ^^^^^^^^^^^^^^^ required by this bound in `check` +LL | const fn check(_: T) {} + | ^^^^^^^^^^^^^^^^ required by this bound in `check` error: aborting due to 1 previous error diff --git a/tests/ui/traits/const-traits/const-drop-fail.new_precise.stderr b/tests/ui/traits/const-traits/const-drop-fail.new_precise.stderr index f38e642bb63e5..9c49ee56b0f4d 100644 --- a/tests/ui/traits/const-traits/const-drop-fail.new_precise.stderr +++ b/tests/ui/traits/const-traits/const-drop-fail.new_precise.stderr @@ -10,8 +10,8 @@ LL | NonTrivialDrop, note: required by a bound in `check` --> $DIR/const-drop-fail.rs:24:19 | -LL | const fn check(_: T) {} - | ^^^^^^^^^^^^^^^ required by this bound in `check` +LL | const fn check(_: T) {} + | ^^^^^^^^^^^^^^^^ required by this bound in `check` error[E0277]: the trait bound `NonTrivialDrop: const Destruct` is not satisfied --> $DIR/const-drop-fail.rs:35:5 @@ -25,8 +25,8 @@ LL | ConstImplWithDropGlue(NonTrivialDrop), note: required by a bound in `check` --> $DIR/const-drop-fail.rs:24:19 | -LL | const fn check(_: T) {} - | ^^^^^^^^^^^^^^^ required by this bound in `check` +LL | const fn check(_: T) {} + | ^^^^^^^^^^^^^^^^ required by this bound in `check` error: aborting due to 2 previous errors diff --git a/tests/ui/traits/const-traits/const-drop-fail.new_stock.stderr b/tests/ui/traits/const-traits/const-drop-fail.new_stock.stderr index f38e642bb63e5..9c49ee56b0f4d 100644 --- a/tests/ui/traits/const-traits/const-drop-fail.new_stock.stderr +++ b/tests/ui/traits/const-traits/const-drop-fail.new_stock.stderr @@ -10,8 +10,8 @@ LL | NonTrivialDrop, note: required by a bound in `check` --> $DIR/const-drop-fail.rs:24:19 | -LL | const fn check(_: T) {} - | ^^^^^^^^^^^^^^^ required by this bound in `check` +LL | const fn check(_: T) {} + | ^^^^^^^^^^^^^^^^ required by this bound in `check` error[E0277]: the trait bound `NonTrivialDrop: const Destruct` is not satisfied --> $DIR/const-drop-fail.rs:35:5 @@ -25,8 +25,8 @@ LL | ConstImplWithDropGlue(NonTrivialDrop), note: required by a bound in `check` --> $DIR/const-drop-fail.rs:24:19 | -LL | const fn check(_: T) {} - | ^^^^^^^^^^^^^^^ required by this bound in `check` +LL | const fn check(_: T) {} + | ^^^^^^^^^^^^^^^^ required by this bound in `check` error: aborting due to 2 previous errors diff --git a/tests/ui/traits/const-traits/const-drop-fail.old_precise.stderr b/tests/ui/traits/const-traits/const-drop-fail.old_precise.stderr index f38e642bb63e5..9c49ee56b0f4d 100644 --- a/tests/ui/traits/const-traits/const-drop-fail.old_precise.stderr +++ b/tests/ui/traits/const-traits/const-drop-fail.old_precise.stderr @@ -10,8 +10,8 @@ LL | NonTrivialDrop, note: required by a bound in `check` --> $DIR/const-drop-fail.rs:24:19 | -LL | const fn check(_: T) {} - | ^^^^^^^^^^^^^^^ required by this bound in `check` +LL | const fn check(_: T) {} + | ^^^^^^^^^^^^^^^^ required by this bound in `check` error[E0277]: the trait bound `NonTrivialDrop: const Destruct` is not satisfied --> $DIR/const-drop-fail.rs:35:5 @@ -25,8 +25,8 @@ LL | ConstImplWithDropGlue(NonTrivialDrop), note: required by a bound in `check` --> $DIR/const-drop-fail.rs:24:19 | -LL | const fn check(_: T) {} - | ^^^^^^^^^^^^^^^ required by this bound in `check` +LL | const fn check(_: T) {} + | ^^^^^^^^^^^^^^^^ required by this bound in `check` error: aborting due to 2 previous errors diff --git a/tests/ui/traits/const-traits/const-drop-fail.old_stock.stderr b/tests/ui/traits/const-traits/const-drop-fail.old_stock.stderr index f38e642bb63e5..9c49ee56b0f4d 100644 --- a/tests/ui/traits/const-traits/const-drop-fail.old_stock.stderr +++ b/tests/ui/traits/const-traits/const-drop-fail.old_stock.stderr @@ -10,8 +10,8 @@ LL | NonTrivialDrop, note: required by a bound in `check` --> $DIR/const-drop-fail.rs:24:19 | -LL | const fn check(_: T) {} - | ^^^^^^^^^^^^^^^ required by this bound in `check` +LL | const fn check(_: T) {} + | ^^^^^^^^^^^^^^^^ required by this bound in `check` error[E0277]: the trait bound `NonTrivialDrop: const Destruct` is not satisfied --> $DIR/const-drop-fail.rs:35:5 @@ -25,8 +25,8 @@ LL | ConstImplWithDropGlue(NonTrivialDrop), note: required by a bound in `check` --> $DIR/const-drop-fail.rs:24:19 | -LL | const fn check(_: T) {} - | ^^^^^^^^^^^^^^^ required by this bound in `check` +LL | const fn check(_: T) {} + | ^^^^^^^^^^^^^^^^ required by this bound in `check` error: aborting due to 2 previous errors diff --git a/tests/ui/traits/const-traits/const-drop-fail.rs b/tests/ui/traits/const-traits/const-drop-fail.rs index a7f3d5654de93..4513d71f61342 100644 --- a/tests/ui/traits/const-traits/const-drop-fail.rs +++ b/tests/ui/traits/const-traits/const-drop-fail.rs @@ -21,7 +21,7 @@ impl const Drop for ConstImplWithDropGlue { fn drop(&mut self) {} } -const fn check(_: T) {} +const fn check(_: T) {} macro_rules! check_all { ($($exp:expr),*$(,)?) => {$( diff --git a/tests/ui/traits/const-traits/const-drop.rs b/tests/ui/traits/const-traits/const-drop.rs index e2d87aeff47fb..5df3a77f73ab6 100644 --- a/tests/ui/traits/const-traits/const-drop.rs +++ b/tests/ui/traits/const-traits/const-drop.rs @@ -16,7 +16,7 @@ impl<'a> const Drop for S<'a> { } } -const fn a(_: T) {} +const fn a(_: T) {} //FIXME ~^ ERROR destructor of const fn b() -> u8 { @@ -108,7 +108,7 @@ fn main() { } } - // These types should pass because ~const in a non-const context should have no effect. + // These types should pass because [const] in a non-const context should have no effect. a(HasDropGlue(Box::new(0))); a(HasDropImpl); diff --git a/tests/ui/traits/const-traits/const-impl-trait.rs b/tests/ui/traits/const-traits/const-impl-trait.rs index d7fe43ef37ced..dc960422a4a41 100644 --- a/tests/ui/traits/const-traits/const-impl-trait.rs +++ b/tests/ui/traits/const-traits/const-impl-trait.rs @@ -8,23 +8,23 @@ use std::marker::Destruct; -const fn cmp(a: &impl ~const PartialEq) -> bool { +const fn cmp(a: &impl [const] PartialEq) -> bool { a == a } const fn wrap( - x: impl ~const PartialEq + ~const Destruct, -) -> impl ~const PartialEq + ~const Destruct { + x: impl [const] PartialEq + [const] Destruct, +) -> impl [const] PartialEq + [const] Destruct { x } #[const_trait] trait Foo { - fn huh() -> impl ~const PartialEq + ~const Destruct + Copy; + fn huh() -> impl [const] PartialEq + [const] Destruct + Copy; } impl const Foo for () { - fn huh() -> impl ~const PartialEq + ~const Destruct + Copy { + fn huh() -> impl [const] PartialEq + [const] Destruct + Copy { 123 } } @@ -43,16 +43,16 @@ trait T {} struct S; impl const T for S {} -const fn rpit() -> impl ~const T { +const fn rpit() -> impl [const] T { S } -const fn apit(_: impl ~const T + ~const Destruct) {} +const fn apit(_: impl [const] T + [const] Destruct) {} -const fn rpit_assoc_bound() -> impl IntoIterator { +const fn rpit_assoc_bound() -> impl IntoIterator { Some(S) } -const fn apit_assoc_bound(_: impl IntoIterator + ~const Destruct) {} +const fn apit_assoc_bound(_: impl IntoIterator + [const] Destruct) {} fn main() {} diff --git a/tests/ui/traits/const-traits/const-impl-trait.stderr b/tests/ui/traits/const-traits/const-impl-trait.stderr index ee922f9689edd..cbb68d8c9839e 100644 --- a/tests/ui/traits/const-traits/const-impl-trait.stderr +++ b/tests/ui/traits/const-traits/const-impl-trait.stderr @@ -9,8 +9,8 @@ LL | assert!(cmp(&())); note: required by a bound in `cmp` --> $DIR/const-impl-trait.rs:11:23 | -LL | const fn cmp(a: &impl ~const PartialEq) -> bool { - | ^^^^^^^^^^^^^^^^ required by this bound in `cmp` +LL | const fn cmp(a: &impl [const] PartialEq) -> bool { + | ^^^^^^^^^^^^^^^^^ required by this bound in `cmp` error: aborting due to 1 previous error diff --git a/tests/ui/traits/const-traits/const-in-closure.rs b/tests/ui/traits/const-traits/const-in-closure.rs index ebc17a50c8660..0657c5af58837 100644 --- a/tests/ui/traits/const-traits/const-in-closure.rs +++ b/tests/ui/traits/const-traits/const-in-closure.rs @@ -3,13 +3,14 @@ #![feature(const_trait_impl)] -#[const_trait] trait Trait { +#[const_trait] +trait Trait { fn method(); } const fn foo() { let _ = || { - // Make sure this doesn't enforce `T: ~const Trait` + // Make sure this doesn't enforce `T: [const] Trait` T::method(); }; } @@ -17,7 +18,9 @@ const fn foo() { fn bar() { let _ = || { // Make sure unconditionally const bounds propagate from parent. - const { T::method(); }; + const { + T::method(); + }; }; } diff --git a/tests/ui/traits/const-traits/const-opaque.no.stderr b/tests/ui/traits/const-traits/const-opaque.no.stderr index 47e692936e046..acf19ba96ab39 100644 --- a/tests/ui/traits/const-traits/const-opaque.no.stderr +++ b/tests/ui/traits/const-traits/const-opaque.no.stderr @@ -9,8 +9,8 @@ LL | let opaque = bar(()); note: required by a bound in `bar` --> $DIR/const-opaque.rs:26:17 | -LL | const fn bar(t: T) -> impl ~const Foo { - | ^^^^^^^^^^ required by this bound in `bar` +LL | const fn bar(t: T) -> impl [const] Foo { + | ^^^^^^^^^^^ required by this bound in `bar` error[E0277]: the trait bound `(): const Foo` is not satisfied --> $DIR/const-opaque.rs:33:12 diff --git a/tests/ui/traits/const-traits/const-opaque.rs b/tests/ui/traits/const-traits/const-opaque.rs index 96cdd7d9f2619..56ebf0aefccfd 100644 --- a/tests/ui/traits/const-traits/const-opaque.rs +++ b/tests/ui/traits/const-traits/const-opaque.rs @@ -9,7 +9,7 @@ trait Foo { fn method(&self); } -impl const Foo for (T,) { +impl const Foo for (T,) { fn method(&self) {} } @@ -23,7 +23,7 @@ impl Foo for () { fn method(&self) {} } -const fn bar(t: T) -> impl ~const Foo { +const fn bar(t: T) -> impl [const] Foo { (t,) } diff --git a/tests/ui/traits/const-traits/const-trait-bounds-trait-objects.rs b/tests/ui/traits/const-traits/const-trait-bounds-trait-objects.rs index 2dac1970835d2..ece87529c3e3b 100644 --- a/tests/ui/traits/const-traits/const-trait-bounds-trait-objects.rs +++ b/tests/ui/traits/const-traits/const-trait-bounds-trait-objects.rs @@ -7,12 +7,12 @@ trait Trait {} fn main() { let _: &dyn const Trait; //~ ERROR const trait bounds are not allowed in trait object types - let _: &dyn ~const Trait; //~ ERROR `~const` is not allowed here + let _: &dyn [const] Trait; //~ ERROR `[const]` is not allowed here } // Regression test for issue #119525. trait NonConst {} const fn handle(_: &dyn const NonConst) {} //~^ ERROR const trait bounds are not allowed in trait object types -const fn take(_: &dyn ~const NonConst) {} -//~^ ERROR `~const` is not allowed here +const fn take(_: &dyn [const] NonConst) {} +//~^ ERROR `[const]` is not allowed here diff --git a/tests/ui/traits/const-traits/const-trait-bounds-trait-objects.stderr b/tests/ui/traits/const-traits/const-trait-bounds-trait-objects.stderr index bd29b4b860b62..c58e2765168b5 100644 --- a/tests/ui/traits/const-traits/const-trait-bounds-trait-objects.stderr +++ b/tests/ui/traits/const-traits/const-trait-bounds-trait-objects.stderr @@ -4,13 +4,13 @@ error: const trait bounds are not allowed in trait object types LL | let _: &dyn const Trait; | ^^^^^^^^^^^ -error: `~const` is not allowed here - --> $DIR/const-trait-bounds-trait-objects.rs:10:17 +error: `[const]` is not allowed here + --> $DIR/const-trait-bounds-trait-objects.rs:10:13 | -LL | let _: &dyn ~const Trait; - | ^^^^^^ +LL | let _: &dyn [const] Trait; + | ^^^^^^^^^^^ | - = note: trait objects cannot have `~const` trait bounds + = note: trait objects cannot have `[const]` trait bounds error: const trait bounds are not allowed in trait object types --> $DIR/const-trait-bounds-trait-objects.rs:15:25 @@ -18,13 +18,13 @@ error: const trait bounds are not allowed in trait object types LL | const fn handle(_: &dyn const NonConst) {} | ^^^^^^^^^^^^^^ -error: `~const` is not allowed here - --> $DIR/const-trait-bounds-trait-objects.rs:17:23 +error: `[const]` is not allowed here + --> $DIR/const-trait-bounds-trait-objects.rs:17:19 | -LL | const fn take(_: &dyn ~const NonConst) {} - | ^^^^^^ +LL | const fn take(_: &dyn [const] NonConst) {} + | ^^^^^^^^^^^ | - = note: trait objects cannot have `~const` trait bounds + = note: trait objects cannot have `[const]` trait bounds error: aborting due to 4 previous errors diff --git a/tests/ui/traits/const-traits/const-trait-impl-parameter-mismatch.rs b/tests/ui/traits/const-traits/const-trait-impl-parameter-mismatch.rs index b563b78f78a16..955063643e2b6 100644 --- a/tests/ui/traits/const-traits/const-trait-impl-parameter-mismatch.rs +++ b/tests/ui/traits/const-traits/const-trait-impl-parameter-mismatch.rs @@ -13,7 +13,7 @@ #[const_trait] trait Main { - fn compute() -> u32; + fn compute() -> u32; } impl const Main for () { diff --git a/tests/ui/traits/const-traits/const-trait-impl-parameter-mismatch.stderr b/tests/ui/traits/const-traits/const-trait-impl-parameter-mismatch.stderr index a04f98e68a633..cac83fe5cb2ed 100644 --- a/tests/ui/traits/const-traits/const-trait-impl-parameter-mismatch.stderr +++ b/tests/ui/traits/const-traits/const-trait-impl-parameter-mismatch.stderr @@ -10,7 +10,7 @@ LL | #![feature(const_trait_impl, effects)] error[E0049]: associated function `compute` has 0 type parameters but its trait declaration has 1 type parameter --> $DIR/const-trait-impl-parameter-mismatch.rs:20:16 | -LL | fn compute() -> u32; +LL | fn compute() -> u32; | - expected 1 type parameter ... LL | fn compute<'x>() -> u32 { diff --git a/tests/ui/traits/const-traits/const_derives/derive-const-use.stderr b/tests/ui/traits/const-traits/const_derives/derive-const-use.stderr index 87ac78908bbaf..ce61eb9a1ab97 100644 --- a/tests/ui/traits/const-traits/const_derives/derive-const-use.stderr +++ b/tests/ui/traits/const-traits/const_derives/derive-const-use.stderr @@ -22,7 +22,7 @@ LL | #[derive_const(Default, PartialEq)] = note: marking a trait with `#[const_trait]` ensures all default method bodies are `const` = note: adding a non-const method body in the future would be a breaking change -error[E0277]: the trait bound `(): ~const PartialEq` is not satisfied +error[E0277]: the trait bound `(): [const] PartialEq` is not satisfied --> $DIR/derive-const-use.rs:16:14 | LL | #[derive_const(Default, PartialEq)] diff --git a/tests/ui/traits/const-traits/cross-crate.gatednc.stderr b/tests/ui/traits/const-traits/cross-crate.gatednc.stderr index 4d5abf643a8c2..1da519151182a 100644 --- a/tests/ui/traits/const-traits/cross-crate.gatednc.stderr +++ b/tests/ui/traits/const-traits/cross-crate.gatednc.stderr @@ -1,4 +1,4 @@ -error[E0277]: the trait bound `cross_crate::NonConst: ~const cross_crate::MyTrait` is not satisfied +error[E0277]: the trait bound `cross_crate::NonConst: [const] cross_crate::MyTrait` is not satisfied --> $DIR/cross-crate.rs:19:14 | LL | NonConst.func(); diff --git a/tests/ui/traits/const-traits/default-method-body-is-const-body-checking.rs b/tests/ui/traits/const-traits/default-method-body-is-const-body-checking.rs index 96acdc300e0dd..ea97f755d55c4 100644 --- a/tests/ui/traits/const-traits/default-method-body-is-const-body-checking.rs +++ b/tests/ui/traits/const-traits/default-method-body-is-const-body-checking.rs @@ -4,13 +4,13 @@ trait Tr {} impl Tr for () {} -const fn foo() where T: ~const Tr {} +const fn foo() where T: [const] Tr {} #[const_trait] pub trait Foo { fn foo() { foo::<()>(); - //~^ ERROR the trait bound `(): ~const Tr` is not satisfied + //~^ ERROR the trait bound `(): [const] Tr` is not satisfied } } diff --git a/tests/ui/traits/const-traits/default-method-body-is-const-body-checking.stderr b/tests/ui/traits/const-traits/default-method-body-is-const-body-checking.stderr index b3017523b27d0..2e236cecfb475 100644 --- a/tests/ui/traits/const-traits/default-method-body-is-const-body-checking.stderr +++ b/tests/ui/traits/const-traits/default-method-body-is-const-body-checking.stderr @@ -1,4 +1,4 @@ -error[E0277]: the trait bound `(): ~const Tr` is not satisfied +error[E0277]: the trait bound `(): [const] Tr` is not satisfied --> $DIR/default-method-body-is-const-body-checking.rs:12:15 | LL | foo::<()>(); @@ -7,8 +7,8 @@ LL | foo::<()>(); note: required by a bound in `foo` --> $DIR/default-method-body-is-const-body-checking.rs:7:28 | -LL | const fn foo() where T: ~const Tr {} - | ^^^^^^^^^ required by this bound in `foo` +LL | const fn foo() where T: [const] Tr {} + | ^^^^^^^^^^ required by this bound in `foo` error: aborting due to 1 previous error diff --git a/tests/ui/traits/const-traits/default-method-body-is-const-same-trait-ck.rs b/tests/ui/traits/const-traits/default-method-body-is-const-same-trait-ck.rs index b3beba08237c1..eb2c472e3bf7b 100644 --- a/tests/ui/traits/const-traits/default-method-body-is-const-same-trait-ck.rs +++ b/tests/ui/traits/const-traits/default-method-body-is-const-same-trait-ck.rs @@ -7,7 +7,7 @@ pub trait Tr { fn b(&self) { ().a() - //~^ ERROR the trait bound `(): ~const Tr` is not satisfied + //~^ ERROR the trait bound `(): [const] Tr` is not satisfied } } diff --git a/tests/ui/traits/const-traits/default-method-body-is-const-same-trait-ck.stderr b/tests/ui/traits/const-traits/default-method-body-is-const-same-trait-ck.stderr index 2bd71c940e736..2dc2d48461749 100644 --- a/tests/ui/traits/const-traits/default-method-body-is-const-same-trait-ck.stderr +++ b/tests/ui/traits/const-traits/default-method-body-is-const-same-trait-ck.stderr @@ -1,4 +1,4 @@ -error[E0277]: the trait bound `(): ~const Tr` is not satisfied +error[E0277]: the trait bound `(): [const] Tr` is not satisfied --> $DIR/default-method-body-is-const-same-trait-ck.rs:9:12 | LL | ().a() diff --git a/tests/ui/traits/const-traits/dont-ice-on-const-pred-for-bounds.rs b/tests/ui/traits/const-traits/dont-ice-on-const-pred-for-bounds.rs index 2295c2c3857c7..d39e661ed9205 100644 --- a/tests/ui/traits/const-traits/dont-ice-on-const-pred-for-bounds.rs +++ b/tests/ui/traits/const-traits/dont-ice-on-const-pred-for-bounds.rs @@ -13,7 +13,7 @@ trait Trait { type Assoc: const Trait; } -const fn needs_trait() {} +const fn needs_trait() {} fn test() { const { needs_trait::() }; diff --git a/tests/ui/traits/const-traits/dont-prefer-param-env-for-infer-self-ty.rs b/tests/ui/traits/const-traits/dont-prefer-param-env-for-infer-self-ty.rs index 08dcd7d80b344..f1fc98d72a547 100644 --- a/tests/ui/traits/const-traits/dont-prefer-param-env-for-infer-self-ty.rs +++ b/tests/ui/traits/const-traits/dont-prefer-param-env-for-infer-self-ty.rs @@ -5,11 +5,11 @@ #[const_trait] trait Foo {} -impl const Foo for (T,) where T: ~const Foo {} +impl const Foo for (T,) where T: [const] Foo {} -const fn needs_const_foo(_: impl ~const Foo + Copy) {} +const fn needs_const_foo(_: impl [const] Foo + Copy) {} -const fn test(t: T) { +const fn test(t: T) { needs_const_foo((t,)); } diff --git a/tests/ui/traits/const-traits/double-error-for-unimplemented-trait.rs b/tests/ui/traits/const-traits/double-error-for-unimplemented-trait.rs index f4b01efe95908..414b80ca0daab 100644 --- a/tests/ui/traits/const-traits/double-error-for-unimplemented-trait.rs +++ b/tests/ui/traits/const-traits/double-error-for-unimplemented-trait.rs @@ -7,7 +7,7 @@ trait Trait { type Out; } -const fn needs_const(_: &T) {} +const fn needs_const(_: &T) {} const IN_CONST: () = { needs_const(&()); diff --git a/tests/ui/traits/const-traits/double-error-for-unimplemented-trait.stderr b/tests/ui/traits/const-traits/double-error-for-unimplemented-trait.stderr index cd68cdaf8a2bf..740a05be06ba6 100644 --- a/tests/ui/traits/const-traits/double-error-for-unimplemented-trait.stderr +++ b/tests/ui/traits/const-traits/double-error-for-unimplemented-trait.stderr @@ -14,8 +14,8 @@ LL | trait Trait { note: required by a bound in `needs_const` --> $DIR/double-error-for-unimplemented-trait.rs:10:25 | -LL | const fn needs_const(_: &T) {} - | ^^^^^^^^^^^^ required by this bound in `needs_const` +LL | const fn needs_const(_: &T) {} + | ^^^^^^^^^^^^^ required by this bound in `needs_const` error[E0277]: the trait bound `(): Trait` is not satisfied --> $DIR/double-error-for-unimplemented-trait.rs:18:15 @@ -33,8 +33,8 @@ LL | trait Trait { note: required by a bound in `needs_const` --> $DIR/double-error-for-unimplemented-trait.rs:10:25 | -LL | const fn needs_const(_: &T) {} - | ^^^^^^^^^^^^ required by this bound in `needs_const` +LL | const fn needs_const(_: &T) {} + | ^^^^^^^^^^^^^ required by this bound in `needs_const` error: aborting due to 2 previous errors diff --git a/tests/ui/traits/const-traits/tilde-twice.rs b/tests/ui/traits/const-traits/duplicate-constness.rs similarity index 50% rename from tests/ui/traits/const-traits/tilde-twice.rs rename to tests/ui/traits/const-traits/duplicate-constness.rs index d341513b8a819..4b13abe3cf2ca 100644 --- a/tests/ui/traits/const-traits/tilde-twice.rs +++ b/tests/ui/traits/const-traits/duplicate-constness.rs @@ -2,5 +2,5 @@ #![feature(const_trait_impl)] -struct S; -//~^ ERROR expected identifier, found `~` +struct S; +//~^ ERROR expected identifier, found `]` diff --git a/tests/ui/traits/const-traits/duplicate-constness.stderr b/tests/ui/traits/const-traits/duplicate-constness.stderr new file mode 100644 index 0000000000000..27f69cd2386c6 --- /dev/null +++ b/tests/ui/traits/const-traits/duplicate-constness.stderr @@ -0,0 +1,8 @@ +error: expected identifier, found `]` + --> $DIR/duplicate-constness.rs:5:27 + | +LL | struct S; + | ^ expected identifier + +error: aborting due to 1 previous error + diff --git a/tests/ui/traits/const-traits/eval-bad-signature.rs b/tests/ui/traits/const-traits/eval-bad-signature.rs index 97c573ea6528d..66e296d438806 100644 --- a/tests/ui/traits/const-traits/eval-bad-signature.rs +++ b/tests/ui/traits/const-traits/eval-bad-signature.rs @@ -7,7 +7,7 @@ trait Value { fn value() -> u32; } -const fn get_value() -> u32 { +const fn get_value() -> u32 { T::value() } diff --git a/tests/ui/traits/const-traits/feature-gate.rs b/tests/ui/traits/const-traits/feature-gate.rs index 921dfb054e305..5ad56ddcd334e 100644 --- a/tests/ui/traits/const-traits/feature-gate.rs +++ b/tests/ui/traits/const-traits/feature-gate.rs @@ -10,12 +10,12 @@ trait T {} impl const T for S {} //[stock]~^ ERROR const trait impls are experimental -const fn f() {} //[stock]~ ERROR const trait impls are experimental +const fn f() {} //[stock]~ ERROR const trait impls are experimental fn g() {} //[stock]~ ERROR const trait impls are experimental macro_rules! discard { ($ty:ty) => {} } -discard! { impl ~const T } //[stock]~ ERROR const trait impls are experimental +discard! { impl [const] T } //[stock]~ ERROR const trait impls are experimental discard! { impl const T } //[stock]~ ERROR const trait impls are experimental fn main() {} diff --git a/tests/ui/traits/const-traits/feature-gate.stock.stderr b/tests/ui/traits/const-traits/feature-gate.stock.stderr index 78157d5705638..37d76e7f3879c 100644 --- a/tests/ui/traits/const-traits/feature-gate.stock.stderr +++ b/tests/ui/traits/const-traits/feature-gate.stock.stderr @@ -9,10 +9,10 @@ LL | impl const T for S {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: const trait impls are experimental - --> $DIR/feature-gate.rs:13:15 + --> $DIR/feature-gate.rs:13:13 | -LL | const fn f() {} - | ^^^^^^ +LL | const fn f() {} + | ^^^^^^^^^ | = note: see issue #67792 for more information = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable @@ -29,10 +29,10 @@ LL | fn g() {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: const trait impls are experimental - --> $DIR/feature-gate.rs:18:17 + --> $DIR/feature-gate.rs:18:12 | -LL | discard! { impl ~const T } - | ^^^^^^ +LL | discard! { impl [const] T } + | ^^^^^^^^^^^^ | = note: see issue #67792 for more information = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable diff --git a/tests/ui/traits/const-traits/function-pointer-does-not-require-const.rs b/tests/ui/traits/const-traits/function-pointer-does-not-require-const.rs index 61826e9977e85..8acd195e546b2 100644 --- a/tests/ui/traits/const-traits/function-pointer-does-not-require-const.rs +++ b/tests/ui/traits/const-traits/function-pointer-does-not-require-const.rs @@ -6,7 +6,7 @@ pub trait Test {} impl Test for () {} -pub const fn test() {} +pub const fn test() {} pub const fn min_by_i32() -> fn() { test::<()> diff --git a/tests/ui/traits/const-traits/ice-112822-expected-type-for-param.rs b/tests/ui/traits/const-traits/ice-112822-expected-type-for-param.rs index 4312d295b113b..026f2c0d60326 100644 --- a/tests/ui/traits/const-traits/ice-112822-expected-type-for-param.rs +++ b/tests/ui/traits/const-traits/ice-112822-expected-type-for-param.rs @@ -1,9 +1,9 @@ #![feature(const_trait_impl)] -const fn test() -> impl ~const Fn() { - //~^ ERROR `~const` can only be applied to `#[const_trait]` traits - //~| ERROR `~const` can only be applied to `#[const_trait]` traits - //~| ERROR `~const` can only be applied to `#[const_trait]` traits +const fn test() -> impl [const] Fn() { + //~^ ERROR `[const]` can only be applied to `#[const_trait]` traits + //~| ERROR `[const]` can only be applied to `#[const_trait]` traits + //~| ERROR `[const]` can only be applied to `#[const_trait]` traits const move || { //~ ERROR const closures are experimental let sl: &[u8] = b"foo"; diff --git a/tests/ui/traits/const-traits/ice-112822-expected-type-for-param.stderr b/tests/ui/traits/const-traits/ice-112822-expected-type-for-param.stderr index f06bacdeb4e27..f340eaab0e330 100644 --- a/tests/ui/traits/const-traits/ice-112822-expected-type-for-param.stderr +++ b/tests/ui/traits/const-traits/ice-112822-expected-type-for-param.stderr @@ -8,32 +8,32 @@ LL | const move || { = help: add `#![feature(const_closures)]` 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 - --> $DIR/ice-112822-expected-type-for-param.rs:3:25 +error: `[const]` can only be applied to `#[const_trait]` traits + --> $DIR/ice-112822-expected-type-for-param.rs:3:20 | -LL | const fn test() -> impl ~const Fn() { - | ^^^^^^ can't be applied to `Fn` +LL | const fn test() -> impl [const] Fn() { + | ^^^^^^^^^^^^ 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/ice-112822-expected-type-for-param.rs:3:25 +error: `[const]` can only be applied to `#[const_trait]` traits + --> $DIR/ice-112822-expected-type-for-param.rs:3:20 | -LL | const fn test() -> impl ~const Fn() { - | ^^^^^^ can't be applied to `Fn` +LL | const fn test() -> impl [const] Fn() { + | ^^^^^^^^^^^^ 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/ice-112822-expected-type-for-param.rs:3:25 +error: `[const]` can only be applied to `#[const_trait]` traits + --> $DIR/ice-112822-expected-type-for-param.rs:3:20 | -LL | const fn test() -> impl ~const Fn() { - | ^^^^^^ can't be applied to `Fn` +LL | const fn test() -> impl [const] Fn() { + | ^^^^^^^^^^^^ 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` diff --git a/tests/ui/traits/const-traits/ice-123664-unexpected-bound-var.rs b/tests/ui/traits/const-traits/ice-123664-unexpected-bound-var.rs index fadcaa3981670..f1dbd94716171 100644 --- a/tests/ui/traits/const-traits/ice-123664-unexpected-bound-var.rs +++ b/tests/ui/traits/const-traits/ice-123664-unexpected-bound-var.rs @@ -1,8 +1,8 @@ #![allow(incomplete_features)] #![feature(generic_const_exprs, const_trait_impl)] -const fn with_positive() {} -//~^ ERROR `~const` can only be applied to `#[const_trait]` traits -//~| ERROR `~const` can only be applied to `#[const_trait]` traits +const fn with_positive() {} +//~^ ERROR `[const]` can only be applied to `#[const_trait]` traits +//~| ERROR `[const]` can only be applied to `#[const_trait]` traits pub fn main() {} diff --git a/tests/ui/traits/const-traits/ice-123664-unexpected-bound-var.stderr b/tests/ui/traits/const-traits/ice-123664-unexpected-bound-var.stderr index 821b257af8807..d8d73173ec4c9 100644 --- a/tests/ui/traits/const-traits/ice-123664-unexpected-bound-var.stderr +++ b/tests/ui/traits/const-traits/ice-123664-unexpected-bound-var.stderr @@ -1,19 +1,19 @@ -error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/ice-123664-unexpected-bound-var.rs:4:27 +error: `[const]` can only be applied to `#[const_trait]` traits + --> $DIR/ice-123664-unexpected-bound-var.rs:4:25 | -LL | const fn with_positive() {} - | ^^^^^^ can't be applied to `Fn` +LL | const fn with_positive() {} + | ^^^^^^^^^ 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/ice-123664-unexpected-bound-var.rs:4:27 +error: `[const]` can only be applied to `#[const_trait]` traits + --> $DIR/ice-123664-unexpected-bound-var.rs:4:25 | -LL | const fn with_positive() {} - | ^^^^^^ can't be applied to `Fn` +LL | const fn with_positive() {} + | ^^^^^^^^^ 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` diff --git a/tests/ui/traits/const-traits/ice-124857-combine-effect-const-infer-vars.rs b/tests/ui/traits/const-traits/ice-124857-combine-effect-const-infer-vars.rs index d6df1714314aa..ea4db0515cd44 100644 --- a/tests/ui/traits/const-traits/ice-124857-combine-effect-const-infer-vars.rs +++ b/tests/ui/traits/const-traits/ice-124857-combine-effect-const-infer-vars.rs @@ -7,7 +7,7 @@ trait Foo {} impl const Foo for i32 {} -impl const Foo for T where T: ~const Foo {} +impl const Foo for T where T: [const] Foo {} //~^ ERROR conflicting implementations of trait `Foo` for type `i32` fn main() {} diff --git a/tests/ui/traits/const-traits/ice-124857-combine-effect-const-infer-vars.stderr b/tests/ui/traits/const-traits/ice-124857-combine-effect-const-infer-vars.stderr index 183c2c2cdf4a6..5b417dcfe2cb2 100644 --- a/tests/ui/traits/const-traits/ice-124857-combine-effect-const-infer-vars.stderr +++ b/tests/ui/traits/const-traits/ice-124857-combine-effect-const-infer-vars.stderr @@ -4,8 +4,8 @@ error[E0119]: conflicting implementations of trait `Foo` for type `i32` LL | impl const Foo for i32 {} | ---------------------- first implementation here LL | -LL | impl const Foo for T where T: ~const Foo {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `i32` +LL | impl const Foo for T where T: [const] Foo {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `i32` error: aborting due to 1 previous error diff --git a/tests/ui/traits/const-traits/impl-conditionally-const-trait.rs b/tests/ui/traits/const-traits/impl-conditionally-const-trait.rs new file mode 100644 index 0000000000000..f3783c9e69b2e --- /dev/null +++ b/tests/ui/traits/const-traits/impl-conditionally-const-trait.rs @@ -0,0 +1,12 @@ +//! This test ensures that we can only implement `const Trait` for a type +//! and not have the conditionally const syntax in that position. + +#![feature(const_trait_impl)] + +struct S; +trait T {} + +impl [const] T for S {} +//~^ ERROR expected identifier, found `]` + +fn main() {} diff --git a/tests/ui/traits/const-traits/impl-conditionally-const-trait.stderr b/tests/ui/traits/const-traits/impl-conditionally-const-trait.stderr new file mode 100644 index 0000000000000..fc8db61b9409d --- /dev/null +++ b/tests/ui/traits/const-traits/impl-conditionally-const-trait.stderr @@ -0,0 +1,8 @@ +error: expected identifier, found `]` + --> $DIR/impl-conditionally-const-trait.rs:9:12 + | +LL | impl [const] T for S {} + | ^ expected identifier + +error: aborting due to 1 previous error + diff --git a/tests/ui/traits/const-traits/impl-tilde-const-trait.rs b/tests/ui/traits/const-traits/impl-tilde-const-trait.rs deleted file mode 100644 index 05b26465c5b0c..0000000000000 --- a/tests/ui/traits/const-traits/impl-tilde-const-trait.rs +++ /dev/null @@ -1,9 +0,0 @@ -#![feature(const_trait_impl)] - -struct S; -trait T {} - -impl ~const T for S {} -//~^ ERROR expected a trait, found type - -fn main() {} diff --git a/tests/ui/traits/const-traits/impl-tilde-const-trait.stderr b/tests/ui/traits/const-traits/impl-tilde-const-trait.stderr deleted file mode 100644 index 4695728f8caac..0000000000000 --- a/tests/ui/traits/const-traits/impl-tilde-const-trait.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: expected a trait, found type - --> $DIR/impl-tilde-const-trait.rs:6:6 - | -LL | impl ~const T for S {} - | ^^^^^^^^ - -error: aborting due to 1 previous error - diff --git a/tests/ui/traits/const-traits/inherent-impl-const-bounds.rs b/tests/ui/traits/const-traits/inherent-impl-const-bounds.rs index 5ead1353bcd96..941f054280375 100644 --- a/tests/ui/traits/const-traits/inherent-impl-const-bounds.rs +++ b/tests/ui/traits/const-traits/inherent-impl-const-bounds.rs @@ -12,7 +12,7 @@ impl const A for S {} impl const B for S {} impl S { - const fn a() where T: ~const B { + const fn a() where T: [const] B { } } diff --git a/tests/ui/traits/const-traits/issue-100222.rs b/tests/ui/traits/const-traits/issue-100222.rs index 55722d35075a2..4c93272b224f8 100644 --- a/tests/ui/traits/const-traits/issue-100222.rs +++ b/tests/ui/traits/const-traits/issue-100222.rs @@ -11,21 +11,28 @@ pub trait Index { } #[cfg_attr(any(ny, yy), const_trait)] -pub trait IndexMut where Self: Index { +pub trait IndexMut +where + Self: Index, +{ const C: ::Output; type Assoc = ::Output; fn foo(&mut self, x: ::Output) -> ::Output; } -impl Index for () { type Output = (); } +impl Index for () { + type Output = (); +} #[cfg(not(any(nn, yn)))] impl const IndexMut for <() as Index>::Output { const C: ::Output = (); type Assoc = ::Output; fn foo(&mut self, x: ::Output) -> ::Output - where ::Output:, - {} + where + ::Output:, + { + } } #[cfg(any(nn, yn))] @@ -33,8 +40,10 @@ impl IndexMut for <() as Index>::Output { const C: ::Output = (); type Assoc = ::Output; fn foo(&mut self, x: ::Output) -> ::Output - where ::Output:, - {} + where + ::Output:, + { + } } const C: <() as Index>::Output = (); diff --git a/tests/ui/traits/const-traits/issue-92111.rs b/tests/ui/traits/const-traits/issue-92111.rs index c8db5cc9e7ad8..2450136793e0c 100644 --- a/tests/ui/traits/const-traits/issue-92111.rs +++ b/tests/ui/traits/const-traits/issue-92111.rs @@ -14,7 +14,7 @@ pub struct S(i32); impl Tr for S {} -const fn a(t: T) {} +const fn a(t: T) {} fn main() { a(S(0)); diff --git a/tests/ui/traits/const-traits/issue-92230-wf-super-trait-env.rs b/tests/ui/traits/const-traits/issue-92230-wf-super-trait-env.rs index a3edc5ff8b107..0eb7f54d596fb 100644 --- a/tests/ui/traits/const-traits/issue-92230-wf-super-trait-env.rs +++ b/tests/ui/traits/const-traits/issue-92230-wf-super-trait-env.rs @@ -10,7 +10,7 @@ pub trait Super {} #[const_trait] pub trait Sub: Super {} -impl const Super for &A where A: ~const Super {} -impl const Sub for &A where A: ~const Sub {} +impl const Super for &A where A: [const] Super {} +impl const Sub for &A where A: [const] Sub {} fn main() {} diff --git a/tests/ui/traits/const-traits/item-bound-entailment-fails.rs b/tests/ui/traits/const-traits/item-bound-entailment-fails.rs index f4bfcbda0ac44..029597ea1f032 100644 --- a/tests/ui/traits/const-traits/item-bound-entailment-fails.rs +++ b/tests/ui/traits/const-traits/item-bound-entailment-fails.rs @@ -2,27 +2,27 @@ #![feature(const_trait_impl)] #[const_trait] trait Foo { - type Assoc: ~const Bar + type Assoc: [const] Bar where - T: ~const Bar; + T: [const] Bar; } #[const_trait] trait Bar {} struct N(T); impl Bar for N where T: Bar {} struct C(T); -impl const Bar for C where T: ~const Bar {} +impl const Bar for C where T: [const] Bar {} impl const Foo for u32 { type Assoc = N - //~^ ERROR the trait bound `N: ~const Bar` is not satisfied + //~^ ERROR the trait bound `N: [const] Bar` is not satisfied where - T: ~const Bar; + T: [const] Bar; } impl const Foo for i32 { type Assoc = C - //~^ ERROR the trait bound `T: ~const Bar` is not satisfied + //~^ ERROR the trait bound `T: [const] Bar` is not satisfied where T: Bar; } diff --git a/tests/ui/traits/const-traits/item-bound-entailment-fails.stderr b/tests/ui/traits/const-traits/item-bound-entailment-fails.stderr index 7e72dc9abaa24..8e5894a32966f 100644 --- a/tests/ui/traits/const-traits/item-bound-entailment-fails.stderr +++ b/tests/ui/traits/const-traits/item-bound-entailment-fails.stderr @@ -1,4 +1,4 @@ -error[E0277]: the trait bound `N: ~const Bar` is not satisfied +error[E0277]: the trait bound `N: [const] Bar` is not satisfied --> $DIR/item-bound-entailment-fails.rs:17:21 | LL | type Assoc = N @@ -7,25 +7,25 @@ LL | type Assoc = N note: required by a bound in `Foo::Assoc` --> $DIR/item-bound-entailment-fails.rs:5:20 | -LL | type Assoc: ~const Bar - | ^^^^^^^^^^ required by this bound in `Foo::Assoc` +LL | type Assoc: [const] Bar + | ^^^^^^^^^^^ required by this bound in `Foo::Assoc` -error[E0277]: the trait bound `T: ~const Bar` is not satisfied +error[E0277]: the trait bound `T: [const] Bar` is not satisfied --> $DIR/item-bound-entailment-fails.rs:24:21 | LL | type Assoc = C | ^^^^ | -note: required for `C` to implement `~const Bar` +note: required for `C` to implement `[const] Bar` --> $DIR/item-bound-entailment-fails.rs:14:15 | -LL | impl const Bar for C where T: ~const Bar {} - | ^^^ ^^^^ ---------- unsatisfied trait bound introduced here +LL | impl const Bar for C where T: [const] Bar {} + | ^^^ ^^^^ ----------- unsatisfied trait bound introduced here note: required by a bound in `Foo::Assoc` --> $DIR/item-bound-entailment-fails.rs:5:20 | -LL | type Assoc: ~const Bar - | ^^^^^^^^^^ required by this bound in `Foo::Assoc` +LL | type Assoc: [const] Bar + | ^^^^^^^^^^^ required by this bound in `Foo::Assoc` error: aborting due to 2 previous errors diff --git a/tests/ui/traits/const-traits/item-bound-entailment.rs b/tests/ui/traits/const-traits/item-bound-entailment.rs index 11db57be81513..6e053adb3850d 100644 --- a/tests/ui/traits/const-traits/item-bound-entailment.rs +++ b/tests/ui/traits/const-traits/item-bound-entailment.rs @@ -4,16 +4,16 @@ #![feature(const_trait_impl)] #[const_trait] trait Foo { - type Assoc: ~const Bar + type Assoc: [const] Bar where - T: ~const Bar; + T: [const] Bar; } #[const_trait] trait Bar {} struct N(T); impl Bar for N where T: Bar {} struct C(T); -impl const Bar for C where T: ~const Bar {} +impl const Bar for C where T: [const] Bar {} impl Foo for u32 { type Assoc = N @@ -24,7 +24,7 @@ impl Foo for u32 { impl const Foo for i32 { type Assoc = C where - T: ~const Bar; + T: [const] Bar; } fn main() {} diff --git a/tests/ui/traits/const-traits/mbe-bare-trait-objects-const-trait-bounds.rs b/tests/ui/traits/const-traits/mbe-bare-trait-objects-const-trait-bounds.rs index 820d3d63b62d1..a5f6ae198f611 100644 --- a/tests/ui/traits/const-traits/mbe-bare-trait-objects-const-trait-bounds.rs +++ b/tests/ui/traits/const-traits/mbe-bare-trait-objects-const-trait-bounds.rs @@ -1,20 +1,24 @@ -// Ensure that we don't consider `const Trait` and `~const Trait` to +// Ensure that we don't consider `const Trait` to // match the macro fragment specifier `ty` as that would be a breaking // change theoretically speaking. Syntactically trait object types can // be "bare", i.e., lack the prefix `dyn`. // By contrast, `?Trait` *does* match `ty` and therefore an arm like // `?$Trait:path` would never be reached. // See `parser/macro/mbe-bare-trait-object-maybe-trait-bound.rs`. - -//@ check-pass +// `[const] Trait` is already an error for a `ty` fragment, +// so we do not need to prevent that. macro_rules! check { - ($Type:ty) => { compile_error!("ty"); }; + ($Type:ty) => { + compile_error!("ty"); + }; (const $Trait:path) => {}; - (~const $Trait:path) => {}; + ([const] $Trait:path) => {}; } check! { const Trait } -check! { ~const Trait } +check! { [const] Trait } +//~^ ERROR: expected identifier, found `]` +//~| ERROR: const trait impls are experimental fn main() {} diff --git a/tests/ui/traits/const-traits/mbe-bare-trait-objects-const-trait-bounds.stderr b/tests/ui/traits/const-traits/mbe-bare-trait-objects-const-trait-bounds.stderr new file mode 100644 index 0000000000000..56dad5301a4a3 --- /dev/null +++ b/tests/ui/traits/const-traits/mbe-bare-trait-objects-const-trait-bounds.stderr @@ -0,0 +1,22 @@ +error: expected identifier, found `]` + --> $DIR/mbe-bare-trait-objects-const-trait-bounds.rs:20:16 + | +LL | ($Type:ty) => { + | -------- while parsing argument for this `ty` macro fragment +... +LL | check! { [const] Trait } + | ^ expected identifier + +error[E0658]: const trait impls are experimental + --> $DIR/mbe-bare-trait-objects-const-trait-bounds.rs:20:11 + | +LL | check! { [const] Trait } + | ^^^^^ + | + = note: see issue #67792 for more information + = 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: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/traits/const-traits/minicore-deref-fail.rs b/tests/ui/traits/const-traits/minicore-deref-fail.rs index f4a7678a00926..d9b33fa040a08 100644 --- a/tests/ui/traits/const-traits/minicore-deref-fail.rs +++ b/tests/ui/traits/const-traits/minicore-deref-fail.rs @@ -11,10 +11,12 @@ use minicore::*; struct Ty; impl Deref for Ty { type Target = (); - fn deref(&self) -> &Self::Target { &() } + fn deref(&self) -> &Self::Target { + &() + } } const fn foo() { *Ty; - //~^ ERROR the trait bound `Ty: ~const minicore::Deref` is not satisfied + //~^ ERROR the trait bound `Ty: [const] minicore::Deref` is not satisfied } diff --git a/tests/ui/traits/const-traits/minicore-deref-fail.stderr b/tests/ui/traits/const-traits/minicore-deref-fail.stderr index a1f840114fc87..4329b235756be 100644 --- a/tests/ui/traits/const-traits/minicore-deref-fail.stderr +++ b/tests/ui/traits/const-traits/minicore-deref-fail.stderr @@ -1,5 +1,5 @@ -error[E0277]: the trait bound `Ty: ~const minicore::Deref` is not satisfied - --> $DIR/minicore-deref-fail.rs:18:5 +error[E0277]: the trait bound `Ty: [const] minicore::Deref` is not satisfied + --> $DIR/minicore-deref-fail.rs:20:5 | LL | *Ty; | ^^^ diff --git a/tests/ui/traits/const-traits/minicore-drop-fail.rs b/tests/ui/traits/const-traits/minicore-drop-fail.rs index 274e5db21c4f6..f3e7c7df4d419 100644 --- a/tests/ui/traits/const-traits/minicore-drop-fail.rs +++ b/tests/ui/traits/const-traits/minicore-drop-fail.rs @@ -19,7 +19,7 @@ impl Drop for NotDropImpl { impl Foo for () {} struct Conditional(T); -impl const Drop for Conditional where T: ~const Foo { +impl const Drop for Conditional where T: [const] Foo { fn drop(&mut self) {} } diff --git a/tests/ui/traits/const-traits/minicore-fn-fail.rs b/tests/ui/traits/const-traits/minicore-fn-fail.rs index ae1cbc6ca5885..d4cd41a51ca5c 100644 --- a/tests/ui/traits/const-traits/minicore-fn-fail.rs +++ b/tests/ui/traits/const-traits/minicore-fn-fail.rs @@ -8,14 +8,14 @@ extern crate minicore; use minicore::*; -const fn call_indirect(t: &T) { t() } +const fn call_indirect(t: &T) { t() } #[const_trait] trait Foo {} impl Foo for () {} -const fn foo() {} +const fn foo() {} const fn test() { call_indirect(&foo::<()>); - //~^ ERROR the trait bound `(): ~const Foo` is not satisfied + //~^ ERROR the trait bound `(): [const] Foo` is not satisfied } diff --git a/tests/ui/traits/const-traits/minicore-fn-fail.stderr b/tests/ui/traits/const-traits/minicore-fn-fail.stderr index 03c7ade87c011..c02a067774b56 100644 --- a/tests/ui/traits/const-traits/minicore-fn-fail.stderr +++ b/tests/ui/traits/const-traits/minicore-fn-fail.stderr @@ -1,4 +1,4 @@ -error[E0277]: the trait bound `(): ~const Foo` is not satisfied +error[E0277]: the trait bound `(): [const] Foo` is not satisfied --> $DIR/minicore-fn-fail.rs:19:19 | LL | call_indirect(&foo::<()>); @@ -9,8 +9,8 @@ LL | call_indirect(&foo::<()>); note: required by a bound in `call_indirect` --> $DIR/minicore-fn-fail.rs:11:27 | -LL | const fn call_indirect(t: &T) { t() } - | ^^^^^^^^^^^ required by this bound in `call_indirect` +LL | const fn call_indirect(t: &T) { t() } + | ^^^^^^^^^^^^ required by this bound in `call_indirect` error: aborting due to 1 previous error diff --git a/tests/ui/traits/const-traits/minicore-works.rs b/tests/ui/traits/const-traits/minicore-works.rs index c79b4fc07dfd6..ef08e84c02b81 100644 --- a/tests/ui/traits/const-traits/minicore-works.rs +++ b/tests/ui/traits/const-traits/minicore-works.rs @@ -21,7 +21,9 @@ const fn test_op() { let _y = Custom + Custom; } -const fn call_indirect(t: &T) { t() } +const fn call_indirect(t: &T) { + t() +} const fn call() { call_indirect(&call); diff --git a/tests/ui/traits/const-traits/mutually-exclusive-trait-bound-modifiers.rs b/tests/ui/traits/const-traits/mutually-exclusive-trait-bound-modifiers.rs index aaab8e819a39c..5f47778a1404f 100644 --- a/tests/ui/traits/const-traits/mutually-exclusive-trait-bound-modifiers.rs +++ b/tests/ui/traits/const-traits/mutually-exclusive-trait-bound-modifiers.rs @@ -1,13 +1,13 @@ #![feature(const_trait_impl)] -const fn maybe_const_maybe() {} -//~^ ERROR `~const` trait not allowed with `?` trait polarity modifier +const fn maybe_const_maybe() {} +//~^ ERROR `[const]` trait not allowed with `?` trait polarity modifier fn const_maybe() {} //~^ ERROR `const` trait not allowed with `?` trait polarity modifier -const fn maybe_const_negative() {} -//~^ ERROR `~const` trait not allowed with `!` trait polarity modifier +const fn maybe_const_negative() {} +//~^ ERROR `[const]` trait not allowed with `!` trait polarity modifier //~| ERROR negative bounds are not supported fn const_negative() {} diff --git a/tests/ui/traits/const-traits/mutually-exclusive-trait-bound-modifiers.stderr b/tests/ui/traits/const-traits/mutually-exclusive-trait-bound-modifiers.stderr index 18e4d160f5f46..429131f905f0e 100644 --- a/tests/ui/traits/const-traits/mutually-exclusive-trait-bound-modifiers.stderr +++ b/tests/ui/traits/const-traits/mutually-exclusive-trait-bound-modifiers.stderr @@ -1,10 +1,10 @@ -error: `~const` trait not allowed with `?` trait polarity modifier - --> $DIR/mutually-exclusive-trait-bound-modifiers.rs:3:38 +error: `[const]` trait not allowed with `?` trait polarity modifier + --> $DIR/mutually-exclusive-trait-bound-modifiers.rs:3:39 | -LL | const fn maybe_const_maybe() {} - | ------ ^ +LL | const fn maybe_const_maybe() {} + | ------- ^ | | - | there is not a well-defined meaning for a `~const ?` trait + | there is not a well-defined meaning for a `[const] ?` trait error: `const` trait not allowed with `?` trait polarity modifier --> $DIR/mutually-exclusive-trait-bound-modifiers.rs:6:25 @@ -14,13 +14,13 @@ LL | fn const_maybe() {} | | | there is not a well-defined meaning for a `const ?` trait -error: `~const` trait not allowed with `!` trait polarity modifier - --> $DIR/mutually-exclusive-trait-bound-modifiers.rs:9:41 +error: `[const]` trait not allowed with `!` trait polarity modifier + --> $DIR/mutually-exclusive-trait-bound-modifiers.rs:9:42 | -LL | const fn maybe_const_negative() {} - | ------ ^ +LL | const fn maybe_const_negative() {} + | ------- ^ | | - | there is not a well-defined meaning for a `~const !` trait + | there is not a well-defined meaning for a `[const] !` trait error: `const` trait not allowed with `!` trait polarity modifier --> $DIR/mutually-exclusive-trait-bound-modifiers.rs:13:28 @@ -31,10 +31,10 @@ LL | fn const_negative() {} | there is not a well-defined meaning for a `const !` trait error: negative bounds are not supported - --> $DIR/mutually-exclusive-trait-bound-modifiers.rs:9:41 + --> $DIR/mutually-exclusive-trait-bound-modifiers.rs:9:42 | -LL | const fn maybe_const_negative() {} - | ^ +LL | const fn maybe_const_negative() {} + | ^ error: negative bounds are not supported --> $DIR/mutually-exclusive-trait-bound-modifiers.rs:13:28 diff --git a/tests/ui/traits/const-traits/non-const-op-in-closure-in-const.rs b/tests/ui/traits/const-traits/non-const-op-in-closure-in-const.rs index 8f11c8a6e5576..86e3e5f769f8a 100644 --- a/tests/ui/traits/const-traits/non-const-op-in-closure-in-const.rs +++ b/tests/ui/traits/const-traits/non-const-op-in-closure-in-const.rs @@ -7,7 +7,7 @@ trait Convert { fn to(self) -> T; } -impl const Convert for A where B: ~const From { +impl const Convert for A where B: [const] From { fn to(self) -> B { B::from(self) } diff --git a/tests/ui/traits/const-traits/non-const-op-in-closure-in-const.stderr b/tests/ui/traits/const-traits/non-const-op-in-closure-in-const.stderr index 190af5e7c2dd1..8211b2b49bfd0 100644 --- a/tests/ui/traits/const-traits/non-const-op-in-closure-in-const.stderr +++ b/tests/ui/traits/const-traits/non-const-op-in-closure-in-const.stderr @@ -1,19 +1,19 @@ -error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/non-const-op-in-closure-in-const.rs:10:44 +error: `[const]` can only be applied to `#[const_trait]` traits + --> $DIR/non-const-op-in-closure-in-const.rs:10:42 | -LL | impl const Convert for A where B: ~const From { - | ^^^^^^ can't be applied to `From` +LL | impl const Convert for A where B: [const] From { + | ^^^^^^^^^ can't be applied to `From` | -note: `From` can't be used with `~const` because it isn't annotated with `#[const_trait]` +note: `From` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/convert/mod.rs:LL:COL -error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/non-const-op-in-closure-in-const.rs:10:44 +error: `[const]` can only be applied to `#[const_trait]` traits + --> $DIR/non-const-op-in-closure-in-const.rs:10:42 | -LL | impl const Convert for A where B: ~const From { - | ^^^^^^ can't be applied to `From` +LL | impl const Convert for A where B: [const] From { + | ^^^^^^^^^ can't be applied to `From` | -note: `From` can't be used with `~const` because it isn't annotated with `#[const_trait]` +note: `From` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/convert/mod.rs:LL:COL = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` diff --git a/tests/ui/traits/const-traits/overlap-const-with-nonconst.min_spec.stderr b/tests/ui/traits/const-traits/overlap-const-with-nonconst.min_spec.stderr index bd822970ad1ef..ed671bee63ab5 100644 --- a/tests/ui/traits/const-traits/overlap-const-with-nonconst.min_spec.stderr +++ b/tests/ui/traits/const-traits/overlap-const-with-nonconst.min_spec.stderr @@ -3,8 +3,8 @@ error[E0119]: conflicting implementations of trait `Foo` for type `(_,)` | LL | / impl const Foo for T LL | | where -LL | | T: ~const Bar, - | |__________________- first implementation here +LL | | T: [const] Bar, + | |___________________- first implementation here ... LL | impl Foo for (T,) { | ^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(_,)` diff --git a/tests/ui/traits/const-traits/overlap-const-with-nonconst.rs b/tests/ui/traits/const-traits/overlap-const-with-nonconst.rs index eb66d03faa638..f45690b2f78b9 100644 --- a/tests/ui/traits/const-traits/overlap-const-with-nonconst.rs +++ b/tests/ui/traits/const-traits/overlap-const-with-nonconst.rs @@ -15,7 +15,7 @@ trait Foo { } impl const Foo for T where - T: ~const Bar, + T: [const] Bar, { default fn method(&self) {} } @@ -27,7 +27,7 @@ impl Foo for (T,) { } } -const fn dispatch(t: T) { +const fn dispatch(t: T) { t.method(); } diff --git a/tests/ui/traits/const-traits/overlap-const-with-nonconst.spec.stderr b/tests/ui/traits/const-traits/overlap-const-with-nonconst.spec.stderr index cbdcb45f6beba..35f4d9184cf5b 100644 --- a/tests/ui/traits/const-traits/overlap-const-with-nonconst.spec.stderr +++ b/tests/ui/traits/const-traits/overlap-const-with-nonconst.spec.stderr @@ -13,8 +13,8 @@ error[E0119]: conflicting implementations of trait `Foo` for type `(_,)` | LL | / impl const Foo for T LL | | where -LL | | T: ~const Bar, - | |__________________- first implementation here +LL | | T: [const] Bar, + | |___________________- first implementation here ... LL | impl Foo for (T,) { | ^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(_,)` diff --git a/tests/ui/traits/const-traits/predicate-entailment-fails.rs b/tests/ui/traits/const-traits/predicate-entailment-fails.rs index 266a49f9e386d..0e6c277fd8220 100644 --- a/tests/ui/traits/const-traits/predicate-entailment-fails.rs +++ b/tests/ui/traits/const-traits/predicate-entailment-fails.rs @@ -6,9 +6,9 @@ impl const Bar for () {} #[const_trait] trait TildeConst { - type Bar where T: ~const Bar; + type Bar where T: [const] Bar; - fn foo() where T: ~const Bar; + fn foo() where T: [const] Bar; } impl TildeConst for () { type Bar = () where T: const Bar; @@ -32,10 +32,10 @@ impl NeverConst for i32 { //~^ ERROR impl has stricter requirements than trait } impl const NeverConst for u32 { - type Bar = () where T: ~const Bar; + type Bar = () where T: [const] Bar; //~^ ERROR impl has stricter requirements than trait - fn foo() where T: ~const Bar {} + fn foo() where T: [const] Bar {} //~^ ERROR impl has stricter requirements than trait } diff --git a/tests/ui/traits/const-traits/predicate-entailment-fails.stderr b/tests/ui/traits/const-traits/predicate-entailment-fails.stderr index dfdc4d232508f..cba7c979a42ae 100644 --- a/tests/ui/traits/const-traits/predicate-entailment-fails.stderr +++ b/tests/ui/traits/const-traits/predicate-entailment-fails.stderr @@ -1,7 +1,7 @@ error[E0276]: impl has stricter requirements than trait --> $DIR/predicate-entailment-fails.rs:14:31 | -LL | type Bar where T: ~const Bar; +LL | type Bar where T: [const] Bar; | ----------- definition of `Bar` from trait ... LL | type Bar = () where T: const Bar; @@ -10,8 +10,8 @@ LL | type Bar = () where T: const Bar; error[E0276]: impl has stricter requirements than trait --> $DIR/predicate-entailment-fails.rs:17:26 | -LL | fn foo() where T: ~const Bar; - | -------------------------------- definition of `foo` from trait +LL | fn foo() where T: [const] Bar; + | --------------------------------- definition of `foo` from trait ... LL | fn foo() where T: const Bar {} | ^^^^^^^^^ impl has extra requirement `T: const Bar` @@ -40,8 +40,8 @@ error[E0276]: impl has stricter requirements than trait LL | type Bar where T: Bar; | ----------- definition of `Bar` from trait ... -LL | type Bar = () where T: ~const Bar; - | ^^^^^^^^^^ impl has extra requirement `T: ~const Bar` +LL | type Bar = () where T: [const] Bar; + | ^^^^^^^^^^^ impl has extra requirement `T: [const] Bar` error[E0276]: impl has stricter requirements than trait --> $DIR/predicate-entailment-fails.rs:38:26 @@ -49,8 +49,8 @@ error[E0276]: impl has stricter requirements than trait LL | fn foo() where T: Bar; | ------------------------- definition of `foo` from trait ... -LL | fn foo() where T: ~const Bar {} - | ^^^^^^^^^^ impl has extra requirement `T: ~const Bar` +LL | fn foo() where T: [const] Bar {} + | ^^^^^^^^^^^ impl has extra requirement `T: [const] Bar` error: aborting due to 6 previous errors diff --git a/tests/ui/traits/const-traits/predicate-entailment-passes.rs b/tests/ui/traits/const-traits/predicate-entailment-passes.rs index 28ae21891f386..fe8714831866a 100644 --- a/tests/ui/traits/const-traits/predicate-entailment-passes.rs +++ b/tests/ui/traits/const-traits/predicate-entailment-passes.rs @@ -7,7 +7,7 @@ impl const Bar for () {} #[const_trait] trait TildeConst { - fn foo() where T: ~const Bar; + fn foo() where T: [const] Bar; } impl TildeConst for () { fn foo() where T: Bar {} @@ -21,7 +21,7 @@ impl AlwaysConst for i32 { fn foo() where T: Bar {} } impl const AlwaysConst for u32 { - fn foo() where T: ~const Bar {} + fn foo() where T: [const] Bar {} } fn main() {} diff --git a/tests/ui/traits/const-traits/specialization/const-default-bound-non-const-specialized-bound.rs b/tests/ui/traits/const-traits/specialization/const-default-bound-non-const-specialized-bound.rs index 5af9ee8614fd5..212d869d94d39 100644 --- a/tests/ui/traits/const-traits/specialization/const-default-bound-non-const-specialized-bound.rs +++ b/tests/ui/traits/const-traits/specialization/const-default-bound-non-const-specialized-bound.rs @@ -1,5 +1,5 @@ -// Tests that trait bounds on specializing trait impls must be `~const` if the -// same bound is present on the default impl and is `~const` there. +// Tests that trait bounds on specializing trait impls must be `[const]` if the +// same bound is present on the default impl and is `[const]` there. //@ known-bug: #110395 // FIXME(const_trait_impl) ^ should error @@ -20,14 +20,14 @@ trait Bar { impl const Bar for T where - T: ~const Foo, + T: [const] Foo, { default fn bar() {} } impl Bar for T where - T: Foo, //FIXME ~ ERROR missing `~const` qualifier + T: Foo, //FIXME ~ ERROR missing `[const]` qualifier T: Specialize, { fn bar() {} @@ -40,7 +40,7 @@ trait Baz { impl const Baz for T where - T: ~const Foo, + T: [const] Foo, { default fn baz() {} } diff --git a/tests/ui/traits/const-traits/specialization/const-default-bound-non-const-specialized-bound.stderr b/tests/ui/traits/const-traits/specialization/const-default-bound-non-const-specialized-bound.stderr index 9166b8ca5d22b..074e6237cc20d 100644 --- a/tests/ui/traits/const-traits/specialization/const-default-bound-non-const-specialized-bound.stderr +++ b/tests/ui/traits/const-traits/specialization/const-default-bound-non-const-specialized-bound.stderr @@ -3,12 +3,12 @@ error[E0119]: conflicting implementations of trait `Bar` | LL | / impl const Bar for T LL | | where -LL | | T: ~const Foo, - | |__________________- first implementation here +LL | | T: [const] Foo, + | |___________________- first implementation here ... LL | / impl Bar for T LL | | where -LL | | T: Foo, //FIXME ~ ERROR missing `~const` qualifier +LL | | T: Foo, //FIXME ~ ERROR missing `[const]` qualifier LL | | T: Specialize, | |__________________^ conflicting implementation @@ -17,8 +17,8 @@ error[E0119]: conflicting implementations of trait `Baz` | LL | / impl const Baz for T LL | | where -LL | | T: ~const Foo, - | |__________________- first implementation here +LL | | T: [const] Foo, + | |___________________- first implementation here ... LL | / impl const Baz for T //FIXME ~ ERROR conflicting implementations of trait `Baz` LL | | where diff --git a/tests/ui/traits/const-traits/specialization/const-default-const-specialized.rs b/tests/ui/traits/const-traits/specialization/const-default-const-specialized.rs index 89ad61c3c31c4..6991b7deda317 100644 --- a/tests/ui/traits/const-traits/specialization/const-default-const-specialized.rs +++ b/tests/ui/traits/const-traits/specialization/const-default-const-specialized.rs @@ -11,7 +11,7 @@ trait Value { fn value() -> u32; } -const fn get_value() -> u32 { +const fn get_value() -> u32 { T::value() } diff --git a/tests/ui/traits/const-traits/specialization/issue-95187-same-trait-bound-different-constness.rs b/tests/ui/traits/const-traits/specialization/issue-95187-same-trait-bound-different-constness.rs index d97469edaf97f..754f1c6d09d5d 100644 --- a/tests/ui/traits/const-traits/specialization/issue-95187-same-trait-bound-different-constness.rs +++ b/tests/ui/traits/const-traits/specialization/issue-95187-same-trait-bound-different-constness.rs @@ -1,4 +1,4 @@ -// Tests that `T: ~const Foo` in a specializing impl is treated as equivalent to +// Tests that `T: [const] Foo` in a specializing impl is treated as equivalent to // `T: Foo` in the default impl for the purposes of specialization (i.e., it // does not think that the user is attempting to specialize on trait `Foo`). @@ -28,7 +28,7 @@ where impl const Bar for T where - T: ~const Foo, + T: [const] Foo, T: Specialize, { fn bar() {} @@ -48,7 +48,7 @@ where impl const Baz for T where - T: ~const Foo, + T: [const] Foo, T: Specialize, { fn baz() {} diff --git a/tests/ui/traits/const-traits/specialization/non-const-default-const-specialized.rs b/tests/ui/traits/const-traits/specialization/non-const-default-const-specialized.rs index e9b494bc2c0d9..b1a1b4a239955 100644 --- a/tests/ui/traits/const-traits/specialization/non-const-default-const-specialized.rs +++ b/tests/ui/traits/const-traits/specialization/non-const-default-const-specialized.rs @@ -11,7 +11,7 @@ trait Value { fn value() -> u32; } -const fn get_value() -> u32 { +const fn get_value() -> u32 { T::value() } diff --git a/tests/ui/traits/const-traits/specialization/issue-95186-specialize-on-tilde-const.rs b/tests/ui/traits/const-traits/specialization/specialize-on-conditionally-const.rs similarity index 72% rename from tests/ui/traits/const-traits/specialization/issue-95186-specialize-on-tilde-const.rs rename to tests/ui/traits/const-traits/specialization/specialize-on-conditionally-const.rs index d80370aee8209..0106bb13875ac 100644 --- a/tests/ui/traits/const-traits/specialization/issue-95186-specialize-on-tilde-const.rs +++ b/tests/ui/traits/const-traits/specialization/specialize-on-conditionally-const.rs @@ -1,4 +1,5 @@ -// Tests that `~const` trait bounds can be used to specialize const trait impls. +// Tests that `[const]` trait bounds can be used to specialize const trait impls. +// cc #95186 //@ check-pass @@ -21,7 +22,7 @@ impl const Foo for T { impl const Foo for T where - T: ~const Specialize, + T: [const] Specialize, { fn foo() {} } @@ -33,15 +34,15 @@ trait Bar { impl const Bar for T where - T: ~const Foo, + T: [const] Foo, { default fn bar() {} } impl const Bar for T where - T: ~const Foo, - T: ~const Specialize, + T: [const] Foo, + T: [const] Specialize, { fn bar() {} } diff --git a/tests/ui/traits/const-traits/specializing-constness-2.rs b/tests/ui/traits/const-traits/specializing-constness-2.rs index c1fe42b975127..86c2cee9fedbc 100644 --- a/tests/ui/traits/const-traits/specializing-constness-2.rs +++ b/tests/ui/traits/const-traits/specializing-constness-2.rs @@ -17,7 +17,7 @@ impl A for T { } } -impl const A for T { +impl const A for T { fn a() -> u32 { 3 } @@ -25,7 +25,7 @@ impl const A for T { const fn generic() { ::a(); - //FIXME ~^ ERROR: the trait bound `T: ~const Sup` is not satisfied + //FIXME ~^ ERROR: the trait bound `T: [const] Sup` is not satisfied } fn main() {} diff --git a/tests/ui/traits/const-traits/specializing-constness-2.stderr b/tests/ui/traits/const-traits/specializing-constness-2.stderr index edba836aac354..850e6939daebc 100644 --- a/tests/ui/traits/const-traits/specializing-constness-2.stderr +++ b/tests/ui/traits/const-traits/specializing-constness-2.stderr @@ -1,4 +1,4 @@ -error[E0277]: the trait bound `T: ~const A` is not satisfied +error[E0277]: the trait bound `T: [const] A` is not satisfied --> $DIR/specializing-constness-2.rs:27:6 | LL | ::a(); diff --git a/tests/ui/traits/const-traits/specializing-constness.rs b/tests/ui/traits/const-traits/specializing-constness.rs index 94b6da7124d29..b64d8b21b24be 100644 --- a/tests/ui/traits/const-traits/specializing-constness.rs +++ b/tests/ui/traits/const-traits/specializing-constness.rs @@ -14,7 +14,7 @@ pub trait A { #[const_trait] pub trait Spec {} -impl const A for T { +impl const A for T { default fn a() -> u32 { 2 } diff --git a/tests/ui/traits/const-traits/specializing-constness.stderr b/tests/ui/traits/const-traits/specializing-constness.stderr index 2ca70b53e4e21..f411ebcdfcac5 100644 --- a/tests/ui/traits/const-traits/specializing-constness.stderr +++ b/tests/ui/traits/const-traits/specializing-constness.stderr @@ -1,8 +1,8 @@ error[E0119]: conflicting implementations of trait `A` --> $DIR/specializing-constness.rs:23:1 | -LL | impl const A for T { - | ---------------------------------- first implementation here +LL | impl const A for T { + | ----------------------------------- first implementation here ... LL | impl A for T { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation diff --git a/tests/ui/traits/const-traits/staged-api.rs b/tests/ui/traits/const-traits/staged-api.rs index bf09a5f780385..d24b26be569ca 100644 --- a/tests/ui/traits/const-traits/staged-api.rs +++ b/tests/ui/traits/const-traits/staged-api.rs @@ -23,7 +23,7 @@ impl const MyTrait for Foo { } #[rustc_allow_const_fn_unstable(const_trait_impl, unstable)] -const fn conditionally_const() { +const fn conditionally_const() { T::func(); } diff --git a/tests/ui/traits/const-traits/super-traits-fail-2.nn.stderr b/tests/ui/traits/const-traits/super-traits-fail-2.nn.stderr index 8f88e3aa8bc6d..11f73cbf0c9ce 100644 --- a/tests/ui/traits/const-traits/super-traits-fail-2.nn.stderr +++ b/tests/ui/traits/const-traits/super-traits-fail-2.nn.stderr @@ -1,31 +1,31 @@ -error: `~const` is not allowed here - --> $DIR/super-traits-fail-2.rs:11:12 +error: `[const]` is not allowed here + --> $DIR/super-traits-fail-2.rs:11:10 | -LL | trait Bar: ~const Foo {} - | ^^^^^^ +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 --> $DIR/super-traits-fail-2.rs:11:1 | -LL | trait Bar: ~const Foo {} - | ^^^^^^^^^^^^^^^^^^^^^^^^ +LL | trait Bar: [const] Foo {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/super-traits-fail-2.rs:11:12 +error: `[const]` can only be applied to `#[const_trait]` traits + --> $DIR/super-traits-fail-2.rs:11:10 | -LL | trait Bar: ~const Foo {} - | ^^^^^^ can't be applied to `Foo` +LL | trait Bar: [const] Foo {} + | ^^^^^^^^^ can't be applied to `Foo` | 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 - --> $DIR/super-traits-fail-2.rs:11:12 +error: `[const]` can only be applied to `#[const_trait]` traits + --> $DIR/super-traits-fail-2.rs:11:10 | -LL | trait Bar: ~const Foo {} - | ^^^^^^ can't be applied to `Foo` +LL | trait Bar: [const] Foo {} + | ^^^^^^^^^ can't be applied to `Foo` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations @@ -33,11 +33,11 @@ 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 - --> $DIR/super-traits-fail-2.rs:11:12 +error: `[const]` can only be applied to `#[const_trait]` traits + --> $DIR/super-traits-fail-2.rs:11:10 | -LL | trait Bar: ~const Foo {} - | ^^^^^^ can't be applied to `Foo` +LL | trait Bar: [const] Foo {} + | ^^^^^^^^^ can't be applied to `Foo` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations diff --git a/tests/ui/traits/const-traits/super-traits-fail-2.ny.stderr b/tests/ui/traits/const-traits/super-traits-fail-2.ny.stderr index 087e80de788e0..1767672e18049 100644 --- a/tests/ui/traits/const-traits/super-traits-fail-2.ny.stderr +++ b/tests/ui/traits/const-traits/super-traits-fail-2.ny.stderr @@ -1,19 +1,19 @@ -error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/super-traits-fail-2.rs:11:12 +error: `[const]` can only be applied to `#[const_trait]` traits + --> $DIR/super-traits-fail-2.rs:11:10 | -LL | trait Bar: ~const Foo {} - | ^^^^^^ can't be applied to `Foo` +LL | trait Bar: [const] Foo {} + | ^^^^^^^^^ can't be applied to `Foo` | 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 - --> $DIR/super-traits-fail-2.rs:11:12 +error: `[const]` can only be applied to `#[const_trait]` traits + --> $DIR/super-traits-fail-2.rs:11:10 | -LL | trait Bar: ~const Foo {} - | ^^^^^^ can't be applied to `Foo` +LL | trait Bar: [const] Foo {} + | ^^^^^^^^^ can't be applied to `Foo` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations @@ -21,11 +21,11 @@ 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 - --> $DIR/super-traits-fail-2.rs:11:12 +error: `[const]` can only be applied to `#[const_trait]` traits + --> $DIR/super-traits-fail-2.rs:11:10 | -LL | trait Bar: ~const Foo {} - | ^^^^^^ can't be applied to `Foo` +LL | trait Bar: [const] Foo {} + | ^^^^^^^^^ can't be applied to `Foo` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations @@ -33,11 +33,11 @@ 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 - --> $DIR/super-traits-fail-2.rs:11:12 +error: `[const]` can only be applied to `#[const_trait]` traits + --> $DIR/super-traits-fail-2.rs:11:10 | -LL | trait Bar: ~const Foo {} - | ^^^^^^ can't be applied to `Foo` +LL | trait Bar: [const] Foo {} + | ^^^^^^^^^ can't be applied to `Foo` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations @@ -45,11 +45,11 @@ 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 - --> $DIR/super-traits-fail-2.rs:11:12 +error: `[const]` can only be applied to `#[const_trait]` traits + --> $DIR/super-traits-fail-2.rs:11:10 | -LL | trait Bar: ~const Foo {} - | ^^^^^^ can't be applied to `Foo` +LL | trait Bar: [const] Foo {} + | ^^^^^^^^^ can't be applied to `Foo` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations diff --git a/tests/ui/traits/const-traits/super-traits-fail-2.rs b/tests/ui/traits/const-traits/super-traits-fail-2.rs index 6cc9d7394767a..781dacb81a197 100644 --- a/tests/ui/traits/const-traits/super-traits-fail-2.rs +++ b/tests/ui/traits/const-traits/super-traits-fail-2.rs @@ -8,17 +8,17 @@ trait Foo { } #[cfg_attr(any(yy, ny), const_trait)] -trait Bar: ~const Foo {} -//[ny,nn]~^ ERROR: `~const` can only be applied to `#[const_trait]` -//[ny,nn]~| ERROR: `~const` can only be applied to `#[const_trait]` -//[ny,nn]~| ERROR: `~const` can only be applied to `#[const_trait]` -//[ny]~| ERROR: `~const` can only be applied to `#[const_trait]` -//[ny]~| ERROR: `~const` can only be applied to `#[const_trait]` -//[yn,nn]~^^^^^^ ERROR: `~const` is not allowed here +trait Bar: [const] Foo {} +//[ny,nn]~^ ERROR: `[const]` can only be applied to `#[const_trait]` +//[ny,nn]~| ERROR: `[const]` can only be applied to `#[const_trait]` +//[ny,nn]~| ERROR: `[const]` can only be applied to `#[const_trait]` +//[ny]~| ERROR: `[const]` can only be applied to `#[const_trait]` +//[ny]~| ERROR: `[const]` can only be applied to `#[const_trait]` +//[yn,nn]~^^^^^^ ERROR: `[const]` is not allowed here const fn foo(x: &T) { x.a(); - //[yy,yn]~^ ERROR the trait bound `T: ~const Foo` + //[yy,yn]~^ ERROR the trait bound `T: [const] Foo` //[nn,ny]~^^ ERROR cannot call non-const method `::a` in constant functions } diff --git a/tests/ui/traits/const-traits/super-traits-fail-2.yn.stderr b/tests/ui/traits/const-traits/super-traits-fail-2.yn.stderr index ee49810bacec4..63c33a00234a6 100644 --- a/tests/ui/traits/const-traits/super-traits-fail-2.yn.stderr +++ b/tests/ui/traits/const-traits/super-traits-fail-2.yn.stderr @@ -1,16 +1,16 @@ -error: `~const` is not allowed here - --> $DIR/super-traits-fail-2.rs:11:12 +error: `[const]` is not allowed here + --> $DIR/super-traits-fail-2.rs:11:10 | -LL | trait Bar: ~const Foo {} - | ^^^^^^ +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 --> $DIR/super-traits-fail-2.rs:11:1 | -LL | trait Bar: ~const Foo {} - | ^^^^^^^^^^^^^^^^^^^^^^^^ +LL | trait Bar: [const] Foo {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0277]: the trait bound `T: ~const Foo` is not satisfied +error[E0277]: the trait bound `T: [const] Foo` is not satisfied --> $DIR/super-traits-fail-2.rs:20:7 | LL | x.a(); diff --git a/tests/ui/traits/const-traits/super-traits-fail-2.yy.stderr b/tests/ui/traits/const-traits/super-traits-fail-2.yy.stderr index a213273c1c78d..4ae4bbde99bb2 100644 --- a/tests/ui/traits/const-traits/super-traits-fail-2.yy.stderr +++ b/tests/ui/traits/const-traits/super-traits-fail-2.yy.stderr @@ -1,4 +1,4 @@ -error[E0277]: the trait bound `T: ~const Foo` is not satisfied +error[E0277]: the trait bound `T: [const] Foo` is not satisfied --> $DIR/super-traits-fail-2.rs:20:7 | LL | x.a(); diff --git a/tests/ui/traits/const-traits/super-traits-fail-3.nnn.stderr b/tests/ui/traits/const-traits/super-traits-fail-3.nnn.stderr index a5ef716a62a5d..c6a06d074c93c 100644 --- a/tests/ui/traits/const-traits/super-traits-fail-3.nnn.stderr +++ b/tests/ui/traits/const-traits/super-traits-fail-3.nnn.stderr @@ -1,51 +1,51 @@ -error: `~const` is not allowed here - --> $DIR/super-traits-fail-3.rs:23:12 +error: `[const]` is not allowed here + --> $DIR/super-traits-fail-3.rs:23:10 | -LL | trait Bar: ~const Foo {} - | ^^^^^^ +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 --> $DIR/super-traits-fail-3.rs:23:1 | -LL | trait Bar: ~const Foo {} - | ^^^^^^^^^^^^^^^^^^^^^^^^ +LL | trait Bar: [const] Foo {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0658]: const trait impls are experimental - --> $DIR/super-traits-fail-3.rs:23:12 + --> $DIR/super-traits-fail-3.rs:23:10 | -LL | trait Bar: ~const Foo {} - | ^^^^^^ +LL | trait Bar: [const] Foo {} + | ^^^^^^^^^ | = note: see issue #67792 for more information = 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[E0658]: const trait impls are experimental - --> $DIR/super-traits-fail-3.rs:32:17 + --> $DIR/super-traits-fail-3.rs:32:15 | -LL | const fn foo(x: &T) { - | ^^^^^^ +LL | const fn foo(x: &T) { + | ^^^^^^^^^ | = note: see issue #67792 for more information = 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 - --> $DIR/super-traits-fail-3.rs:23:12 +error: `[const]` can only be applied to `#[const_trait]` traits + --> $DIR/super-traits-fail-3.rs:23:10 | -LL | trait Bar: ~const Foo {} - | ^^^^^^ can't be applied to `Foo` +LL | trait Bar: [const] Foo {} + | ^^^^^^^^^ can't be applied to `Foo` | help: enable `#![feature(const_trait_impl)]` in your crate and 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 - --> $DIR/super-traits-fail-3.rs:23:12 +error: `[const]` can only be applied to `#[const_trait]` traits + --> $DIR/super-traits-fail-3.rs:23:10 | -LL | trait Bar: ~const Foo {} - | ^^^^^^ can't be applied to `Foo` +LL | trait Bar: [const] Foo {} + | ^^^^^^^^^ can't be applied to `Foo` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: enable `#![feature(const_trait_impl)]` in your crate and mark `Foo` as `#[const_trait]` to allow it to have `const` implementations @@ -53,11 +53,11 @@ 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 - --> $DIR/super-traits-fail-3.rs:23:12 +error: `[const]` can only be applied to `#[const_trait]` traits + --> $DIR/super-traits-fail-3.rs:23:10 | -LL | trait Bar: ~const Foo {} - | ^^^^^^ can't be applied to `Foo` +LL | trait Bar: [const] Foo {} + | ^^^^^^^^^ can't be applied to `Foo` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: enable `#![feature(const_trait_impl)]` in your crate and mark `Foo` as `#[const_trait]` to allow it to have `const` implementations @@ -65,27 +65,27 @@ 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 - --> $DIR/super-traits-fail-3.rs:32:17 +error: `[const]` can only be applied to `#[const_trait]` traits + --> $DIR/super-traits-fail-3.rs:32:15 | -LL | const fn foo(x: &T) { - | ^^^^^^ can't be applied to `Bar` +LL | const fn foo(x: &T) { + | ^^^^^^^^^ can't be applied to `Bar` | help: enable `#![feature(const_trait_impl)]` in your crate and mark `Bar` as `#[const_trait]` to allow it to have `const` implementations | -LL | #[const_trait] trait Bar: ~const Foo {} +LL | #[const_trait] trait Bar: [const] Foo {} | ++++++++++++++ -error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/super-traits-fail-3.rs:32:17 +error: `[const]` can only be applied to `#[const_trait]` traits + --> $DIR/super-traits-fail-3.rs:32:15 | -LL | const fn foo(x: &T) { - | ^^^^^^ can't be applied to `Bar` +LL | const fn foo(x: &T) { + | ^^^^^^^^^ can't be applied to `Bar` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: enable `#![feature(const_trait_impl)]` in your crate and mark `Bar` as `#[const_trait]` to allow it to have `const` implementations | -LL | #[const_trait] trait Bar: ~const Foo {} +LL | #[const_trait] trait Bar: [const] Foo {} | ++++++++++++++ error[E0015]: cannot call non-const method `::a` in constant functions diff --git a/tests/ui/traits/const-traits/super-traits-fail-3.nny.stderr b/tests/ui/traits/const-traits/super-traits-fail-3.nny.stderr index a5ef716a62a5d..c6a06d074c93c 100644 --- a/tests/ui/traits/const-traits/super-traits-fail-3.nny.stderr +++ b/tests/ui/traits/const-traits/super-traits-fail-3.nny.stderr @@ -1,51 +1,51 @@ -error: `~const` is not allowed here - --> $DIR/super-traits-fail-3.rs:23:12 +error: `[const]` is not allowed here + --> $DIR/super-traits-fail-3.rs:23:10 | -LL | trait Bar: ~const Foo {} - | ^^^^^^ +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 --> $DIR/super-traits-fail-3.rs:23:1 | -LL | trait Bar: ~const Foo {} - | ^^^^^^^^^^^^^^^^^^^^^^^^ +LL | trait Bar: [const] Foo {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0658]: const trait impls are experimental - --> $DIR/super-traits-fail-3.rs:23:12 + --> $DIR/super-traits-fail-3.rs:23:10 | -LL | trait Bar: ~const Foo {} - | ^^^^^^ +LL | trait Bar: [const] Foo {} + | ^^^^^^^^^ | = note: see issue #67792 for more information = 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[E0658]: const trait impls are experimental - --> $DIR/super-traits-fail-3.rs:32:17 + --> $DIR/super-traits-fail-3.rs:32:15 | -LL | const fn foo(x: &T) { - | ^^^^^^ +LL | const fn foo(x: &T) { + | ^^^^^^^^^ | = note: see issue #67792 for more information = 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 - --> $DIR/super-traits-fail-3.rs:23:12 +error: `[const]` can only be applied to `#[const_trait]` traits + --> $DIR/super-traits-fail-3.rs:23:10 | -LL | trait Bar: ~const Foo {} - | ^^^^^^ can't be applied to `Foo` +LL | trait Bar: [const] Foo {} + | ^^^^^^^^^ can't be applied to `Foo` | help: enable `#![feature(const_trait_impl)]` in your crate and 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 - --> $DIR/super-traits-fail-3.rs:23:12 +error: `[const]` can only be applied to `#[const_trait]` traits + --> $DIR/super-traits-fail-3.rs:23:10 | -LL | trait Bar: ~const Foo {} - | ^^^^^^ can't be applied to `Foo` +LL | trait Bar: [const] Foo {} + | ^^^^^^^^^ can't be applied to `Foo` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: enable `#![feature(const_trait_impl)]` in your crate and mark `Foo` as `#[const_trait]` to allow it to have `const` implementations @@ -53,11 +53,11 @@ 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 - --> $DIR/super-traits-fail-3.rs:23:12 +error: `[const]` can only be applied to `#[const_trait]` traits + --> $DIR/super-traits-fail-3.rs:23:10 | -LL | trait Bar: ~const Foo {} - | ^^^^^^ can't be applied to `Foo` +LL | trait Bar: [const] Foo {} + | ^^^^^^^^^ can't be applied to `Foo` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: enable `#![feature(const_trait_impl)]` in your crate and mark `Foo` as `#[const_trait]` to allow it to have `const` implementations @@ -65,27 +65,27 @@ 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 - --> $DIR/super-traits-fail-3.rs:32:17 +error: `[const]` can only be applied to `#[const_trait]` traits + --> $DIR/super-traits-fail-3.rs:32:15 | -LL | const fn foo(x: &T) { - | ^^^^^^ can't be applied to `Bar` +LL | const fn foo(x: &T) { + | ^^^^^^^^^ can't be applied to `Bar` | help: enable `#![feature(const_trait_impl)]` in your crate and mark `Bar` as `#[const_trait]` to allow it to have `const` implementations | -LL | #[const_trait] trait Bar: ~const Foo {} +LL | #[const_trait] trait Bar: [const] Foo {} | ++++++++++++++ -error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/super-traits-fail-3.rs:32:17 +error: `[const]` can only be applied to `#[const_trait]` traits + --> $DIR/super-traits-fail-3.rs:32:15 | -LL | const fn foo(x: &T) { - | ^^^^^^ can't be applied to `Bar` +LL | const fn foo(x: &T) { + | ^^^^^^^^^ can't be applied to `Bar` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: enable `#![feature(const_trait_impl)]` in your crate and mark `Bar` as `#[const_trait]` to allow it to have `const` implementations | -LL | #[const_trait] trait Bar: ~const Foo {} +LL | #[const_trait] trait Bar: [const] Foo {} | ++++++++++++++ error[E0015]: cannot call non-const method `::a` in constant functions diff --git a/tests/ui/traits/const-traits/super-traits-fail-3.nyn.stderr b/tests/ui/traits/const-traits/super-traits-fail-3.nyn.stderr index 024db4b6d68d0..feca029aa6cba 100644 --- a/tests/ui/traits/const-traits/super-traits-fail-3.nyn.stderr +++ b/tests/ui/traits/const-traits/super-traits-fail-3.nyn.stderr @@ -1,18 +1,18 @@ error[E0658]: const trait impls are experimental - --> $DIR/super-traits-fail-3.rs:23:12 + --> $DIR/super-traits-fail-3.rs:23:10 | -LL | trait Bar: ~const Foo {} - | ^^^^^^ +LL | trait Bar: [const] Foo {} + | ^^^^^^^^^ | = note: see issue #67792 for more information = 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[E0658]: const trait impls are experimental - --> $DIR/super-traits-fail-3.rs:32:17 + --> $DIR/super-traits-fail-3.rs:32:15 | -LL | const fn foo(x: &T) { - | ^^^^^^ +LL | const fn foo(x: &T) { + | ^^^^^^^^^ | = note: see issue #67792 for more information = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable diff --git a/tests/ui/traits/const-traits/super-traits-fail-3.nyy.stderr b/tests/ui/traits/const-traits/super-traits-fail-3.nyy.stderr index 024db4b6d68d0..feca029aa6cba 100644 --- a/tests/ui/traits/const-traits/super-traits-fail-3.nyy.stderr +++ b/tests/ui/traits/const-traits/super-traits-fail-3.nyy.stderr @@ -1,18 +1,18 @@ error[E0658]: const trait impls are experimental - --> $DIR/super-traits-fail-3.rs:23:12 + --> $DIR/super-traits-fail-3.rs:23:10 | -LL | trait Bar: ~const Foo {} - | ^^^^^^ +LL | trait Bar: [const] Foo {} + | ^^^^^^^^^ | = note: see issue #67792 for more information = 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[E0658]: const trait impls are experimental - --> $DIR/super-traits-fail-3.rs:32:17 + --> $DIR/super-traits-fail-3.rs:32:15 | -LL | const fn foo(x: &T) { - | ^^^^^^ +LL | const fn foo(x: &T) { + | ^^^^^^^^^ | = note: see issue #67792 for more information = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable diff --git a/tests/ui/traits/const-traits/super-traits-fail-3.rs b/tests/ui/traits/const-traits/super-traits-fail-3.rs index d7e0cdc26edd0..5370f607decb7 100644 --- a/tests/ui/traits/const-traits/super-traits-fail-3.rs +++ b/tests/ui/traits/const-traits/super-traits-fail-3.rs @@ -20,21 +20,21 @@ trait Foo { #[cfg_attr(any(yyy, yny, nyy, nyn), const_trait)] //[nyy,nyn]~^ ERROR: `const_trait` is a temporary placeholder for marking a trait that is suitable for `const` `impls` and all default bodies as `const`, which may be removed or renamed in the future -trait Bar: ~const Foo {} -//[yny,ynn,nny,nnn]~^ ERROR: `~const` can only be applied to `#[const_trait]` -//[yny,ynn,nny,nnn]~| ERROR: `~const` can only be applied to `#[const_trait]` -//[yny,ynn,nny,nnn]~| ERROR: `~const` can only be applied to `#[const_trait]` -//[yny]~^^^^ ERROR: `~const` can only be applied to `#[const_trait]` -//[yny]~| ERROR: `~const` can only be applied to `#[const_trait]` -//[yyn,ynn,nny,nnn]~^^^^^^ ERROR: `~const` is not allowed here +trait Bar: [const] Foo {} +//[yny,ynn,nny,nnn]~^ ERROR: `[const]` can only be applied to `#[const_trait]` +//[yny,ynn,nny,nnn]~| ERROR: `[const]` can only be applied to `#[const_trait]` +//[yny,ynn,nny,nnn]~| ERROR: `[const]` can only be applied to `#[const_trait]` +//[yny]~^^^^ ERROR: `[const]` can only be applied to `#[const_trait]` +//[yny]~| ERROR: `[const]` can only be applied to `#[const_trait]` +//[yyn,ynn,nny,nnn]~^^^^^^ ERROR: `[const]` is not allowed here //[nyy,nyn,nny,nnn]~^^^^^^^ ERROR: const trait impls are experimental -const fn foo(x: &T) { - //[yyn,ynn,nny,nnn]~^ ERROR: `~const` can only be applied to `#[const_trait]` - //[yyn,ynn,nny,nnn]~| ERROR: `~const` can only be applied to `#[const_trait]` +const fn foo(x: &T) { + //[yyn,ynn,nny,nnn]~^ ERROR: `[const]` can only be applied to `#[const_trait]` + //[yyn,ynn,nny,nnn]~| ERROR: `[const]` can only be applied to `#[const_trait]` //[nyy,nyn,nny,nnn]~^^^ ERROR: const trait impls are experimental x.a(); - //[yyn]~^ ERROR: the trait bound `T: ~const Foo` is not satisfied + //[yyn]~^ ERROR: the trait bound `T: [const] Foo` is not satisfied //[ynn,yny,nny,nnn]~^^ ERROR: cannot call non-const method `::a` in constant functions //[nyy,nyn]~^^^ ERROR: cannot call conditionally-const method `::a` in constant functions } diff --git a/tests/ui/traits/const-traits/super-traits-fail-3.ynn.stderr b/tests/ui/traits/const-traits/super-traits-fail-3.ynn.stderr index f22bdd472e538..d9112c91776db 100644 --- a/tests/ui/traits/const-traits/super-traits-fail-3.ynn.stderr +++ b/tests/ui/traits/const-traits/super-traits-fail-3.ynn.stderr @@ -1,31 +1,31 @@ -error: `~const` is not allowed here - --> $DIR/super-traits-fail-3.rs:23:12 +error: `[const]` is not allowed here + --> $DIR/super-traits-fail-3.rs:23:10 | -LL | trait Bar: ~const Foo {} - | ^^^^^^ +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 --> $DIR/super-traits-fail-3.rs:23:1 | -LL | trait Bar: ~const Foo {} - | ^^^^^^^^^^^^^^^^^^^^^^^^ +LL | trait Bar: [const] Foo {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/super-traits-fail-3.rs:23:12 +error: `[const]` can only be applied to `#[const_trait]` traits + --> $DIR/super-traits-fail-3.rs:23:10 | -LL | trait Bar: ~const Foo {} - | ^^^^^^ can't be applied to `Foo` +LL | trait Bar: [const] Foo {} + | ^^^^^^^^^ can't be applied to `Foo` | 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 - --> $DIR/super-traits-fail-3.rs:23:12 +error: `[const]` can only be applied to `#[const_trait]` traits + --> $DIR/super-traits-fail-3.rs:23:10 | -LL | trait Bar: ~const Foo {} - | ^^^^^^ can't be applied to `Foo` +LL | trait Bar: [const] Foo {} + | ^^^^^^^^^ can't be applied to `Foo` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations @@ -33,11 +33,11 @@ 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 - --> $DIR/super-traits-fail-3.rs:23:12 +error: `[const]` can only be applied to `#[const_trait]` traits + --> $DIR/super-traits-fail-3.rs:23:10 | -LL | trait Bar: ~const Foo {} - | ^^^^^^ can't be applied to `Foo` +LL | trait Bar: [const] Foo {} + | ^^^^^^^^^ can't be applied to `Foo` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations @@ -45,27 +45,27 @@ 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 - --> $DIR/super-traits-fail-3.rs:32:17 +error: `[const]` can only be applied to `#[const_trait]` traits + --> $DIR/super-traits-fail-3.rs:32:15 | -LL | const fn foo(x: &T) { - | ^^^^^^ can't be applied to `Bar` +LL | const fn foo(x: &T) { + | ^^^^^^^^^ can't be applied to `Bar` | help: mark `Bar` as `#[const_trait]` to allow it to have `const` implementations | -LL | #[const_trait] trait Bar: ~const Foo {} +LL | #[const_trait] trait Bar: [const] Foo {} | ++++++++++++++ -error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/super-traits-fail-3.rs:32:17 +error: `[const]` can only be applied to `#[const_trait]` traits + --> $DIR/super-traits-fail-3.rs:32:15 | -LL | const fn foo(x: &T) { - | ^^^^^^ can't be applied to `Bar` +LL | const fn foo(x: &T) { + | ^^^^^^^^^ can't be applied to `Bar` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: mark `Bar` as `#[const_trait]` to allow it to have `const` implementations | -LL | #[const_trait] trait Bar: ~const Foo {} +LL | #[const_trait] trait Bar: [const] Foo {} | ++++++++++++++ error[E0015]: cannot call non-const method `::a` in constant functions diff --git a/tests/ui/traits/const-traits/super-traits-fail-3.yny.stderr b/tests/ui/traits/const-traits/super-traits-fail-3.yny.stderr index 14b50815b8e9c..3520b61a81c94 100644 --- a/tests/ui/traits/const-traits/super-traits-fail-3.yny.stderr +++ b/tests/ui/traits/const-traits/super-traits-fail-3.yny.stderr @@ -1,19 +1,19 @@ -error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/super-traits-fail-3.rs:23:12 +error: `[const]` can only be applied to `#[const_trait]` traits + --> $DIR/super-traits-fail-3.rs:23:10 | -LL | trait Bar: ~const Foo {} - | ^^^^^^ can't be applied to `Foo` +LL | trait Bar: [const] Foo {} + | ^^^^^^^^^ can't be applied to `Foo` | 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 - --> $DIR/super-traits-fail-3.rs:23:12 +error: `[const]` can only be applied to `#[const_trait]` traits + --> $DIR/super-traits-fail-3.rs:23:10 | -LL | trait Bar: ~const Foo {} - | ^^^^^^ can't be applied to `Foo` +LL | trait Bar: [const] Foo {} + | ^^^^^^^^^ can't be applied to `Foo` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations @@ -21,11 +21,11 @@ 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 - --> $DIR/super-traits-fail-3.rs:23:12 +error: `[const]` can only be applied to `#[const_trait]` traits + --> $DIR/super-traits-fail-3.rs:23:10 | -LL | trait Bar: ~const Foo {} - | ^^^^^^ can't be applied to `Foo` +LL | trait Bar: [const] Foo {} + | ^^^^^^^^^ can't be applied to `Foo` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations @@ -33,11 +33,11 @@ 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 - --> $DIR/super-traits-fail-3.rs:23:12 +error: `[const]` can only be applied to `#[const_trait]` traits + --> $DIR/super-traits-fail-3.rs:23:10 | -LL | trait Bar: ~const Foo {} - | ^^^^^^ can't be applied to `Foo` +LL | trait Bar: [const] Foo {} + | ^^^^^^^^^ can't be applied to `Foo` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations @@ -45,11 +45,11 @@ 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 - --> $DIR/super-traits-fail-3.rs:23:12 +error: `[const]` can only be applied to `#[const_trait]` traits + --> $DIR/super-traits-fail-3.rs:23:10 | -LL | trait Bar: ~const Foo {} - | ^^^^^^ can't be applied to `Foo` +LL | trait Bar: [const] Foo {} + | ^^^^^^^^^ can't be applied to `Foo` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations diff --git a/tests/ui/traits/const-traits/super-traits-fail-3.yyn.stderr b/tests/ui/traits/const-traits/super-traits-fail-3.yyn.stderr index 3270611dace2e..d714118df6222 100644 --- a/tests/ui/traits/const-traits/super-traits-fail-3.yyn.stderr +++ b/tests/ui/traits/const-traits/super-traits-fail-3.yyn.stderr @@ -1,39 +1,39 @@ -error: `~const` is not allowed here - --> $DIR/super-traits-fail-3.rs:23:12 +error: `[const]` is not allowed here + --> $DIR/super-traits-fail-3.rs:23:10 | -LL | trait Bar: ~const Foo {} - | ^^^^^^ +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 --> $DIR/super-traits-fail-3.rs:23:1 | -LL | trait Bar: ~const Foo {} - | ^^^^^^^^^^^^^^^^^^^^^^^^ +LL | trait Bar: [const] Foo {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/super-traits-fail-3.rs:32:17 +error: `[const]` can only be applied to `#[const_trait]` traits + --> $DIR/super-traits-fail-3.rs:32:15 | -LL | const fn foo(x: &T) { - | ^^^^^^ can't be applied to `Bar` +LL | const fn foo(x: &T) { + | ^^^^^^^^^ can't be applied to `Bar` | help: mark `Bar` as `#[const_trait]` to allow it to have `const` implementations | -LL | #[const_trait] trait Bar: ~const Foo {} +LL | #[const_trait] trait Bar: [const] Foo {} | ++++++++++++++ -error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/super-traits-fail-3.rs:32:17 +error: `[const]` can only be applied to `#[const_trait]` traits + --> $DIR/super-traits-fail-3.rs:32:15 | -LL | const fn foo(x: &T) { - | ^^^^^^ can't be applied to `Bar` +LL | const fn foo(x: &T) { + | ^^^^^^^^^ can't be applied to `Bar` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: mark `Bar` as `#[const_trait]` to allow it to have `const` implementations | -LL | #[const_trait] trait Bar: ~const Foo {} +LL | #[const_trait] trait Bar: [const] Foo {} | ++++++++++++++ -error[E0277]: the trait bound `T: ~const Foo` is not satisfied +error[E0277]: the trait bound `T: [const] Foo` is not satisfied --> $DIR/super-traits-fail-3.rs:36:7 | LL | x.a(); diff --git a/tests/ui/traits/const-traits/super-traits-fail.rs b/tests/ui/traits/const-traits/super-traits-fail.rs index 9fd6263118bdc..15e05be4d8628 100644 --- a/tests/ui/traits/const-traits/super-traits-fail.rs +++ b/tests/ui/traits/const-traits/super-traits-fail.rs @@ -7,7 +7,7 @@ trait Foo { fn a(&self); } #[const_trait] -trait Bar: ~const Foo {} +trait Bar: [const] Foo {} struct S; impl Foo for S { diff --git a/tests/ui/traits/const-traits/super-traits-fail.stderr b/tests/ui/traits/const-traits/super-traits-fail.stderr index 1f453edf0359d..e19aa30cf95c3 100644 --- a/tests/ui/traits/const-traits/super-traits-fail.stderr +++ b/tests/ui/traits/const-traits/super-traits-fail.stderr @@ -1,4 +1,4 @@ -error[E0277]: the trait bound `S: ~const Foo` is not satisfied +error[E0277]: the trait bound `S: [const] Foo` is not satisfied --> $DIR/super-traits-fail.rs:17:20 | LL | impl const Bar for S {} diff --git a/tests/ui/traits/const-traits/super-traits.rs b/tests/ui/traits/const-traits/super-traits.rs index 73ddc037cd795..b5fd985ae439e 100644 --- a/tests/ui/traits/const-traits/super-traits.rs +++ b/tests/ui/traits/const-traits/super-traits.rs @@ -8,7 +8,7 @@ trait Foo { } #[const_trait] -trait Bar: ~const Foo {} +trait Bar: [const] Foo {} struct S; impl const Foo for S { @@ -17,7 +17,7 @@ impl const Foo for S { impl const Bar for S {} -const fn foo(t: &T) { +const fn foo(t: &T) { t.a(); } diff --git a/tests/ui/traits/const-traits/syntactical-unstable.rs b/tests/ui/traits/const-traits/syntactical-unstable.rs index e192e80fabd9e..5c542d327f151 100644 --- a/tests/ui/traits/const-traits/syntactical-unstable.rs +++ b/tests/ui/traits/const-traits/syntactical-unstable.rs @@ -1,6 +1,6 @@ //@ aux-build:staged-api.rs -// Ensure that we enforce const stability of traits in `~const`/`const` bounds. +// Ensure that we enforce const stability of traits in `[const]`/`const` bounds. #![feature(const_trait_impl)] @@ -10,19 +10,19 @@ extern crate staged_api; use staged_api::MyTrait; #[const_trait] -trait Foo: ~const MyTrait { +trait Foo: [const] MyTrait { //~^ ERROR use of unstable const library feature `unstable` - type Item: ~const MyTrait; + type Item: [const] MyTrait; //~^ ERROR use of unstable const library feature `unstable` } -const fn where_clause() where T: ~const MyTrait {} +const fn where_clause() where T: [const] MyTrait {} //~^ ERROR use of unstable const library feature `unstable` -const fn nested() where T: Deref {} +const fn nested() where T: Deref {} //~^ ERROR use of unstable const library feature `unstable` -const fn rpit() -> impl ~const MyTrait { Local } +const fn rpit() -> impl [const] MyTrait { Local } //~^ ERROR use of unstable const library feature `unstable` struct Local; diff --git a/tests/ui/traits/const-traits/syntactical-unstable.stderr b/tests/ui/traits/const-traits/syntactical-unstable.stderr index a2ce2f2b6e9d2..657773d91217e 100644 --- a/tests/ui/traits/const-traits/syntactical-unstable.stderr +++ b/tests/ui/traits/const-traits/syntactical-unstable.stderr @@ -1,43 +1,43 @@ error[E0658]: use of unstable const library feature `unstable` - --> $DIR/syntactical-unstable.rs:13:19 + --> $DIR/syntactical-unstable.rs:13:20 | -LL | trait Foo: ~const MyTrait { - | ------ ^^^^^^^ - | | - | trait is not stable as const yet +LL | trait Foo: [const] MyTrait { + | --------- ^^^^^^^ + | | + | trait is not stable as const yet | = help: add `#![feature(unstable)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: use of unstable const library feature `unstable` - --> $DIR/syntactical-unstable.rs:19:44 + --> $DIR/syntactical-unstable.rs:19:45 | -LL | const fn where_clause() where T: ~const MyTrait {} - | ------ ^^^^^^^ - | | - | trait is not stable as const yet +LL | const fn where_clause() where T: [const] MyTrait {} + | --------- ^^^^^^^ + | | + | trait is not stable as const yet | = help: add `#![feature(unstable)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: use of unstable const library feature `unstable` - --> $DIR/syntactical-unstable.rs:22:52 + --> $DIR/syntactical-unstable.rs:22:53 | -LL | const fn nested() where T: Deref {} - | ------ ^^^^^^^ - | | - | trait is not stable as const yet +LL | const fn nested() where T: Deref {} + | --------- ^^^^^^^ + | | + | trait is not stable as const yet | = help: add `#![feature(unstable)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: use of unstable const library feature `unstable` - --> $DIR/syntactical-unstable.rs:25:32 + --> $DIR/syntactical-unstable.rs:25:33 | -LL | const fn rpit() -> impl ~const MyTrait { Local } - | ------ ^^^^^^^ - | | - | trait is not stable as const yet +LL | const fn rpit() -> impl [const] MyTrait { Local } + | ------------ ^^^^^^^ + | | + | trait is not stable as const yet | = help: add `#![feature(unstable)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date @@ -52,12 +52,12 @@ LL | impl const MyTrait for Local { = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: use of unstable const library feature `unstable` - --> $DIR/syntactical-unstable.rs:15:23 + --> $DIR/syntactical-unstable.rs:15:24 | -LL | type Item: ~const MyTrait; - | ------ ^^^^^^^ - | | - | trait is not stable as const yet +LL | type Item: [const] MyTrait; + | --------- ^^^^^^^ + | | + | trait is not stable as const yet | = help: add `#![feature(unstable)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date diff --git a/tests/ui/traits/const-traits/syntax.rs b/tests/ui/traits/const-traits/syntax.rs index cfac6e0a93e38..b8e0f46e4f8f6 100644 --- a/tests/ui/traits/const-traits/syntax.rs +++ b/tests/ui/traits/const-traits/syntax.rs @@ -1,8 +1,9 @@ //@ compile-flags: -Z parse-crate-root-only -//@ check-pass -#![feature(const_trait_bound_opt_out)] #![feature(const_trait_impl)] -// For now, this parses since an error does not occur until AST lowering. -impl ~const T {} +// This is going down the slice/array parsing route +impl [const] T {} +//~^ ERROR: expected identifier, found `]` + +impl const T {} diff --git a/tests/ui/traits/const-traits/syntax.stderr b/tests/ui/traits/const-traits/syntax.stderr new file mode 100644 index 0000000000000..2e9807866b03b --- /dev/null +++ b/tests/ui/traits/const-traits/syntax.stderr @@ -0,0 +1,8 @@ +error: expected identifier, found `]` + --> $DIR/syntax.rs:6:12 + | +LL | impl [const] T {} + | ^ expected identifier + +error: aborting due to 1 previous error + diff --git a/tests/ui/traits/const-traits/tilde-const-and-const-params.stderr b/tests/ui/traits/const-traits/tilde-const-and-const-params.stderr deleted file mode 100644 index 95e684bd0c47d..0000000000000 --- a/tests/ui/traits/const-traits/tilde-const-and-const-params.stderr +++ /dev/null @@ -1,39 +0,0 @@ -error: `~const` is not allowed here - --> $DIR/tilde-const-and-const-params.rs:8:15 - | -LL | fn add(self) -> Foo<{ A::add(N) }> { - | ^^^^^^ - | -note: this function is not `const`, so it cannot have `~const` trait bounds - --> $DIR/tilde-const-and-const-params.rs:8:8 - | -LL | fn add(self) -> Foo<{ A::add(N) }> { - | ^^^ - -error: `~const` is not allowed here - --> $DIR/tilde-const-and-const-params.rs:26:11 - | -LL | fn bar(_: Foo) -> Foo<{ A::add(N) }> { - | ^^^^^^ - | -note: this function is not `const`, so it cannot have `~const` trait bounds - --> $DIR/tilde-const-and-const-params.rs:26:4 - | -LL | fn bar(_: Foo) -> Foo<{ A::add(N) }> { - | ^^^ - -error[E0277]: the trait bound `A: const Add42` is not satisfied - --> $DIR/tilde-const-and-const-params.rs:26:61 - | -LL | fn bar(_: Foo) -> Foo<{ A::add(N) }> { - | ^ - -error[E0277]: the trait bound `A: const Add42` is not satisfied - --> $DIR/tilde-const-and-const-params.rs:8:44 - | -LL | fn add(self) -> Foo<{ A::add(N) }> { - | ^ - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/const-traits/tilde-const-invalid-places.rs b/tests/ui/traits/const-traits/tilde-const-invalid-places.rs deleted file mode 100644 index 9d220686771ec..0000000000000 --- a/tests/ui/traits/const-traits/tilde-const-invalid-places.rs +++ /dev/null @@ -1,61 +0,0 @@ -#![feature(const_trait_impl)] - -#[const_trait] -trait Trait {} - -// Regression test for issue #90052. -fn non_const_function() {} //~ ERROR `~const` is not allowed - -struct Struct { field: T } //~ ERROR `~const` is not allowed here -struct TupleStruct(T); //~ ERROR `~const` is not allowed here -struct UnitStruct; //~ ERROR `~const` is not allowed here -//~^ ERROR parameter `T` is never used - -enum Enum { Variant(T) } //~ ERROR `~const` is not allowed here - -union Union { field: T } //~ ERROR `~const` is not allowed here -//~^ ERROR field must implement `Copy` - -type Type = T; //~ ERROR `~const` is not allowed here - -const CONSTANT: () = (); //~ ERROR `~const` is not allowed here -//~^ ERROR generic const items are experimental - -trait NonConstTrait { - type Type: ~const Trait; - //~^ ERROR `~const` is not allowed - //~| ERROR `~const` is not allowed - fn non_const_function(); //~ ERROR `~const` is not allowed - const CONSTANT: (); //~ ERROR `~const` is not allowed - //~^ ERROR generic const items are experimental -} - -impl NonConstTrait for () { - type Type = (); //~ ERROR `~const` is not allowed - //~^ ERROR overflow evaluating the requirement `(): Trait` - fn non_const_function() {} //~ ERROR `~const` is not allowed - const CONSTANT: () = (); //~ ERROR `~const` is not allowed - //~^ ERROR generic const items are experimental -} - -struct Implementor; - -impl Implementor { - type Type = (); //~ ERROR `~const` is not allowed - //~^ ERROR inherent associated types are unstable - fn non_const_function() {} //~ ERROR `~const` is not allowed - const CONSTANT: () = (); //~ ERROR `~const` is not allowed - //~^ ERROR generic const items are experimental -} - -// non-const traits -trait Child0: ~const Trait {} //~ ERROR `~const` is not allowed -trait Child1 where Self: ~const Trait {} //~ ERROR `~const` is not allowed - -// non-const impl -impl Trait for T {} //~ ERROR `~const` is not allowed - -// inherent impl (regression test for issue #117004) -impl Struct {} //~ ERROR `~const` is not allowed - -fn main() {} diff --git a/tests/ui/traits/const-traits/tilde-const-invalid-places.stderr b/tests/ui/traits/const-traits/tilde-const-invalid-places.stderr deleted file mode 100644 index 8151b9aaa23de..0000000000000 --- a/tests/ui/traits/const-traits/tilde-const-invalid-places.stderr +++ /dev/null @@ -1,310 +0,0 @@ -error: `~const` is not allowed here - --> $DIR/tilde-const-invalid-places.rs:7:26 - | -LL | fn non_const_function() {} - | ^^^^^^ - | -note: this function is not `const`, so it cannot have `~const` trait bounds - --> $DIR/tilde-const-invalid-places.rs:7:4 - | -LL | fn non_const_function() {} - | ^^^^^^^^^^^^^^^^^^ - -error: `~const` is not allowed here - --> $DIR/tilde-const-invalid-places.rs:9:18 - | -LL | struct Struct { field: T } - | ^^^^^^ - | - = note: this item cannot have `~const` trait bounds - -error: `~const` is not allowed here - --> $DIR/tilde-const-invalid-places.rs:10:23 - | -LL | struct TupleStruct(T); - | ^^^^^^ - | - = note: this item cannot have `~const` trait bounds - -error: `~const` is not allowed here - --> $DIR/tilde-const-invalid-places.rs:11:22 - | -LL | struct UnitStruct; - | ^^^^^^ - | - = note: this item cannot have `~const` trait bounds - -error: `~const` is not allowed here - --> $DIR/tilde-const-invalid-places.rs:14:14 - | -LL | enum Enum { Variant(T) } - | ^^^^^^ - | - = note: this item cannot have `~const` trait bounds - -error: `~const` is not allowed here - --> $DIR/tilde-const-invalid-places.rs:16:16 - | -LL | union Union { field: T } - | ^^^^^^ - | - = note: this item cannot have `~const` trait bounds - -error: `~const` is not allowed here - --> $DIR/tilde-const-invalid-places.rs:19:14 - | -LL | type Type = T; - | ^^^^^^ - | - = note: this item cannot have `~const` trait bounds - -error: `~const` is not allowed here - --> $DIR/tilde-const-invalid-places.rs:21:19 - | -LL | const CONSTANT: () = (); - | ^^^^^^ - | - = note: this item cannot have `~const` trait bounds - -error: `~const` is not allowed here - --> $DIR/tilde-const-invalid-places.rs:25:18 - | -LL | type Type: ~const Trait; - | ^^^^^^ - | -note: associated types in non-`#[const_trait]` traits cannot have `~const` trait bounds - --> $DIR/tilde-const-invalid-places.rs:25:5 - | -LL | type Type: ~const Trait; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: `~const` is not allowed here - --> $DIR/tilde-const-invalid-places.rs:25:33 - | -LL | type Type: ~const Trait; - | ^^^^^^ - | -note: associated types in non-`#[const_trait]` traits cannot have `~const` trait bounds - --> $DIR/tilde-const-invalid-places.rs:25:5 - | -LL | type Type: ~const Trait; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: `~const` is not allowed here - --> $DIR/tilde-const-invalid-places.rs:28:30 - | -LL | fn non_const_function(); - | ^^^^^^ - | -note: this function is not `const`, so it cannot have `~const` trait bounds - --> $DIR/tilde-const-invalid-places.rs:28:8 - | -LL | fn non_const_function(); - | ^^^^^^^^^^^^^^^^^^ - -error: `~const` is not allowed here - --> $DIR/tilde-const-invalid-places.rs:29:23 - | -LL | const CONSTANT: (); - | ^^^^^^ - | - = note: this item cannot have `~const` trait bounds - -error: `~const` is not allowed here - --> $DIR/tilde-const-invalid-places.rs:34:18 - | -LL | type Type = (); - | ^^^^^^ - | -note: associated types in non-const impls cannot have `~const` trait bounds - --> $DIR/tilde-const-invalid-places.rs:34:5 - | -LL | type Type = (); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: `~const` is not allowed here - --> $DIR/tilde-const-invalid-places.rs:36:30 - | -LL | fn non_const_function() {} - | ^^^^^^ - | -note: this function is not `const`, so it cannot have `~const` trait bounds - --> $DIR/tilde-const-invalid-places.rs:36:8 - | -LL | fn non_const_function() {} - | ^^^^^^^^^^^^^^^^^^ - -error: `~const` is not allowed here - --> $DIR/tilde-const-invalid-places.rs:37:23 - | -LL | const CONSTANT: () = (); - | ^^^^^^ - | - = note: this item cannot have `~const` trait bounds - -error: `~const` is not allowed here - --> $DIR/tilde-const-invalid-places.rs:44:18 - | -LL | type Type = (); - | ^^^^^^ - | -note: inherent associated types cannot have `~const` trait bounds - --> $DIR/tilde-const-invalid-places.rs:44:5 - | -LL | type Type = (); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: `~const` is not allowed here - --> $DIR/tilde-const-invalid-places.rs:46:30 - | -LL | fn non_const_function() {} - | ^^^^^^ - | -note: this function is not `const`, so it cannot have `~const` trait bounds - --> $DIR/tilde-const-invalid-places.rs:46:8 - | -LL | fn non_const_function() {} - | ^^^^^^^^^^^^^^^^^^ - -error: `~const` is not allowed here - --> $DIR/tilde-const-invalid-places.rs:47:23 - | -LL | const CONSTANT: () = (); - | ^^^^^^ - | - = note: this item cannot have `~const` trait bounds - -error: `~const` is not allowed here - --> $DIR/tilde-const-invalid-places.rs:52:15 - | -LL | trait Child0: ~const Trait {} - | ^^^^^^ - | -note: this trait is not a `#[const_trait]`, so it cannot have `~const` trait bounds - --> $DIR/tilde-const-invalid-places.rs:52:1 - | -LL | trait Child0: ~const Trait {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: `~const` is not allowed here - --> $DIR/tilde-const-invalid-places.rs:53:26 - | -LL | trait Child1 where Self: ~const Trait {} - | ^^^^^^ - | -note: this trait is not a `#[const_trait]`, so it cannot have `~const` trait bounds - --> $DIR/tilde-const-invalid-places.rs:53:1 - | -LL | trait Child1 where Self: ~const Trait {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: `~const` is not allowed here - --> $DIR/tilde-const-invalid-places.rs:56:9 - | -LL | impl Trait for T {} - | ^^^^^^ - | -note: this impl is not `const`, so it cannot have `~const` trait bounds - --> $DIR/tilde-const-invalid-places.rs:56:1 - | -LL | impl Trait for T {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: `~const` is not allowed here - --> $DIR/tilde-const-invalid-places.rs:59:9 - | -LL | impl Struct {} - | ^^^^^^ - | -note: inherent impls cannot have `~const` trait bounds - --> $DIR/tilde-const-invalid-places.rs:59:1 - | -LL | impl Struct {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0658]: generic const items are experimental - --> $DIR/tilde-const-invalid-places.rs:21:15 - | -LL | const CONSTANT: () = (); - | ^^^^^^^^^^^^^^^^^ - | - = note: see issue #113521 for more information - = help: add `#![feature(generic_const_items)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error[E0658]: generic const items are experimental - --> $DIR/tilde-const-invalid-places.rs:29:19 - | -LL | const CONSTANT: (); - | ^^^^^^^^^^^^^^^^^ - | - = note: see issue #113521 for more information - = help: add `#![feature(generic_const_items)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error[E0658]: generic const items are experimental - --> $DIR/tilde-const-invalid-places.rs:37:19 - | -LL | const CONSTANT: () = (); - | ^^^^^^^^^^^^^^^^^ - | - = note: see issue #113521 for more information - = help: add `#![feature(generic_const_items)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error[E0658]: generic const items are experimental - --> $DIR/tilde-const-invalid-places.rs:47:19 - | -LL | const CONSTANT: () = (); - | ^^^^^^^^^^^^^^^^^ - | - = note: see issue #113521 for more information - = help: add `#![feature(generic_const_items)]` 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[E0392]: type parameter `T` is never used - --> $DIR/tilde-const-invalid-places.rs:11:19 - | -LL | struct UnitStruct; - | ^ unused type parameter - | - = help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData` - -error[E0740]: field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union - --> $DIR/tilde-const-invalid-places.rs:16:32 - | -LL | union Union { field: T } - | ^^^^^^^^ - | - = note: union fields must not have drop side-effects, which is currently enforced via either `Copy` or `ManuallyDrop<...>` -help: wrap the field type in `ManuallyDrop<...>` - | -LL | union Union { field: std::mem::ManuallyDrop } - | +++++++++++++++++++++++ + - -error[E0275]: overflow evaluating the requirement `(): Trait` - --> $DIR/tilde-const-invalid-places.rs:34:34 - | -LL | type Type = (); - | ^^ - | -note: required by a bound in `NonConstTrait::Type` - --> $DIR/tilde-const-invalid-places.rs:25:33 - | -LL | type Type: ~const Trait; - | ^^^^^^^^^^^^ required by this bound in `NonConstTrait::Type` - -error[E0658]: inherent associated types are unstable - --> $DIR/tilde-const-invalid-places.rs:44:5 - | -LL | type Type = (); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #8995 for more information - = help: add `#![feature(inherent_associated_types)]` 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: aborting due to 30 previous errors - -Some errors have detailed explanations: E0275, E0392, E0658, E0740. -For more information about an error, try `rustc --explain E0275`. diff --git a/tests/ui/traits/const-traits/tilde-const-syntax.rs b/tests/ui/traits/const-traits/tilde-const-syntax.rs deleted file mode 100644 index f9944c426ccee..0000000000000 --- a/tests/ui/traits/const-traits/tilde-const-syntax.rs +++ /dev/null @@ -1,9 +0,0 @@ -//@ compile-flags: -Z parse-crate-root-only -//@ check-pass - -#![feature(const_trait_impl)] - -struct S< - T: for<'a> ~const Tr<'a> + 'static + ~const std::ops::Add, - T: for<'a: 'b> ~const m::Trait<'a>, ->; diff --git a/tests/ui/traits/const-traits/tilde-twice.stderr b/tests/ui/traits/const-traits/tilde-twice.stderr deleted file mode 100644 index a809736a4f824..0000000000000 --- a/tests/ui/traits/const-traits/tilde-twice.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: expected identifier, found `~` - --> $DIR/tilde-twice.rs:5:20 - | -LL | struct S; - | ^ expected identifier - -error: aborting due to 1 previous error - diff --git a/tests/ui/traits/const-traits/trait-where-clause-const.rs b/tests/ui/traits/const-traits/trait-where-clause-const.rs index 6f281ca571805..ccb514086cc87 100644 --- a/tests/ui/traits/const-traits/trait-where-clause-const.rs +++ b/tests/ui/traits/const-traits/trait-where-clause-const.rs @@ -12,11 +12,11 @@ trait Bar {} #[const_trait] trait Foo { fn a(); - fn b() where Self: ~const Bar; - fn c(); + fn b() where Self: [const] Bar; + fn c(); } -const fn test1() { +const fn test1() { T::a(); T::b(); //~^ ERROR the trait bound @@ -24,7 +24,7 @@ const fn test1() { //~^ ERROR the trait bound } -const fn test2() { +const fn test2() { T::a(); T::b(); T::c::(); diff --git a/tests/ui/traits/const-traits/trait-where-clause-const.stderr b/tests/ui/traits/const-traits/trait-where-clause-const.stderr index 4ebd7b9757fe7..71f9bdff8786e 100644 --- a/tests/ui/traits/const-traits/trait-where-clause-const.stderr +++ b/tests/ui/traits/const-traits/trait-where-clause-const.stderr @@ -1,4 +1,4 @@ -error[E0277]: the trait bound `T: ~const Bar` is not satisfied +error[E0277]: the trait bound `T: [const] Bar` is not satisfied --> $DIR/trait-where-clause-const.rs:21:5 | LL | T::b(); @@ -7,10 +7,10 @@ LL | T::b(); note: required by a bound in `Foo::b` --> $DIR/trait-where-clause-const.rs:15:24 | -LL | fn b() where Self: ~const Bar; - | ^^^^^^^^^^ required by this bound in `Foo::b` +LL | fn b() where Self: [const] Bar; + | ^^^^^^^^^^^ required by this bound in `Foo::b` -error[E0277]: the trait bound `T: ~const Bar` is not satisfied +error[E0277]: the trait bound `T: [const] Bar` is not satisfied --> $DIR/trait-where-clause-const.rs:23:12 | LL | T::c::(); @@ -19,8 +19,8 @@ LL | T::c::(); note: required by a bound in `Foo::c` --> $DIR/trait-where-clause-const.rs:16:13 | -LL | fn c(); - | ^^^^^^^^^^ required by this bound in `Foo::c` +LL | fn c(); + | ^^^^^^^^^^^ required by this bound in `Foo::c` error: aborting due to 2 previous errors diff --git a/tests/ui/traits/const-traits/trait-where-clause-run.rs b/tests/ui/traits/const-traits/trait-where-clause-run.rs index 2582a69acab20..c40f071f45728 100644 --- a/tests/ui/traits/const-traits/trait-where-clause-run.rs +++ b/tests/ui/traits/const-traits/trait-where-clause-run.rs @@ -10,7 +10,7 @@ trait Bar { #[const_trait] trait Foo { - fn foo() -> u8 where Self: ~const Bar { + fn foo() -> u8 where Self: [const] Bar { ::bar() * 6 } } diff --git a/tests/ui/traits/const-traits/trait-where-clause-self-referential.rs b/tests/ui/traits/const-traits/trait-where-clause-self-referential.rs index b6ac574a4fcd8..3a5350cd4ea3d 100644 --- a/tests/ui/traits/const-traits/trait-where-clause-self-referential.rs +++ b/tests/ui/traits/const-traits/trait-where-clause-self-referential.rs @@ -4,7 +4,7 @@ #[const_trait] trait Foo { - fn bar() where Self: ~const Foo; + fn bar() where Self: [const] Foo; } struct S; @@ -17,7 +17,7 @@ fn baz() { T::bar(); } -const fn qux() { +const fn qux() { T::bar(); } diff --git a/tests/ui/traits/const-traits/trait-where-clause.rs b/tests/ui/traits/const-traits/trait-where-clause.rs index 11f353f3f8ad3..6aebab79090a9 100644 --- a/tests/ui/traits/const-traits/trait-where-clause.rs +++ b/tests/ui/traits/const-traits/trait-where-clause.rs @@ -5,10 +5,10 @@ trait Bar {} trait Foo { fn a(); - fn b() where Self: ~const Bar; - //~^ ERROR `~const` is not allowed here - fn c(); - //~^ ERROR `~const` is not allowed here + fn b() where Self: [const] Bar; + //~^ ERROR `[const]` is not allowed here + fn c(); + //~^ ERROR `[const]` is not allowed here } fn test1() { diff --git a/tests/ui/traits/const-traits/trait-where-clause.stderr b/tests/ui/traits/const-traits/trait-where-clause.stderr index 3a15cc63f3223..04c67903ef50d 100644 --- a/tests/ui/traits/const-traits/trait-where-clause.stderr +++ b/tests/ui/traits/const-traits/trait-where-clause.stderr @@ -1,25 +1,25 @@ -error: `~const` is not allowed here - --> $DIR/trait-where-clause.rs:8:24 +error: `[const]` is not allowed here + --> $DIR/trait-where-clause.rs:8:22 | -LL | fn b() where Self: ~const Bar; - | ^^^^^^ +LL | fn b() where Self: [const] Bar; + | ^^^^^^^^^ | -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/trait-where-clause.rs:8:8 | -LL | fn b() where Self: ~const Bar; +LL | fn b() where Self: [const] Bar; | ^ -error: `~const` is not allowed here - --> $DIR/trait-where-clause.rs:10:13 +error: `[const]` is not allowed here + --> $DIR/trait-where-clause.rs:10:11 | -LL | fn c(); - | ^^^^^^ +LL | fn c(); + | ^^^^^^^^^ | -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/trait-where-clause.rs:10:8 | -LL | fn c(); +LL | fn c(); | ^ error[E0277]: the trait bound `T: Bar` is not satisfied @@ -31,8 +31,8 @@ LL | T::b(); note: required by a bound in `Foo::b` --> $DIR/trait-where-clause.rs:8:24 | -LL | fn b() where Self: ~const Bar; - | ^^^^^^^^^^ required by this bound in `Foo::b` +LL | fn b() where Self: [const] Bar; + | ^^^^^^^^^^^ required by this bound in `Foo::b` help: consider further restricting type parameter `T` with trait `Bar` | LL | fn test1() { @@ -47,8 +47,8 @@ LL | T::c::(); note: required by a bound in `Foo::c` --> $DIR/trait-where-clause.rs:10:13 | -LL | fn c(); - | ^^^^^^^^^^ required by this bound in `Foo::c` +LL | fn c(); + | ^^^^^^^^^^^ required by this bound in `Foo::c` help: consider further restricting type parameter `T` with trait `Bar` | LL | fn test1() { diff --git a/tests/ui/traits/const-traits/unsatisfied-const-trait-bound.rs b/tests/ui/traits/const-traits/unsatisfied-const-trait-bound.rs index 6d19ef771af1f..c82b442750097 100644 --- a/tests/ui/traits/const-traits/unsatisfied-const-trait-bound.rs +++ b/tests/ui/traits/const-traits/unsatisfied-const-trait-bound.rs @@ -29,5 +29,5 @@ struct Container; fn accept0(_: Container<{ T::make() }>) {} // FIXME(const_trait_impl): Instead of suggesting `+ const Trait`, suggest -// changing `~const Trait` to `const Trait`. -const fn accept1(_: Container<{ T::make() }>) {} +// changing `[const] Trait` to `const Trait`. +const fn accept1(_: Container<{ T::make() }>) {} diff --git a/tests/ui/traits/const-traits/unsatisfied-const-trait-bound.stderr b/tests/ui/traits/const-traits/unsatisfied-const-trait-bound.stderr index 03e26615d7edc..9b536b801823e 100644 --- a/tests/ui/traits/const-traits/unsatisfied-const-trait-bound.stderr +++ b/tests/ui/traits/const-traits/unsatisfied-const-trait-bound.stderr @@ -71,67 +71,67 @@ LL | fn accept0(_: Container<{ T::make() }>) {} = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error[E0391]: cycle detected when caching mir of `accept1::{constant#0}` for CTFE - --> $DIR/unsatisfied-const-trait-bound.rs:33:48 + --> $DIR/unsatisfied-const-trait-bound.rs:33:49 | -LL | const fn accept1(_: Container<{ T::make() }>) {} - | ^^^^^^^^^^^^^ +LL | const fn accept1(_: Container<{ T::make() }>) {} + | ^^^^^^^^^^^^^ | note: ...which requires elaborating drops for `accept1::{constant#0}`... - --> $DIR/unsatisfied-const-trait-bound.rs:33:48 + --> $DIR/unsatisfied-const-trait-bound.rs:33:49 | -LL | const fn accept1(_: Container<{ T::make() }>) {} - | ^^^^^^^^^^^^^ +LL | const fn accept1(_: Container<{ T::make() }>) {} + | ^^^^^^^^^^^^^ note: ...which requires borrow-checking `accept1::{constant#0}`... - --> $DIR/unsatisfied-const-trait-bound.rs:33:48 + --> $DIR/unsatisfied-const-trait-bound.rs:33:49 | -LL | const fn accept1(_: Container<{ T::make() }>) {} - | ^^^^^^^^^^^^^ +LL | const fn accept1(_: Container<{ T::make() }>) {} + | ^^^^^^^^^^^^^ note: ...which requires promoting constants in MIR for `accept1::{constant#0}`... - --> $DIR/unsatisfied-const-trait-bound.rs:33:48 + --> $DIR/unsatisfied-const-trait-bound.rs:33:49 | -LL | const fn accept1(_: Container<{ T::make() }>) {} - | ^^^^^^^^^^^^^ +LL | const fn accept1(_: Container<{ T::make() }>) {} + | ^^^^^^^^^^^^^ note: ...which requires const checking `accept1::{constant#0}`... - --> $DIR/unsatisfied-const-trait-bound.rs:33:48 + --> $DIR/unsatisfied-const-trait-bound.rs:33:49 | -LL | const fn accept1(_: Container<{ T::make() }>) {} - | ^^^^^^^^^^^^^ +LL | const fn accept1(_: Container<{ T::make() }>) {} + | ^^^^^^^^^^^^^ note: ...which requires building MIR for `accept1::{constant#0}`... - --> $DIR/unsatisfied-const-trait-bound.rs:33:48 + --> $DIR/unsatisfied-const-trait-bound.rs:33:49 | -LL | const fn accept1(_: Container<{ T::make() }>) {} - | ^^^^^^^^^^^^^ +LL | const fn accept1(_: Container<{ T::make() }>) {} + | ^^^^^^^^^^^^^ note: ...which requires building an abstract representation for `accept1::{constant#0}`... - --> $DIR/unsatisfied-const-trait-bound.rs:33:48 + --> $DIR/unsatisfied-const-trait-bound.rs:33:49 | -LL | const fn accept1(_: Container<{ T::make() }>) {} - | ^^^^^^^^^^^^^ +LL | const fn accept1(_: Container<{ T::make() }>) {} + | ^^^^^^^^^^^^^ note: ...which requires building THIR for `accept1::{constant#0}`... - --> $DIR/unsatisfied-const-trait-bound.rs:33:48 + --> $DIR/unsatisfied-const-trait-bound.rs:33:49 | -LL | const fn accept1(_: Container<{ T::make() }>) {} - | ^^^^^^^^^^^^^ +LL | const fn accept1(_: Container<{ T::make() }>) {} + | ^^^^^^^^^^^^^ note: ...which requires type-checking `accept1::{constant#0}`... - --> $DIR/unsatisfied-const-trait-bound.rs:33:48 + --> $DIR/unsatisfied-const-trait-bound.rs:33:49 | -LL | const fn accept1(_: Container<{ T::make() }>) {} - | ^^^^^^^^^^^^^ +LL | const fn accept1(_: Container<{ T::make() }>) {} + | ^^^^^^^^^^^^^ note: ...which requires evaluating type-level constant... - --> $DIR/unsatisfied-const-trait-bound.rs:33:48 + --> $DIR/unsatisfied-const-trait-bound.rs:33:49 | -LL | const fn accept1(_: Container<{ T::make() }>) {} - | ^^^^^^^^^^^^^ +LL | const fn accept1(_: Container<{ T::make() }>) {} + | ^^^^^^^^^^^^^ note: ...which requires const-evaluating + checking `accept1::{constant#0}`... - --> $DIR/unsatisfied-const-trait-bound.rs:33:48 + --> $DIR/unsatisfied-const-trait-bound.rs:33:49 | -LL | const fn accept1(_: Container<{ T::make() }>) {} - | ^^^^^^^^^^^^^ +LL | const fn accept1(_: Container<{ T::make() }>) {} + | ^^^^^^^^^^^^^ = note: ...which again requires caching mir of `accept1::{constant#0}` for CTFE, completing the cycle note: cycle used when const-evaluating + checking `accept1::{constant#0}` - --> $DIR/unsatisfied-const-trait-bound.rs:33:48 + --> $DIR/unsatisfied-const-trait-bound.rs:33:49 | -LL | const fn accept1(_: Container<{ T::make() }>) {} - | ^^^^^^^^^^^^^ +LL | const fn accept1(_: Container<{ T::make() }>) {} + | ^^^^^^^^^^^^^ = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error: aborting due to 3 previous errors diff --git a/tests/ui/unpretty/ast-const-trait-bound.rs b/tests/ui/unpretty/ast-const-trait-bound.rs index f4de86bb0d03a..761bff87a628a 100644 --- a/tests/ui/unpretty/ast-const-trait-bound.rs +++ b/tests/ui/unpretty/ast-const-trait-bound.rs @@ -1,4 +1,4 @@ //@ compile-flags: -Zunpretty=normal //@ check-pass -fn foo() where T: ~const Bar {} +fn foo() where T: [const] Bar {} diff --git a/tests/ui/unpretty/ast-const-trait-bound.stdout b/tests/ui/unpretty/ast-const-trait-bound.stdout index f4de86bb0d03a..761bff87a628a 100644 --- a/tests/ui/unpretty/ast-const-trait-bound.stdout +++ b/tests/ui/unpretty/ast-const-trait-bound.stdout @@ -1,4 +1,4 @@ //@ compile-flags: -Zunpretty=normal //@ check-pass -fn foo() where T: ~const Bar {} +fn foo() where T: [const] Bar {} diff --git a/tests/ui/unpretty/exhaustive.expanded.stdout b/tests/ui/unpretty/exhaustive.expanded.stdout index cd1a5d0af08af..e714e4e952597 100644 --- a/tests/ui/unpretty/exhaustive.expanded.stdout +++ b/tests/ui/unpretty/exhaustive.expanded.stdout @@ -606,7 +606,7 @@ mod types { let _: impl Send + 'static; let _: impl 'static + Send; let _: impl ?Sized; - let _: impl ~const Clone; + let _: impl [const] Clone; let _: impl for<'a> Send; } /// TyKind::Paren diff --git a/tests/ui/unpretty/exhaustive.hir.stderr b/tests/ui/unpretty/exhaustive.hir.stderr index 58f7ff0f59812..2d535c18ab9af 100644 --- a/tests/ui/unpretty/exhaustive.hir.stderr +++ b/tests/ui/unpretty/exhaustive.hir.stderr @@ -147,8 +147,8 @@ LL | let _: impl ?Sized; error[E0562]: `impl Trait` is not allowed in the type of variable bindings --> $DIR/exhaustive.rs:813:16 | -LL | let _: impl ~const Clone; - | ^^^^^^^^^^^^^^^^^ +LL | let _: impl [const] Clone; + | ^^^^^^^^^^^^^^^^^^ | = note: `impl Trait` is only allowed in arguments and return types of functions and methods = note: see issue #63065 for more information diff --git a/tests/ui/unpretty/exhaustive.rs b/tests/ui/unpretty/exhaustive.rs index 60ad3564689d7..4f59f63dcd61d 100644 --- a/tests/ui/unpretty/exhaustive.rs +++ b/tests/ui/unpretty/exhaustive.rs @@ -810,7 +810,7 @@ mod types { let _: impl Send + 'static; //[hir]~ ERROR `impl Trait` is not allowed let _: impl 'static + Send; //[hir]~ ERROR `impl Trait` is not allowed let _: impl ?Sized; //[hir]~ ERROR `impl Trait` is not allowed - let _: impl ~const Clone; //[hir]~ ERROR `impl Trait` is not allowed + let _: impl [const] Clone; //[hir]~ ERROR `impl Trait` is not allowed let _: impl for<'a> Send; //[hir]~ ERROR `impl Trait` is not allowed }