]> git.lizzy.rs Git - rust.git/blobdiff - clippy_lints/src/utils/conf.rs
Merge branch 'master' into fix-4727
[rust.git] / clippy_lints / src / utils / conf.rs
index 2c96d9a8b5aa58fc9e6986516268e752070bf4e6..734b689ab1a6cebb54f4599764682b2f732846e2 100644 (file)
 /// Gets the configuration file from arguments.
 pub fn file_from_args(args: &[ast::NestedMetaItem]) -> Result<Option<path::PathBuf>, (&'static str, source_map::Span)> {
     for arg in args.iter().filter_map(syntax::ast::NestedMetaItem::meta_item) {
-        if arg.check_name("conf_file") {
-            return match arg.node {
+        if arg.check_name(sym!(conf_file)) {
+            return match arg.kind {
                 ast::MetaItemKind::Word | ast::MetaItemKind::List(_) => {
                     Err(("`conf_file` must be a named value", arg.span))
                 },
                 ast::MetaItemKind::NameValue(ref value) => {
-                    if let ast::LitKind::Str(ref file, _) = value.node {
+                    if let ast::LitKind::Str(ref file, _) = value.kind {
                         Ok(Some(file.to_string().into()))
                     } else {
                         Err(("`conf_file` value must be a string", value.span))
@@ -44,15 +44,15 @@ pub enum Error {
 impl fmt::Display for Error {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
         match *self {
-            Error::Io(ref err) => err.fmt(f),
-            Error::Toml(ref err) => err.fmt(f),
+            Self::Io(ref err) => err.fmt(f),
+            Self::Toml(ref err) => err.fmt(f),
         }
     }
 }
 
 impl From<io::Error> for Error {
     fn from(e: io::Error) -> Self {
-        Error::Io(e)
+        Self::Io(e)
     }
 }
 
@@ -64,7 +64,7 @@ macro_rules! define_Conf {
     ($(#[$doc: meta] ($rust_name: ident, $rust_name_str: expr, $default: expr => $($ty: tt)+),)+) => {
         pub use self::helpers::Conf;
         mod helpers {
-            use serde_derive::Deserialize;
+            use serde::Deserialize;
             /// Type used to store lint configuration.
             #[derive(Deserialize)]
             #[serde(rename_all="kebab-case", deny_unknown_fields)]
@@ -90,6 +90,7 @@ mod $rust_name {
                     }
                 }
 
+                #[must_use]
                 fn $rust_name() -> define_Conf!(TY $($ty)+) {
                     define_Conf!(DEFAULT $($ty)+, $default)
                 }
@@ -153,6 +154,7 @@ fn $rust_name() -> define_Conf!(TY $($ty)+) {
 }
 
 impl Default for Conf {
+    #[must_use]
     fn default() -> Self {
         toml::from_str("").expect("we never error on empty config files")
     }