Skip to content

Commit aadf486

Browse files
committed
Rust: suppress macro call expansion warnings in Meta
1 parent eff3fd3 commit aadf486

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

rust/extractor/src/translate/base.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,18 @@ macro_rules! pre_emit {
2929
return Some(label);
3030
}
3131
};
32+
(Meta, $self:ident, $node:ident) => {
33+
// rust-analyzer doesn't expand macros in this context
34+
$self.macro_context_depth += 1;
35+
};
3236
($($_:tt)*) => {};
3337
}
3438

3539
#[macro_export]
3640
macro_rules! post_emit {
41+
(Meta, $self:ident, $node:ident, $label:ident) => {
42+
$self.macro_context_depth -= 1;
43+
};
3744
(MacroCall, $self:ident, $node:ident, $label:ident) => {
3845
$self.extract_macro_call_expanded($node, $label);
3946
};
@@ -122,7 +129,7 @@ pub struct Translator<'a> {
122129
pub semantics: Option<&'a Semantics<'a, RootDatabase>>,
123130
resolve_paths: bool,
124131
source_kind: SourceKind,
125-
macro_context_depth: usize,
132+
pub(crate) macro_context_depth: usize,
126133
}
127134

128135
const UNKNOWN_LOCATION: (LineCol, LineCol) =

rust/ql/integration-tests/macro-expansion/test.expected

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,3 @@ unexpanded_macro_calls
4040
warnings
4141
| calls/src/included.rs:2:9:2:39 | macro expansion failed: could not resolve macro 'concat' |
4242
| calls/src/lib.rs:22:9:22:31 | macro expansion failed: could not resolve macro 'concat' |
43-
| calls/src/lib.rs:29:9:29:32 | macro expansion failed: could not resolve macro 'include_str' |

0 commit comments

Comments
 (0)