diff options
| author | Eduard-Mihai Burtescu <eddyb@lyken.rs> | 2021-10-10 18:50:44 +0300 |
|---|---|---|
| committer | Eduard-Mihai Burtescu <eddyb@lyken.rs> | 2021-10-10 18:58:28 +0300 |
| commit | f14e8dd4e719bd29c6f559ffffa9a17317f4af1e (patch) | |
| tree | 68d7ba3721f268baff0f3742929bfa999064bb79 /compiler | |
| parent | 152e40377aefe966486515c392d741f851510a8a (diff) | |
| download | rust-f14e8dd4e719bd29c6f559ffffa9a17317f4af1e.tar.gz rust-f14e8dd4e719bd29c6f559ffffa9a17317f4af1e.zip | |
ty::pretty: prevent infinite recursion for `extern crate` paths.
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_middle/src/ty/print/pretty.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index ae0cc97c704..b11a54d5dcb 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -360,7 +360,14 @@ pub trait PrettyPrinter<'tcx>: return Ok((self.path_crate(cnum)?, true)); } - return Ok((self.print_def_path(def_id, &[])?, true)); + // Disable `try_print_trimmed_def_path` behavior within + // the `print_def_path` call, to avoid infinite recursion + // 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, &[]))?; + + return Ok((self, true)); } (ExternCrateSource::Path, LOCAL_CRATE) => { return Ok((self.path_crate(cnum)?, true)); |
