diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 69e81fb..c273e98 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,10 +29,3 @@ jobs: - name: Run compile-fail tests if: matrix.rust-version == 'stable' run: cargo test -- ui_compile_fail - - - name: Build with nightly feature - if: matrix.rust-version == 'nightly' - run: cargo build --features=nightly - - name: Run tests with nightly feature - if: matrix.rust-version == 'nightly' - run: cargo test --features=nightly -- --skip ui_compile_fail diff --git a/Cargo.toml b/Cargo.toml index 490178c..c8563c8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,9 +20,6 @@ rust-version = "1.37" [lib] proc-macro = true -[features] -nightly = [] - [dependencies] proc-macro2 = "1.0" quote = "1.0" diff --git a/examples/error_messages.rs b/examples/error_messages.rs index 19649e4..4ce17af 100644 --- a/examples/error_messages.rs +++ b/examples/error_messages.rs @@ -8,7 +8,6 @@ use auto_impl::auto_impl; - // Shows the error message for the case that `#[auto_impl]` was used with // incorrect proxy types. Only proxy types like `&` and `Box` are allowed. Add // this next line to see the error! @@ -24,5 +23,4 @@ struct Bar { x: u32, } - fn main() {} diff --git a/examples/greet_closure.rs b/examples/greet_closure.rs index 2f8daf1..4e7251d 100644 --- a/examples/greet_closure.rs +++ b/examples/greet_closure.rs @@ -1,6 +1,5 @@ use auto_impl::auto_impl; - /// This simple trait can be implemented for `Fn` types, but not for `FnMut` or /// `FnOnce` types. The latter two types require a mutable reference to `self` /// or a `self` by value to be called, but `greet()` only has an immutable @@ -21,13 +20,11 @@ trait Greeter { fn greet(&self, name: &str); } - fn greet_people(greeter: impl Greeter) { greeter.greet("Anna"); greeter.greet("Bob"); } - fn main() { // We can simply pass a closure here, since this specific closure // implements `Fn(&str)` and therefore also `Greeter`. Note that we need diff --git a/examples/keep_default_for.rs b/examples/keep_default_for.rs index eb22e9b..5c92395 100644 --- a/examples/keep_default_for.rs +++ b/examples/keep_default_for.rs @@ -7,7 +7,6 @@ //! type. use auto_impl::auto_impl; - #[auto_impl(&, Box)] trait Foo { fn required(&self) -> String; diff --git a/examples/refs.rs b/examples/refs.rs index 454a6d6..2de9565 100644 --- a/examples/refs.rs +++ b/examples/refs.rs @@ -2,7 +2,6 @@ use std::fmt::Display; use auto_impl::auto_impl; - /// This trait can be implemented for all reference or pointer types: &, &mut, /// Box, Rc and Arc. /// diff --git a/rustfmt.toml b/rustfmt.toml index d9c3de8..a0182ec 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -2,6 +2,6 @@ unstable_features = true blank_lines_upper_bound = 3 format_macro_matchers = true -merge_imports = true +imports_granularity="Crate" normalize_comments = true reorder_impl_items = true diff --git a/src/analyze.rs b/src/analyze.rs index 3c4e473..4790db2 100644 --- a/src/analyze.rs +++ b/src/analyze.rs @@ -6,7 +6,6 @@ use syn::{ Block, Ident, ItemTrait, Lifetime, }; - /// The type parameter used in the proxy type. Usually, one would just use `T`, /// but this could conflict with type parameters on the trait. /// @@ -21,7 +20,6 @@ const PROXY_TY_PARAM_NAME: &str = "__AutoImplProxyT"; /// `&mut`. For more information see `PROXY_TY_PARAM_NAME`. const PROXY_LT_PARAM_NAME: &str = "'__auto_impl_proxy_lifetime"; - /// We need to introduce our own type and lifetime parameter. Regardless of /// what kind of hygiene we use for the parameter, it would be nice (for docs /// and compiler errors) if the names are as simple as possible ('a and T, for @@ -68,7 +66,6 @@ pub(crate) fn find_suitable_param_names(trait_def: &ItemTrait) -> (Ident, Lifeti }; visit_item_trait(&mut visitor, trait_def); - fn char_to_ident(c: u8) -> Ident { let arr = [c]; let s = ::std::str::from_utf8(&arr).unwrap(); @@ -95,19 +92,6 @@ pub(crate) fn find_suitable_param_names(trait_def: &ItemTrait) -> (Ident, Lifeti (ty_name, lt) } -/// On nightly, we use `def_site` hygiene which puts our names into another -/// universe than the names of the user. This is not strictly required as our -/// name is already pretty much guaranteed to not conflict with another name, -/// but this is cleaner and just the correct thing to do. -#[cfg(feature = "nightly")] -fn param_span() -> Span2 { - crate::proc_macro::Span::def_site().into() -} - -/// On stable, we use `call_site()` hygiene. That means that our names could -/// theoretically collide with names of the user. But we made sure this doesn't -/// happen. -#[cfg(not(feature = "nightly"))] fn param_span() -> Span2 { Span2::call_site() } diff --git a/src/lib.rs b/src/lib.rs index 382ac45..1339113 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -202,31 +202,6 @@ //! } //! } //! ``` -//! -//! -//! # The `nightly` feature gate -//! -//! By default, this crate compiles on stable. If you don't need stable support, -//! you can enable the `nightly` feature of this crate: -//! -//! ```toml -//! [dependencies] -//! auto_impl = { version = "*", features = ["nightly"] } -//! ``` -//! -//! The nightly feature enables a few additional features that are not -//! available on stable yet. Currently, you get these advantages: -//! - All idents generated by auto_impl use the `def_site` hygiene and -//! therefore will never ever have name collisions with user written idents. -//! Note that `auto_impl` already (even without nightly feature) takes care -//! that idents never collide, if possible. But `def_site` hygiene is still -//! technically the more correct solution. - -#![cfg_attr( - feature = "nightly", - feature(proc_macro_diagnostic, proc_macro_span, proc_macro_def_site) -)] - extern crate proc_macro; #[macro_use] @@ -237,7 +212,6 @@ use proc_macro2::TokenStream as TokenStream2; use proc_macro_error::{abort_call_site, proc_macro_error, set_dummy}; use quote::ToTokens; - mod analyze; mod attr; mod gen; diff --git a/src/proxy.rs b/src/proxy.rs index 0d9c640..f753509 100644 --- a/src/proxy.rs +++ b/src/proxy.rs @@ -143,7 +143,6 @@ fn eat_type(iter: &mut Peekable) -> Result