Verify we are not in a macro attempt 2
This commit is contained in:
parent
0faa2940c7
commit
701068daf2
@ -25,10 +25,13 @@ pub(crate) fn unused_variables(
|
|||||||
}
|
}
|
||||||
let diagnostic_range = ctx.sema.diagnostics_display_range(ast);
|
let diagnostic_range = ctx.sema.diagnostics_display_range(ast);
|
||||||
// The range for the Actual Name. We don't want to replace the entire declarition. Using the diagnostic range causes issues within in Array Destructuring.
|
// The range for the Actual Name. We don't want to replace the entire declarition. Using the diagnostic range causes issues within in Array Destructuring.
|
||||||
let name_range =
|
let name_range = d
|
||||||
d.local.primary_source(ctx.sema.db).name().map(|v| v.syntax().value.text_range())?;
|
.local
|
||||||
// Make sure we are within the diagnostic range for the variable
|
.primary_source(ctx.sema.db)
|
||||||
if !diagnostic_range.range.contains_range(name_range) {
|
.name()
|
||||||
|
.map(|v| v.syntax().original_file_range_rooted(ctx.sema.db))
|
||||||
|
.filter(|it| Some(it.file_id) == ast.file_id.file_id())?;
|
||||||
|
if !diagnostic_range.range.contains_range(name_range.range) {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
let var_name = d.local.name(ctx.sema.db);
|
let var_name = d.local.name(ctx.sema.db);
|
||||||
@ -42,7 +45,7 @@ pub(crate) fn unused_variables(
|
|||||||
.with_fixes(fixes(
|
.with_fixes(fixes(
|
||||||
ctx.sema.db,
|
ctx.sema.db,
|
||||||
var_name,
|
var_name,
|
||||||
name_range,
|
name_range.range,
|
||||||
diagnostic_range,
|
diagnostic_range,
|
||||||
ast.file_id.is_macro(),
|
ast.file_id.is_macro(),
|
||||||
))
|
))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user