Auto merge of #102040 - TaKO8Ki:separate-definitions-and-hir-owners, r=cjgillot

Separate definitions and HIR owners in the type system

Fixes #83158

r? `@cjgillot`
This commit is contained in:
bors 2022-09-24 22:42:07 +00:00
commit d0ece44cfa
114 changed files with 659 additions and 518 deletions

View file

@ -1898,7 +1898,9 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'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_id.owner, self.tcx)
self.tcx
.visibility(def.did())
.is_accessible_from(body_id.owner.def_id, self.tcx)
} else {
true
}

View file

@ -659,7 +659,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
_ => {}
}
hir_id = self.tcx.hir().local_def_id_to_hir_id(self.tcx.hir().get_parent_item(hir_id));
hir_id = self.tcx.hir().get_parent_item(hir_id).into();
}
}
@ -2712,7 +2712,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
let parent_id = hir.get_parent_item(arg_hir_id);
let typeck_results: &TypeckResults<'tcx> = match &in_progress_typeck_results {
Some(t) if t.hir_owner == parent_id => t,
_ => self.tcx.typeck(parent_id),
_ => self.tcx.typeck(parent_id.def_id),
};
let expr = expr.peel_blocks();
let ty = typeck_results.expr_ty_adjusted_opt(expr).unwrap_or(tcx.ty_error());