mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-13 21:54:42 +00:00
Don't show unused_variables fixes if the name comes from a macro definition
This commit is contained in:
parent
701068daf2
commit
0eb7b6c7b5
1 changed files with 7 additions and 11 deletions
|
@ -30,10 +30,10 @@ pub(crate) fn unused_variables(
|
||||||
.primary_source(ctx.sema.db)
|
.primary_source(ctx.sema.db)
|
||||||
.name()
|
.name()
|
||||||
.map(|v| v.syntax().original_file_range_rooted(ctx.sema.db))
|
.map(|v| v.syntax().original_file_range_rooted(ctx.sema.db))
|
||||||
.filter(|it| Some(it.file_id) == ast.file_id.file_id())?;
|
.filter(|it| {
|
||||||
if !diagnostic_range.range.contains_range(name_range.range) {
|
Some(it.file_id) == ast.file_id.file_id()
|
||||||
return None;
|
&& diagnostic_range.range.contains_range(it.range)
|
||||||
}
|
});
|
||||||
let var_name = d.local.name(ctx.sema.db);
|
let var_name = d.local.name(ctx.sema.db);
|
||||||
Some(
|
Some(
|
||||||
Diagnostic::new_with_syntax_node_ptr(
|
Diagnostic::new_with_syntax_node_ptr(
|
||||||
|
@ -42,13 +42,9 @@ pub(crate) fn unused_variables(
|
||||||
"unused variable",
|
"unused variable",
|
||||||
ast,
|
ast,
|
||||||
)
|
)
|
||||||
.with_fixes(fixes(
|
.with_fixes(name_range.and_then(|it| {
|
||||||
ctx.sema.db,
|
fixes(ctx.sema.db, var_name, it.range, diagnostic_range, ast.file_id.is_macro())
|
||||||
var_name,
|
}))
|
||||||
name_range.range,
|
|
||||||
diagnostic_range,
|
|
||||||
ast.file_id.is_macro(),
|
|
||||||
))
|
|
||||||
.experimental(),
|
.experimental(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue