Skip to content

Commit 84a81c9

Browse files
committed
actually match on applicability again
1 parent 302720c commit 84a81c9

File tree

1 file changed

+23
-7
lines changed
  • crates/ruff_db/src/diagnostic/render

1 file changed

+23
-7
lines changed

crates/ruff_db/src/diagnostic/render/full.rs

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::num::NonZeroUsize;
44
use similar::{ChangeTag, TextDiff};
55

66
use ruff_annotate_snippets::Renderer as AnnotateRenderer;
7-
use ruff_diagnostics::Fix;
7+
use ruff_diagnostics::{Applicability, Fix};
88
use ruff_source_file::OneIndexed;
99
use ruff_text_size::{Ranged, TextRange, TextSize};
1010

@@ -182,12 +182,28 @@ impl std::fmt::Display for Diff<'_> {
182182
}
183183
}
184184
}
185-
writeln!(
186-
f,
187-
"{note}: {msg}",
188-
note = fmt_styled("note", self.stylesheet.warning),
189-
msg = fmt_styled("This is an unsafe fix", self.stylesheet.emphasis)
190-
)?;
185+
186+
match self.fix.applicability() {
187+
Applicability::Safe => {}
188+
Applicability::Unsafe => {
189+
writeln!(
190+
f,
191+
"{note}: {msg}",
192+
note = fmt_styled("note", self.stylesheet.warning),
193+
msg = fmt_styled("This is an unsafe fix", self.stylesheet.emphasis)
194+
)?;
195+
}
196+
Applicability::DisplayOnly => {
197+
// Note that this is still only used in tests. There's no `--display-only-fixes`
198+
// analog to `--unsafe-fixes` for users to activate this or see the styling.
199+
writeln!(
200+
f,
201+
"{note}: {msg}",
202+
note = fmt_styled("note", self.stylesheet.error),
203+
msg = fmt_styled("This is a display-only fix", self.stylesheet.emphasis)
204+
)?;
205+
}
206+
}
191207

192208
Ok(())
193209
}

0 commit comments

Comments
 (0)