aboutsummaryrefslogtreecommitdiff
path: root/src/comp/middle/ty.rs
diff options
context:
space:
mode:
authorPatrick Walton <[email protected]>2011-05-09 14:00:02 -0700
committerPatrick Walton <[email protected]>2011-05-09 14:00:50 -0700
commit70c759030ccf27222a04f918e235bc9dbcf88c94 (patch)
treee8e0439b47606fe6500df7e9c3e455c4ef35a82c /src/comp/middle/ty.rs
parentAlias-ify a variety of fn signatures in ty. Cuts 180kb off rustc. (diff)
downloadrust-70c759030ccf27222a04f918e235bc9dbcf88c94.tar.xz
rust-70c759030ccf27222a04f918e235bc9dbcf88c94.zip
rustc: Alias fix part 2 -- Check that the aliasness of function parameters matches. Add a test case.
Diffstat (limited to 'src/comp/middle/ty.rs')
-rw-r--r--src/comp/middle/ty.rs15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/comp/middle/ty.rs b/src/comp/middle/ty.rs
index 9e90d125..4a630af1 100644
--- a/src/comp/middle/ty.rs
+++ b/src/comp/middle/ty.rs
@@ -2098,14 +2098,17 @@ mod Unify {
auto expected_input = expected_inputs.(i);
auto actual_input = actual_inputs.(i);
- // This should be safe, I think?
- // FIXME: It's not. At all.
+ // Unify the result modes. "mo_either" unifies with both modes.
auto result_mode;
- if (expected_input.mode == mo_alias ||
- actual_input.mode == mo_alias) {
- result_mode = mo_alias;
+ if (expected_input.mode == mo_either) {
+ result_mode = actual_input.mode;
+ } else if (actual_input.mode == mo_either) {
+ result_mode = expected_input.mode;
+ } else if (expected_input.mode != actual_input.mode) {
+ ret fn_common_res_err(ures_err(terr_arg_count,
+ expected, actual));
} else {
- result_mode = mo_val;
+ result_mode = expected_input.mode;
}
auto result = unify_step(cx, actual_input.ty, expected_input.ty);