mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 04:44:57 +00:00
feat: Tag macro calls as unsafe if they expand to unsafe expressions
This commit is contained in:
parent
5a87f09a71
commit
68de7b30e0
25 changed files with 208 additions and 68 deletions
|
@ -358,6 +358,10 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> {
|
|||
self.imp.resolve_macro_call(macro_call)
|
||||
}
|
||||
|
||||
pub fn is_unsafe_macro_call(&self, macro_call: &ast::MacroCall) -> bool {
|
||||
self.imp.is_unsafe_macro_call(macro_call)
|
||||
}
|
||||
|
||||
pub fn resolve_attr_macro_call(&self, item: &ast::Item) -> Option<Macro> {
|
||||
self.imp.resolve_attr_macro_call(item)
|
||||
}
|
||||
|
@ -961,6 +965,12 @@ impl<'db> SemanticsImpl<'db> {
|
|||
sa.resolve_macro_call(self.db, macro_call)
|
||||
}
|
||||
|
||||
fn is_unsafe_macro_call(&self, macro_call: &ast::MacroCall) -> bool {
|
||||
let sa = self.analyze(macro_call.syntax());
|
||||
let macro_call = self.find_file(macro_call.syntax()).with_value(macro_call);
|
||||
sa.is_unsafe_macro_call(self.db, macro_call)
|
||||
}
|
||||
|
||||
fn resolve_attr_macro_call(&self, item: &ast::Item) -> Option<Macro> {
|
||||
let item_in_file = self.wrap_node_infile(item.clone());
|
||||
let id = self.with_ctx(|ctx| {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue