Skip to content

Commit c822525

Browse files
committed
---
yaml --- r: 164614 b: refs/heads/auto c: 1b24602 h: refs/heads/master v: v3
1 parent 5a2ee10 commit c822525

File tree

2 files changed

+33
-19
lines changed
  • branches/auto/src/librustc/middle/infer/higher_ranked

2 files changed

+33
-19
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: 885f7ee12ec568ea2c3094407f8b1a94628b3853
13+
refs/heads/auto: 1b24602ca083cc20169190556a51066af0438049
1414
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1515
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1616
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/src/librustc/middle/infer/higher_ranked/mod.rs

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -84,30 +84,17 @@ impl<'tcx,C> HigherRankedRelations<'tcx> for C
8484

8585
// Presuming type comparison succeeds, we need to check
8686
// that the skolemized regions do not "leak".
87-
let new_vars = self.infcx().region_vars_confined_to_snapshot(snapshot);
88-
for (&skol_br, &skol) in skol_map.iter() {
89-
let tainted = self.infcx().tainted_regions(snapshot, skol);
90-
for tainted_region in tainted.iter() {
91-
// Each skolemized should only be relatable to itself
92-
// or new variables:
93-
match *tainted_region {
94-
ty::ReInfer(ty::ReVar(ref vid)) => {
95-
if new_vars.iter().any(|x| x == vid) { continue; }
96-
}
97-
_ => {
98-
if *tainted_region == skol { continue; }
99-
}
100-
};
101-
102-
// A is not as polymorphic as B:
87+
match leak_check(self.infcx(), &skol_map, snapshot) {
88+
Ok(()) => { }
89+
Err((skol_br, tainted_region)) => {
10390
if self.a_is_expected() {
10491
debug!("Not as polymorphic!");
10592
return Err(ty::terr_regions_insufficiently_polymorphic(skol_br,
106-
*tainted_region));
93+
tainted_region));
10794
} else {
10895
debug!("Overly polymorphic!");
10996
return Err(ty::terr_regions_overly_polymorphic(skol_br,
110-
*tainted_region));
97+
tainted_region));
11198
}
11299
}
113100
}
@@ -548,3 +535,30 @@ fn skolemize_regions<'a,'tcx,HR>(infcx: &InferCtxt<'a,'tcx>,
548535
skol
549536
})
550537
}
538+
539+
fn leak_check<'a,'tcx>(infcx: &InferCtxt<'a,'tcx>,
540+
skol_map: &FnvHashMap<ty::BoundRegion,ty::Region>,
541+
snapshot: &CombinedSnapshot)
542+
-> Result<(),(ty::BoundRegion,ty::Region)>
543+
{
544+
let new_vars = infcx.region_vars_confined_to_snapshot(snapshot);
545+
for (&skol_br, &skol) in skol_map.iter() {
546+
let tainted = infcx.tainted_regions(snapshot, skol);
547+
for &tainted_region in tainted.iter() {
548+
// Each skolemized should only be relatable to itself
549+
// or new variables:
550+
match tainted_region {
551+
ty::ReInfer(ty::ReVar(vid)) => {
552+
if new_vars.iter().any(|&x| x == vid) { continue; }
553+
}
554+
_ => {
555+
if tainted_region == skol { continue; }
556+
}
557+
};
558+
559+
// A is not as polymorphic as B:
560+
return Err((skol_br, tainted_region));
561+
}
562+
}
563+
Ok(())
564+
}

0 commit comments

Comments
 (0)