Skip to content

Commit 801dd1d

Browse files
Remove cause
1 parent c87b727 commit 801dd1d

File tree

4 files changed

+8
-35
lines changed

4 files changed

+8
-35
lines changed

compiler/rustc_infer/src/infer/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -836,7 +836,6 @@ impl<'tcx> InferCtxt<'tcx> {
836836
CombineFields {
837837
infcx: self,
838838
trace,
839-
cause: None,
840839
param_env,
841840
obligations: PredicateObligations::new(),
842841
define_opaque_types,

compiler/rustc_infer/src/infer/relate/combine.rs

-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ use rustc_span::Span;
4242
pub struct CombineFields<'infcx, 'tcx> {
4343
pub infcx: &'infcx InferCtxt<'tcx>,
4444
pub trace: TypeTrace<'tcx>,
45-
pub cause: Option<ty::relate::Cause>,
4645
pub param_env: ty::ParamEnv<'tcx>,
4746
pub obligations: PredicateObligations<'tcx>,
4847
pub define_opaque_types: DefineOpaqueTypes,

compiler/rustc_infer/src/infer/relate/type_relating.rs

+2-22
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@ use crate::infer::{
44
};
55
use crate::traits::{Obligation, PredicateObligations};
66

7-
use rustc_middle::ty::relate::{Cause, Relate, RelateResult, TypeRelation};
8-
use rustc_middle::ty::visit::TypeVisitableExt;
7+
use rustc_middle::ty::relate::{Relate, RelateResult, TypeRelation};
98
use rustc_middle::ty::TyVar;
109
use rustc_middle::ty::{self, Ty, TyCtxt};
1110
use rustc_span::Span;
12-
use std::mem;
1311

1412
/// Enforce that `a` is equal to or a subtype of `b`.
1513
pub struct TypeRelating<'combine, 'a, 'tcx> {
@@ -43,18 +41,6 @@ impl<'tcx> TypeRelation<'tcx> for TypeRelating<'_, '_, 'tcx> {
4341
self.a_is_expected
4442
}
4543

46-
fn with_cause<F, R>(&mut self, cause: Cause, f: F) -> R
47-
where
48-
F: FnOnce(&mut Self) -> R,
49-
{
50-
debug!("sub with_cause={:?}", cause);
51-
let old_cause = mem::replace(&mut self.fields.cause, Some(cause));
52-
let r = f(self);
53-
debug!("sub old_cause={:?}", old_cause);
54-
self.fields.cause = old_cause;
55-
r
56-
}
57-
5844
fn relate_with_variance<T: Relate<'tcx>>(
5945
&mut self,
6046
variance: ty::Variance,
@@ -84,12 +70,6 @@ impl<'tcx> TypeRelation<'tcx> for TypeRelating<'_, '_, 'tcx> {
8470

8571
match (a.kind(), b.kind()) {
8672
(&ty::Infer(TyVar(a_id)), &ty::Infer(TyVar(b_id))) => {
87-
// Shouldn't have any LBR here, so we can safely put
88-
// this under a binder below without fear of accidental
89-
// capture.
90-
assert!(!a.has_escaping_bound_vars());
91-
assert!(!b.has_escaping_bound_vars());
92-
9373
match self.ambient_variance {
9474
ty::Covariant => {
9575
// can't make progress on `A <: B` if both A and B are
@@ -191,7 +171,7 @@ impl<'tcx> TypeRelation<'tcx> for TypeRelating<'_, '_, 'tcx> {
191171
a: ty::Region<'tcx>,
192172
b: ty::Region<'tcx>,
193173
) -> RelateResult<'tcx, ty::Region<'tcx>> {
194-
debug!("{}.regions({:?}, {:?}) self.cause={:?}", self.tag(), a, b, self.fields.cause);
174+
debug!("{}.regions({:?}, {:?})", self.tag(), a, b);
195175

196176
// FIXME -- we have more fine-grained information available
197177
// from the "cause" field, we could perhaps give more tailored

compiler/rustc_middle/src/ty/relate.rs

+6-11
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,6 @@ pub trait TypeRelation<'tcx>: Sized {
3030
/// relation. Just affects error messages.
3131
fn a_is_expected(&self) -> bool;
3232

33-
fn with_cause<F, R>(&mut self, _cause: Cause, f: F) -> R
34-
where
35-
F: FnOnce(&mut Self) -> R,
36-
{
37-
f(self)
38-
}
39-
4033
/// Generic relation routine suitable for most anything.
4134
fn relate<T: Relate<'tcx>>(&mut self, a: T, b: T) -> RelateResult<'tcx, T> {
4235
Relate::relate(self, a, b)
@@ -452,10 +445,12 @@ pub fn structurally_relate_tys<'tcx, R: TypeRelation<'tcx>>(
452445
(&ty::Dynamic(a_obj, a_region, a_repr), &ty::Dynamic(b_obj, b_region, b_repr))
453446
if a_repr == b_repr =>
454447
{
455-
let region_bound = relation.with_cause(Cause::ExistentialRegionBound, |relation| {
456-
relation.relate(a_region, b_region)
457-
})?;
458-
Ok(Ty::new_dynamic(tcx, relation.relate(a_obj, b_obj)?, region_bound, a_repr))
448+
Ok(Ty::new_dynamic(
449+
tcx,
450+
relation.relate(a_obj, b_obj)?,
451+
relation.relate(a_region, b_region)?,
452+
a_repr,
453+
))
459454
}
460455

461456
(&ty::Coroutine(a_id, a_args), &ty::Coroutine(b_id, b_args)) if a_id == b_id => {

0 commit comments

Comments
 (0)