-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Add a warning to LateContext::get_def_path #142593
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
base: master
Are you sure you want to change the base?
Conversation
rustbot has assigned @jdonszelmann. Use |
@@ -709,6 +709,12 @@ impl<'tcx> LateContext<'tcx> { | |||
} | |||
|
|||
/// Gets the absolute path of `def_id` as a vector of `Symbol`. | |||
/// Note that this is kinda expensive because it has to |
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.
/// Note that this is kinda expensive because it has to | |
/// | |
/// Note that this is kinda expensive because it has to |
compiler/rustc_lint/src/context.rs
Outdated
/// Note that this is kinda expensive because it has to | ||
/// travel the tree and pretty-print. Use sparingly (or find a | ||
/// way to only get the segments you're interested in, e.g. via | ||
/// [`TyCtxt::crate_name`]). |
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.
or use a diagnostic item if the intention was to match an item by its path.
I'm not sure how this connects to rust-lang/clippy#15030. That looks like some test harness problem? |
I'm also somewhat skeptical that this function is that notable. Grabbing the symbols for every segment in a def path doesn't seem like that much work in the grand scheme of things. Of course, if this is being done in a tight loop it may be expensive, but we use similar a to compute symbol names and stuff even on the good path. Can you explain more about what led you to this function being expensive? |
Oops, I meant rust-lang/rust-clippy#15043, 15030 is the one I'm working on right now. I'll edit that. In our case,
The call graph is like this:
I haven't really looked into why pretty-printing a type would execute early lint checks. Maybe it has something to do with the pretty-printer calling As to the necessity of this little warning, I've looked very briefly into other uses of |
3537451
to
6d04085
Compare
Preventing anyone from doing the same error as rust-lang/rust-clippy#15043 fixed