@@ -14,8 +14,8 @@ use borrow_check::nll::constraints::{
14
14
ConstraintIndex , ConstraintSccIndex , ConstraintSet , OutlivesConstraint ,
15
15
} ;
16
16
use borrow_check:: nll:: region_infer:: values:: { RegionElement , ToElementIndex } ;
17
- use borrow_check:: nll:: type_check:: Locations ;
18
17
use borrow_check:: nll:: type_check:: free_region_relations:: UniversalRegionRelations ;
18
+ use borrow_check:: nll:: type_check:: Locations ;
19
19
use rustc:: hir:: def_id:: DefId ;
20
20
use rustc:: infer:: canonical:: QueryRegionConstraint ;
21
21
use rustc:: infer:: region_constraints:: { GenericKind , VarInfos } ;
@@ -313,8 +313,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
313
313
for ( external_name, variable) in self . universal_regions . named_universal_regions ( ) {
314
314
debug ! (
315
315
"init_universal_regions: region {:?} has external name {:?}" ,
316
- variable,
317
- external_name
316
+ variable, external_name
318
317
) ;
319
318
self . definitions [ variable] . external_name = Some ( external_name) ;
320
319
}
@@ -424,10 +423,20 @@ impl<'tcx> RegionInferenceContext<'tcx> {
424
423
} ;
425
424
426
425
self . check_type_tests (
427
- infcx, mir, mir_def_id, outlives_requirements. as_mut ( ) , errors_buffer) ;
426
+ infcx,
427
+ mir,
428
+ mir_def_id,
429
+ outlives_requirements. as_mut ( ) ,
430
+ errors_buffer,
431
+ ) ;
428
432
429
433
self . check_universal_regions (
430
- infcx, mir, mir_def_id, outlives_requirements. as_mut ( ) , errors_buffer) ;
434
+ infcx,
435
+ mir,
436
+ mir_def_id,
437
+ outlives_requirements. as_mut ( ) ,
438
+ errors_buffer,
439
+ ) ;
431
440
432
441
let outlives_requirements = outlives_requirements. unwrap_or ( vec ! [ ] ) ;
433
442
@@ -586,13 +595,15 @@ impl<'tcx> RegionInferenceContext<'tcx> {
586
595
if let Some ( lower_bound_region) = lower_bound_region {
587
596
let region_scope_tree = & tcx. region_scope_tree ( mir_def_id) ;
588
597
let type_test_span = type_test. locations . span ( mir) ;
589
- infcx. construct_generic_bound_failure (
590
- region_scope_tree,
591
- type_test_span,
592
- None ,
593
- type_test. generic_kind ,
594
- lower_bound_region,
595
- ) . buffer ( errors_buffer) ;
598
+ infcx
599
+ . construct_generic_bound_failure (
600
+ region_scope_tree,
601
+ type_test_span,
602
+ None ,
603
+ type_test. generic_kind ,
604
+ lower_bound_region,
605
+ )
606
+ . buffer ( errors_buffer) ;
596
607
} else {
597
608
// FIXME. We should handle this case better. It
598
609
// indicates that we have e.g. some region variable
@@ -604,10 +615,12 @@ impl<'tcx> RegionInferenceContext<'tcx> {
604
615
// iterating over the universal regions and reporting
605
616
// an error that multiple bounds are required.
606
617
let type_test_span = type_test. locations . span ( mir) ;
607
- tcx. sess . struct_span_err (
608
- type_test_span,
609
- & format ! ( "`{}` does not live long enough" , type_test. generic_kind, ) ,
610
- ) . buffer ( errors_buffer) ;
618
+ tcx. sess
619
+ . struct_span_err (
620
+ type_test_span,
621
+ & format ! ( "`{}` does not live long enough" , type_test. generic_kind, ) ,
622
+ )
623
+ . buffer ( errors_buffer) ;
611
624
}
612
625
}
613
626
}
@@ -659,8 +672,11 @@ impl<'tcx> RegionInferenceContext<'tcx> {
659
672
// region, which ensures it can be encoded in a `ClosureOutlivesRequirement`.
660
673
let lower_bound_plus = self . non_local_universal_upper_bound ( * lower_bound) ;
661
674
assert ! ( self . universal_regions. is_universal_region( lower_bound_plus) ) ;
662
- assert ! ( !self . universal_regions
663
- . is_local_free_region( lower_bound_plus) ) ;
675
+ assert ! (
676
+ !self
677
+ . universal_regions
678
+ . is_local_free_region( lower_bound_plus)
679
+ ) ;
664
680
665
681
propagated_outlives_requirements. push ( ClosureOutlivesRequirement {
666
682
subject,
@@ -892,7 +908,8 @@ impl<'tcx> RegionInferenceContext<'tcx> {
892
908
return true ;
893
909
}
894
910
895
- self . scc_values . contains_points ( sup_region_scc, sub_region_scc)
911
+ self . scc_values
912
+ . contains_points ( sup_region_scc, sub_region_scc)
896
913
}
897
914
898
915
/// Once regions have been propagated, this method is used to see
@@ -982,7 +999,10 @@ impl<'tcx> RegionInferenceContext<'tcx> {
982
999
// (because `fr` includes `end(o)`).
983
1000
for shorter_fr in self . scc_values . universal_regions_outlived_by ( longer_fr_scc) {
984
1001
// If it is known that `fr: o`, carry on.
985
- if self . universal_region_relations . outlives ( longer_fr, shorter_fr) {
1002
+ if self
1003
+ . universal_region_relations
1004
+ . outlives ( longer_fr, shorter_fr)
1005
+ {
986
1006
continue ;
987
1007
}
988
1008
@@ -996,14 +1016,19 @@ impl<'tcx> RegionInferenceContext<'tcx> {
996
1016
if let Some ( propagated_outlives_requirements) = propagated_outlives_requirements {
997
1017
// Shrink `fr` until we find a non-local region (if we do).
998
1018
// We'll call that `fr-` -- it's ever so slightly smaller than `fr`.
999
- if let Some ( fr_minus) = self . universal_region_relations . non_local_lower_bound ( longer_fr) {
1019
+ if let Some ( fr_minus) = self
1020
+ . universal_region_relations
1021
+ . non_local_lower_bound ( longer_fr)
1022
+ {
1000
1023
debug ! ( "check_universal_region: fr_minus={:?}" , fr_minus) ;
1001
1024
1002
1025
// Grow `shorter_fr` until we find a non-local
1003
1026
// region. (We always will.) We'll call that
1004
1027
// `shorter_fr+` -- it's ever so slightly larger than
1005
1028
// `fr`.
1006
- let shorter_fr_plus = self . universal_region_relations . non_local_upper_bound ( shorter_fr) ;
1029
+ let shorter_fr_plus = self
1030
+ . universal_region_relations
1031
+ . non_local_upper_bound ( shorter_fr) ;
1007
1032
debug ! (
1008
1033
"check_universal_region: shorter_fr_plus={:?}" ,
1009
1034
shorter_fr_plus
@@ -1026,8 +1051,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
1026
1051
// Note: in this case, we use the unapproximated regions
1027
1052
// to report the error. This gives better error messages
1028
1053
// in some cases.
1029
- self . report_error (
1030
- mir, infcx, mir_def_id, longer_fr, shorter_fr, errors_buffer) ;
1054
+ self . report_error ( mir, infcx, mir_def_id, longer_fr, shorter_fr, errors_buffer) ;
1031
1055
}
1032
1056
}
1033
1057
0 commit comments