Skip to content

Commit 3660a4e

Browse files
committed
Applied suggestions
1 parent 2db927d commit 3660a4e

File tree

2 files changed

+12
-16
lines changed

2 files changed

+12
-16
lines changed

compiler/rustc_feature/src/builtin_attrs.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,12 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
349349
),
350350

351351
gated!(cmse_nonsecure_entry, AssumedUsed, template!(Word), experimental!(cmse_nonsecure_entry)),
352+
// RFC 2632
353+
gated!(
354+
default_method_body_is_const, AssumedUsed, template!(Word), const_trait_impl,
355+
"`default_method_body_is_const` is a temporary placeholder for declaring default bodies \
356+
as `const`, which may be removed or renamed in the future."
357+
),
352358

353359
// ==========================================================================
354360
// Internal attributes: Stability, deprecation, and unsafe:
@@ -470,11 +476,6 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
470476

471477
rustc_attr!(rustc_promotable, AssumedUsed, template!(Word), IMPL_DETAIL),
472478
rustc_attr!(rustc_legacy_const_generics, AssumedUsed, template!(List: "N"), INTERNAL_UNSTABLE),
473-
gated!(
474-
default_method_body_is_const, AssumedUsed, template!(Word), const_trait_impl,
475-
"the `#[default_method_body_is_const]` attribute marks a default method of a trait \
476-
as const, so it does not need to be duplicated by a const impl."
477-
),
478479

479480
// ==========================================================================
480481
// Internal attributes, Layout related:

compiler/rustc_passes/src/check_const.rs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -93,17 +93,12 @@ impl<'tcx> hir::itemlikevisit::ItemLikeVisitor<'tcx> for CheckConstTraitVisitor<
9393
kind: ty::AssocKind::Fn, ident, defaultness, ..
9494
} = self.tcx.associated_item(*did)
9595
{
96-
match (
97-
self.tcx.has_attr(*did, sym::default_method_body_is_const),
98-
defaultness.has_value(),
99-
) {
100-
(false, true) => {
101-
to_implement.insert(ident);
102-
}
103-
// ignore functions that do not have default bodies
104-
// if those are unimplemented it will be catched by
105-
// typeck.
106-
_ => {}
96+
// we can ignore functions that do not have default bodies:
97+
// if those are unimplemented it will be catched by typeck.
98+
if defaultness.has_value()
99+
&& !self.tcx.has_attr(*did, sym::default_method_body_is_const)
100+
{
101+
to_implement.insert(ident);
107102
}
108103
}
109104
}

0 commit comments

Comments
 (0)