/// 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))
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)
}
}
($(#[$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)]
}
}
+ #[must_use]
fn $rust_name() -> define_Conf!(TY $($ty)+) {
define_Conf!(DEFAULT $($ty)+, $default)
}
}
impl Default for Conf {
+ #[must_use]
fn default() -> Self {
toml::from_str("").expect("we never error on empty config files")
}