Skip to content

Commit

Permalink
Auto merge of rust-lang#15527 - HKalbasi:diagnostics-allow, r=HKalbasi
Browse files Browse the repository at this point in the history
Respect `#[allow(unused_braces)]`

fix rust-lang#15526
  • Loading branch information
bors committed Aug 28, 2023
2 parents 144526c + 514fefa commit 62268e4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion crates/ide-diagnostics/src/handlers/mutability_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ pub(crate) fn unused_mut(ctx: &DiagnosticsContext<'_>, d: &hir::UnusedMut) -> Di
"variable does not need to be mutable",
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)
}

Expand Down
21 changes: 21 additions & 0 deletions crates/ide-diagnostics/src/handlers/useless_braces.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use hir::InFile;
use ide_db::{base_db::FileId, source_change::SourceChange};
use itertools::Itertools;
use syntax::{ast, AstNode, SyntaxNode};
Expand Down Expand Up @@ -39,6 +40,7 @@ pub(crate) fn useless_braces(
"Unnecessary braces in use statement".to_string(),
use_range,
)
.with_main_node(InFile::new(file_id.into(), node.clone()))
.with_fixes(Some(vec![fix(
"remove_braces",
"Remove unnecessary braces",
Expand Down Expand Up @@ -153,6 +155,25 @@ use a::{c, d::{e$0}};
r#"
mod a { pub mod c {} pub mod d { pub mod 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
"#,
);
}
Expand Down

0 comments on commit 62268e4

Please sign in to comment.