@@ -288,7 +288,7 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> {
288
288
tcx. predicates_of ( def_id) . instantiate ( tcx, substs) ;
289
289
type_checker. normalize_and_prove_instantiated_predicates (
290
290
instantiated_predicates,
291
- location,
291
+ location. boring ( ) ,
292
292
) ;
293
293
}
294
294
@@ -313,10 +313,7 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> {
313
313
314
314
debug ! ( "sanitize_constant: expected_ty={:?}" , expected_ty) ;
315
315
316
- if let Err ( terr) = self
317
- . cx
318
- . eq_types ( expected_ty, constant. ty , location. at_self ( ) )
319
- {
316
+ if let Err ( terr) = self . cx . eq_types ( expected_ty, constant. ty , location. boring ( ) ) {
320
317
span_mirbug ! (
321
318
self ,
322
319
constant,
@@ -346,7 +343,7 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> {
346
343
let sty = self . sanitize_type ( place, sty) ;
347
344
let ty = self . tcx ( ) . type_of ( def_id) ;
348
345
let ty = self . cx . normalize ( ty, location) ;
349
- if let Err ( terr) = self . cx . eq_types ( ty, sty, location. at_self ( ) ) {
346
+ if let Err ( terr) = self . cx . eq_types ( ty, sty, location. boring ( ) ) {
350
347
span_mirbug ! (
351
348
self ,
352
349
place,
@@ -390,7 +387,7 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> {
390
387
// (e.g., #29149). Note that we decide to use Copy before knowing whether the bounds
391
388
// fully apply: in effect, the rule is that if a value of some type could implement
392
389
// Copy, then it must.
393
- self . cx . prove_trait_ref ( trait_ref, location) ;
390
+ self . cx . prove_trait_ref ( trait_ref, location. interesting ( ) ) ;
394
391
}
395
392
place_ty
396
393
}
@@ -489,7 +486,7 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> {
489
486
ProjectionElem :: Field ( field, fty) => {
490
487
let fty = self . sanitize_type ( place, fty) ;
491
488
match self . field_ty ( place, base, field, location) {
492
- Ok ( ty) => if let Err ( terr) = self . cx . eq_types ( ty, fty, location. at_self ( ) ) {
489
+ Ok ( ty) => if let Err ( terr) = self . cx . eq_types ( ty, fty, location. boring ( ) ) {
493
490
span_mirbug ! (
494
491
self ,
495
492
place,
@@ -787,7 +784,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
787
784
StatementKind :: Assign ( ref place, ref rv) => {
788
785
let place_ty = place. ty ( mir, tcx) . to_ty ( tcx) ;
789
786
let rv_ty = rv. ty ( mir, tcx) ;
790
- if let Err ( terr) = self . sub_types ( rv_ty, place_ty, location. at_self ( ) ) {
787
+ if let Err ( terr) = self . sub_types ( rv_ty, place_ty, location. interesting ( ) ) {
791
788
span_mirbug ! (
792
789
self ,
793
790
stmt,
@@ -802,7 +799,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
802
799
def_id : tcx. lang_items ( ) . sized_trait ( ) . unwrap ( ) ,
803
800
substs : tcx. mk_substs_trait ( place_ty, & [ ] ) ,
804
801
} ;
805
- self . prove_trait_ref ( trait_ref, location) ;
802
+ self . prove_trait_ref ( trait_ref, location. interesting ( ) ) ;
806
803
}
807
804
StatementKind :: SetDiscriminant {
808
805
ref place,
@@ -909,7 +906,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
909
906
..
910
907
} => {
911
908
let discr_ty = discr. ty ( mir, tcx) ;
912
- if let Err ( terr) = self . sub_types ( discr_ty, switch_ty, term_location. at_self ( ) ) {
909
+ if let Err ( terr) = self . sub_types ( discr_ty, switch_ty, term_location. boring ( ) ) {
913
910
span_mirbug ! (
914
911
self ,
915
912
term,
@@ -949,7 +946,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
949
946
950
947
self . prove_predicates (
951
948
sig. inputs ( ) . iter ( ) . map ( |ty| ty:: Predicate :: WellFormed ( ty) ) ,
952
- term_location,
949
+ term_location. boring ( ) ,
953
950
) ;
954
951
955
952
// The ordinary liveness rules will ensure that all
@@ -991,7 +988,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
991
988
match mir. yield_ty {
992
989
None => span_mirbug ! ( self , term, "yield in non-generator" ) ,
993
990
Some ( ty) => {
994
- if let Err ( terr) = self . sub_types ( value_ty, ty, term_location. at_self ( ) ) {
991
+ if let Err ( terr) = self . sub_types ( value_ty, ty, term_location. interesting ( ) ) {
995
992
span_mirbug ! (
996
993
self ,
997
994
term,
@@ -1056,7 +1053,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
1056
1053
}
1057
1054
for ( n, ( fn_arg, op_arg) ) in sig. inputs ( ) . iter ( ) . zip ( args) . enumerate ( ) {
1058
1055
let op_arg_ty = op_arg. ty ( mir, self . tcx ( ) ) ;
1059
- if let Err ( terr) = self . sub_types ( op_arg_ty, fn_arg, term_location. at_self ( ) ) {
1056
+ if let Err ( terr) = self . sub_types ( op_arg_ty, fn_arg, term_location. interesting ( ) ) {
1060
1057
span_mirbug ! (
1061
1058
self ,
1062
1059
term,
@@ -1284,7 +1281,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
1284
1281
substs : tcx. mk_substs_trait ( operand_ty, & [ ] ) ,
1285
1282
} ;
1286
1283
1287
- self . prove_trait_ref ( trait_ref, location) ;
1284
+ self . prove_trait_ref ( trait_ref, location. interesting ( ) ) ;
1288
1285
} ,
1289
1286
1290
1287
Rvalue :: NullaryOp ( _, ty) => {
@@ -1293,7 +1290,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
1293
1290
substs : tcx. mk_substs_trait ( ty, & [ ] ) ,
1294
1291
} ;
1295
1292
1296
- self . prove_trait_ref ( trait_ref, location) ;
1293
+ self . prove_trait_ref ( trait_ref, location. interesting ( ) ) ;
1297
1294
}
1298
1295
1299
1296
Rvalue :: Cast ( cast_kind, op, ty) => match cast_kind {
@@ -1309,7 +1306,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
1309
1306
1310
1307
let ty_fn_ptr_from = tcx. mk_fn_ptr ( fn_sig) ;
1311
1308
1312
- if let Err ( terr) = self . eq_types ( ty_fn_ptr_from, ty, location. at_self ( ) ) {
1309
+ if let Err ( terr) = self . eq_types ( ty_fn_ptr_from, ty, location. interesting ( ) ) {
1313
1310
span_mirbug ! (
1314
1311
self ,
1315
1312
rvalue,
@@ -1330,7 +1327,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
1330
1327
} ;
1331
1328
let ty_fn_ptr_from = tcx. coerce_closure_fn_ty ( sig) ;
1332
1329
1333
- if let Err ( terr) = self . eq_types ( ty_fn_ptr_from, ty, location. at_self ( ) ) {
1330
+ if let Err ( terr) = self . eq_types ( ty_fn_ptr_from, ty, location. interesting ( ) ) {
1334
1331
span_mirbug ! (
1335
1332
self ,
1336
1333
rvalue,
@@ -1354,7 +1351,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
1354
1351
1355
1352
let ty_fn_ptr_from = tcx. safe_to_unsafe_fn_ty ( fn_sig) ;
1356
1353
1357
- if let Err ( terr) = self . eq_types ( ty_fn_ptr_from, ty, location. at_self ( ) ) {
1354
+ if let Err ( terr) = self . eq_types ( ty_fn_ptr_from, ty, location. interesting ( ) ) {
1358
1355
span_mirbug ! (
1359
1356
self ,
1360
1357
rvalue,
@@ -1373,7 +1370,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
1373
1370
substs : tcx. mk_substs_trait ( op. ty ( mir, tcx) , & [ ty. into ( ) ] ) ,
1374
1371
} ;
1375
1372
1376
- self . prove_trait_ref ( trait_ref, location) ;
1373
+ self . prove_trait_ref ( trait_ref, location. interesting ( ) ) ;
1377
1374
}
1378
1375
1379
1376
CastKind :: Misc => { }
@@ -1422,7 +1419,8 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
1422
1419
}
1423
1420
} ;
1424
1421
let operand_ty = operand. ty ( mir, tcx) ;
1425
- if let Err ( terr) = self . sub_types ( operand_ty, field_ty, location. at_self ( ) ) {
1422
+
1423
+ if let Err ( terr) = self . sub_types ( operand_ty, field_ty, location. boring ( ) ) {
1426
1424
span_mirbug ! (
1427
1425
self ,
1428
1426
rvalue,
@@ -1483,8 +1481,9 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
1483
1481
* substs,
1484
1482
) ;
1485
1483
1484
+ // Hmm, are these constraints *really* boring?
1486
1485
self . push_region_constraints (
1487
- location. at_self ( ) ,
1486
+ location. boring ( ) ,
1488
1487
& closure_constraints,
1489
1488
) ;
1490
1489
}
@@ -1499,53 +1498,53 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
1499
1498
AggregateKind :: Array ( _) | AggregateKind :: Tuple => ty:: InstantiatedPredicates :: empty ( ) ,
1500
1499
} ;
1501
1500
1502
- self . normalize_and_prove_instantiated_predicates ( instantiated_predicates, location) ;
1501
+ self . normalize_and_prove_instantiated_predicates ( instantiated_predicates, location. boring ( ) ) ;
1503
1502
}
1504
1503
1505
- fn prove_trait_ref ( & mut self , trait_ref : ty:: TraitRef < ' tcx > , location : Location ) {
1504
+ fn prove_trait_ref ( & mut self , trait_ref : ty:: TraitRef < ' tcx > , locations : Locations ) {
1506
1505
self . prove_predicates (
1507
1506
Some ( ty:: Predicate :: Trait (
1508
1507
trait_ref. to_poly_trait_ref ( ) . to_poly_trait_predicate ( ) ,
1509
1508
) ) ,
1510
- location ,
1509
+ locations ,
1511
1510
) ;
1512
1511
}
1513
1512
1514
1513
fn normalize_and_prove_instantiated_predicates (
1515
1514
& mut self ,
1516
1515
instantiated_predicates : ty:: InstantiatedPredicates < ' tcx > ,
1517
- location : Location ,
1516
+ locations : Locations ,
1518
1517
) {
1519
1518
for predicate in instantiated_predicates. predicates {
1520
- let predicate = self . normalize ( predicate, location ) ;
1521
- self . prove_predicate ( predicate, location ) ;
1519
+ let predicate = self . normalize ( predicate, locations ) ;
1520
+ self . prove_predicate ( predicate, locations ) ;
1522
1521
}
1523
1522
}
1524
1523
1525
1524
fn prove_predicates (
1526
1525
& mut self ,
1527
1526
predicates : impl IntoIterator < Item = ty:: Predicate < ' tcx > > ,
1528
- location : Location ,
1527
+ locations : Locations ,
1529
1528
) {
1530
1529
for predicate in predicates {
1531
1530
debug ! (
1532
- "prove_predicates(predicate={:?}, location ={:?})" ,
1533
- predicate, location ,
1531
+ "prove_predicates(predicate={:?}, locations ={:?})" ,
1532
+ predicate, locations ,
1534
1533
) ;
1535
1534
1536
- self . prove_predicate ( predicate, location ) ;
1535
+ self . prove_predicate ( predicate, locations ) ;
1537
1536
}
1538
1537
}
1539
1538
1540
- fn prove_predicate ( & mut self , predicate : ty:: Predicate < ' tcx > , location : Location ) {
1539
+ fn prove_predicate ( & mut self , predicate : ty:: Predicate < ' tcx > , locations : Locations ) {
1541
1540
debug ! (
1542
1541
"prove_predicate(predicate={:?}, location={:?})" ,
1543
- predicate, location ,
1542
+ predicate, locations ,
1544
1543
) ;
1545
1544
1546
1545
let param_env = self . param_env ;
1547
1546
self . fully_perform_op (
1548
- location . at_self ( ) ,
1547
+ locations ,
1549
1548
param_env. and ( type_op:: prove_predicate:: ProvePredicate :: new ( predicate) ) ,
1550
1549
) . unwrap_or_else ( |NoSolution | {
1551
1550
span_mirbug ! ( self , NoSolution , "could not prove {:?}" , predicate) ;
@@ -1632,20 +1631,25 @@ impl MirPass for TypeckMir {
1632
1631
}
1633
1632
1634
1633
trait AtLocation {
1635
- /// Creates a `Locations` where `self` is both the from-location
1636
- /// and the at-location. This means that any required region
1637
- /// relationships must hold upon entering the statement/terminator
1638
- /// indicated by `self`. This is typically used when processing
1639
- /// "inputs" to the given location.
1640
- fn at_self ( self ) -> Locations ;
1634
+ /// Indicates a "boring" constraint that the user probably
1635
+ /// woudln't want to see highlights.
1636
+ fn boring ( self ) -> Locations ;
1637
+
1638
+ /// Indicates an "interesting" edge, which is of significance only
1639
+ /// for diagnostics.
1640
+ fn interesting ( self ) -> Locations ;
1641
1641
}
1642
1642
1643
1643
impl AtLocation for Location {
1644
- fn at_self ( self ) -> Locations {
1644
+ fn boring ( self ) -> Locations {
1645
1645
Locations :: Pair {
1646
1646
from_location : self ,
1647
1647
}
1648
1648
}
1649
+
1650
+ fn interesting ( self ) -> Locations {
1651
+ self . boring ( )
1652
+ }
1649
1653
}
1650
1654
1651
1655
trait NormalizeLocation : fmt:: Debug + Copy {
@@ -1660,6 +1664,6 @@ impl NormalizeLocation for Locations {
1660
1664
1661
1665
impl NormalizeLocation for Location {
1662
1666
fn to_locations ( self ) -> Locations {
1663
- self . at_self ( )
1667
+ self . boring ( )
1664
1668
}
1665
1669
}
0 commit comments