Skip to content

Commit 8ecab44

Browse files
Fix invalid privacy computation for associated type on impl blocks
1 parent cd59848 commit 8ecab44

File tree

1 file changed

+9
-1
lines changed
  • compiler/rustc_privacy/src

1 file changed

+9
-1
lines changed

compiler/rustc_privacy/src/lib.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,15 @@ trait VisibilityLike: Sized {
339339
effective_visibilities: &EffectiveVisibilities,
340340
) -> Self {
341341
let mut find = FindMin { tcx, effective_visibilities, min: Self::MAX };
342-
find.visit(tcx.type_of(def_id));
342+
let mut ty = tcx.type_of(def_id);
343+
let param_env = tcx.param_env(def_id);
344+
// We need this normalization when we check the visibility of a projection so it is applied
345+
// to the item behind the projection and not to the projection itself.
346+
ty = match tcx.try_normalize_erasing_regions(param_env, ty) {
347+
Ok(new_ty) => new_ty,
348+
Err(_) => ty,
349+
};
350+
find.visit(ty);
343351
if let Some(trait_ref) = tcx.impl_trait_ref(def_id) {
344352
find.visit_trait(trait_ref.subst_identity());
345353
}

0 commit comments

Comments
 (0)