ty::pretty: prevent infinite recursion for extern crate paths.#89738
Merged
bors merged 2 commits intorust-lang:masterfrom Oct 17, 2021
Merged
ty::pretty: prevent infinite recursion for extern crate paths.#89738bors merged 2 commits intorust-lang:masterfrom
extern crate paths.#89738bors merged 2 commits intorust-lang:masterfrom
Conversation
Contributor
|
r? @nagisa (rust-highfive has picked a reviewer for you, use r? to override) |
Member
Author
|
cc @nikomatsakis @petrochenkov (I'm not sure who should review) |
nagisa
reviewed
Oct 10, 2021
| // in cases where the `extern crate foo` has non-trivial | ||
| // parents, e.g. it's nested in `impl foo::Trait for Bar` | ||
| // (see also issues #55779 and #87932). | ||
| self = with_no_visible_paths(|| self.print_def_path(def_id, &[]))?; |
Member
There was a problem hiding this comment.
Reassigning self like this seems somewhat footgunny but looks like its already being done elsewhere…
Member
Author
There was a problem hiding this comment.
This mess of an API is all "linear" so there's not really any risk - the result has to be used, because a Self value has to be returned, and the call consumes self.
Member
|
Seems reasonable enough to me. r=me, but giving some time for others to give a look too. |
Member
|
@bors r+ |
Collaborator
|
📌 Commit f14e8dd has been approved by |
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Oct 17, 2021
…askrgr Rollup of 7 pull requests Successful merges: - rust-lang#89738 (ty::pretty: prevent infinite recursion for `extern crate` paths.) - rust-lang#89888 (Make `llvm.download-ci-llvm="if-available"` work for tier 2 targets with host tools) - rust-lang#89945 (Remove a mention to `copy_from_slice` from `clone_from_slice` doc) - rust-lang#89946 (Fix an ICE with TAITs and Future) - rust-lang#89963 (Some "parenthesis" and "parentheses" fixes) - rust-lang#89975 (Add a regression test for rust-lang#85921) - rust-lang#89977 (Make Result::as_mut const) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #55779, fixes #87932.
This fix is based on @estebank's idea in #55779 (comment) - but instead of trying to get
try_print_visible_def_path_recur's cycle detection to work in this case, this PR "just" disables the "visible path" feature when printing the path to anextern crate, so that the old recursion chain oftry_print_visible_def_path -> print_def_path -> try_print_visible_def_path, is now impossible.Both tests have been confirmed to crash
rustcbecause of a stack overflow, without the fix.