Skip to content

Commit da4c099

Browse files
Merge pull request rust-lang#19117 from gohome001/implicit-drop-inlay-hints-bug
Fix: don't emit implicit drop inlay hints for macro
2 parents 4883966 + 4036a7a commit da4c099

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

src/tools/rust-analyzer/crates/ide/src/inlay_hints/implicit_drop.rs

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ pub(super) fn hints(
5454
};
5555
let range = match terminator.span {
5656
MirSpan::ExprId(e) => match source_map.expr_syntax(e) {
57-
Ok(s) => {
57+
// don't show inlay hint for macro
58+
Ok(s) if !s.file_id.is_macro() => {
5859
let root = &s.file_syntax(sema.db);
5960
let expr = s.value.to_node(root);
6061
let expr = expr.syntax();
@@ -69,7 +70,7 @@ pub(super) fn hints(
6970
}
7071
}
7172
}
72-
Err(_) => continue,
73+
_ => continue,
7374
},
7475
MirSpan::PatId(p) => match source_map.pat_syntax(p) {
7576
Ok(s) => s.value.text_range(),
@@ -228,6 +229,27 @@ mod tests {
228229
//^ drop(y)
229230
}
230231
//^ drop(x)
232+
"#,
233+
);
234+
}
235+
236+
#[test]
237+
fn ignore_inlay_hint_for_macro_call() {
238+
check_with_config(
239+
ONLY_DROP_CONFIG,
240+
r#"
241+
struct X;
242+
243+
macro_rules! my_macro {
244+
() => {{
245+
let bbb = X;
246+
bbb
247+
}};
248+
}
249+
250+
fn test() -> X {
251+
my_macro!()
252+
}
231253
"#,
232254
);
233255
}

0 commit comments

Comments
 (0)