use dep_graph::DepGraph;
use middle::infer::InferCtxt;
-use middle::ty::{self, Ty, TypeFoldable};
+use middle::ty::{self, Ty, TypeFoldable, ToPolyTraitRef};
use rustc_data_structures::obligation_forest::{Backtrace, ObligationForest, Error};
use std::iter;
use syntax::ast;
}
}
+
+/// Return the set of type variables contained in a trait ref
+fn trait_ref_type_vars<'a, 'tcx>(selcx: &mut SelectionContext<'a, 'tcx>,
+ t: ty::PolyTraitRef<'tcx>) -> Vec<Ty<'tcx>>
+{
+ t.skip_binder() // ok b/c this check doesn't care about regions
+ .input_types()
+ .iter()
+ .map(|t| selcx.infcx().resolve_type_vars_if_possible(t))
+ .filter(|t| t.has_infer_types())
+ .flat_map(|t| t.walk())
+ .filter(|t| match t.sty { ty::TyInfer(_) => true, _ => false })
+ .collect()
+}
+
/// Processes a predicate obligation and returns either:
/// - `Ok(Some(v))` if the predicate is true, presuming that `v` are also true
/// - `Ok(None)` if we don't have enough info to be sure
// doing more work yet
if !pending_obligation.stalled_on.is_empty() {
if pending_obligation.stalled_on.iter().all(|&ty| {
- let resolved_ty = selcx.infcx().resolve_type_vars_if_possible(&ty);
+ let resolved_ty = selcx.infcx().shallow_resolve(&ty);
resolved_ty == ty // nothing changed here
}) {
debug!("process_predicate: pending obligation {:?} still stalled on {:?}",
// of its type, and those types are resolved at
// the same time.
pending_obligation.stalled_on =
- data.skip_binder() // ok b/c this check doesn't care about regions
- .input_types()
- .iter()
- .map(|t| selcx.infcx().resolve_type_vars_if_possible(t))
- .filter(|t| t.has_infer_types())
- .flat_map(|t| t.walk())
- .filter(|t| match t.sty { ty::TyInfer(_) => true, _ => false })
- .collect();
+ trait_ref_type_vars(selcx, data.to_poly_trait_ref());
debug!("process_predicate: pending obligation {:?} now stalled on {:?}",
selcx.infcx().resolve_type_vars_if_possible(obligation),
ty::Predicate::Projection(ref data) => {
let project_obligation = obligation.with(data.clone());
match project::poly_project_and_unify_type(selcx, &project_obligation) {
+ Ok(None) => {
+ pending_obligation.stalled_on =
+ trait_ref_type_vars(selcx, data.to_poly_trait_ref());
+ Ok(None)
+ }
Ok(v) => Ok(v),
Err(e) => Err(CodeProjectionError(e))
}
}
ty::Predicate::WellFormed(ty) => {
- Ok(ty::wf::obligations(selcx.infcx(), obligation.cause.body_id,
- ty, obligation.cause.span))
+ match ty::wf::obligations(selcx.infcx(), obligation.cause.body_id,
+ ty, obligation.cause.span) {
+ None => {
+ pending_obligation.stalled_on = vec![ty];
+ Ok(None)
+ }
+ s => Ok(s)
+ }
}
}
}
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+fn main() {
+ macro_rules! f {
+ () => { 0 + 0 }
+ }
+ // 16 per line
+ f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();
+ f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();
+ f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();
+ f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();
+
+ f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();
+ f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();
+ f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();
+ f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();
+
+ f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();
+ f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();
+ f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();
+ f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();
+
+ f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();
+ f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();
+ f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();
+ f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();
+}