-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
ty::pretty: prevent infinite recursion for extern crate
paths.
#89738
Conversation
r? @nagisa (rust-highfive has picked a reviewer for you, use r? to override) |
cc @nikomatsakis @petrochenkov (I'm not sure who should review) |
// 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, &[]))?; |
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.
Reassigning self
like this seems somewhat footgunny but looks like its already being done elsewhere…
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.
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
.
Seems reasonable enough to me. r=me, but giving some time for others to give a look too. |
@bors r+ |
📌 Commit f14e8dd has been approved by |
…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
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
rustc
because of a stack overflow, without the fix.