Rollup merge of #139858 - oli-obk:new-const-traits-syntax, r=fee1-dead
New const traits syntax This PR only affects the AST and doesn't actually change anything semantically. All occurrences of `~const` outside of libcore have been replaced by `[const]`. Within libcore we have to wait for rustfmt to be bumped in the bootstrap compiler. This will happen "automatically" (when rustfmt is run) during the bootstrap bump, as rustfmt converts `~const` into `[const]`. After this we can remove the `~const` support from the parser Caveat discovered during impl: there is no legacy bare trait object recovery for `[const] Trait` as that snippet in type position goes down the slice /array parsing code and will error r? ``@fee1-dead`` cc ``@nikomatsakis`` ``@traviscross`` ``@compiler-errors``
This commit is contained in:
@@ -344,7 +344,7 @@ fn check_opaque_meets_bounds<'tcx>(
|
||||
let misc_cause = ObligationCause::misc(span, def_id);
|
||||
// FIXME: We should just register the item bounds here, rather than equating.
|
||||
// FIXME(const_trait_impl): When we do that, please make sure to also register
|
||||
// the `~const` bounds.
|
||||
// the `[const]` bounds.
|
||||
match ocx.eq(&misc_cause, param_env, opaque_ty, hidden_ty) {
|
||||
Ok(()) => {}
|
||||
Err(ty_err) => {
|
||||
|
||||
@@ -264,9 +264,9 @@ fn compare_method_predicate_entailment<'tcx>(
|
||||
}
|
||||
|
||||
// If we're within a const implementation, we need to make sure that the method
|
||||
// does not assume stronger `~const` bounds than the trait definition.
|
||||
// does not assume stronger `[const]` bounds than the trait definition.
|
||||
//
|
||||
// This registers the `~const` bounds of the impl method, which we will prove
|
||||
// This registers the `[const]` bounds of the impl method, which we will prove
|
||||
// using the hybrid param-env that we earlier augmented with the const conditions
|
||||
// from the impl header and trait method declaration.
|
||||
if is_conditionally_const {
|
||||
@@ -2335,7 +2335,7 @@ pub(super) fn check_type_bounds<'tcx>(
|
||||
)
|
||||
.collect();
|
||||
|
||||
// Only in a const implementation do we need to check that the `~const` item bounds hold.
|
||||
// Only in a const implementation do we need to check that the `[const]` item bounds hold.
|
||||
if tcx.is_conditionally_const(impl_ty_def_id) {
|
||||
obligations.extend(util::elaborate(
|
||||
tcx,
|
||||
|
||||
@@ -1402,7 +1402,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)
|
||||
|
||||
Reference in New Issue
Block a user