Skip to content

Commit e649b53

Browse files
committed
---
yaml --- r: 181863 b: refs/heads/auto c: 5511add h: refs/heads/master i: 181861: 0ae25c2 181859: cb7d430 181855: 2df2032 v: v3
1 parent 98ec95d commit e649b53

File tree

2 files changed

+34
-15
lines changed

2 files changed

+34
-15
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1010
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1111
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1212
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
13-
refs/heads/auto: 7134ad4d6402e4a1d84a7ebfa417170c107642cb
13+
refs/heads/auto: 5511add74205d8547f98959b01e5053be2395723
1414
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1515
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1616
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/src/librustc/middle/traits/mod.rs

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ pub use self::FulfillmentErrorCode::*;
1515
pub use self::Vtable::*;
1616
pub use self::ObligationCauseCode::*;
1717

18-
use middle::mem_categorization::Typer;
1918
use middle::subst;
20-
use middle::ty::{self, Ty};
19+
use middle::ty::{self, HasProjectionTypes, Ty};
20+
use middle::ty_fold::TypeFoldable;
2121
use middle::infer::{self, InferCtxt};
2222
use std::slice::Iter;
2323
use std::rc::Rc;
@@ -432,25 +432,44 @@ pub fn normalize_param_env<'a,'tcx>(param_env: &ty::ParameterEnvironment<'a,'tcx
432432
debug!("normalize_param_env(param_env={})",
433433
param_env.repr(tcx));
434434

435-
let predicates: Vec<ty::Predicate<'tcx>> = {
436-
let infcx = infer::new_infer_ctxt(tcx);
437-
let mut selcx = &mut SelectionContext::new(&infcx, param_env);
438-
let mut fulfill_cx = FulfillmentContext::new();
439-
let Normalized { value: predicates, obligations } =
440-
project::normalize(selcx, cause, &param_env.caller_bounds);
441-
for obligation in obligations {
442-
fulfill_cx.register_predicate_obligation(selcx.infcx(), obligation);
443-
}
444-
try!(fulfill_cx.select_all_or_error(selcx.infcx(), param_env));
445-
predicates.iter().map(|p| infcx.resolve_type_vars_if_possible(p)).collect()
446-
};
435+
let infcx = infer::new_infer_ctxt(tcx);
436+
let predicates = try!(fully_normalize(&infcx, param_env, cause, &param_env.caller_bounds));
447437

448438
debug!("normalize_param_env: predicates={}",
449439
predicates.repr(tcx));
450440

451441
Ok(param_env.with_caller_bounds(predicates))
452442
}
453443

444+
pub fn fully_normalize<'a,'tcx,T>(infcx: &InferCtxt<'a,'tcx>,
445+
closure_typer: &ty::ClosureTyper<'tcx>,
446+
cause: ObligationCause<'tcx>,
447+
value: &T)
448+
-> Result<T, Vec<FulfillmentError<'tcx>>>
449+
where T : TypeFoldable<'tcx> + HasProjectionTypes + Clone + Repr<'tcx>
450+
{
451+
let tcx = closure_typer.tcx();
452+
453+
debug!("normalize_param_env(value={})",
454+
value.repr(tcx));
455+
456+
let mut selcx = &mut SelectionContext::new(infcx, closure_typer);
457+
let mut fulfill_cx = FulfillmentContext::new();
458+
let Normalized { value: normalized_value, obligations } =
459+
project::normalize(selcx, cause, value);
460+
debug!("normalize_param_env: normalized_value={} obligations={}",
461+
normalized_value.repr(tcx),
462+
obligations.repr(tcx));
463+
for obligation in obligations {
464+
fulfill_cx.register_predicate_obligation(selcx.infcx(), obligation);
465+
}
466+
try!(fulfill_cx.select_all_or_error(infcx, closure_typer));
467+
let resolved_value = infcx.resolve_type_vars_if_possible(&normalized_value);
468+
debug!("normalize_param_env: resolved_value={}",
469+
resolved_value.repr(tcx));
470+
Ok(resolved_value)
471+
}
472+
454473
impl<'tcx,O> Obligation<'tcx,O> {
455474
pub fn new(cause: ObligationCause<'tcx>,
456475
trait_ref: O)

0 commit comments

Comments
 (0)