fix: handle skip_macro_invocations from config file

This commit is contained in:
Caleb Cartwright 2023-07-05 14:05:53 -05:00 committed by Yacin Tmimi
parent d9a09925d7
commit f2bad9c7af
4 changed files with 29 additions and 2 deletions

View File

@ -3,7 +3,7 @@
use itertools::Itertools; use itertools::Itertools;
use std::{fmt, str}; use std::{fmt, str};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Deserializer, Serialize};
use serde_json as json; use serde_json as json;
use thiserror::Error; use thiserror::Error;
@ -30,12 +30,22 @@ fn from(other: MacroName) -> Self {
} }
/// Defines a selector to match against a macro. /// 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 { pub enum MacroSelector {
Name(MacroName), Name(MacroName),
All, 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 { impl fmt::Display for MacroSelector {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self { match self {

View File

@ -0,0 +1 @@
skip_macro_invocations=["*", "println"]

View File

@ -0,0 +1,9 @@
// rustfmt-unstable: true
// rustfmt-config: issue-5816.toml
fn main() {
println!( "Hello, world!");
let x =
7
;
}

View File

@ -0,0 +1,7 @@
// rustfmt-unstable: true
// rustfmt-config: issue-5816.toml
fn main() {
println!( "Hello, world!");
let x = 7;
}