Rewrite std_instead_of_core#17364
Conversation
|
Lintcheck changes for b37f793
This comment will be updated if you push new changes |
eca13eb to
226f1c7
Compare
std_instead_of_core
std_instead_of_corestd_instead_of_core
|
r? @llogiq rustbot has assigned @llogiq. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
r? Jarcho Please feel free to reverse this! I'm assigning it to you since this is an alternative to #17252 and based on your feedback to me, so I feel you'd be most appropriate to review. Again, thanks for all your help so far! |
This comment has been minimized.
This comment has been minimized.
226f1c7 to
a834ba8
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
a834ba8 to
9ee6d98
Compare
This comment has been minimized.
This comment has been minimized.
9ee6d98 to
bad1275
Compare
| _ => {}, | ||
| } | ||
| }, | ||
| ItemKind::Use(_path, UseKind::ListStem) => { |
There was a problem hiding this comment.
if you store this path in the ItemContext, you should be able to still get the resolutions from that after rust-lang/rust#159760 (comment)
There was a problem hiding this comment.
I think that's exactly right, but I've taken this experience as an opportunity to redo this PR to be much simpler and just directly store the first and last PathSegments. As long as one contains the resolution data for the first segment, that can be used for all lint points sharing that segment.
bad1275 to
de99588
Compare
|
This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
de99588 to
b37f793
Compare
|
You beat me to finishing my first review by a few hours (I had it mostly typed up yesterday). You ended up doing one of the major things I was pointing out so that's cool. |
Objective
std_instead_of_coredoes not detect uses of non-fully qualified items #11159std_instead_of_corecreates an invalid fix on stacked imports #12468std_instead_of_core/etc. miss macros #17260Solution
This PR is a major rewrite of
std_instead_of_corewhich reduces allocations and hardens against possible changes to path segment resolution information, such as what is proposed in rust-lang/rust#159760. Instead of relying exclusively oncheck_pathto collect possible lint points, we primarily rely oncheck_itemforusestatements.check_pathis still used to catch instances such asstd::boxed::Box::new(123), but such cases will contain resolution information for the full path, as the path is not shared across multiple items.Lintcheck Interpretation
alloc_instead_of_corefmt::Resultwhen a crate doesuse std::fmt;. This is intended.std_instead_of_allocsync::{Arc, Mutex}and catching crate renames (extern crate std as alloc, etc.)std_instead_of_corehash::Hash.extern crate core as std, etc.)std::fmt::{self, Debug}(whileDebugis defined incore,std::fmt::selfisalloc::fmt, so this cannot be a merged suggestion.Please write a short comment explaining your change (or "none" for internal only changes)
changelog: [
std_instead_of_core], [std_instead_of_alloc], [alloc_instead_of_core]: fix false positive suggestions for multi-importschangelog: [
std_instead_of_core], [std_instead_of_alloc], [alloc_instead_of_core]: consider crate renameschangelog: [
std_instead_of_core], [std_instead_of_alloc], [alloc_instead_of_core]: include relative pathschangelog: [
std_instead_of_core], [std_instead_of_alloc], [alloc_instead_of_core]: include macros