From f14e8dd4e719bd29c6f559ffffa9a17317f4af1e Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Sun, 10 Oct 2021 18:50:44 +0300 Subject: ty::pretty: prevent infinite recursion for `extern crate` paths. --- compiler/rustc_middle/src/ty/print/pretty.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'compiler') 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)); -- cgit 1.4.1-3-g733a5