]> git.lizzy.rs Git - rust.git/blobdiff - src/config/lists.rs
deps: update rustc-ap to v642.0.0
[rust.git] / src / config / lists.rs
index 61496e21642415c125cec3c583a51c89e3e92250..11cb17068fb4aef9dc61b08520ab34cfb0630e49 100644 (file)
@@ -1,17 +1,8 @@
-// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
 //! Configuration options related to rewriting a list.
 
-use config::config_type::ConfigType;
-use config::IndentStyle;
+use rustfmt_config_proc_macro::config_type;
+
+use crate::config::IndentStyle;
 
 /// The definitive formatting tactic for lists.
 #[derive(Eq, PartialEq, Debug, Copy, Clone)]
@@ -35,31 +26,27 @@ pub fn ends_with_newline(&self, indent_style: IndentStyle) -> bool {
 /// Formatting tactic for lists. This will be cast down to a
 /// `DefinitiveListTactic` depending on the number and length of the items and
 /// their comments.
-#[derive(Eq, PartialEq, Debug, Copy, Clone)]
+#[config_type]
 pub enum ListTactic {
-    // One item per row.
+    /// One item per row.
     Vertical,
-    // All items on one row.
+    /// All items on one row.
     Horizontal,
-    // Try Horizontal layout, if that fails then vertical.
+    /// Try Horizontal layout, if that fails then vertical.
     HorizontalVertical,
-    // HorizontalVertical with a soft limit of n characters.
+    /// HorizontalVertical with a soft limit of n characters.
     LimitedHorizontalVertical(usize),
-    // Pack as many items as possible per row over (possibly) many rows.
+    /// Pack as many items as possible per row over (possibly) many rows.
     Mixed,
 }
 
-impl_enum_serialize_and_deserialize!(ListTactic, Vertical, Horizontal, HorizontalVertical, Mixed);
-
-#[derive(Eq, PartialEq, Debug, Copy, Clone)]
+#[config_type]
 pub enum SeparatorTactic {
     Always,
     Never,
     Vertical,
 }
 
-impl_enum_serialize_and_deserialize!(SeparatorTactic, Always, Never, Vertical);
-
 impl SeparatorTactic {
     pub fn from_bool(b: bool) -> SeparatorTactic {
         if b {
@@ -71,14 +58,12 @@ pub fn from_bool(b: bool) -> SeparatorTactic {
 }
 
 /// Where to put separator.
-#[derive(Eq, PartialEq, Debug, Copy, Clone)]
+#[config_type]
 pub enum SeparatorPlace {
     Front,
     Back,
 }
 
-impl_enum_serialize_and_deserialize!(SeparatorPlace, Front, Back);
-
 impl SeparatorPlace {
     pub fn is_front(self) -> bool {
         self == SeparatorPlace::Front
@@ -95,11 +80,13 @@ pub fn from_tactic(
     ) -> SeparatorPlace {
         match tactic {
             DefinitiveListTactic::Vertical => default,
-            _ => if sep == "," {
-                SeparatorPlace::Back
-            } else {
-                default
-            },
+            _ => {
+                if sep == "," {
+                    SeparatorPlace::Back
+                } else {
+                    default
+                }
+            }
         }
     }
 }