Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CI failures #35

Merged
merged 4 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,7 @@ stylish-plain.optional = true
all-features = true
targets = ["x86_64-unknown-linux-gnu"]
rustdoc-args = ["--cfg", "docsrs"]

[lints.rust]
unexpected_cfgs.level = "warn"
unexpected_cfgs.check-cfg = ['cfg(stylish_proc_macro_expand)']
4 changes: 4 additions & 0 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,7 @@ stylish.version = "0.1.0"
all-features = true
targets = ["x86_64-unknown-linux-gnu"]
rustdoc-args = ["--cfg", "docsrs"]

[lints.rust]
unexpected_cfgs.level = "warn"
unexpected_cfgs.check-cfg = ['cfg(stylish_proc_macro_expand)']
4 changes: 4 additions & 0 deletions macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,7 @@ unicode-ident.version = "1.0.3"
all-features = true
targets = ["x86_64-unknown-linux-gnu"]
rustdoc-args = ["--cfg", "docsrs"]

[lints.rust]
unexpected_cfgs.level = "warn"
unexpected_cfgs.check-cfg = ['cfg(stylish_proc_macro_expand)']
30 changes: 15 additions & 15 deletions macros/src/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ fn identifier(input: &str) -> IResult<&str, &str> {
}

pub trait Parse<'a>: Sized {
fn parse(input: &'a str) -> IResult<&str, Self>;
fn parse(input: &'a str) -> IResult<&'a str, Self>;
}

impl<'a> Parse<'a> for Color {
fn parse(input: &'a str) -> IResult<&str, Self> {
fn parse(input: &'a str) -> IResult<&'a str, Self> {
alt((
value(Color::Black, tag("black")),
value(Color::Red, tag("red")),
Expand All @@ -39,7 +39,7 @@ impl<'a> Parse<'a> for Color {
}

impl<'a> Parse<'a> for Intensity {
fn parse(input: &'a str) -> IResult<&str, Self> {
fn parse(input: &'a str) -> IResult<&'a str, Self> {
alt((
value(Intensity::Normal, tag("normal")),
value(Intensity::Bold, tag("bold")),
Expand All @@ -50,7 +50,7 @@ impl<'a> Parse<'a> for Intensity {

impl<'a> Parse<'a> for Box<dyn Restyle> {
#[allow(trivial_casts)]
fn parse(input: &'a str) -> IResult<&str, Self> {
fn parse(input: &'a str) -> IResult<&'a str, Self> {
alt((
map(
preceded(tag("fg"), cut(preceded(tag("="), Color::parse))),
Expand All @@ -66,7 +66,7 @@ impl<'a> Parse<'a> for Box<dyn Restyle> {
}

impl<'a> Parse<'a> for StyleDiff {
fn parse(input: &'a str) -> IResult<&str, Self> {
fn parse(input: &'a str) -> IResult<&'a str, Self> {
// TODO: This should only allow each variant once, but there's no sort of
// optional-permutation helper in nom
map(
Expand All @@ -88,7 +88,7 @@ pub enum Align {
}

impl<'a> Parse<'a> for Align {
fn parse(input: &'a str) -> IResult<&str, Self> {
fn parse(input: &'a str) -> IResult<&'a str, Self> {
alt((
value(Self::Left, tag("<")),
value(Self::Center, tag("^")),
Expand All @@ -104,7 +104,7 @@ pub enum Sign {
}

impl<'a> Parse<'a> for Sign {
fn parse(input: &'a str) -> IResult<&str, Self> {
fn parse(input: &'a str) -> IResult<&'a str, Self> {
alt((value(Self::Plus, tag("+")), value(Self::Minus, tag("-"))))(input)
}
}
Expand Down Expand Up @@ -153,7 +153,7 @@ pub enum Count<'a> {
}

impl<'a> Parse<'a> for Count<'a> {
fn parse(input: &'a str) -> IResult<&str, Self> {
fn parse(input: &'a str) -> IResult<&'a str, Self> {
alt((
map(terminated(FormatArgRef::parse, tag("$")), Self::Parameter),
map(map_res(digit1, usize::from_str), Self::Integer),
Expand All @@ -169,7 +169,7 @@ pub struct FormatSpec<'a> {
}

impl<'a> Parse<'a> for FormatSpec<'a> {
fn parse(input: &'a str) -> IResult<&str, Self> {
fn parse(input: &'a str) -> IResult<&'a str, Self> {
let (input, align) = opt(alt((
pair(anychar, Align::parse),
map(Align::parse, |align| (' ', align)),
Expand Down Expand Up @@ -227,7 +227,7 @@ pub enum FormatArgRef<'a> {
}

impl<'a> Parse<'a> for FormatArgRef<'a> {
fn parse(input: &'a str) -> IResult<&str, Self> {
fn parse(input: &'a str) -> IResult<&'a str, Self> {
alt((
map(map_res(digit1, usize::from_str), FormatArgRef::Positional),
map(identifier, FormatArgRef::Named),
Expand All @@ -242,7 +242,7 @@ pub struct FormatArg<'a> {
}

impl<'a> Parse<'a> for FormatArg<'a> {
fn parse(input: &'a str) -> IResult<&str, Self> {
fn parse(input: &'a str) -> IResult<&'a str, Self> {
let (input, arg) = opt(FormatArgRef::parse)(input)?;
let (input, format_spec) = opt(preceded(tag(":"), FormatSpec::parse))(input)?;
Ok((
Expand All @@ -263,15 +263,15 @@ pub enum Piece<'a> {
}

impl<'a> Piece<'a> {
pub fn parse_lit(input: &'a str) -> IResult<&str, Self> {
pub fn parse_lit(input: &'a str) -> IResult<&'a str, Self> {
alt((
map(recognize(many1(none_of("{}"))), Self::Lit),
value(Self::Lit("{"), tag("{{")),
value(Self::Lit("}"), tag("}}")),
))(input)
}

pub fn parse_arg(input: &'a str) -> IResult<&str, Self> {
pub fn parse_arg(input: &'a str) -> IResult<&'a str, Self> {
map(
delimited(tag("{"), cut(FormatArg::parse), tag("}")),
Self::Arg,
Expand All @@ -280,7 +280,7 @@ impl<'a> Piece<'a> {
}

impl<'a> Parse<'a> for Piece<'a> {
fn parse(input: &'a str) -> IResult<&str, Self> {
fn parse(input: &'a str) -> IResult<&'a str, Self> {
alt((Self::parse_lit, Self::parse_arg))(input)
}
}
Expand All @@ -291,7 +291,7 @@ pub struct Format<'a> {
}

impl<'a> Parse<'a> for Format<'a> {
fn parse(input: &'a str) -> IResult<&str, Self> {
fn parse(input: &'a str) -> IResult<&'a str, Self> {
all_consuming(map(many0(Piece::parse), |pieces| Self { pieces }))(input)
}
}
2 changes: 1 addition & 1 deletion macros/src/to_tokens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ impl<'a> ToTokens for Scoped<'a, Sign> {
impl<'a, 'b: 'a> ToTokens for Scoped<'a, Count<'b>> {
fn to_tokens(&self, tokens: &mut TokenStream) {
match self.as_ref() {
Count::Parameter(_) => todo!(),
Count::Parameter(_value) => todo!("parameter reference counts are not yet supported"),
Count::Integer(value) => quote!(&#value).to_tokens(tokens),
}
}
Expand Down
1 change: 1 addition & 0 deletions plain/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ mod tests {

#[test]
fn large() {
#[allow(dead_code)]
struct Foo([usize; 24]);

impl stylish_core::Display for Foo {
Expand Down
1 change: 1 addition & 0 deletions tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ mod tests {

#[test]
fn large() {
#[allow(dead_code)]
struct Foo([usize; 24]);

impl stylish::Display for Foo {
Expand Down
Loading