mirror of
https://github.com/github/codeql.git
synced 2026-05-01 03:35:13 +02:00
Rust: suppress some expected macro expansion warnings
This commit is contained in:
@@ -167,9 +167,19 @@ impl<'a> Extractor<'a> {
|
||||
let Some(id) = path_to_file_id(file, vfs) else {
|
||||
return Err("not included in files loaded from manifest".to_string());
|
||||
};
|
||||
if semantics.file_to_module_def(id).is_none() {
|
||||
return Err("not included as a module".to_string());
|
||||
}
|
||||
match semantics.file_to_module_def(id) {
|
||||
None => return Err("not included as a module".to_string()),
|
||||
Some(module)
|
||||
if module
|
||||
.as_source_file_id(semantics.db)
|
||||
.is_none_or(|mod_file_id| mod_file_id.file_id(semantics.db) != id) =>
|
||||
{
|
||||
return Err(
|
||||
"not loaded as its own module, probably included by `!include`".to_string(),
|
||||
);
|
||||
}
|
||||
_ => {}
|
||||
};
|
||||
self.steps.push(ExtractionStep::load_source(before, file));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -29,6 +29,10 @@ macro_rules! pre_emit {
|
||||
return Some(label);
|
||||
}
|
||||
};
|
||||
(Meta, $self:ident, $node:ident) => {
|
||||
// rust-analyzer doesn't expand macros in this context
|
||||
$self.macro_context_depth += 1;
|
||||
};
|
||||
($($_:tt)*) => {};
|
||||
}
|
||||
|
||||
@@ -122,7 +126,7 @@ pub struct Translator<'a> {
|
||||
pub semantics: Option<&'a Semantics<'a, RootDatabase>>,
|
||||
resolve_paths: bool,
|
||||
source_kind: SourceKind,
|
||||
macro_context_depth: usize,
|
||||
pub(crate) macro_context_depth: usize,
|
||||
}
|
||||
|
||||
const UNKNOWN_LOCATION: (LineCol, LineCol) =
|
||||
|
||||
Reference in New Issue
Block a user