@@ -4,7 +4,7 @@ use std::num::NonZeroUsize;
44use similar:: { ChangeTag , TextDiff } ;
55
66use ruff_annotate_snippets:: Renderer as AnnotateRenderer ;
7- use ruff_diagnostics:: Fix ;
7+ use ruff_diagnostics:: { Applicability , Fix } ;
88use ruff_source_file:: OneIndexed ;
99use 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