diff options
| author | morine0122 <k0000.m000.job@gmail.com> | 2025-03-22 21:57:45 +0900 |
|---|---|---|
| committer | morine0122 <k0000.m000.job@gmail.com> | 2025-04-04 20:50:16 +0900 |
| commit | d0591827ddc8268b0f248dcb02c2e20a737229aa (patch) | |
| tree | fdd01822b0fd0ad08319b9bdf5703a04b5828b80 /compiler/rustc_middle/src | |
| parent | e0883a2a6c8e4afcb6e26a182885f687ba63a7f5 (diff) | |
| download | rust-d0591827ddc8268b0f248dcb02c2e20a737229aa.tar.gz rust-d0591827ddc8268b0f248dcb02c2e20a737229aa.zip | |
Make the compiler suggest actual paths instead of visible paths if the visible paths are through any doc hidden path.
Diffstat (limited to 'compiler/rustc_middle/src')
| -rw-r--r-- | compiler/rustc_middle/src/ty/print/pretty.rs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index 3281cb4135a..c914f7cc882 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -63,6 +63,7 @@ thread_local! { static FORCE_TRIMMED_PATH: Cell<bool> = const { Cell::new(false) }; static REDUCED_QUERIES: Cell<bool> = const { Cell::new(false) }; static NO_VISIBLE_PATH: Cell<bool> = const { Cell::new(false) }; + static NO_VISIBLE_PATH_IF_DOC_HIDDEN: Cell<bool> = const { Cell::new(false) }; static RTN_MODE: Cell<RtnMode> = const { Cell::new(RtnMode::ForDiagnostic) }; } @@ -134,6 +135,8 @@ define_helper!( /// Prevent selection of visible paths. `Display` impl of DefId will prefer /// visible (public) reexports of types as paths. fn with_no_visible_paths(NoVisibleGuard, NO_VISIBLE_PATH); + /// Prevent selection of visible paths if the paths are through a doc hidden path. + fn with_no_visible_paths_if_doc_hidden(NoVisibleIfDocHiddenGuard, NO_VISIBLE_PATH_IF_DOC_HIDDEN); ); #[must_use] @@ -569,6 +572,10 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write { return Ok(false); }; + if self.tcx().is_doc_hidden(visible_parent) && with_no_visible_paths_if_doc_hidden() { + return Ok(false); + } + let actual_parent = self.tcx().opt_parent(def_id); debug!( "try_print_visible_def_path: visible_parent={:?} actual_parent={:?}", |
