Add a warning to LateContext::get_def_path#142593
Conversation
|
rustbot has assigned @jdonszelmann. Use |
| } | ||
|
|
||
| /// 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.
| /// 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.
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
|
@bors r+ rollup |
Rollup of 10 pull requests Successful merges: - #142458 (Merge unboxed trait object error suggestion into regular dyn incompat error) - #142593 (Add a warning to LateContext::get_def_path) - #142594 (Add DesugaringKind::FormatLiteral) - #142740 (Clean-up `FnCtxt::is_destruct_assignment_desugaring`) - #142780 (Port `#[must_use]` to new attribute parsing infrastructure) - #142798 (Don't fail to parse a struct if a semicolon is used to separate fields) - #142856 (Add a few inline directives in rustc_serialize.) - #142868 (remove few allow(dead_code)) - #142874 (cranelift: fix target feature name typo: "fxsr") - #142877 (Document why tidy checks if `eslint` is installed via `npm`) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of #142593 - blyxyas:improve-docs-itty-bitty-change, r=compiler-errors Add a warning to LateContext::get_def_path Preventing anyone from doing the same error as rust-lang/rust-clippy#15043 fixed
Rollup of 10 pull requests Successful merges: - rust-lang/rust#142458 (Merge unboxed trait object error suggestion into regular dyn incompat error) - rust-lang/rust#142593 (Add a warning to LateContext::get_def_path) - rust-lang/rust#142594 (Add DesugaringKind::FormatLiteral) - rust-lang/rust#142740 (Clean-up `FnCtxt::is_destruct_assignment_desugaring`) - rust-lang/rust#142780 (Port `#[must_use]` to new attribute parsing infrastructure) - rust-lang/rust#142798 (Don't fail to parse a struct if a semicolon is used to separate fields) - rust-lang/rust#142856 (Add a few inline directives in rustc_serialize.) - rust-lang/rust#142868 (remove few allow(dead_code)) - rust-lang/rust#142874 (cranelift: fix target feature name typo: "fxsr") - rust-lang/rust#142877 (Document why tidy checks if `eslint` is installed via `npm`) r? `@ghost` `@rustbot` modify labels: rollup
Rollup of 10 pull requests Successful merges: - rust-lang/rust#142458 (Merge unboxed trait object error suggestion into regular dyn incompat error) - rust-lang/rust#142593 (Add a warning to LateContext::get_def_path) - rust-lang/rust#142594 (Add DesugaringKind::FormatLiteral) - rust-lang/rust#142740 (Clean-up `FnCtxt::is_destruct_assignment_desugaring`) - rust-lang/rust#142780 (Port `#[must_use]` to new attribute parsing infrastructure) - rust-lang/rust#142798 (Don't fail to parse a struct if a semicolon is used to separate fields) - rust-lang/rust#142856 (Add a few inline directives in rustc_serialize.) - rust-lang/rust#142868 (remove few allow(dead_code)) - rust-lang/rust#142874 (cranelift: fix target feature name typo: "fxsr") - rust-lang/rust#142877 (Document why tidy checks if `eslint` is installed via `npm`) r? `@ghost` `@rustbot` modify labels: rollup

Preventing anyone from doing the same error as rust-lang/rust-clippy#15043 fixed