rustc: Parameterize ty::Visibility
over used ID
It allows using `LocalDefId` instead of `DefId` when possible, and also encode cheaper `Visibility<DefIndex>` into metadata.
This commit is contained in:
parent
0568b0a3de
commit
d8d3b83e3a
24 changed files with 170 additions and 127 deletions
|
@ -375,7 +375,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
|
||||
let field_is_local = sole_field.did.is_local();
|
||||
let field_is_accessible =
|
||||
sole_field.vis.is_accessible_from(expr.hir_id.owner.to_def_id(), self.tcx)
|
||||
sole_field.vis.is_accessible_from(expr.hir_id.owner, self.tcx)
|
||||
// Skip suggestions for unstable public fields (for example `Pin::pointer`)
|
||||
&& matches!(self.tcx.eval_stability(sole_field.did, None, expr.span, None), EvalResult::Allow | EvalResult::Unmarked);
|
||||
|
||||
|
|
|
@ -1729,9 +1729,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
let private_fields: Vec<&ty::FieldDef> = variant
|
||||
.fields
|
||||
.iter()
|
||||
.filter(|field| {
|
||||
!field.vis.is_accessible_from(tcx.parent_module(expr_id).to_def_id(), tcx)
|
||||
})
|
||||
.filter(|field| !field.vis.is_accessible_from(tcx.parent_module(expr_id), tcx))
|
||||
.collect();
|
||||
|
||||
if !private_fields.is_empty() {
|
||||
|
@ -2343,7 +2341,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
if let ty::Adt(def, _) = output_ty.kind() && !def.is_enum() {
|
||||
def.non_enum_variant().fields.iter().any(|field| {
|
||||
field.ident(self.tcx) == ident
|
||||
&& field.vis.is_accessible_from(expr.hir_id.owner.to_def_id(), self.tcx)
|
||||
&& field.vis.is_accessible_from(expr.hir_id.owner, self.tcx)
|
||||
})
|
||||
} else if let ty::Tuple(tys) = output_ty.kind()
|
||||
&& let Ok(idx) = ident.as_str().parse::<usize>()
|
||||
|
|
|
@ -1161,7 +1161,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
_ => None,
|
||||
});
|
||||
if let Some((field, field_ty)) = field_receiver {
|
||||
let scope = tcx.parent_module(self.body_id).to_def_id();
|
||||
let scope = tcx.parent_module(self.body_id);
|
||||
let is_accessible = field.vis.is_accessible_from(scope, tcx);
|
||||
|
||||
if is_accessible {
|
||||
|
|
|
@ -1397,7 +1397,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
.iter()
|
||||
.copied()
|
||||
.filter(|(field, _)| {
|
||||
field.vis.is_accessible_from(tcx.parent_module(pat.hir_id).to_def_id(), tcx)
|
||||
field.vis.is_accessible_from(tcx.parent_module(pat.hir_id), tcx)
|
||||
&& !matches!(
|
||||
tcx.eval_stability(field.did, None, DUMMY_SP, None),
|
||||
EvalResult::Deny { .. }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue