1
Fork 0

Applied suggestions

This commit is contained in:
Deadbeef 2021-07-04 23:50:34 +08:00
parent 2db927d8d8
commit 3660a4e972
No known key found for this signature in database
GPG key ID: 6525773485376D92
2 changed files with 12 additions and 16 deletions

View file

@ -349,6 +349,12 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
),
gated!(cmse_nonsecure_entry, AssumedUsed, template!(Word), experimental!(cmse_nonsecure_entry)),
// RFC 2632
gated!(
default_method_body_is_const, AssumedUsed, template!(Word), const_trait_impl,
"`default_method_body_is_const` is a temporary placeholder for declaring default bodies \
as `const`, which may be removed or renamed in the future."
),
// ==========================================================================
// Internal attributes: Stability, deprecation, and unsafe:
@ -470,11 +476,6 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
rustc_attr!(rustc_promotable, AssumedUsed, template!(Word), IMPL_DETAIL),
rustc_attr!(rustc_legacy_const_generics, AssumedUsed, template!(List: "N"), INTERNAL_UNSTABLE),
gated!(
default_method_body_is_const, AssumedUsed, template!(Word), const_trait_impl,
"the `#[default_method_body_is_const]` attribute marks a default method of a trait \
as const, so it does not need to be duplicated by a const impl."
),
// ==========================================================================
// Internal attributes, Layout related:

View file

@ -93,18 +93,13 @@ impl<'tcx> hir::itemlikevisit::ItemLikeVisitor<'tcx> for CheckConstTraitVisitor<
kind: ty::AssocKind::Fn, ident, defaultness, ..
} = self.tcx.associated_item(*did)
{
match (
self.tcx.has_attr(*did, sym::default_method_body_is_const),
defaultness.has_value(),
) {
(false, true) => {
// we can ignore functions that do not have default bodies:
// if those are unimplemented it will be catched by typeck.
if defaultness.has_value()
&& !self.tcx.has_attr(*did, sym::default_method_body_is_const)
{
to_implement.insert(ident);
}
// ignore functions that do not have default bodies
// if those are unimplemented it will be catched by
// typeck.
_ => {}
}
}
}