Sfoglia il codice sorgente

refactor: change cast to coertion, remove rustfmt skip and clippy lint ignore directives

Milo Moisson 2 anni fa
parent
commit
b6e5b2af21
1 ha cambiato i file con 5 aggiunte e 7 eliminazioni
  1. 5 7
      src/theme/mod.rs

+ 5 - 7
src/theme/mod.rs

@@ -54,7 +54,6 @@ pub struct Theme {
 }
 
 impl Options {
-    #[allow(trivial_casts)] // the `as Box<_>` stuff below warns about this for some reason
     pub fn to_theme(&self, isatty: bool) -> Theme {
         if self.use_colours == UseColours::Never
             || (self.use_colours == UseColours::Automatic && !isatty)
@@ -69,12 +68,11 @@ impl Options {
         let (exts, use_default_filetypes) = self.definitions.parse_color_vars(&mut ui);
 
         // Use between 0 and 2 file name highlighters
-        #[rustfmt::skip]
-        let exts = match (exts.is_non_empty(), use_default_filetypes) {
-            (false, false)  => Box::new(NoFileStyle)     as Box<_>,
-            (false,  true)  => Box::new(FileTypes)         as Box<_>,
-            ( true, false)  => Box::new(exts)              as Box<_>,
-            ( true,  true)  => Box::new((exts, FileTypes)) as Box<_>,
+        let exts: Box<dyn FileStyle> = match (exts.is_non_empty(), use_default_filetypes) {
+            (false, false) => Box::new(NoFileStyle),
+            (false, true) => Box::new(FileTypes),
+            (true, false) => Box::new(exts),
+            (true, true) => Box::new((exts, FileTypes)),
         };
 
         Theme { ui, exts }