Skip to content

Commit f2bad9c

Browse files
calebcartwrightytmimi
authored andcommitted
fix: handle skip_macro_invocations from config file
1 parent d9a0992 commit f2bad9c

File tree

4 files changed

+29
-2
lines changed

4 files changed

+29
-2
lines changed

src/config/macro_names.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use itertools::Itertools;
44
use std::{fmt, str};
55

6-
use serde::{Deserialize, Serialize};
6+
use serde::{Deserialize, Deserializer, Serialize};
77
use serde_json as json;
88
use thiserror::Error;
99

@@ -30,12 +30,22 @@ impl From<MacroName> for String {
3030
}
3131

3232
/// Defines a selector to match against a macro.
33-
#[derive(Clone, Debug, Eq, PartialEq, Hash, Ord, PartialOrd, Deserialize, Serialize)]
33+
#[derive(Clone, Debug, Eq, PartialEq, Hash, Ord, PartialOrd, Serialize)]
3434
pub enum MacroSelector {
3535
Name(MacroName),
3636
All,
3737
}
3838

39+
impl<'de> Deserialize<'de> for MacroSelector {
40+
fn deserialize<D>(de: D) -> Result<Self, D::Error>
41+
where
42+
D: Deserializer<'de>,
43+
{
44+
let s = String::deserialize(de)?;
45+
std::str::FromStr::from_str(&s).map_err(serde::de::Error::custom)
46+
}
47+
}
48+
3949
impl fmt::Display for MacroSelector {
4050
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
4151
match self {

tests/config/issue-5816.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
skip_macro_invocations=["*", "println"]
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// rustfmt-unstable: true
2+
// rustfmt-config: issue-5816.toml
3+
4+
fn main() {
5+
println!( "Hello, world!");
6+
let x =
7+
7
8+
;
9+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// rustfmt-unstable: true
2+
// rustfmt-config: issue-5816.toml
3+
4+
fn main() {
5+
println!( "Hello, world!");
6+
let x = 7;
7+
}

0 commit comments

Comments
 (0)