mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 12:29:21 +00:00
Handle lint attributes that are under #[cfg_attr]
This commit is contained in:
parent
6dad8c5528
commit
82124f33b5
5 changed files with 120 additions and 16 deletions
|
@ -386,6 +386,19 @@ impl<'db> SemanticsImpl<'db> {
|
|||
Some(node)
|
||||
}
|
||||
|
||||
pub fn check_cfg_attr(&self, attr: &ast::TokenTree) -> Option<bool> {
|
||||
let file_id = self.find_file(attr.syntax()).file_id;
|
||||
let krate = match file_id.repr() {
|
||||
HirFileIdRepr::FileId(file_id) => {
|
||||
self.file_to_module_defs(file_id.file_id()).next()?.krate().id
|
||||
}
|
||||
HirFileIdRepr::MacroFile(macro_file) => {
|
||||
self.db.lookup_intern_macro_call(macro_file.macro_call_id).krate
|
||||
}
|
||||
};
|
||||
hir_expand::check_cfg_attr_value(self.db.upcast(), attr, krate)
|
||||
}
|
||||
|
||||
/// Expands the macro if it isn't one of the built-in ones that expand to custom syntax or dummy
|
||||
/// expansions.
|
||||
pub fn expand_allowed_builtins(&self, macro_call: &ast::MacroCall) -> Option<SyntaxNode> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue