mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-25 11:17:13 +00:00
Merge pull request #19117 from gohome001/implicit-drop-inlay-hints-bug
Fix: don't emit implicit drop inlay hints for macro
This commit is contained in:
commit
8aa4ae5e69
@ -54,7 +54,8 @@ pub(super) fn hints(
|
||||
};
|
||||
let range = match terminator.span {
|
||||
MirSpan::ExprId(e) => match source_map.expr_syntax(e) {
|
||||
Ok(s) => {
|
||||
// don't show inlay hint for macro
|
||||
Ok(s) if !s.file_id.is_macro() => {
|
||||
let root = &s.file_syntax(sema.db);
|
||||
let expr = s.value.to_node(root);
|
||||
let expr = expr.syntax();
|
||||
@ -69,7 +70,7 @@ pub(super) fn hints(
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(_) => continue,
|
||||
_ => continue,
|
||||
},
|
||||
MirSpan::PatId(p) => match source_map.pat_syntax(p) {
|
||||
Ok(s) => s.value.text_range(),
|
||||
@ -228,6 +229,27 @@ mod tests {
|
||||
//^ drop(y)
|
||||
}
|
||||
//^ drop(x)
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ignore_inlay_hint_for_macro_call() {
|
||||
check_with_config(
|
||||
ONLY_DROP_CONFIG,
|
||||
r#"
|
||||
struct X;
|
||||
|
||||
macro_rules! my_macro {
|
||||
() => {{
|
||||
let bbb = X;
|
||||
bbb
|
||||
}};
|
||||
}
|
||||
|
||||
fn test() -> X {
|
||||
my_macro!()
|
||||
}
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user