diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml index 1a3499ee6..04737aa8d 100644 --- a/.github/workflows/changelog.yml +++ b/.github/workflows/changelog.yml @@ -5,7 +5,7 @@ on: jobs: test: - runs-on: ubuntu-20.04 + runs-on: ${{ vars.UBUNTU_VERSION }} steps: - uses: actions/checkout@v1 with: diff --git a/.github/workflows/esprc.yml b/.github/workflows/esprc.yml index 83a2ac377..0d18749ed 100644 --- a/.github/workflows/esprc.yml +++ b/.github/workflows/esprc.yml @@ -8,7 +8,7 @@ on: jobs: parse: - runs-on: ubuntu-20.04 + runs-on: ${{ vars.UBUNTU_VERSION }} strategy: matrix: ap: @@ -18,7 +18,7 @@ jobs: - uses: actions/checkout@v1 - uses: actions-rs/toolchain@v1 with: - toolchain: "1.56.0" + toolchain: ${{ vars.MSRV }} profile: minimal default: true override: true @@ -28,7 +28,7 @@ jobs: args: --release --bin esprc -- ./schemas/APs/10303-${{ matrix.ap }}-aim-long.exp --check generate: - runs-on: ubuntu-20.04 + runs-on: ${{ vars.UBUNTU_VERSION }} strategy: matrix: ap: @@ -38,7 +38,7 @@ jobs: - uses: actions/checkout@v1 - uses: actions-rs/toolchain@v1 with: - toolchain: "1.56.0" + toolchain: ${{ vars.MSRV }} profile: minimal components: rustfmt default: true diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index f8f39d6a0..afce96945 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -7,12 +7,12 @@ on: jobs: pages: - runs-on: ubuntu-20.04 + runs-on: ${{ vars.UBUNTU_VERSION }} steps: - uses: actions/checkout@v2 - uses: actions-rs/toolchain@v1 with: - toolchain: "1.56.0" + toolchain: ${{ vars.MSRV }} profile: minimal default: true override: true diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index f3376817e..6962fe995 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -8,12 +8,12 @@ on: jobs: test: - runs-on: ubuntu-20.04 + runs-on: ${{ vars.UBUNTU_VERSION }} strategy: matrix: rust: - stable - - "1.56.0" # MSRV (for edition 2021) + - ${{ vars.MSRV }} steps: - uses: actions/checkout@v1 - uses: actions-rs/toolchain@v1 @@ -30,12 +30,12 @@ jobs: args: --all-features check-format: - runs-on: ubuntu-20.04 + runs-on: ${{ vars.UBUNTU_VERSION }} steps: - uses: actions/checkout@v1 - uses: actions-rs/toolchain@v1 with: - toolchain: "1.56.0" + toolchain: ${{ vars.MSRV }} profile: minimal components: rustfmt default: true @@ -46,12 +46,12 @@ jobs: args: -- --check doc: - runs-on: ubuntu-20.04 + runs-on: ${{ vars.UBUNTU_VERSION }} steps: - uses: actions/checkout@v1 - uses: actions-rs/toolchain@v1 with: - toolchain: "1.56.0" + toolchain: ${{ vars.MSRV }} profile: minimal default: true override: true @@ -61,12 +61,12 @@ jobs: args: --no-deps clippy: - runs-on: ubuntu-20.04 + runs-on: ${{ vars.UBUNTU_VERSION }} steps: - uses: actions/checkout@v1 - uses: actions-rs/toolchain@v1 with: - toolchain: "1.56.0" + toolchain: ${{ vars.MSRV }} profile: minimal components: clippy default: true diff --git a/CHANGELOG.md b/CHANGELOG.md index 8658e1571..4d02016e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ In addition to original Keep-a-Changelog, we use following rules: ### Internal - `cargo upgrade --workspace` https://github.com/ricosjp/ruststep/pull/240 +- Upgrading MSRV, updating dependent packages, and supporting the new clippy https://github.com/ricosjp/ruststep/pull/246 ## 0.3.0 - 2022-06-14 diff --git a/Cargo.toml b/Cargo.toml index 7ae596511..983f083a5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,4 +1,5 @@ [workspace] +resolver = "2" members = [ "espr", "espr-derive", diff --git a/espr-derive/Cargo.toml b/espr-derive/Cargo.toml index 19142a02e..c1979a027 100644 --- a/espr-derive/Cargo.toml +++ b/espr-derive/Cargo.toml @@ -16,9 +16,9 @@ categories = ["science", "development-tools"] proc-macro = true [dependencies] -quote = "1.0.26" -proc-macro2 = "1.0.53" -syn = { version = "2.0.9", features = ["full", "extra-traits"] } +quote = "1.0.37" +proc-macro2 = "1.0.86" +syn = { version = "2.0.77", features = ["full", "extra-traits"] } [dependencies.espr] version = "0.3.0" @@ -27,5 +27,5 @@ path = "../espr" [dev-dependencies] ruststep = { version = "0.3.0", path = "../ruststep" } ruststep-derive = { version = "0.3.0", path = "../ruststep-derive" } -serde = "1.0.158" +serde = "1.0.210" derive-new = "0.5.9" diff --git a/espr/Cargo.toml b/espr/Cargo.toml index 719362145..bccd03215 100644 --- a/espr/Cargo.toml +++ b/espr/Cargo.toml @@ -18,20 +18,20 @@ categories = ["science", "development-tools"] nom = "7.1.3" # For Rust code generation -syn = "2.0.9" -quote = "1.0.26" -proc-macro2 = "1.0.53" +syn = "2.0.56" +quote = "1.0.37" +proc-macro2 = "1.0.86" # Utilities Inflector = "0.11.4" -derive_more = "0.99.17" +derive_more = "0.99.18" itertools = "0.10.5" maplit = "1.0.2" -thiserror = "1.0.40" +thiserror = "1.0.63" structopt = "0.3.26" check_keyword = "0.2.0" katexit = "0.1.4" [dev-dependencies] -insta = "1.29.0" +insta = "1.39.0" maplit = "1.0.2" diff --git a/espr/src/ast/mod.rs b/espr/src/ast/mod.rs index 3330e3a13..5d6524980 100644 --- a/espr/src/ast/mod.rs +++ b/espr/src/ast/mod.rs @@ -25,18 +25,18 @@ pub trait Component: Sized { } } -#[macro_export(local_inner_macro)] +#[macro_export(local_inner_macros)] macro_rules! derive_ast_component { ($component:ty, $parser:path) => { - impl crate::ast::Component for $component { + impl $crate::ast::Component for $component { fn parse( input: &str, - ) -> Result<(Self, Vec), crate::ast::TokenizeFailed> { + ) -> Result<(Self, Vec<$crate::ast::Remark>), $crate::ast::TokenizeFailed> { use nom::Finish; let input = input.trim(); let (_input, parsed) = $parser(input) .finish() - .map_err(|err| crate::ast::TokenizeFailed::new(input, err))?; + .map_err(|err| $crate::ast::TokenizeFailed::new(input, err))?; Ok(parsed) } } diff --git a/espr/src/codegen/rust/mod.rs b/espr/src/codegen/rust/mod.rs index 60fc3e7b0..f747893db 100644 --- a/espr/src/codegen/rust/mod.rs +++ b/espr/src/codegen/rust/mod.rs @@ -7,6 +7,5 @@ mod simple_type; mod type_decl; mod type_ref; -pub use entity::*; pub use format::rustfmt; pub use schema::*; diff --git a/espr/src/codegen/rust/schema.rs b/espr/src/codegen/rust/schema.rs index 33bd6e846..3744e3e35 100644 --- a/espr/src/codegen/rust/schema.rs +++ b/espr/src/codegen/rust/schema.rs @@ -36,10 +36,10 @@ impl Schema { let name = format_ident!("{}", self.name); let types = &self.types; let entities = &self.entities; - let type_decls = self.types.iter().filter(|e| match e { - TypeDecl::Enumeration(_) => false, - _ => true, - }); + let type_decls = self + .types + .iter() + .filter(|e| !matches!(e, TypeDecl::Enumeration(_))); let entity_types: Vec<_> = entities .iter() .map(|e| format_ident!("{}", e.name.to_pascal_case())) diff --git a/espr/src/ir/complex_entity.rs b/espr/src/ir/complex_entity.rs index fedf14b82..ec2e4922d 100644 --- a/espr/src/ir/complex_entity.rs +++ b/espr/src/ir/complex_entity.rs @@ -49,17 +49,16 @@ pub struct PartialComplexEntity { impl PartialOrd for PartialComplexEntity { fn partial_cmp(&self, rhs: &Self) -> Option { - match PartialOrd::partial_cmp(&self.indices.len(), &rhs.indices.len()) { - Some(Ordering::Equal) => PartialOrd::partial_cmp(&self.indices, &rhs.indices), - a @ Some(Ordering::Less) | a @ Some(Ordering::Greater) => a, - None => unreachable!(), - } + Some(self.cmp(rhs)) } } impl Ord for PartialComplexEntity { fn cmp(&self, rhs: &Self) -> Ordering { - self.partial_cmp(rhs).unwrap() + match Ord::cmp(&self.indices.len(), &rhs.indices.len()) { + Ordering::Equal => Ord::cmp(&self.indices, &rhs.indices), + a @ Ordering::Less | a @ Ordering::Greater => a, + } } } diff --git a/espr/src/ir/scope.rs b/espr/src/ir/scope.rs index 5854a00d0..a65b55f8c 100644 --- a/espr/src/ir/scope.rs +++ b/espr/src/ir/scope.rs @@ -78,13 +78,7 @@ impl PartialOrd for Scope { return None; } } - if self.0.len() == other.0.len() { - Some(cmp::Ordering::Equal) - } else if self.0.len() > other.0.len() { - Some(cmp::Ordering::Less) - } else { - Some(cmp::Ordering::Greater) - } + Some(other.0.len().cmp(&self.0.len())) } } diff --git a/espr/src/parser/basis.rs b/espr/src/parser/basis.rs index 268b77e4c..873471a2c 100644 --- a/espr/src/parser/basis.rs +++ b/espr/src/parser/basis.rs @@ -1,3 +1,5 @@ +#![allow(clippy::manual_is_ascii_check)] + use super::{combinator::RawParseResult, reserved::is_reserved}; use nom::{branch::*, character::complete::*, multi::*, sequence::*, Parser}; diff --git a/espr/src/parser/entity/mod.rs b/espr/src/parser/entity/mod.rs index 131a9243f..6c5c58bdb 100644 --- a/espr/src/parser/entity/mod.rs +++ b/espr/src/parser/entity/mod.rs @@ -1,6 +1,7 @@ mod attribute; mod derive; mod domain; +#[allow(clippy::module_inception)] mod entity; mod inverse; mod unique; diff --git a/espr/src/parser/schema.rs b/espr/src/parser/schema.rs index ed7850805..e159c8b31 100644 --- a/espr/src/parser/schema.rs +++ b/espr/src/parser/schema.rs @@ -103,7 +103,7 @@ pub fn procedure_decl(input: &str) -> ParseResult { /// `)` \] `;` . pub fn procedure_head(input: &str) -> ParseResult<(String, Vec)> { let param = tuple((opt(tag("VAR")), formal_parameter)).map(|(var, mut params)| { - for mut param in &mut params { + for param in &mut params { param.is_variable = var.is_some(); } params diff --git a/ruststep-derive/Cargo.toml b/ruststep-derive/Cargo.toml index 0a94ce980..e9b21d45c 100644 --- a/ruststep-derive/Cargo.toml +++ b/ruststep-derive/Cargo.toml @@ -17,17 +17,17 @@ categories = ["science", "development-tools"] proc-macro = true [dependencies] -quote = "1.0.26" -proc-macro2 = "1.0.53" -syn = { version = "2.0.9", features = ["full", "extra-traits"] } -proc-macro-crate = "1.2.1" +quote = "1.0.37" +proc-macro2 = "1.0.86" +syn = { version = "2.0.56", features = ["full", "extra-traits"] } +proc-macro-crate = "1.3.0" Inflector = "0.11.4" proc-macro-error = "1.0.4" [dev-dependencies] -serde = "1.0.158" -trybuild = "1.0.80" -insta = "1.29.0" +serde = "1.0.210" +trybuild = "1.0.90" +insta = "1.39.0" [dev-dependencies.ruststep] path = "../ruststep" diff --git a/ruststep-derive/src/common.rs b/ruststep-derive/src/common.rs index 3125091ae..ae0762ab6 100644 --- a/ruststep-derive/src/common.rs +++ b/ruststep-derive/src/common.rs @@ -19,7 +19,7 @@ pub fn as_holder_path(input: &syn::Type) -> syn::Type { .clone() .try_into() .expect_or_abort("as_holder! only accepts espr-generated type"); - ft.as_holder().into() + ft.into_holder().into() } pub fn as_visitor_ident(input: &syn::Ident) -> syn::Ident { diff --git a/ruststep-derive/src/entity.rs b/ruststep-derive/src/entity.rs index 98a65f7ab..7975063fb 100644 --- a/ruststep-derive/src/entity.rs +++ b/ruststep-derive/src/entity.rs @@ -85,7 +85,7 @@ impl FieldEntries { }), FieldType::Boxed(_) => abort_call_site!("Unexpected Box"), } - holder_types.push(ft.as_holder().as_place_holder().into()); + holder_types.push(ft.into_holder().into_place_holder().into()); } else { into_owned.push(quote! { #ident }); holder_types.push(ft.into()); diff --git a/ruststep-derive/src/field_type.rs b/ruststep-derive/src/field_type.rs index 54800a300..fd4233eb8 100644 --- a/ruststep-derive/src/field_type.rs +++ b/ruststep-derive/src/field_type.rs @@ -17,14 +17,14 @@ pub enum FieldType { } impl FieldType { - pub fn as_holder(self) -> Self { + pub fn into_holder(self) -> Self { match self { FieldType::Path(path) => { let syn::Path { leading_colon, mut segments, } = path; - let mut last_seg = segments.last_mut().unwrap(); + let last_seg = segments.last_mut().unwrap(); match &mut last_seg.arguments { syn::PathArguments::None => { last_seg.ident = as_holder_ident(&last_seg.ident); @@ -37,21 +37,21 @@ impl FieldType { }) } FieldType::Optional(ty) => { - let holder = ty.as_holder(); + let holder = ty.into_holder(); FieldType::Optional(Box::new(holder)) } FieldType::List(ty) => { - let holder = ty.as_holder(); + let holder = ty.into_holder(); FieldType::List(Box::new(holder)) } FieldType::Boxed(ty) => { - let holder = ty.as_holder(); + let holder = ty.into_holder(); FieldType::Boxed(Box::new(holder)) } } } - pub fn as_place_holder(self) -> Self { + pub fn into_place_holder(self) -> Self { let ruststep = ruststep_crate(); match self { FieldType::Path(path) => { @@ -59,15 +59,15 @@ impl FieldType { FieldType::Path(path) } FieldType::Optional(ty) => { - let place_holder = ty.as_place_holder(); + let place_holder = ty.into_place_holder(); FieldType::Optional(Box::new(place_holder)) } FieldType::List(ty) => { - let place_holder = ty.as_place_holder(); + let place_holder = ty.into_place_holder(); FieldType::List(Box::new(place_holder)) } FieldType::Boxed(ty) => { - let place_holder = ty.as_place_holder(); + let place_holder = ty.into_place_holder(); FieldType::Boxed(Box::new(place_holder)) } } @@ -77,18 +77,18 @@ impl FieldType { #[derive(Debug, Clone)] pub struct UnsupportedTypeError {} -impl Into for UnsupportedTypeError { - fn into(self) -> Diagnostic { - Diagnostic::new( +impl From for Diagnostic { + fn from(_: UnsupportedTypeError) -> Self { + Self::new( Level::Error, "Unsupported Type for ruststep and espr".to_string(), ) } } -impl Into for FieldType { - fn into(self) -> syn::Type { - let path = match self { +impl From for syn::Type { + fn from(field_type: FieldType) -> Self { + let path = match field_type { FieldType::Path(path) => path, FieldType::Optional(ty) => { let ty: syn::Type = (*ty).into(); @@ -181,25 +181,25 @@ mod tests { fn as_holder() { let ty: syn::Type = syn::parse_str("T").unwrap(); let f: FieldType = ty.try_into().unwrap(); - let holder = f.as_holder(); + let holder = f.into_holder(); let ans: syn::Type = syn::parse_str("THolder").unwrap(); assert_eq!(>::into(holder), ans); let ty: syn::Type = syn::parse_str("Option").unwrap(); let f: FieldType = ty.try_into().unwrap(); - let holder = f.as_holder(); + let holder = f.into_holder(); let ans: syn::Type = syn::parse_str("Option").unwrap(); assert_eq!(>::into(holder), ans); let ty: syn::Type = syn::parse_str("Vec").unwrap(); let f: FieldType = ty.try_into().unwrap(); - let holder = f.as_holder(); + let holder = f.into_holder(); let ans: syn::Type = syn::parse_str("Vec").unwrap(); assert_eq!(>::into(holder), ans); let ty: syn::Type = syn::parse_str("Option>").unwrap(); let f: FieldType = ty.try_into().unwrap(); - let holder = f.as_holder(); + let holder = f.into_holder(); let ans: syn::Type = syn::parse_str("Option>").unwrap(); assert_eq!(>::into(holder), ans); } @@ -208,27 +208,27 @@ mod tests { fn as_place_holder() { let ty: syn::Type = syn::parse_str("T").unwrap(); let f: FieldType = ty.try_into().unwrap(); - let place_holder = f.as_holder().as_place_holder(); + let place_holder = f.into_holder().into_place_holder(); let ans: syn::Type = syn::parse_str("::ruststep::tables::PlaceHolder").unwrap(); assert_eq!(>::into(place_holder), ans); let ty: syn::Type = syn::parse_str("Option").unwrap(); let f: FieldType = ty.try_into().unwrap(); - let place_holder = f.as_holder().as_place_holder(); + let place_holder = f.into_holder().into_place_holder(); let ans: syn::Type = syn::parse_str("Option<::ruststep::tables::PlaceHolder>").unwrap(); assert_eq!(>::into(place_holder), ans); let ty: syn::Type = syn::parse_str("Vec").unwrap(); let f: FieldType = ty.try_into().unwrap(); - let place_holder = f.as_holder().as_place_holder(); + let place_holder = f.into_holder().into_place_holder(); let ans: syn::Type = syn::parse_str("Vec<::ruststep::tables::PlaceHolder>").unwrap(); assert_eq!(>::into(place_holder), ans); let ty: syn::Type = syn::parse_str("Option>").unwrap(); let f: FieldType = ty.try_into().unwrap(); - let place_holder = f.as_holder().as_place_holder(); + let place_holder = f.into_holder().into_place_holder(); let ans: syn::Type = syn::parse_str("Option>>").unwrap(); assert_eq!(>::into(place_holder), ans); diff --git a/ruststep-derive/src/type_decl.rs b/ruststep-derive/src/type_decl.rs index fc2a5f014..db1631e8c 100644 --- a/ruststep-derive/src/type_decl.rs +++ b/ruststep-derive/src/type_decl.rs @@ -217,7 +217,7 @@ impl FieldEntries { }), FieldType::Boxed(_) => abort_call_site!("Unexpected Box"), } - holder_types.push(ft.as_holder().as_place_holder().into()); + holder_types.push(ft.into_holder().into_place_holder().into()); } else { into_owned.push(quote! { self.#index }); holder_types.push(ft.into()); diff --git a/ruststep/Cargo.toml b/ruststep/Cargo.toml index fed5e0e6f..a2f042dcf 100644 --- a/ruststep/Cargo.toml +++ b/ruststep/Cargo.toml @@ -19,11 +19,11 @@ ap201 = [] ap203 = [] [dependencies] -derive_more = "0.99.17" +derive_more = "0.99.18" derive-new = "0.5.9" nom = "7.1.3" -serde = { version = "1.0.158", features = ["derive"] } -thiserror = "1.0.40" +serde = { version = "1.0.210", features = ["derive"] } +thiserror = "1.0.63" Inflector = "0.11.4" itertools = "0.10.5" @@ -32,7 +32,7 @@ path = "../ruststep-derive" version = "0.3.0" [dev-dependencies] -anyhow = "1.0.70" +anyhow = "1.0.89" maplit = "1.0.2" [dev-dependencies.espr-derive] diff --git a/ruststep/src/ast/de/record.rs b/ruststep/src/ast/de/record.rs index f269c8e26..416e12133 100644 --- a/ruststep/src/ast/de/record.rs +++ b/ruststep/src/ast/de/record.rs @@ -25,7 +25,7 @@ impl<'de, 'record> de::Deserializer<'de> for &'record Record { { if name == self.name { if let Parameter::List(ref parameters) = self.parameter { - return visitor.visit_map(RecordStructDeserializer::new(fields, ¶meters)); + return visitor.visit_map(RecordStructDeserializer::new(fields, parameters)); } } Self::deserialize_any(self, visitor) diff --git a/ruststep/src/ast/de/subsuper.rs b/ruststep/src/ast/de/subsuper.rs index 7be54b742..dbecaeb3b 100644 --- a/ruststep/src/ast/de/subsuper.rs +++ b/ruststep/src/ast/de/subsuper.rs @@ -49,7 +49,7 @@ impl<'de, 'record> de::MapAccess<'de> for SubSuperRecordDeserializer<'record> { let key: K::Value = seed.deserialize(key)?; Ok(Some(key)) } else { - return Ok(None); + Ok(None) } } diff --git a/ruststep/src/parser/basic.rs b/ruststep/src/parser/basic.rs index aa0e202a2..c7a4c1eb8 100644 --- a/ruststep/src/parser/basic.rs +++ b/ruststep/src/parser/basic.rs @@ -1,5 +1,7 @@ //! Parser for basic alphabets defined in the table 1 of ISO-10303-21 +#![allow(clippy::manual_is_ascii_check)] + use super::combinator::*; use nom::{ branch::alt, diff --git a/ruststep/src/tables.rs b/ruststep/src/tables.rs index 6467dab1e..d4c3bdb63 100644 --- a/ruststep/src/tables.rs +++ b/ruststep/src/tables.rs @@ -194,7 +194,10 @@ pub fn insert_record<'de, T: de::Deserialize<'de>>( id: u64, record: &Record, ) -> crate::error::Result<()> { - if let Some(_) = table.insert(id, de::Deserialize::deserialize(record)?) { + if table + .insert(id, de::Deserialize::deserialize(record)?) + .is_some() + { Err(Error::DuplicatedEntity(id)) } else { Ok(())