mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-09 05:23:07 +00:00
Use Visibility::is_accessible_from to make suggestion more specific
This commit is contained in:
parent
f2d8af10c2
commit
913023b6b4
@ -673,6 +673,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||||||
if !self.report_similar_impl_candidates(
|
if !self.report_similar_impl_candidates(
|
||||||
impl_candidates,
|
impl_candidates,
|
||||||
trait_ref,
|
trait_ref,
|
||||||
|
obligation.cause.body_id,
|
||||||
&mut err,
|
&mut err,
|
||||||
) {
|
) {
|
||||||
// This is *almost* equivalent to
|
// This is *almost* equivalent to
|
||||||
@ -707,6 +708,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||||||
self.report_similar_impl_candidates(
|
self.report_similar_impl_candidates(
|
||||||
impl_candidates,
|
impl_candidates,
|
||||||
trait_ref,
|
trait_ref,
|
||||||
|
obligation.cause.body_id,
|
||||||
&mut err,
|
&mut err,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -1353,6 +1355,7 @@ trait InferCtxtPrivExt<'hir, 'tcx> {
|
|||||||
&self,
|
&self,
|
||||||
impl_candidates: Vec<ImplCandidate<'tcx>>,
|
impl_candidates: Vec<ImplCandidate<'tcx>>,
|
||||||
trait_ref: ty::PolyTraitRef<'tcx>,
|
trait_ref: ty::PolyTraitRef<'tcx>,
|
||||||
|
body_id: hir::HirId,
|
||||||
err: &mut Diagnostic,
|
err: &mut Diagnostic,
|
||||||
) -> bool;
|
) -> bool;
|
||||||
|
|
||||||
@ -1735,6 +1738,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> {
|
|||||||
&self,
|
&self,
|
||||||
impl_candidates: Vec<ImplCandidate<'tcx>>,
|
impl_candidates: Vec<ImplCandidate<'tcx>>,
|
||||||
trait_ref: ty::PolyTraitRef<'tcx>,
|
trait_ref: ty::PolyTraitRef<'tcx>,
|
||||||
|
body_id: hir::HirId,
|
||||||
err: &mut Diagnostic,
|
err: &mut Diagnostic,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
let report = |mut candidates: Vec<TraitRef<'tcx>>, err: &mut Diagnostic| {
|
let report = |mut candidates: Vec<TraitRef<'tcx>>, err: &mut Diagnostic| {
|
||||||
@ -1816,11 +1820,9 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> {
|
|||||||
// FIXME(compiler-errors): This could be generalized, both to
|
// FIXME(compiler-errors): This could be generalized, both to
|
||||||
// be more granular, and probably look past other `#[fundamental]`
|
// be more granular, and probably look past other `#[fundamental]`
|
||||||
// types, too.
|
// types, too.
|
||||||
match self.tcx.visibility(def.did()) {
|
self.tcx
|
||||||
ty::Visibility::Public => true,
|
.visibility(def.did())
|
||||||
ty::Visibility::Restricted(def_id) => def_id.is_local(),
|
.is_accessible_from(body_id.owner.to_def_id(), self.tcx)
|
||||||
ty::Visibility::Invisible => false,
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user