Skip to content

Commit e38c6b4

Browse files
Pre cleanups
1 parent 2947be7 commit e38c6b4

File tree

4 files changed

+20
-16
lines changed

4 files changed

+20
-16
lines changed

compiler/rustc_hir_typeck/src/closure.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
164164
let resume_ty = liberated_sig.inputs().get(0).copied().unwrap_or(tcx.types.unit);
165165

166166
let interior = self.next_ty_var(expr_span);
167-
self.deferred_coroutine_interiors.borrow_mut().push((
168-
expr_def_id,
169-
body.id(),
170-
interior,
171-
));
167+
self.deferred_coroutine_interiors.borrow_mut().push((expr_def_id, interior));
172168

173169
// Coroutines that come from coroutine closures have not yet determined
174170
// their kind ty, so make a fresh infer var which will be constrained

compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs

+17-10
Original file line numberDiff line numberDiff line change
@@ -633,18 +633,20 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
633633
let coroutines = std::mem::take(&mut *self.deferred_coroutine_interiors.borrow_mut());
634634
debug!(?coroutines);
635635

636-
for &(expr_def_id, body_id, interior) in coroutines.iter() {
637-
debug!(?expr_def_id);
636+
let mut obligations = vec![];
637+
638+
for &(coroutine_def_id, interior) in coroutines.iter() {
639+
debug!(?coroutine_def_id);
638640

639641
// Create the `CoroutineWitness` type that we will unify with `interior`.
640642
let args = ty::GenericArgs::identity_for_item(
641643
self.tcx,
642-
self.tcx.typeck_root_def_id(expr_def_id.to_def_id()),
644+
self.tcx.typeck_root_def_id(coroutine_def_id.to_def_id()),
643645
);
644-
let witness = Ty::new_coroutine_witness(self.tcx, expr_def_id.to_def_id(), args);
646+
let witness = Ty::new_coroutine_witness(self.tcx, coroutine_def_id.to_def_id(), args);
645647

646648
// Unify `interior` with `witness` and collect all the resulting obligations.
647-
let span = self.tcx.hir_body(body_id).value.span;
649+
let span = self.tcx.hir_body_owned_by(coroutine_def_id).value.span;
648650
let ty::Infer(ty::InferTy::TyVar(_)) = interior.kind() else {
649651
span_bug!(span, "coroutine interior witness not infer: {:?}", interior.kind())
650652
};
@@ -653,15 +655,20 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
653655
// Will never define opaque types, as all we do is instantiate a type variable.
654656
.eq(DefineOpaqueTypes::Yes, interior, witness)
655657
.expect("Failed to unify coroutine interior type");
656-
let mut obligations = ok.obligations;
657658

658-
// Also collect the obligations that were unstalled by this unification.
659+
obligations.extend(ok.obligations);
660+
}
661+
662+
// FIXME: Use a real visitor for unstalled obligations in the new solver.
663+
if !coroutines.is_empty() {
659664
obligations
660665
.extend(self.fulfillment_cx.borrow_mut().drain_unstalled_obligations(&self.infcx));
661-
662-
let obligations = obligations.into_iter().map(|o| (o.predicate, o.cause));
663-
self.typeck_results.borrow_mut().coroutine_stalled_predicates.extend(obligations);
664666
}
667+
668+
self.typeck_results
669+
.borrow_mut()
670+
.coroutine_stalled_predicates
671+
.extend(obligations.into_iter().map(|o| (o.predicate, o.cause)));
665672
}
666673

667674
#[instrument(skip(self), level = "debug")]

compiler/rustc_hir_typeck/src/typeck_root_ctxt.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ pub(crate) struct TypeckRootCtxt<'tcx> {
5959

6060
pub(super) deferred_asm_checks: RefCell<Vec<(&'tcx hir::InlineAsm<'tcx>, HirId)>>,
6161

62-
pub(super) deferred_coroutine_interiors: RefCell<Vec<(LocalDefId, hir::BodyId, Ty<'tcx>)>>,
62+
pub(super) deferred_coroutine_interiors: RefCell<Vec<(LocalDefId, Ty<'tcx>)>>,
6363

6464
pub(super) deferred_repeat_expr_checks:
6565
RefCell<Vec<(&'tcx hir::Expr<'tcx>, Ty<'tcx>, ty::Const<'tcx>)>>,

src/tools/clippy/clippy_lints/src/lifetimes.rs

+1
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,7 @@ where
633633
bounded_ty,
634634
bounds,
635635
bound_generic_params,
636+
bound_assumptions: _,
636637
origin: _,
637638
}) = predicate.kind
638639
{

0 commit comments

Comments
 (0)