@@ -673,6 +673,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
673673 if !self . report_similar_impl_candidates (
674674 impl_candidates,
675675 trait_ref,
676+ obligation. cause . body_id ,
676677 & mut err,
677678 ) {
678679 // This is *almost* equivalent to
@@ -707,6 +708,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
707708 self . report_similar_impl_candidates (
708709 impl_candidates,
709710 trait_ref,
711+ obligation. cause . body_id ,
710712 & mut err,
711713 ) ;
712714 }
@@ -1353,6 +1355,7 @@ trait InferCtxtPrivExt<'hir, 'tcx> {
13531355 & self ,
13541356 impl_candidates : Vec < ImplCandidate < ' tcx > > ,
13551357 trait_ref : ty:: PolyTraitRef < ' tcx > ,
1358+ body_id : hir:: HirId ,
13561359 err : & mut Diagnostic ,
13571360 ) -> bool ;
13581361
@@ -1735,6 +1738,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> {
17351738 & self ,
17361739 impl_candidates : Vec < ImplCandidate < ' tcx > > ,
17371740 trait_ref : ty:: PolyTraitRef < ' tcx > ,
1741+ body_id : hir:: HirId ,
17381742 err : & mut Diagnostic ,
17391743 ) -> bool {
17401744 let report = |mut candidates : Vec < TraitRef < ' tcx > > , err : & mut Diagnostic | {
@@ -1816,11 +1820,9 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> {
18161820 // FIXME(compiler-errors): This could be generalized, both to
18171821 // be more granular, and probably look past other `#[fundamental]`
18181822 // types, too.
1819- match self . tcx . visibility ( def. did ( ) ) {
1820- ty:: Visibility :: Public => true ,
1821- ty:: Visibility :: Restricted ( def_id) => def_id. is_local ( ) ,
1822- ty:: Visibility :: Invisible => false ,
1823- }
1823+ self . tcx
1824+ . visibility ( def. did ( ) )
1825+ . is_accessible_from ( body_id. owner . to_def_id ( ) , self . tcx )
18241826 } else {
18251827 true
18261828 }
0 commit comments