Add #[rustc_no_implicit_autorefs] and apply it to std methods

This commit is contained in:
Urgau 2024-03-30 16:00:28 +01:00
parent 191df20fca
commit 1632f624fb
7 changed files with 20 additions and 0 deletions

View file

@ -931,6 +931,10 @@ pub static BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
EncodeCrossCrate::Yes,
"#[rustc_never_returns_null_ptr] is used to mark functions returning non-null pointers."
),
rustc_attr!(
rustc_no_implicit_autorefs, AttributeType::Normal, template!(Word), ErrorFollowing, EncodeCrossCrate::Yes,
"`#[rustc_no_implicit_autorefs]` is used to mark functions for which an autoref to the dereference of a raw pointer should not be used as an argument."
),
rustc_attr!(
rustc_coherence_is_core, AttributeType::CrateLevel, template!(Word), ErrorFollowing, EncodeCrossCrate::No,
"#![rustc_coherence_is_core] allows inherent methods on builtin types, only intended to be used in `core`."

View file

@ -179,6 +179,9 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
[sym::rustc_as_ptr, ..] => {
self.check_applied_to_fn_or_method(hir_id, attr, span, target)
}
[sym::rustc_no_implicit_autorefs, ..] => {
self.check_applied_to_fn_or_method(hir_id, attr, span, target)
}
[sym::rustc_never_returns_null_ptr, ..] => {
self.check_applied_to_fn_or_method(hir_id, attr, span, target)
}

View file

@ -1830,6 +1830,7 @@ symbols! {
rustc_must_implement_one_of,
rustc_never_returns_null_ptr,
rustc_never_type_options,
rustc_no_implicit_autorefs,
rustc_no_mir_inline,
rustc_nonnull_optimization_guaranteed,
rustc_nounwind,