diff options
| author | Matthias Krüger <476013+matthiaskrgr@users.noreply.github.com> | 2025-09-30 21:53:34 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-09-30 21:53:34 +0200 |
| commit | 014e0af1497aaa932fc6c51eb4b2e6f9e9fab63f (patch) | |
| tree | 3758b994440f2e84b5a27e64e168c802586ef9f5 /compiler/rustc_trait_selection | |
| parent | 5a4713d8ea9af8185e61a93a97c4f63020f4fc06 (diff) | |
| parent | 9e2f9edd7f79c1e11339277bfb83a0c888740438 (diff) | |
| download | rust-014e0af1497aaa932fc6c51eb4b2e6f9e9fab63f.tar.gz rust-014e0af1497aaa932fc6c51eb4b2e6f9e9fab63f.zip | |
Rollup merge of #146617 - Jules-Bertholet:E0277-NOFORN, r=SparrowLii
Don’t suggest foreign `doc(hidden)` types in "the following other types implement trait" diagnostics Fixes https://github.com/rust-lang/rust/issues/132024. ``@rustbot`` label A-diagnostics T-compiler
Diffstat (limited to 'compiler/rustc_trait_selection')
| -rw-r--r-- | compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs index d485eb7266b..bec12750728 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs @@ -1897,6 +1897,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { other: bool, param_env: ty::ParamEnv<'tcx>, ) -> bool { + let parent_map = self.tcx.visible_parent_map(()); let alternative_candidates = |def_id: DefId| { let mut impl_candidates: Vec<_> = self .tcx @@ -1921,7 +1922,21 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { // FIXME(compiler-errors): This could be generalized, both to // be more granular, and probably look past other `#[fundamental]` // types, too. - self.tcx.visibility(def.did()).is_accessible_from(body_def_id, self.tcx) + let mut did = def.did(); + if self.tcx.visibility(did).is_accessible_from(body_def_id, self.tcx) { + // don't suggest foreign `#[doc(hidden)]` types + if !did.is_local() { + while let Some(parent) = parent_map.get(&did) { + if self.tcx.is_doc_hidden(did) { + return false; + } + did = *parent; + } + } + true + } else { + false + } } else { true } |
