Make some report and emit errors take DefIds instead of BodyIds
This commit is contained in:
parent
39f2657d11
commit
5b99723439
5 changed files with 50 additions and 43 deletions
|
@ -10,7 +10,7 @@ use rustc_errors::{DiagnosticBuilder, ErrorGuaranteed, IntoDiagnosticArg};
|
|||
use rustc_hir as hir;
|
||||
use rustc_hir::def::Res;
|
||||
use rustc_hir::def::{CtorOf, DefKind, Namespace};
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_hir::def_id::{DefId, LocalDefId};
|
||||
use rustc_hir::intravisit::{self, Visitor};
|
||||
use rustc_hir::{Body, Closure, Expr, ExprKind, FnRetTy, HirId, Local, LocalSource};
|
||||
use rustc_middle::hir::nested_filter;
|
||||
|
@ -386,7 +386,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
#[instrument(level = "debug", skip(self, error_code))]
|
||||
pub fn emit_inference_failure_err(
|
||||
&self,
|
||||
body_id: Option<hir::BodyId>,
|
||||
body_def_id: Option<LocalDefId>,
|
||||
failure_span: Span,
|
||||
arg: GenericArg<'tcx>,
|
||||
error_code: TypeAnnotationNeeded,
|
||||
|
@ -403,8 +403,10 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
};
|
||||
|
||||
let mut local_visitor = FindInferSourceVisitor::new(&self, typeck_results, arg);
|
||||
if let Some(body_id) = body_id {
|
||||
let expr = self.tcx.hir().expect_expr(body_id.hir_id);
|
||||
if let Some(body_def_id) = body_def_id
|
||||
&& let Some(body_id) = self.tcx.hir().maybe_body_owned_by(body_def_id)
|
||||
{
|
||||
let expr = self.tcx.hir().body(body_id).value;
|
||||
local_visitor.visit_expr(expr);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue