-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Do not warn when deriving Copy
for raw pointers
#21362
Conversation
@cmr Is there a way to test the lack of a warning? |
@aochagavia you can use |
@cmr Thanks! I have added a test. |
r? @huonw (You have the strongest opinions about this lint, I believe) |
Any news on this? |
Sorry, @aochagavia, lost track of this. I think it's good, just a small implementation nit. |
ast::ItemImpl(..) => { | ||
ast::ItemImpl(_, _, _, ref t_ref_opt, _, _) => { | ||
// Deriving the Copy trait does not cause a warning | ||
if let &Some(ref t_ref) = t_ref_opt { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently this code will mean that any trait called Copy
isn't warned about, while the compiler actually has enough info to do it "perfectly", i.e. only avoid warning for the special Copy
trait.
let trait_ref = ty::node_id_to_trait_ref(cx.tcx, t_ref.ref_id);
let def_id = ty::trait_ref_to_def_id(cx.tcx, trait_ref.def_id);
if Some(def_id) == cx.tcx.lang_items.copy_trait() {
return
}
(I'm not 100% certain that will work, and I haven't compiled it.)
If I'm so slow again be feel to pester me. |
@huonw Addressed your nit. Thanks for reviewing! |
Sorry to comment after closing, but should deriving Debug produce the raw_pointer_derive warning like it currently does? |
Fixes #21272 and #21296
r? @cmr