Skip to content

Commit 19c26cf

Browse files
committed
---
yaml --- r: 164608 b: refs/heads/auto c: 3efc9d2 h: refs/heads/master v: v3
1 parent 224fe03 commit 19c26cf

File tree

18 files changed

+457
-242
lines changed

18 files changed

+457
-242
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: 514dfdbf12b71758c7abc3219ae1a3936e4d59d9
13+
refs/heads/auto: 3efc9d2c55af6e58dd96c5814260bacc2b582ef3
1414
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1515
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1616
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/src/librustc/middle/infer/coercion.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
286286
let ty = ty::mk_rptr(self.get_ref().infcx.tcx,
287287
r_borrow,
288288
ty::mt{ty: ty, mutbl: mt_b.mutbl});
289-
try!(self.get_ref().infcx.try(|| sub.tys(ty, b)));
289+
try!(self.get_ref().infcx.try(|_| sub.tys(ty, b)));
290290
debug!("Success, coerced with AutoDerefRef(1, \
291291
AutoPtr(AutoUnsize({})))", kind);
292292
Ok(Some(AdjustDerefRef(AutoDerefRef {
@@ -309,7 +309,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
309309

310310
let ty = ty::mk_ptr(self.get_ref().infcx.tcx,
311311
ty::mt{ty: ty, mutbl: mt_b.mutbl});
312-
try!(self.get_ref().infcx.try(|| sub.tys(ty, b)));
312+
try!(self.get_ref().infcx.try(|_| sub.tys(ty, b)));
313313
debug!("Success, coerced with AutoDerefRef(1, \
314314
AutoPtr(AutoUnsize({})))", kind);
315315
Ok(Some(AdjustDerefRef(AutoDerefRef {
@@ -327,7 +327,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
327327
match self.unsize_ty(t_a, sty_a, t_b) {
328328
Some((ty, kind)) => {
329329
let ty = ty::mk_uniq(self.get_ref().infcx.tcx, ty);
330-
try!(self.get_ref().infcx.try(|| sub.tys(ty, b)));
330+
try!(self.get_ref().infcx.try(|_| sub.tys(ty, b)));
331331
debug!("Success, coerced with AutoDerefRef(1, \
332332
AutoUnsizeUniq({}))", kind);
333333
Ok(Some(AdjustDerefRef(AutoDerefRef {
@@ -384,7 +384,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
384384
let mut result = None;
385385
let mut tps = ty_substs_a.iter().zip(ty_substs_b.iter()).enumerate();
386386
for (i, (tp_a, tp_b)) in tps {
387-
if self.get_ref().infcx.try(|| sub.tys(*tp_a, *tp_b)).is_ok() {
387+
if self.get_ref().infcx.try(|_| sub.tys(*tp_a, *tp_b)).is_ok() {
388388
continue;
389389
}
390390
match
@@ -397,7 +397,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
397397
let mut new_substs = substs_a.clone();
398398
new_substs.types.get_mut_slice(subst::TypeSpace)[i] = new_tp;
399399
let ty = ty::mk_struct(tcx, did_a, new_substs);
400-
if self.get_ref().infcx.try(|| sub.tys(ty, ty_b)).is_err() {
400+
if self.get_ref().infcx.try(|_| sub.tys(ty, ty_b)).is_err() {
401401
debug!("Unsized type parameter '{}', but still \
402402
could not match types {} and {}",
403403
ppaux::ty_to_string(tcx, *tp_a),

branches/auto/src/librustc/middle/infer/combine.rs

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -706,14 +706,38 @@ impl<'cx, 'tcx> ty_fold::TypeFolder<'tcx> for Generalizer<'cx, 'tcx> {
706706

707707
fn fold_region(&mut self, r: ty::Region) -> ty::Region {
708708
match r {
709-
ty::ReLateBound(..) | ty::ReEarlyBound(..) => r,
710-
_ if self.make_region_vars => {
711-
// FIXME: This is non-ideal because we don't give a
712-
// very descriptive origin for this region variable.
713-
self.infcx.next_region_var(MiscVariable(self.span))
709+
// Never make variables for regions bound within the type itself.
710+
ty::ReLateBound(..) => { return r; }
711+
712+
// Early-bound regions should really have been substituted away before
713+
// we get to this point.
714+
ty::ReEarlyBound(..) => {
715+
self.tcx().sess.span_bug(
716+
self.span,
717+
format!("Encountered early bound region when generalizing: {}",
718+
r.repr(self.tcx()))[]);
719+
}
720+
721+
// Always make a fresh region variable for skolemized regions;
722+
// the higher-ranked decision procedures rely on this.
723+
ty::ReInfer(ty::ReSkolemized(..)) => { }
724+
725+
// For anything else, we make a region variable, unless we
726+
// are *equating*, in which case it's just wasteful.
727+
ty::ReEmpty |
728+
ty::ReStatic |
729+
ty::ReScope(..) |
730+
ty::ReInfer(ty::ReVar(..)) |
731+
ty::ReFree(..) => {
732+
if !self.make_region_vars {
733+
return r;
734+
}
714735
}
715-
_ => r,
716736
}
737+
738+
// FIXME: This is non-ideal because we don't give a
739+
// very descriptive origin for this region variable.
740+
self.infcx.next_region_var(MiscVariable(self.span))
717741
}
718742
}
719743

branches/auto/src/librustc/middle/infer/error_reporting.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1640,7 +1640,7 @@ pub trait Resolvable<'tcx> {
16401640

16411641
impl<'tcx> Resolvable<'tcx> for Ty<'tcx> {
16421642
fn resolve<'a>(&self, infcx: &InferCtxt<'a, 'tcx>) -> Ty<'tcx> {
1643-
infcx.resolve_type_vars_if_possible(*self)
1643+
infcx.resolve_type_vars_if_possible(self)
16441644
}
16451645
fn contains_error(&self) -> bool {
16461646
ty::type_is_error(*self)
@@ -1650,7 +1650,7 @@ impl<'tcx> Resolvable<'tcx> for Ty<'tcx> {
16501650
impl<'tcx> Resolvable<'tcx> for Rc<ty::TraitRef<'tcx>> {
16511651
fn resolve<'a>(&self, infcx: &InferCtxt<'a, 'tcx>)
16521652
-> Rc<ty::TraitRef<'tcx>> {
1653-
Rc::new(infcx.resolve_type_vars_in_trait_ref_if_possible(&**self))
1653+
Rc::new(infcx.resolve_type_vars_if_possible(&**self))
16541654
}
16551655
fn contains_error(&self) -> bool {
16561656
ty::trait_ref_contains_error(&**self)

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

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -249,19 +249,21 @@
249249
//! in T and try to, in some cases, replace them with bound regions to
250250
//! yield the final result.
251251
//!
252-
//! To decide whether to replace a region `R` that appears in `T` with a
253-
//! bound region, the algorithms make use of two bits of information.
254-
//! First is a set `V` that contains all region variables created as part
255-
//! of the LUB/GLB computation. `V` will contain the region variables
256-
//! created to replace the bound regions in the input types, but it also
257-
//! contains 'intermediate' variables created to represent the LUB/GLB of
258-
//! individual regions. Basically, when asked to compute the LUB/GLB of a
259-
//! region variable with another region, the inferencer cannot oblige
260-
//! immediately since the values of that variables are not known.
261-
//! Therefore, it creates a new variable that is related to the two
262-
//! regions. For example, the LUB of two variables `$x` and `$y` is a
263-
//! fresh variable `$z` that is constrained such that `$x <= $z` and `$y
264-
//! <= $z`. So `V` will contain these intermediate variables as well.
252+
//! To decide whether to replace a region `R` that appears in `T` with
253+
//! a bound region, the algorithms make use of two bits of
254+
//! information. First is a set `V` that contains all region
255+
//! variables created as part of the LUB/GLB computation (roughly; see
256+
//! `region_vars_confined_to_snapshot()` for full details). `V` will
257+
//! contain the region variables created to replace the bound regions
258+
//! in the input types, but it also contains 'intermediate' variables
259+
//! created to represent the LUB/GLB of individual regions.
260+
//! Basically, when asked to compute the LUB/GLB of a region variable
261+
//! with another region, the inferencer cannot oblige immediately
262+
//! since the values of that variables are not known. Therefore, it
263+
//! creates a new variable that is related to the two regions. For
264+
//! example, the LUB of two variables `$x` and `$y` is a fresh
265+
//! variable `$z` that is constrained such that `$x <= $z` and `$y <=
266+
//! $z`. So `V` will contain these intermediate variables as well.
265267
//!
266268
//! The other important factor in deciding how to replace a region in T is
267269
//! the function `Tainted($r)` which, for a region variable, identifies

0 commit comments

Comments
 (0)