diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4c82c20..05ee2dc 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,7 +21,7 @@ jobs: - os: windows-latest toolchain: stable - os: ubuntu-latest - toolchain: "1.70.0" + toolchain: "1.85.0" targets: "--lib --tests" variant: MSRV @@ -31,9 +31,9 @@ jobs: - name: Checkout uses: actions/checkout@v6 - - name: MSRV + - name: Not MSRV if: ${{ matrix.variant == 'MSRV' }} - run: cp Cargo.lock.msrv Cargo.lock + run: cargo generate-lockfile --ignore-rust-version - name: Install toolchain uses: dtolnay/rust-toolchain@master diff --git a/Cargo.lock.msrv b/Cargo.lock.msrv deleted file mode 100644 index c7216f6..0000000 --- a/Cargo.lock.msrv +++ /dev/null @@ -1,441 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "autocfg" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" - -[[package]] -name = "cfg-if" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9555578bc9e57714c812a1f84e4fc5b4d21fcb063490c624de019f7464c91268" - -[[package]] -name = "doc-comment" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" - -[[package]] -name = "equivalent" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" - -[[package]] -name = "getrandom" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592" -dependencies = [ - "cfg-if", - "libc", - "wasi", -] - -[[package]] -name = "glob" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8d1add55171497b4705a648c6b583acafb01d58050a51727785f0b2c8e0a2b2" - -[[package]] -name = "hashbrown" -version = "0.15.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5971ac85611da7067dbfcabef3c70ebb5606018acd9e2a3903a0da507521e0d5" - -[[package]] -name = "impl-tools" -version = "0.10.3" -dependencies = [ - "autocfg", - "doc-comment", - "impl-tools-lib", - "proc-macro-error2", - "syn", - "trybuild", - "twox-hash", -] - -[[package]] -name = "impl-tools-lib" -version = "0.11.1" -dependencies = [ - "proc-macro-error2", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "indexmap" -version = "2.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cea70ddb795996207ad57735b50c5982d8844f38ba9ee5f1aedcfb708a2aa11e" -dependencies = [ - "equivalent", - "hashbrown", -] - -[[package]] -name = "itoa" -version = "1.0.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" - -[[package]] -name = "libc" -version = "0.2.172" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d750af042f7ef4f724306de029d18836c26c1765a54a6a3f094cbd23a7267ffa" - -[[package]] -name = "memchr" -version = "2.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" - -[[package]] -name = "once_cell" -version = "1.21.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" - -[[package]] -name = "ppv-lite86" -version = "0.2.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" -dependencies = [ - "zerocopy", -] - -[[package]] -name = "proc-macro-error-attr2" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96de42df36bb9bba5542fe9f1a054b8cc87e172759a1868aa05c1f3acc89dfc5" -dependencies = [ - "proc-macro2", - "quote", -] - -[[package]] -name = "proc-macro-error2" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11ec05c52be0a07b08061f7dd003e7d7092e0472bc731b4af7bb1ef876109802" -dependencies = [ - "proc-macro-error-attr2", - "proc-macro2", - "quote", -] - -[[package]] -name = "proc-macro2" -version = "1.0.95" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "quote" -version = "1.0.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "rand" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" -dependencies = [ - "libc", - "rand_chacha", - "rand_core", -] - -[[package]] -name = "rand_chacha" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" -dependencies = [ - "ppv-lite86", - "rand_core", -] - -[[package]] -name = "rand_core" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" -dependencies = [ - "getrandom", -] - -[[package]] -name = "ryu" -version = "1.0.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" - -[[package]] -name = "serde" -version = "1.0.219" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde_derive" -version = "1.0.219" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "serde_json" -version = "1.0.140" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373" -dependencies = [ - "itoa", - "memchr", - "ryu", - "serde", -] - -[[package]] -name = "serde_spanned" -version = "0.6.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87607cb1398ed59d48732e575a4c28a7a8ebf2454b964fe3f224f2afc07909e1" -dependencies = [ - "serde", -] - -[[package]] -name = "static_assertions" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" - -[[package]] -name = "syn" -version = "2.0.102" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6397daf94fa90f058bd0fd88429dd9e5738999cca8d701813c80723add80462" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "termcolor" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" -dependencies = [ - "winapi-util", -] - -[[package]] -name = "toml" -version = "0.8.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd87a5cdd6ffab733b2f74bc4fd7ee5fff6634124999ac278c35fc78c6120148" -dependencies = [ - "serde", - "serde_spanned", - "toml_datetime", - "toml_edit", -] - -[[package]] -name = "toml_datetime" -version = "0.6.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" -dependencies = [ - "serde", -] - -[[package]] -name = "toml_edit" -version = "0.22.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02a8b472d1a3d7c18e2d61a489aee3453fd9031c33e4f55bd533f4a7adca1bee" -dependencies = [ - "indexmap", - "serde", - "serde_spanned", - "toml_datetime", - "winnow", -] - -[[package]] -name = "trybuild" -version = "1.0.90" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2aa6f84ec205ebf87fb7a0abdbcd1467fa5af0e86878eb6d888b78ecbb10b6d5" -dependencies = [ - "glob", - "once_cell", - "serde", - "serde_derive", - "serde_json", - "termcolor", - "toml", -] - -[[package]] -name = "twox-hash" -version = "1.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" -dependencies = [ - "cfg-if", - "rand", - "static_assertions", -] - -[[package]] -name = "unicode-ident" -version = "1.0.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" - -[[package]] -name = "wasi" -version = "0.11.1+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" - -[[package]] -name = "winapi-util" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" -dependencies = [ - "windows-sys", -] - -[[package]] -name = "windows-sys" -version = "0.59.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" -dependencies = [ - "windows-targets", -] - -[[package]] -name = "windows-targets" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" -dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_gnullvm", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", -] - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" - -[[package]] -name = "windows_i686_gnu" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" - -[[package]] -name = "windows_i686_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" - -[[package]] -name = "windows_i686_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" - -[[package]] -name = "winnow" -version = "0.7.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74c7b26e3480b707944fc872477815d29a8e429d2f93a1ce000f5fa84a15cbcd" -dependencies = [ - "memchr", -] - -[[package]] -name = "zerocopy" -version = "0.8.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1702d9583232ddb9174e01bb7c15a2ab8fb1bc6f227aa1233858c351a3ba0cb" -dependencies = [ - "zerocopy-derive", -] - -[[package]] -name = "zerocopy-derive" -version = "0.8.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28a6e20d751156648aa063f3800b706ee209a32c0b4d9f24be3d980b01be55ef" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] diff --git a/Cargo.toml b/Cargo.toml index b40159a..468fabd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,8 +5,8 @@ members = ["lib", "tests/test-cfg"] authors = ["Diggory Hardy "] license = "MIT/Apache-2.0" repository = "https://github.com/kas-gui/impl-tools" -rust-version = "1.70.0" -edition = "2021" +rust-version = "1.85.0" +edition = "2024" [package] name = "impl-tools" @@ -27,12 +27,12 @@ proc-macro = true [features] # Enables better proc-macro diagnostics (including warnings); nightly only. -nightly-diagnostics = ["proc-macro-error2/nightly"] +nightly-diagnostics = ["proc-macro-error3/nightly"] # Squelch lint: "autoimpl on trait that has a method with Self: Sized bound" allow-trait-autoimpl-with-sized-fn-bound = ["impl-tools-lib/allow-trait-autoimpl-with-sized-fn-bound"] -[dependencies.proc-macro-error2] -version = "2.0" +[dependencies.proc-macro-error3] +version = "3.0.2" default-features = false [dependencies.syn] @@ -44,7 +44,7 @@ path = "lib" [dev-dependencies] doc-comment = "0.3.3" -twox-hash = "1.6.3" +twox-hash = "2.1.1" trybuild = "1.0.90" [build-dependencies] diff --git a/lib/Cargo.toml b/lib/Cargo.toml index e500dae..4f90414 100644 --- a/lib/Cargo.toml +++ b/lib/Cargo.toml @@ -19,8 +19,8 @@ allow-trait-autoimpl-with-sized-fn-bound = [] quote = "1.0" proc-macro2 = "1.0" -[dependencies.proc-macro-error2] -version = "2.0" +[dependencies.proc-macro-error3] +version = "3.0.2" default-features = false [dependencies.syn] diff --git a/lib/src/anon.rs b/lib/src/anon.rs index e7e135e..60fb4ad 100644 --- a/lib/src/anon.rs +++ b/lib/src/anon.rs @@ -5,14 +5,14 @@ //! The `impl_anon!` macro +use crate::IdentFormatter; use crate::fields::{Field, Fields, FieldsNamed, FieldsUnnamed, StructStyle}; use crate::scope::{Scope, ScopeItem}; -use crate::IdentFormatter; use proc_macro2::{Span, TokenStream}; -use quote::{quote, ToTokens, TokenStreamExt}; +use quote::{ToTokens, TokenStreamExt, quote}; use syn::token::{Brace, Colon, Comma, Eq, Paren, Semi}; -use syn::{parse_quote, punctuated::Punctuated, spanned::Spanned}; use syn::{Attribute, GenericParam, Generics, Ident, ItemImpl, Member, Token, Type, TypePath}; +use syn::{parse_quote, punctuated::Punctuated, spanned::Spanned}; /// A field of a [`Anon`] #[derive(Debug)] @@ -291,7 +291,7 @@ impl ToTokens for AnonScope { mod parsing { use super::*; - use proc_macro_error2::abort; + use proc_macro_error3::abort; use syn::parse::{Error, Parse, ParseStream, Result}; use syn::{braced, parenthesized}; diff --git a/lib/src/autoimpl.rs b/lib/src/autoimpl.rs index 1c207a1..9b8ba95 100644 --- a/lib/src/autoimpl.rs +++ b/lib/src/autoimpl.rs @@ -5,16 +5,16 @@ //! Implementation of the `#[autoimpl]` attribute -use crate::generics::{clause_to_toks, WhereClause}; use crate::SimplePath; +use crate::generics::{WhereClause, clause_to_toks}; +use proc_macro_error3::emit_error; use proc_macro2::{Span, TokenStream as Toks}; -use proc_macro_error2::emit_error; -use quote::{quote, TokenStreamExt}; +use quote::{TokenStreamExt, quote}; use syn::spanned::Spanned; use syn::token::Comma; use syn::{ - parse2, Field, Fields, Ident, Index, Item, ItemEnum, ItemStruct, Member, Path, PathArguments, - Token, + Field, Fields, Ident, Index, Item, ItemEnum, ItemStruct, Member, Path, PathArguments, Token, + parse2, }; mod for_deref; @@ -188,7 +188,7 @@ pub enum Error { } impl Error { - /// Report via [`proc_macro_error2::emit_error`]. + /// Report via [`proc_macro_error3::emit_error`]. pub fn emit(self, target: Span, path_args: Span) { match self { Error::RequireUsing => { @@ -293,7 +293,7 @@ impl ImplTraits { /// This attribute does not modify the item. /// The caller should append the result to `item` tokens. /// - /// Errors are reported via [`proc_macro_error2::emit_error`]. + /// Errors are reported via [`proc_macro_error3::emit_error`]. pub fn expand( self, item: Toks, @@ -440,7 +440,7 @@ impl ImplTraits { fn check_is_field(mem: &Member, fields: &Fields) { match (fields, mem) { - (Fields::Named(fields), Member::Named(ref ident)) => { + (Fields::Named(fields), Member::Named(ident)) => { if fields .named .iter() diff --git a/lib/src/autoimpl/for_deref.rs b/lib/src/autoimpl/for_deref.rs index b38087e..a2efa52 100644 --- a/lib/src/autoimpl/for_deref.rs +++ b/lib/src/autoimpl/for_deref.rs @@ -7,13 +7,13 @@ use crate::generics::{GenericParam, Generics, TypeParamBound, WherePredicate}; use crate::utils::propegate_attr_to_impl; +use proc_macro_error3::{emit_call_site_error, emit_call_site_warning, emit_error}; use proc_macro2::{Span, TokenStream}; -use proc_macro_error2::{emit_call_site_error, emit_call_site_warning, emit_error}; -use quote::{quote, ToTokens, TokenStreamExt}; +use quote::{ToTokens, TokenStreamExt, quote}; use syn::punctuated::Punctuated; use syn::spanned::Spanned; use syn::token::{Comma, Eq, PathSep}; -use syn::{parse_quote, FnArg, Ident, Item, Member, Pat, Token, TraitItem, Type, TypePath}; +use syn::{FnArg, Ident, Item, Member, Pat, Token, TraitItem, Type, TypePath, parse_quote}; mod kw { syn::custom_keyword!(using); @@ -93,10 +93,10 @@ mod parsing { } } -fn has_bound_on_self(gen: &syn::Generics) -> bool { - if let Some(ref clause) = gen.where_clause { +fn has_bound_on_self(generics: &syn::Generics) -> bool { + if let Some(ref clause) = generics.where_clause { for pred in clause.predicates.iter() { - if let syn::WherePredicate::Type(ref ty) = pred { + if let syn::WherePredicate::Type(ty) = pred { if let Type::Path(ref bounded) = ty.bounded_ty { if bounded.qself.is_none() && bounded.path.is_ident("Self") { if ty @@ -163,7 +163,10 @@ impl ForDeref { match item { TraitItem::Const(item) => { let Some(definitive) = opt_definitive.as_ref() else { - emit_error!(item, "cannot autoimpl an associated constant without a definitive type (e.g. `T: trait`)"); + emit_error!( + item, + "cannot autoimpl an associated constant without a definitive type (e.g. `T: trait`)" + ); continue; }; @@ -214,7 +217,7 @@ impl ForDeref { } for (i, arg) in item.sig.inputs.iter_mut().enumerate() { - if let FnArg::Typed(ref mut ty) = arg { + if let FnArg::Typed(ty) = arg { if let Pat::Ident(pat) = &mut *ty.pat { // We can keep the ident but must not use `ref` / `mut` modifiers pat.by_ref = None; @@ -249,7 +252,7 @@ impl ForDeref { Bound::ErrorEmitted } } - Some(FnArg::Typed(ref pat)) => match &*pat.ty { + Some(FnArg::Typed(pat)) => match &*pat.ty { Type::Reference(rf) if rf.elem == parse_quote! { Self } => { Bound::Deref(rf.mutability.is_some()) } @@ -300,7 +303,10 @@ impl ForDeref { } TraitItem::Type(item) => { let Some(definitive) = opt_definitive.as_ref() else { - emit_error!(item, "cannot autoimpl an associated type without a definitive type (e.g. `T: trait`)"); + emit_error!( + item, + "cannot autoimpl an associated type without a definitive type (e.g. `T: trait`)" + ); continue; }; diff --git a/lib/src/autoimpl/impl_misc.rs b/lib/src/autoimpl/impl_misc.rs index f7778fa..9b309a1 100644 --- a/lib/src/autoimpl/impl_misc.rs +++ b/lib/src/autoimpl/impl_misc.rs @@ -8,7 +8,7 @@ use super::{ImplArgs, ImplTrait, Result}; use crate::{IdentFormatter, SimplePath}; use proc_macro2::TokenStream as Toks; -use quote::{quote, ToTokens, TokenStreamExt}; +use quote::{ToTokens, TokenStreamExt, quote}; use syn::{Fields, Index, ItemEnum, ItemStruct, Member, Token}; /// Implement [`core::clone::Clone`] diff --git a/lib/src/default.rs b/lib/src/default.rs index b2d04dd..74905d1 100644 --- a/lib/src/default.rs +++ b/lib/src/default.rs @@ -3,16 +3,16 @@ // You may obtain a copy of the License in the LICENSE-APACHE file or at: // https://www.apache.org/licenses/LICENSE-2.0 +use crate::SimplePath; use crate::fields::{Fields, FieldsNamed, FieldsUnnamed}; -use crate::generics::{clause_to_toks, WhereClause}; +use crate::generics::{WhereClause, clause_to_toks}; use crate::scope::{Scope, ScopeAttr, ScopeItem}; -use crate::SimplePath; +use proc_macro_error3::emit_error; use proc_macro2::{Span, TokenStream}; -use proc_macro_error2::emit_error; use quote::quote; use syn::parse::{Error, Parse, ParseStream, Result}; use syn::spanned::Spanned; -use syn::{parse2, Attribute, Expr, Generics, Ident, Item, Meta, Token}; +use syn::{Attribute, Expr, Generics, Ident, Item, Meta, Token, parse2}; /// `#[impl_default]` attribute pub struct ImplDefault { diff --git a/lib/src/fields.rs b/lib/src/fields.rs index 39e64e3..2820e3c 100644 --- a/lib/src/fields.rs +++ b/lib/src/fields.rs @@ -5,12 +5,12 @@ //! Custom version of [`syn`] fields types supporting initializers +use proc_macro_error3::emit_error; use proc_macro2::TokenStream; -use proc_macro_error2::emit_error; use quote::{ToTokens, TokenStreamExt}; use syn::parse::{Parse, ParseStream, Result}; use syn::punctuated::Punctuated; -use syn::{token, Attribute, Expr, Ident, Token, Type, Visibility}; +use syn::{Attribute, Expr, Ident, Token, Type, Visibility, token}; /// Struct style: unit/tuple/regular #[derive(Debug)] @@ -85,7 +85,7 @@ pub struct Field { pub(crate) mod parsing { use super::*; use syn::ext::IdentExt; - use syn::{braced, parenthesized, WhereClause}; + use syn::{WhereClause, braced, parenthesized}; impl Parse for FieldsNamed { fn parse(input: ParseStream) -> Result { diff --git a/lib/src/generics.rs b/lib/src/generics.rs index b8d610e..7767f81 100644 --- a/lib/src/generics.rs +++ b/lib/src/generics.rs @@ -6,7 +6,7 @@ //! Custom version of [`syn`] generics supporting 'X: trait' bound use proc_macro2::TokenStream; -use quote::{quote, ToTokens, TokenStreamExt}; +use quote::{ToTokens, TokenStreamExt, quote}; use syn::parse::{Parse, ParseStream, Result}; use syn::punctuated::{Pair, Punctuated}; use syn::token; diff --git a/lib/src/scope.rs b/lib/src/scope.rs index 784e801..37ce4d3 100644 --- a/lib/src/scope.rs +++ b/lib/src/scope.rs @@ -5,19 +5,19 @@ //! The `impl_scope!` macro -use crate::{fields::Fields, utils::extend_generics, SimplePath}; +use crate::{SimplePath, fields::Fields, utils::extend_generics}; +use proc_macro_error3::emit_error; use proc_macro2::{Span, TokenStream}; -use proc_macro_error2::emit_error; use quote::{ToTokens, TokenStreamExt}; use syn::punctuated::Punctuated; use syn::spanned::Spanned; use syn::token::{Brace, Comma, Semi}; use syn::{ - parse_quote, Attribute, FieldsNamed, Generics, Ident, ItemImpl, Path, Result, Token, Type, - Variant, Visibility, + Attribute, FieldsNamed, Generics, Ident, ItemImpl, Path, Result, Token, Type, Variant, + Visibility, parse_quote, }; -pub use super::default::{find_impl_default, AttrImplDefault}; +pub use super::default::{AttrImplDefault, find_impl_default}; /// Attribute for `#[impl_scope]` pub struct ScopeModAttrs; @@ -237,7 +237,7 @@ mod parsing { use crate::fields::parsing::data_struct; use syn::parse::{Parse, ParseStream}; use syn::spanned::Spanned; - use syn::{braced, Error, Field, Lifetime, Path, TypePath, WhereClause}; + use syn::{Error, Field, Lifetime, Path, TypePath, WhereClause, braced}; impl Parse for ScopeModAttrs { fn parse(_input: ParseStream) -> Result { diff --git a/lib/src/split_impl.rs b/lib/src/split_impl.rs index a83776f..bc5da1a 100644 --- a/lib/src/split_impl.rs +++ b/lib/src/split_impl.rs @@ -5,11 +5,11 @@ //! `#[split_impl]` -use crate::utils::{self, copy_non_doc_attrs, PathAsStr}; +use crate::utils::{self, PathAsStr, copy_non_doc_attrs}; +use proc_macro_error3::emit_error; use proc_macro2::TokenStream; -use proc_macro_error2::emit_error; use quote::quote; -use syn::{parse_quote, Generics, ImplItem, ItemTrait, Token, TraitItem, Type}; +use syn::{Generics, ImplItem, ItemTrait, Token, TraitItem, Type, parse_quote}; /// `#[split_impl]` attribute pub struct SplitImpl { diff --git a/src/lib.rs b/src/lib.rs index cf40ca4..6f4f9cb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -34,7 +34,7 @@ extern crate proc_macro; use lib::{anon, scope}; use proc_macro::TokenStream; -use proc_macro_error2::{emit_call_site_error, proc_macro_error}; +use proc_macro_error3::{emit_call_site_error, proc_macro_error}; use syn::parse_macro_input; use impl_tools_lib::{self as lib, autoimpl};