mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-11-01 04:18:20 +00:00
Differentiate between asm!(), global_asm!() and naked_asm!(), and make only asm!() unsafe
This commit is contained in:
parent
edb804a100
commit
bd8087e86e
16 changed files with 198 additions and 16 deletions
|
|
@ -3220,7 +3220,8 @@ impl Macro {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn is_asm_or_global_asm(&self, db: &dyn HirDatabase) -> bool {
|
||||
/// Is this `asm!()`, or a variant of it (e.g. `global_asm!()`)?
|
||||
pub fn is_asm_like(&self, db: &dyn HirDatabase) -> bool {
|
||||
match self.id {
|
||||
MacroId::Macro2Id(it) => {
|
||||
matches!(it.lookup(db).expander, MacroExpander::BuiltIn(m) if m.is_asm())
|
||||
|
|
|
|||
|
|
@ -1776,7 +1776,7 @@ impl<'db> SemanticsImpl<'db> {
|
|||
|
||||
pub fn is_unsafe_macro_call(&self, macro_call: &ast::MacroCall) -> bool {
|
||||
let Some(mac) = self.resolve_macro_call(macro_call) else { return false };
|
||||
if mac.is_asm_or_global_asm(self.db) {
|
||||
if mac.is_asm_like(self.db) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue