Skip to content

Fix: don't emit implicit drop inlay hints for macro #19117

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions crates/ide/src/inlay_hints/implicit_drop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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(),
Expand Down Expand Up @@ -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!()
}
"#,
);
}
Expand Down