Skip to content

Commit 8edda7e

Browse files
committed
crash reproduction for rust-analyzer
1 parent 69c5f7f commit 8edda7e

File tree

1 file changed

+14
-14
lines changed
  • compiler/rustc_infer/src/infer/nll_relate

1 file changed

+14
-14
lines changed

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

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ 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};
3232
use std::fmt::Debug;
33+
use std::marker::PhantomData;
3334
use std::ops::ControlFlow;
3435

3536
#[derive(PartialEq)]
@@ -44,7 +45,7 @@ where
4445
{
4546
/// Callback to use when we deduce an outlives relationship
4647
delegate: D,
47-
_infcx: std::marker::PhantomData<&'cx mut InferCtxt<'cx, 'tcx>>,
48+
_infcx: PhantomData<&'cx mut InferCtxt<'cx, 'tcx>>,
4849

4950
/// How are we relating `a` and `b`?
5051
///
@@ -136,7 +137,7 @@ where
136137
delegate: D,
137138
ambient_variance: ty::Variance,
138139
) -> Self {
139-
Self { _infcx: std::marker::PhantomData, delegate, ambient_variance, a_scopes: vec![], b_scopes: vec![] }
140+
Self { _infcx: PhantomData, delegate, ambient_variance, a_scopes: vec![], b_scopes: vec![] }
140141
}
141142

142143
fn ambient_covariance(&self) -> bool {
@@ -355,15 +356,17 @@ where
355356
let universe = self.delegate.infcx().probe_ty_var(for_vid).unwrap_err();
356357

357358
let mut generalizer = TypeGeneralizer {
358-
infcx: self.delegate.infcx(),
359-
delegate: &mut self.delegate,
359+
_tcx: PhantomData,
360+
delegate: self.delegate,
360361
first_free_index: ty::INNERMOST,
361362
ambient_variance: self.ambient_variance,
362363
for_vid_sub_root: self.delegate.infcx().inner.type_variables().sub_root_var(for_vid),
363364
universe,
364365
};
365366

366-
generalizer.relate(value, value)
367+
let relation = generalizer.relate(value, value);
368+
self.delegate = generalizer.delegate;
369+
relation
367370
}
368371
}
369372

@@ -786,13 +789,12 @@ impl<'me, 'tcx> TypeVisitor<'tcx> for ScopeInstantiator<'me, 'tcx> {
786789
/// scopes.
787790
///
788791
/// [blog post]: https://is.gd/0hKvIr
789-
struct TypeGeneralizer<'me, 'tcx, D>
792+
struct TypeGeneralizer<'cx, 'tcx, D>
790793
where
791-
D: TypeRelatingDelegate<'me, 'tcx>,
794+
D: TypeRelatingDelegate<'cx, 'tcx>,
792795
{
793-
infcx: &'me InferCtxt<'me, 'tcx>,
794-
795-
delegate: &'me mut D,
796+
_tcx: PhantomData<(&'cx (), &'tcx ())>,
797+
delegate: D,
796798

797799
/// After we generalize this type, we are going to relative it to
798800
/// some other type. What will be the variance at this point?
@@ -873,8 +875,7 @@ where
873875
}
874876

875877
ty::Infer(ty::TyVar(vid)) => {
876-
let mut inner = self.infcx.inner;
877-
let variables = &mut inner.type_variables();
878+
let variables = self.delegate.infcx().inner.type_variables();
878879
let vid = variables.root_var(vid);
879880
let sub_vid = variables.sub_root_var(vid);
880881
if sub_vid == self.for_vid_sub_root {
@@ -976,8 +977,7 @@ where
976977
bug!("unexpected inference variable encountered in NLL generalization: {:?}", a);
977978
}
978979
ty::ConstKind::Infer(InferConst::Var(vid)) => {
979-
let mut inner = self.infcx.inner;
980-
let variable_table = &mut inner.const_unification_table();
980+
let mut variable_table = self.delegate.infcx().inner.const_unification_table();
981981
let var_value = variable_table.probe_value(vid);
982982
match var_value.val.known() {
983983
Some(u) => self.relate(u, u),

0 commit comments

Comments
 (0)