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

New false positive expl_impl_clone_on_copy lint in expansion of custom tokens #976

Closed
dtolnay opened this issue Mar 14, 2021 · 0 comments · Fixed by #977
Closed

New false positive expl_impl_clone_on_copy lint in expansion of custom tokens #976

dtolnay opened this issue Mar 14, 2021 · 0 comments · Fixed by #977

Comments

@dtolnay
Copy link
Owner

dtolnay commented Mar 14, 2021

The following began emitting lints in nightly-2021-03-14. Fine in nightly-2021-03-13 and earlier.

#![deny(clippy::all, clippy::pedantic)]

syn::custom_keyword!(test);
error: you are implementing `Clone` explicitly on a `Copy` type
 --> src/main.rs:3:1
  |
3 | syn::custom_keyword!(test);
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
note: the lint level is defined here
 --> src/main.rs:1:22
  |
1 | #![deny(clippy::all, clippy::pedantic)]
  |                      ^^^^^^^^^^^^^^^^
  = note: `#[deny(clippy::expl_impl_clone_on_copy)]` implied by `#[deny(clippy::pedantic)]`
note: consider deriving `Clone` or removing `Copy`
 --> src/main.rs:3:1
  |
3 | syn::custom_keyword!(test);
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#expl_impl_clone_on_copy
  = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

The warning is a false positive because there is not a way to accomplish the same effect (impl in downstream crate conditional on Syn's clone-impls feature) with derive.

syn/src/custom_keyword.rs

Lines 193 to 215 in 92b1129

// Not public API.
#[cfg(feature = "clone-impls")]
#[doc(hidden)]
#[macro_export]
macro_rules! impl_clone_for_custom_keyword {
($ident:ident) => {
impl $crate::__private::Copy for $ident {}
impl $crate::__private::Clone for $ident {
fn clone(&self) -> Self {
*self
}
}
};
}
// Not public API.
#[cfg(not(feature = "clone-impls"))]
#[doc(hidden)]
#[macro_export]
macro_rules! impl_clone_for_custom_keyword {
($ident:ident) => {};
}

This was referenced Mar 14, 2021
This was referenced Mar 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant