Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions crates/hir-def/src/signatures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,7 @@ bitflags! {
const HAS_TARGET_FEATURE = 1 << 9;
const DEPRECATED_SAFE_2024 = 1 << 10;
const EXPLICIT_SAFE = 1 << 11;
const RUSTC_INTRINSIC = 1 << 12;
}
}

Expand Down Expand Up @@ -522,6 +523,9 @@ impl FunctionSignature {
if attrs.by_key(sym::target_feature).exists() {
flags.insert(FnFlags::HAS_TARGET_FEATURE);
}
if attrs.by_key(sym::rustc_intrinsic).exists() {
flags.insert(FnFlags::RUSTC_INTRINSIC);
}
let legacy_const_generics_indices = attrs.rustc_legacy_const_generics();

let source = loc.source(db);
Expand Down Expand Up @@ -617,6 +621,21 @@ impl FunctionSignature {
pub fn has_target_feature(&self) -> bool {
self.flags.contains(FnFlags::HAS_TARGET_FEATURE)
}

pub fn is_intrinsic(db: &dyn DefDatabase, id: FunctionId) -> bool {
let data = db.function_signature(id);
data.flags.contains(FnFlags::RUSTC_INTRINSIC)
// Keep this around for a bit until extern "rustc-intrinsic" abis are no longer used
|| match &data.abi {
Some(abi) => *abi == sym::rust_dash_intrinsic,
None => match id.lookup(db).container {
ItemContainerId::ExternBlockId(block) => {
block.abi(db) == Some(sym::rust_dash_intrinsic)
}
_ => false,
},
}
}
}

bitflags! {
Expand Down
Loading
Loading