fix: use LocalDefId instead of HirId in trait res
use LocalDefId instead of HirId in trait resolution to simplify the obligation clause resolution Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
This commit is contained in:
parent
6b3cd03fdb
commit
7d2c1103d7
48 changed files with 265 additions and 280 deletions
|
@ -1844,16 +1844,8 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
// In some (most?) cases cause.body_id points to actual body, but in some cases
|
||||
// it's an actual definition. According to the comments (e.g. in
|
||||
// rustc_hir_analysis/check/compare_impl_item.rs:compare_predicate_entailment) the latter
|
||||
// is relied upon by some other code. This might (or might not) need cleanup.
|
||||
let body_owner_def_id =
|
||||
self.tcx.hir().opt_local_def_id(cause.body_id).unwrap_or_else(|| {
|
||||
self.tcx.hir().body_owner_def_id(hir::BodyId { hir_id: cause.body_id })
|
||||
});
|
||||
self.check_and_note_conflicting_crates(diag, terr);
|
||||
self.tcx.note_and_explain_type_err(diag, terr, cause, span, body_owner_def_id.to_def_id());
|
||||
self.tcx.note_and_explain_type_err(diag, terr, cause, span, cause.body_id.to_def_id());
|
||||
|
||||
if let Some(ValuePairs::PolyTraitRefs(exp_found)) = values
|
||||
&& let ty::Closure(def_id, _) = exp_found.expected.skip_binder().self_ty().kind()
|
||||
|
|
|
@ -411,8 +411,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
span: Span,
|
||||
) {
|
||||
let hir = self.tcx.hir();
|
||||
let fn_hir_id = hir.parent_id(cause.body_id);
|
||||
if let Some(node) = self.tcx.hir().find(fn_hir_id) &&
|
||||
if let Some(node) = self.tcx.hir().find_by_def_id(cause.body_id) &&
|
||||
let hir::Node::Item(hir::Item {
|
||||
kind: hir::ItemKind::Fn(_sig, _, body_id), ..
|
||||
}) = node {
|
||||
|
|
|
@ -3,7 +3,7 @@ use crate::infer::{DefiningAnchor, InferCtxt, InferOk};
|
|||
use crate::traits;
|
||||
use hir::def::DefKind;
|
||||
use hir::def_id::{DefId, LocalDefId};
|
||||
use hir::{HirId, OpaqueTyOrigin};
|
||||
use hir::OpaqueTyOrigin;
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
use rustc_data_structures::vec_map::VecMap;
|
||||
use rustc_hir as hir;
|
||||
|
@ -48,7 +48,7 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||
pub fn replace_opaque_types_with_inference_vars<T: TypeFoldable<'tcx>>(
|
||||
&self,
|
||||
value: T,
|
||||
body_id: HirId,
|
||||
body_id: LocalDefId,
|
||||
span: Span,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
) -> InferOk<'tcx, T> {
|
||||
|
|
|
@ -8,6 +8,7 @@ mod project;
|
|||
mod structural_impls;
|
||||
pub mod util;
|
||||
|
||||
use hir::def_id::LocalDefId;
|
||||
use rustc_hir as hir;
|
||||
use rustc_middle::ty::error::{ExpectedFound, TypeError};
|
||||
use rustc_middle::ty::{self, Const, ToPredicate, Ty, TyCtxt};
|
||||
|
@ -146,7 +147,7 @@ impl<'tcx, O> Obligation<'tcx, O> {
|
|||
pub fn misc(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
span: Span,
|
||||
body_id: hir::HirId,
|
||||
body_id: LocalDefId,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
trait_ref: impl ToPredicate<'tcx, O>,
|
||||
) -> Obligation<'tcx, O> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue