Skip to content

Commit d1ee1b2

Browse files
committed
move drain_fulfillment_cx_or_panic to be private to traits::trans
1 parent 3937a5e commit d1ee1b2

File tree

2 files changed

+44
-40
lines changed

2 files changed

+44
-40
lines changed

src/librustc/infer/mod.rs

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -493,46 +493,6 @@ pub struct CombinedSnapshot<'a, 'tcx:'a> {
493493
}
494494

495495
impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
496-
/// Finishes processes any obligations that remain in the
497-
/// fulfillment context, and then returns the result with all type
498-
/// variables removed and regions erased. Because this is intended
499-
/// for use after type-check has completed, if any errors occur,
500-
/// it will panic. It is used during normalization and other cases
501-
/// where processing the obligations in `fulfill_cx` may cause
502-
/// type inference variables that appear in `result` to be
503-
/// unified, and hence we need to process those obligations to get
504-
/// the complete picture of the type.
505-
pub fn drain_fulfillment_cx_or_panic<T>(&self,
506-
span: Span,
507-
fulfill_cx: &mut traits::FulfillmentContext<'tcx>,
508-
result: &T)
509-
-> T::Lifted
510-
where T: TypeFoldable<'tcx> + ty::Lift<'gcx>
511-
{
512-
debug!("drain_fulfillment_cx_or_panic()");
513-
514-
// In principle, we only need to do this so long as `result`
515-
// contains unbound type parameters. It could be a slight
516-
// optimization to stop iterating early.
517-
match fulfill_cx.select_all_or_error(self) {
518-
Ok(()) => { }
519-
Err(errors) => {
520-
span_bug!(span, "Encountered errors `{:?}` resolving bounds after type-checking",
521-
errors);
522-
}
523-
}
524-
525-
let result = self.resolve_type_vars_if_possible(result);
526-
let result = self.tcx.erase_regions(&result);
527-
528-
match self.tcx.lift_to_global(&result) {
529-
Some(result) => result,
530-
None => {
531-
span_bug!(span, "Uninferred types/regions in `{:?}`", result);
532-
}
533-
}
534-
}
535-
536496
pub fn is_in_snapshot(&self) -> bool {
537497
self.in_snapshot.get()
538498
}

src/librustc/traits/trans/mod.rs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ use dep_graph::{DepKind, DepTrackingMapConfig};
1717
use std::marker::PhantomData;
1818
use syntax_pos::DUMMY_SP;
1919
use hir::def_id::DefId;
20+
use infer::InferCtxt;
21+
use syntax_pos::Span;
2022
use traits::{FulfillmentContext, Obligation, ObligationCause, SelectionContext, Vtable};
2123
use ty::{self, Ty, TyCtxt};
2224
use ty::subst::{Subst, Substs};
@@ -151,3 +153,45 @@ impl<'gcx> DepTrackingMapConfig for ProjectionCache<'gcx> {
151153
DepKind::TraitSelect
152154
}
153155
}
156+
157+
impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
158+
/// Finishes processes any obligations that remain in the
159+
/// fulfillment context, and then returns the result with all type
160+
/// variables removed and regions erased. Because this is intended
161+
/// for use after type-check has completed, if any errors occur,
162+
/// it will panic. It is used during normalization and other cases
163+
/// where processing the obligations in `fulfill_cx` may cause
164+
/// type inference variables that appear in `result` to be
165+
/// unified, and hence we need to process those obligations to get
166+
/// the complete picture of the type.
167+
fn drain_fulfillment_cx_or_panic<T>(&self,
168+
span: Span,
169+
fulfill_cx: &mut FulfillmentContext<'tcx>,
170+
result: &T)
171+
-> T::Lifted
172+
where T: TypeFoldable<'tcx> + ty::Lift<'gcx>
173+
{
174+
debug!("drain_fulfillment_cx_or_panic()");
175+
176+
// In principle, we only need to do this so long as `result`
177+
// contains unbound type parameters. It could be a slight
178+
// optimization to stop iterating early.
179+
match fulfill_cx.select_all_or_error(self) {
180+
Ok(()) => { }
181+
Err(errors) => {
182+
span_bug!(span, "Encountered errors `{:?}` resolving bounds after type-checking",
183+
errors);
184+
}
185+
}
186+
187+
let result = self.resolve_type_vars_if_possible(result);
188+
let result = self.tcx.erase_regions(&result);
189+
190+
match self.tcx.lift_to_global(&result) {
191+
Some(result) => result,
192+
None => {
193+
span_bug!(span, "Uninferred types/regions in `{:?}`", result);
194+
}
195+
}
196+
}
197+
}

0 commit comments

Comments
 (0)