Skip to content

Commit f7abc1b

Browse files
committed
Expose current span to type equality checking in nll
1 parent 47a6a24 commit f7abc1b

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

compiler/rustc_borrowck/src/type_check/relate_tys.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use rustc_infer::infer::NllRegionVariableOrigin;
33
use rustc_middle::mir::ConstraintCategory;
44
use rustc_middle::ty::relate::TypeRelation;
55
use rustc_middle::ty::{self, Const, Ty};
6+
use rustc_span::{Span, DUMMY_SP};
67
use rustc_trait_selection::traits::query::Fallible;
78

89
use crate::constraints::OutlivesConstraint;
@@ -63,6 +64,13 @@ impl<'me, 'bccx, 'tcx> NllTypeRelatingDelegate<'me, 'bccx, 'tcx> {
6364
}
6465

6566
impl<'tcx> TypeRelatingDelegate<'tcx> for NllTypeRelatingDelegate<'_, '_, 'tcx> {
67+
fn span(&self) -> Span {
68+
match self.locations {
69+
Locations::All(span) => span,
70+
Locations::Single(_) => DUMMY_SP,
71+
}
72+
}
73+
6674
fn param_env(&self) -> ty::ParamEnv<'tcx> {
6775
self.type_checker.param_env
6876
}

compiler/rustc_infer/src/infer/canonical/query_response.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ use rustc_middle::ty::fold::TypeFoldable;
2626
use rustc_middle::ty::relate::TypeRelation;
2727
use rustc_middle::ty::subst::{GenericArg, GenericArgKind};
2828
use rustc_middle::ty::{self, BoundVar, Const, ToPredicate, Ty, TyCtxt};
29+
use rustc_span::Span;
2930
use std::fmt::Debug;
3031
use std::iter;
3132

@@ -631,6 +632,10 @@ struct QueryTypeRelatingDelegate<'a, 'tcx> {
631632
}
632633

633634
impl<'tcx> TypeRelatingDelegate<'tcx> for QueryTypeRelatingDelegate<'_, 'tcx> {
635+
fn span(&self) -> Span {
636+
self.cause.span
637+
}
638+
634639
fn param_env(&self) -> ty::ParamEnv<'tcx> {
635640
self.param_env
636641
}

compiler/rustc_infer/src/infer/nll_relate/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ use rustc_middle::ty::error::TypeError;
2929
use rustc_middle::ty::fold::{TypeFoldable, TypeVisitor};
3030
use rustc_middle::ty::relate::{self, Relate, RelateResult, TypeRelation};
3131
use rustc_middle::ty::{self, InferConst, Ty, TyCtxt};
32+
use rustc_span::Span;
3233
use std::fmt::Debug;
3334
use std::ops::ControlFlow;
3435

@@ -75,6 +76,7 @@ where
7576

7677
pub trait TypeRelatingDelegate<'tcx> {
7778
fn param_env(&self) -> ty::ParamEnv<'tcx>;
79+
fn span(&self) -> Span;
7880

7981
/// Push a constraint `sup: sub` -- this constraint must be
8082
/// satisfied for the two types to be related. `sub` and `sup` may

0 commit comments

Comments
 (0)