Auto merge of #15527 - HKalbasi:diagnostics-allow, r=HKalbasi
Respect `#[allow(unused_braces)]` fix #15526
This commit is contained in:
commit
62268e474e
@ -76,7 +76,7 @@ pub(crate) fn unused_mut(ctx: &DiagnosticsContext<'_>, d: &hir::UnusedMut) -> Di
|
|||||||
"variable does not need to be mutable",
|
"variable does not need to be mutable",
|
||||||
ast,
|
ast,
|
||||||
)
|
)
|
||||||
.experimental() // Not supporting `#[allow(unused_mut)]` leads to false positive.
|
.experimental() // Not supporting `#[allow(unused_mut)]` in proc macros leads to false positive.
|
||||||
.with_fixes(fixes)
|
.with_fixes(fixes)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
use hir::InFile;
|
||||||
use ide_db::{base_db::FileId, source_change::SourceChange};
|
use ide_db::{base_db::FileId, source_change::SourceChange};
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use syntax::{ast, AstNode, SyntaxNode};
|
use syntax::{ast, AstNode, SyntaxNode};
|
||||||
@ -39,6 +40,7 @@ pub(crate) fn useless_braces(
|
|||||||
"Unnecessary braces in use statement".to_string(),
|
"Unnecessary braces in use statement".to_string(),
|
||||||
use_range,
|
use_range,
|
||||||
)
|
)
|
||||||
|
.with_main_node(InFile::new(file_id.into(), node.clone()))
|
||||||
.with_fixes(Some(vec![fix(
|
.with_fixes(Some(vec![fix(
|
||||||
"remove_braces",
|
"remove_braces",
|
||||||
"Remove unnecessary braces",
|
"Remove unnecessary braces",
|
||||||
@ -153,6 +155,25 @@ use a::{c, d::{e$0}};
|
|||||||
r#"
|
r#"
|
||||||
mod a { pub mod c {} pub mod d { pub mod e {} } }
|
mod a { pub mod c {} pub mod d { pub mod e {} } }
|
||||||
use a::{c, d::e};
|
use a::{c, d::e};
|
||||||
|
"#,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn respect_lint_attributes_for_unused_braces() {
|
||||||
|
check_diagnostics(
|
||||||
|
r#"
|
||||||
|
mod b {}
|
||||||
|
#[allow(unused_braces)]
|
||||||
|
use {b};
|
||||||
|
"#,
|
||||||
|
);
|
||||||
|
check_diagnostics(
|
||||||
|
r#"
|
||||||
|
mod b {}
|
||||||
|
#[deny(unused_braces)]
|
||||||
|
use {b};
|
||||||
|
//^^^ 💡 error: Unnecessary braces in use statement
|
||||||
"#,
|
"#,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user