Skip to content

Commit 1dbc161

Browse files
committed
---
yaml --- r: 164609 b: refs/heads/auto c: eb6ea5d h: refs/heads/master i: 164607: 224fe03 v: v3
1 parent 19c26cf commit 1dbc161

File tree

9 files changed

+156
-427
lines changed

9 files changed

+156
-427
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: 3efc9d2c55af6e58dd96c5814260bacc2b582ef3
13+
refs/heads/auto: eb6ea5d49b4eb21278d6ecdfa472f2cd90d379d0
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: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,9 @@
6060
//! sort of a minor point so I've opted to leave it for later---after all
6161
//! we may want to adjust precisely when coercions occur.
6262
63-
use super::{CoerceResult, resolve_type, Coercion};
63+
use super::{CoerceResult, Coercion};
6464
use super::combine::{CombineFields, Combine};
6565
use super::sub::Sub;
66-
use super::resolve::try_resolve_tvar_shallow;
6766

6867
use middle::subst;
6968
use middle::ty::{AutoPtr, AutoDerefRef, AdjustDerefRef, AutoUnsize, AutoUnsafe};
@@ -197,18 +196,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
197196
pub fn unpack_actual_value<T, F>(&self, a: Ty<'tcx>, f: F) -> T where
198197
F: FnOnce(&ty::sty<'tcx>) -> T,
199198
{
200-
match resolve_type(self.get_ref().infcx, None,
201-
a, try_resolve_tvar_shallow) {
202-
Ok(t) => {
203-
f(&t.sty)
204-
}
205-
Err(e) => {
206-
self.get_ref().infcx.tcx.sess.span_bug(
207-
self.get_ref().trace.origin.span(),
208-
format!("failed to resolve even without \
209-
any force options: {}", e).as_slice());
210-
}
211-
}
199+
f(&self.get_ref().infcx.shallow_resolve(a).sty)
212200
}
213201

214202
// ~T -> &T or &mut T -> &T (including where T = [U] or str)

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

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,6 @@ pub use self::TypeOrigin::*;
1919
pub use self::ValuePairs::*;
2020
pub use self::fixup_err::*;
2121
pub use middle::ty::IntVarValue;
22-
pub use self::resolve::resolve_and_force_all_but_regions;
23-
pub use self::resolve::{force_all, not_regions};
24-
pub use self::resolve::{force_ivar};
25-
pub use self::resolve::{force_tvar, force_rvar};
26-
pub use self::resolve::{resolve_ivar, resolve_all};
27-
pub use self::resolve::{resolve_nested_tvar};
28-
pub use self::resolve::{resolve_rvar};
2922
pub use self::skolemize::TypeSkolemizer;
3023

3124
use middle::subst;
@@ -47,7 +40,6 @@ use util::ppaux::{trait_ref_to_string, Repr};
4740
use self::coercion::Coerce;
4841
use self::combine::{Combine, CombineFields};
4942
use self::region_inference::{RegionVarBindings, RegionSnapshot};
50-
use self::resolve::{resolver};
5143
use self::equate::Equate;
5244
use self::sub::Sub;
5345
use self::lub::Lub;
@@ -453,22 +445,6 @@ pub fn mk_coercety<'a, 'tcx>(cx: &InferCtxt<'a, 'tcx>,
453445
})
454446
}
455447

456-
// See comment on the type `resolve_state` below
457-
pub fn resolve_type<'a, 'tcx>(cx: &InferCtxt<'a, 'tcx>,
458-
span: Option<Span>,
459-
a: Ty<'tcx>,
460-
modes: uint)
461-
-> fres<Ty<'tcx>> {
462-
let mut resolver = resolver(cx, modes, span);
463-
cx.commit_unconditionally(|| resolver.resolve_type_chk(a))
464-
}
465-
466-
pub fn resolve_region(cx: &InferCtxt, r: ty::Region, modes: uint)
467-
-> fres<ty::Region> {
468-
let mut resolver = resolver(cx, modes, None);
469-
resolver.resolve_region_chk(r)
470-
}
471-
472448
trait then<'tcx> {
473449
fn then<T, F>(&self, f: F) -> Result<T, ty::type_err<'tcx>> where
474450
T: Clone,
@@ -835,20 +811,21 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
835811
trait_ref_to_string(self.tcx, &t)
836812
}
837813

838-
pub fn contains_unbound_type_variables(&self, typ: Ty<'tcx>) -> Ty<'tcx> {
839-
match resolve_type(self,
840-
None,
841-
typ, resolve_nested_tvar | resolve_ivar) {
842-
Ok(new_type) => new_type,
843-
Err(_) => typ
844-
}
845-
}
846-
847814
pub fn shallow_resolve(&self, typ: Ty<'tcx>) -> Ty<'tcx> {
848815
match typ.sty {
849816
ty::ty_infer(ty::TyVar(v)) => {
817+
// Not entirely obvious: if `typ` is a type variable,
818+
// it can be resolved to an int/float variable, which
819+
// can then be recursively resolved, hence the
820+
// recursion. Note though that we prevent type
821+
// variables from unifying to other type variables
822+
// directly (though they may be embedded
823+
// structurally), and we prevent cycles in any case,
824+
// so this recursion should always be of very limited
825+
// depth.
850826
self.type_variables.borrow()
851827
.probe(v)
828+
.map(|t| self.shallow_resolve(t))
852829
.unwrap_or(typ)
853830
}
854831

@@ -869,10 +846,33 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
869846
}
870847

871848
pub fn resolve_type_vars_if_possible<T:TypeFoldable<'tcx>>(&self, value: &T) -> T {
872-
let mut r = resolve::DeepTypeResolver::new(self);
849+
/*!
850+
* Where possible, replaces type/int/float variables in
851+
* `value` with their final value. Note that region variables
852+
* are unaffected. If a type variable has not been unified, it
853+
* is left as is. This is an idempotent operation that does
854+
* not affect inference state in any way and so you can do it
855+
* at will.
856+
*/
857+
858+
let mut r = resolve::OpportunisticTypeResolver::new(self);
873859
value.fold_with(&mut r)
874860
}
875861

862+
pub fn fully_resolve<T:TypeFoldable<'tcx>>(&self, value: &T) -> fres<T> {
863+
/*!
864+
* Attempts to resolve all type/region variables in
865+
* `value`. Region inference must have been run already (e.g.,
866+
* by calling `resolve_regions_and_report_errors`). If some
867+
* variable was never unified, an `Err` results.
868+
*
869+
* This method is idempotent, but it not typically not invoked
870+
* except during the writeback phase.
871+
*/
872+
873+
resolve::fully_resolve(self, value)
874+
}
875+
876876
// [Note-Type-error-reporting]
877877
// An invariant is that anytime the expected or actual type is ty_err (the special
878878
// error type, meaning that an error occurred when typechecking this expression),

0 commit comments

Comments
 (0)