Skip to content

Commit 4e28612

Browse files
Port a bunch of stuff from rustc and fix a bunch of type mismatches/diagnostics
This started from porting coercion, but ended with porting much more.
1 parent af5ca03 commit 4e28612

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+9358
-3944
lines changed

src/tools/rust-analyzer/crates/hir-def/src/signatures.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,7 @@ bitflags! {
489489
const HAS_TARGET_FEATURE = 1 << 9;
490490
const DEPRECATED_SAFE_2024 = 1 << 10;
491491
const EXPLICIT_SAFE = 1 << 11;
492+
const RUSTC_INTRINSIC = 1 << 12;
492493
}
493494
}
494495

@@ -522,6 +523,9 @@ impl FunctionSignature {
522523
if attrs.by_key(sym::target_feature).exists() {
523524
flags.insert(FnFlags::HAS_TARGET_FEATURE);
524525
}
526+
if attrs.by_key(sym::rustc_intrinsic).exists() {
527+
flags.insert(FnFlags::RUSTC_INTRINSIC);
528+
}
525529
let legacy_const_generics_indices = attrs.rustc_legacy_const_generics();
526530

527531
let source = loc.source(db);
@@ -617,6 +621,21 @@ impl FunctionSignature {
617621
pub fn has_target_feature(&self) -> bool {
618622
self.flags.contains(FnFlags::HAS_TARGET_FEATURE)
619623
}
624+
625+
pub fn is_intrinsic(db: &dyn DefDatabase, id: FunctionId) -> bool {
626+
let data = db.function_signature(id);
627+
data.flags.contains(FnFlags::RUSTC_INTRINSIC)
628+
// Keep this around for a bit until extern "rustc-intrinsic" abis are no longer used
629+
|| match &data.abi {
630+
Some(abi) => *abi == sym::rust_dash_intrinsic,
631+
None => match id.lookup(db).container {
632+
ItemContainerId::ExternBlockId(block) => {
633+
block.abi(db) == Some(sym::rust_dash_intrinsic)
634+
}
635+
_ => false,
636+
},
637+
}
638+
}
620639
}
621640

622641
bitflags! {

0 commit comments

Comments
 (0)