Skip to content

Commit

Permalink
fmt, clippy, and edition fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomas Tauber committed Apr 9, 2023
1 parent 164bc25 commit 4ffce0a
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 24 deletions.
9 changes: 5 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@ members = ["derive"]

[package]
name = "from-pest"
version = "0.3.1"
version = "0.3.2"
edition = "2021"
authors = ["cad97 <[email protected]>"]
readme = "./README.md"
description = "Convert from a pest grammar to a typed AST"
license = "MIT"
license = "MIT/Apache-2.0"
repository = "https://github.com/pest-parser/pest_deconstruct"

[dependencies]
void = "1.0"
pest = "2.0"
pest = "2.5"
log = "0.4.6"

[dev-dependencies]
pest_derive = "2.0"
pest_derive = "2.5"
pest-ast = { version = "0.3", path = "derive" }
9 changes: 5 additions & 4 deletions derive/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
[package]
name = "pest-ast"
version = "0.3.3"
version = "0.3.4"
edition = "2021"
authors = ["cad97 <[email protected]>"]
description = "Derive to convert from pest parse tree to typed syntax tree"
license = "MIT"
license = "MIT/Apache-2.0"
readme = "./README.md"
repository = "https://github.com/pest-parser/pest_deconstruct"

Expand All @@ -19,8 +20,8 @@ itertools = "0.7"

[dev-dependencies]
from-pest = { version = "0.3", path = ".." }
pest = "2.0"
pest_derive = "2.0"
pest = "2.5"
pest_derive = "2.5"

[features]
default = ["trace"]
Expand Down
2 changes: 1 addition & 1 deletion derive/examples/simple_enum_derives.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(bad_style)]
#![allow(bad_style, dead_code)]

#[macro_use]
extern crate pest_derive;
Expand Down
2 changes: 1 addition & 1 deletion derive/examples/simple_struct_derives.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(bad_style)]
#![allow(bad_style, dead_code)]

#[macro_use]
extern crate pest_derive;
Expand Down
4 changes: 2 additions & 2 deletions derive/src/attributes.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(clippy::eval_order_dependence)] // syn patterns
#![allow(clippy::mixed_read_write_in_expression)] // syn patterns

use {
itertools::Itertools,
Expand Down Expand Up @@ -217,7 +217,7 @@ impl Parse for InnerAttribute {
let inner = input.parse()?;
let paren = parenthesized!(content in input);
let (rule, comma) = if content.peek(kw::rule) {
(Some(content.parse()?), content.parse().ok().and_then(Some))
(Some(content.parse()?), content.parse().ok())
} else {
(None, None)
};
Expand Down
4 changes: 2 additions & 2 deletions derive/src/from_pest/field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use {
},
};

use attributes::FieldAttribute;
use ::trace;
use crate::attributes::FieldAttribute;
use crate::trace;

#[derive(Clone, Debug)]
enum ConversionStrategy {
Expand Down
11 changes: 6 additions & 5 deletions derive/src/from_pest/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
use {
proc_macro2::TokenStream,
std::{path::PathBuf as FilePath},
std::path::PathBuf as FilePath,
syn::{
parse::Error, parse::Result, spanned::Spanned, Data, DataEnum, DataStruct, DeriveInput,
Ident, Path,
},
};

use attributes::DeriveAttribute;
use crate::attributes::DeriveAttribute;

mod field;

Expand Down Expand Up @@ -135,8 +135,9 @@ fn derive_for_struct(

let construct = field::convert(&parse_quote!(#name), fields)?;

let extraneous =
::trace(quote! { "when converting {}, found extraneous {:?}", stringify!(#name), inner});
let extraneous = crate::trace(
quote! { "when converting {}, found extraneous {:?}", stringify!(#name), inner},
);

Ok(quote! {
let mut clone = pest.clone();
Expand Down Expand Up @@ -178,7 +179,7 @@ fn derive_for_enum(
.map(|variant| {
let variant_name = variant.ident;
let construct_variant = field::convert(&parse_quote!(#name::#variant_name), variant.fields)?;
let extraneous = ::trace(quote! {
let extraneous = crate::trace(quote! {
"when converting {}, found extraneous {:?}", stringify!(#name), stringify!(#variant_name)
});

Expand Down
4 changes: 2 additions & 2 deletions examples/csv.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(bad_style)]
#![allow(bad_style, dead_code)]

// Unfortunately, you currently have to import all four of these.
// We're considering what it would look like to make this redundant,
Expand Down Expand Up @@ -51,7 +51,7 @@ mod ast {
}

fn main() -> Result<(), Box<dyn std::error::Error>> {
use ast::File;
use crate::ast::File;
use from_pest::FromPest;
use pest::Parser;
use std::fs;
Expand Down
10 changes: 7 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
//! The [`FromPest`] conversion framework to convert from pest trees into typed structure.
#[doc(hidden)]
pub extern crate log;
#[doc(hidden)]
pub extern crate pest;
extern crate void;
#[doc(hidden)]
pub extern crate log;

#[doc(inline)]
pub use void::Void;
Expand Down Expand Up @@ -38,7 +38,11 @@ where
match self {
ConversionError::NoMatch => write!(f, "Rule did not match, failed to convert node"),
ConversionError::Malformed(fatalerror) => write!(f, "Malformed node: {}", fatalerror),
ConversionError::Extraneous { current_node, .. } => write!(f, "when converting {}, found extraneous tokens", current_node),
ConversionError::Extraneous { current_node, .. } => write!(
f,
"when converting {}, found extraneous tokens",
current_node
),
}
}
}
Expand Down

0 comments on commit 4ffce0a

Please sign in to comment.