|
14 | 14 | use borrow_check::nll::region_infer::Cause;
|
15 | 15 | use borrow_check::nll::region_infer::ClosureRegionRequirementsExt;
|
16 | 16 | use borrow_check::nll::universal_regions::UniversalRegions;
|
| 17 | +use dataflow::move_paths::MoveData; |
17 | 18 | use dataflow::FlowAtLocation;
|
18 | 19 | use dataflow::MaybeInitializedPlaces;
|
19 |
| -use dataflow::move_paths::MoveData; |
20 | 20 | use rustc::hir::def_id::DefId;
|
21 |
| -use rustc::infer::{InferCtxt, InferOk, InferResult, LateBoundRegionConversionTime, UnitResult}; |
22 | 21 | use rustc::infer::region_constraints::{GenericKind, RegionConstraintData};
|
23 |
| -use rustc::traits::{self, Normalized, TraitEngine}; |
| 22 | +use rustc::infer::{InferCtxt, InferOk, InferResult, LateBoundRegionConversionTime, UnitResult}; |
| 23 | +use rustc::mir::tcx::PlaceTy; |
| 24 | +use rustc::mir::visit::{PlaceContext, Visitor}; |
| 25 | +use rustc::mir::*; |
24 | 26 | use rustc::traits::query::NoSolution;
|
| 27 | +use rustc::traits::{self, Normalized, TraitEngine}; |
25 | 28 | use rustc::ty::error::TypeError;
|
26 | 29 | use rustc::ty::fold::TypeFoldable;
|
27 | 30 | use rustc::ty::{self, ToPolyTraitRef, Ty, TyCtxt, TypeVariants};
|
28 |
| -use rustc::mir::*; |
29 |
| -use rustc::mir::tcx::PlaceTy; |
30 |
| -use rustc::mir::visit::{PlaceContext, Visitor}; |
31 | 31 | use std::fmt;
|
32 | 32 | use syntax::ast;
|
33 | 33 | use syntax_pos::{Span, DUMMY_SP};
|
@@ -61,8 +61,8 @@ macro_rules! span_mirbug_and_err {
|
61 | 61 | })
|
62 | 62 | }
|
63 | 63 |
|
64 |
| -mod liveness; |
65 | 64 | mod input_output;
|
| 65 | +mod liveness; |
66 | 66 |
|
67 | 67 | /// Type checks the given `mir` in the context of the inference
|
68 | 68 | /// context `infcx`. Returns any region constraints that have yet to
|
@@ -275,7 +275,7 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> {
|
275 | 275 | tcx.predicates_of(def_id).instantiate(tcx, substs);
|
276 | 276 | let predicates =
|
277 | 277 | type_checker.normalize(&instantiated_predicates.predicates, location);
|
278 |
| - type_checker.prove_predicates(&predicates, location); |
| 278 | + type_checker.prove_predicates(predicates.iter().cloned(), location); |
279 | 279 | }
|
280 | 280 |
|
281 | 281 | value.ty
|
@@ -763,9 +763,12 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
|
763 | 763 | }
|
764 | 764 | StatementKind::UserAssertTy(ref c_ty, ref local) => {
|
765 | 765 | let local_ty = mir.local_decls()[*local].ty;
|
766 |
| - let (ty, _) = self.infcx.instantiate_canonical_with_fresh_inference_vars( |
767 |
| - stmt.source_info.span, c_ty); |
768 |
| - debug!("check_stmt: user_assert_ty ty={:?} local_ty={:?}", ty, local_ty); |
| 766 | + let (ty, _) = self.infcx |
| 767 | + .instantiate_canonical_with_fresh_inference_vars(stmt.source_info.span, c_ty); |
| 768 | + debug!( |
| 769 | + "check_stmt: user_assert_ty ty={:?} local_ty={:?}", |
| 770 | + ty, local_ty |
| 771 | + ); |
769 | 772 | if let Err(terr) = self.eq_types(ty, local_ty, location.at_self()) {
|
770 | 773 | span_mirbug!(
|
771 | 774 | self,
|
@@ -895,6 +898,11 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
|
895 | 898 | let sig = self.normalize(&sig, term_location);
|
896 | 899 | self.check_call_dest(mir, term, &sig, destination, term_location);
|
897 | 900 |
|
| 901 | + self.prove_predicates( |
| 902 | + sig.inputs().iter().map(|ty| ty::Predicate::WellFormed(ty)), |
| 903 | + term_location, |
| 904 | + ); |
| 905 | + |
898 | 906 | // The ordinary liveness rules will ensure that all
|
899 | 907 | // regions in the type of the callee are live here. We
|
900 | 908 | // then further constrain the late-bound regions that
|
@@ -1508,28 +1516,35 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
|
1508 | 1516 |
|
1509 | 1517 | let predicates = self.normalize(&instantiated_predicates.predicates, location);
|
1510 | 1518 | debug!("prove_aggregate_predicates: predicates={:?}", predicates);
|
1511 |
| - self.prove_predicates(&predicates, location); |
| 1519 | + self.prove_predicates(predicates.iter().cloned(), location); |
1512 | 1520 | }
|
1513 | 1521 |
|
1514 | 1522 | fn prove_trait_ref(&mut self, trait_ref: ty::TraitRef<'tcx>, location: Location) {
|
1515 | 1523 | self.prove_predicates(
|
1516 |
| - &[ |
1517 |
| - ty::Predicate::Trait(trait_ref.to_poly_trait_ref().to_poly_trait_predicate()), |
1518 |
| - ], |
| 1524 | + [ty::Predicate::Trait( |
| 1525 | + trait_ref.to_poly_trait_ref().to_poly_trait_predicate(), |
| 1526 | + )].iter() |
| 1527 | + .cloned(), |
1519 | 1528 | location,
|
1520 | 1529 | );
|
1521 | 1530 | }
|
1522 | 1531 |
|
1523 |
| - fn prove_predicates(&mut self, predicates: &[ty::Predicate<'tcx>], location: Location) { |
| 1532 | + fn prove_predicates( |
| 1533 | + &mut self, |
| 1534 | + predicates: impl IntoIterator<Item = ty::Predicate<'tcx>>, |
| 1535 | + location: Location, |
| 1536 | + ) { |
| 1537 | + let mut predicates_iter = predicates.into_iter(); |
| 1538 | + |
1524 | 1539 | debug!(
|
1525 | 1540 | "prove_predicates(predicates={:?}, location={:?})",
|
1526 |
| - predicates, location |
| 1541 | + predicates_iter.by_ref().collect::<Vec<_>>(), |
| 1542 | + location |
1527 | 1543 | );
|
1528 | 1544 | self.fully_perform_op(location.at_self(), |this| {
|
1529 | 1545 | let cause = this.misc(this.last_span);
|
1530 |
| - let obligations = predicates |
1531 |
| - .iter() |
1532 |
| - .map(|&p| traits::Obligation::new(cause.clone(), this.param_env, p)) |
| 1546 | + let obligations = predicates_iter |
| 1547 | + .map(|p| traits::Obligation::new(cause.clone(), this.param_env, p)) |
1533 | 1548 | .collect();
|
1534 | 1549 | Ok(InferOk {
|
1535 | 1550 | value: (),
|
|
0 commit comments