diff options
| author | Graydon Hoare <[email protected]> | 2011-04-25 18:05:09 -0700 |
|---|---|---|
| committer | Graydon Hoare <[email protected]> | 2011-04-25 18:08:13 -0700 |
| commit | cf23db6be52179f2acce1577ca1045fe2b5647cb (patch) | |
| tree | 64437970a3dc27c3b626b752c7f044880519e471 /src/comp/middle/ty.rs | |
| parent | rustc: Use the abbreviated type names to avoid LLVM bitcode size explosion (diff) | |
| download | rust-cf23db6be52179f2acce1577ca1045fe2b5647cb.tar.xz rust-cf23db6be52179f2acce1577ca1045fe2b5647cb.zip | |
A little more guarding against wasted work in ty, typeck.
Diffstat (limited to 'src/comp/middle/ty.rs')
| -rw-r--r-- | src/comp/middle/ty.rs | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/comp/middle/ty.rs b/src/comp/middle/ty.rs index ca461bc4..04bea450 100644 --- a/src/comp/middle/ty.rs +++ b/src/comp/middle/ty.rs @@ -1629,6 +1629,10 @@ fn type_contains_vars(ctxt cx, t typ) -> bool { ret typ.has_vars; } +fn type_contains_locals(ctxt cx, t typ) -> bool { + ret typ.has_locals; +} + fn type_contains_params(ctxt cx, t typ) -> bool { ret typ.has_params; } @@ -2606,6 +2610,10 @@ mod Unify { // Performs type binding substitution. fn substitute(@ctxt cx, vec[t] set_types, t typ) -> t { + if (!type_contains_vars(cx.tcx, typ)) { + ret typ; + } + fn substituter(@ctxt cx, vec[t] types, t typ) -> t { alt (struct(cx.tcx, typ)) { case (ty_var(?id)) { @@ -2755,8 +2763,9 @@ fn substitute_type_params(ctxt cx, vec[t] bindings, t typ) -> t { // Converts type parameters in a type to bound type parameters. fn bind_params_in_type(ctxt cx, t typ) -> t { - if (!type_contains_params(cx, typ)) { ret typ; } - + if (!type_contains_params(cx, typ)) { + ret typ; + } fn binder(ctxt cx, t typ) -> t { alt (struct(cx, typ)) { case (ty_bound_param(?index)) { |