mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-03 15:15:24 +00:00
Auto merge of #16861 - Veykril:macro-diag-exceptions, r=Veykril
fix: Ignore some warnings if they originate from within macro expansions These tend to be annoying noise as we can't handle `allow`s for them properly for the time being.
This commit is contained in:
commit
b6d1887bc4
5 changed files with 77 additions and 40 deletions
|
@ -21,17 +21,24 @@ use crate::{
|
|||
pub(crate) fn remove_unnecessary_else(
|
||||
ctx: &DiagnosticsContext<'_>,
|
||||
d: &RemoveUnnecessaryElse,
|
||||
) -> Diagnostic {
|
||||
) -> Option<Diagnostic> {
|
||||
if d.if_expr.file_id.macro_file().is_some() {
|
||||
// FIXME: Our infra can't handle allow from within macro expansions rn
|
||||
return None;
|
||||
}
|
||||
|
||||
let display_range = adjusted_display_range(ctx, d.if_expr, &|if_expr| {
|
||||
if_expr.else_token().as_ref().map(SyntaxToken::text_range)
|
||||
});
|
||||
Diagnostic::new(
|
||||
DiagnosticCode::Ra("remove-unnecessary-else", Severity::WeakWarning),
|
||||
"remove unnecessary else block",
|
||||
display_range,
|
||||
Some(
|
||||
Diagnostic::new(
|
||||
DiagnosticCode::Ra("remove-unnecessary-else", Severity::WeakWarning),
|
||||
"remove unnecessary else block",
|
||||
display_range,
|
||||
)
|
||||
.experimental()
|
||||
.with_fixes(fixes(ctx, d)),
|
||||
)
|
||||
.experimental()
|
||||
.with_fixes(fixes(ctx, d))
|
||||
}
|
||||
|
||||
fn fixes(ctx: &DiagnosticsContext<'_>, d: &RemoveUnnecessaryElse) -> Option<Vec<Assist>> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue