fix: handle skip_macro_invocations from config file
This commit is contained in:
parent
d9a09925d7
commit
f2bad9c7af
@ -3,7 +3,7 @@
|
||||
use itertools::Itertools;
|
||||
use std::{fmt, str};
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde::{Deserialize, Deserializer, Serialize};
|
||||
use serde_json as json;
|
||||
use thiserror::Error;
|
||||
|
||||
@ -30,12 +30,22 @@ fn from(other: MacroName) -> Self {
|
||||
}
|
||||
|
||||
/// Defines a selector to match against a macro.
|
||||
#[derive(Clone, Debug, Eq, PartialEq, Hash, Ord, PartialOrd, Deserialize, Serialize)]
|
||||
#[derive(Clone, Debug, Eq, PartialEq, Hash, Ord, PartialOrd, Serialize)]
|
||||
pub enum MacroSelector {
|
||||
Name(MacroName),
|
||||
All,
|
||||
}
|
||||
|
||||
impl<'de> Deserialize<'de> for MacroSelector {
|
||||
fn deserialize<D>(de: D) -> Result<Self, D::Error>
|
||||
where
|
||||
D: Deserializer<'de>,
|
||||
{
|
||||
let s = String::deserialize(de)?;
|
||||
std::str::FromStr::from_str(&s).map_err(serde::de::Error::custom)
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for MacroSelector {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
|
1
tests/config/issue-5816.toml
Normal file
1
tests/config/issue-5816.toml
Normal file
@ -0,0 +1 @@
|
||||
skip_macro_invocations=["*", "println"]
|
9
tests/source/skip_macro_invocations/config_file.rs
Normal file
9
tests/source/skip_macro_invocations/config_file.rs
Normal file
@ -0,0 +1,9 @@
|
||||
// rustfmt-unstable: true
|
||||
// rustfmt-config: issue-5816.toml
|
||||
|
||||
fn main() {
|
||||
println!( "Hello, world!");
|
||||
let x =
|
||||
7
|
||||
;
|
||||
}
|
7
tests/target/skip_macro_invocations/config_file.rs
Normal file
7
tests/target/skip_macro_invocations/config_file.rs
Normal file
@ -0,0 +1,7 @@
|
||||
// rustfmt-unstable: true
|
||||
// rustfmt-config: issue-5816.toml
|
||||
|
||||
fn main() {
|
||||
println!( "Hello, world!");
|
||||
let x = 7;
|
||||
}
|
Loading…
Reference in New Issue
Block a user