Skip to content

Commit 5f443df

Browse files
committed
Add #[rustc_as_ptr] attribute
1 parent 145f9cf commit 5f443df

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

compiler/rustc_feature/src/builtin_attrs.rs

+5
Original file line numberDiff line numberDiff line change
@@ -875,6 +875,11 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
875875
lang, Normal, template!(NameValueStr: "name"), DuplicatesOk, EncodeCrossCrate::No, lang_items,
876876
"lang items are subject to change",
877877
),
878+
rustc_attr!(
879+
rustc_as_ptr, Normal, template!(Word), ErrorFollowing,
880+
EncodeCrossCrate::Yes,
881+
"#[rustc_as_ptr] is used to mark functions returning pointers to their inner allocations."
882+
),
878883
rustc_attr!(
879884
rustc_pass_by_value, Normal, template!(Word), ErrorFollowing,
880885
EncodeCrossCrate::Yes,

compiler/rustc_passes/src/check_attr.rs

+3
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,9 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
162162
self.check_rustc_std_internal_symbol(attr, span, target)
163163
}
164164
[sym::naked, ..] => self.check_naked(hir_id, attr, span, target, attrs),
165+
[sym::rustc_as_ptr, ..] => {
166+
self.check_applied_to_fn_or_method(hir_id, attr, span, target)
167+
}
165168
[sym::rustc_never_returns_null_ptr, ..] => {
166169
self.check_applied_to_fn_or_method(hir_id, attr, span, target)
167170
}

compiler/rustc_span/src/symbol.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1652,6 +1652,7 @@ symbols! {
16521652
rustc_allow_const_fn_unstable,
16531653
rustc_allow_incoherent_impl,
16541654
rustc_allowed_through_unstable_modules,
1655+
rustc_as_ptr,
16551656
rustc_attrs,
16561657
rustc_autodiff,
16571658
rustc_box,

0 commit comments

Comments
 (0)