From 45c1dfe5b318dac6641dee439d6498209cae455a Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Tue, 31 Jan 2012 11:52:46 -0800 Subject: [PATCH] Don't compute pre- and postconditions for item_consts Since item_consts can't refer to or modify local variables, they don't participate in typestate and thus get empty pre and postconditions by default. Closes #1660 --- src/comp/middle/tstate/pre_post_conditions.rs | 17 +---------------- src/test/run-pass/issue-1660.rs | 3 +++ 2 files changed, 4 insertions(+), 16 deletions(-) create mode 100644 src/test/run-pass/issue-1660.rs diff --git a/src/comp/middle/tstate/pre_post_conditions.rs b/src/comp/middle/tstate/pre_post_conditions.rs index 9977b20cddb..dcb117cb6a3 100644 --- a/src/comp/middle/tstate/pre_post_conditions.rs +++ b/src/comp/middle/tstate/pre_post_conditions.rs @@ -41,22 +41,7 @@ fn find_pre_post_method(ccx: crate_ctxt, m: @method) { fn find_pre_post_item(ccx: crate_ctxt, i: item) { alt i.node { item_const(_, e) { - // make a fake fcx - let v: @mutable [node_id] = @mutable []; - let fake_fcx = - { - // just bogus - enclosing: - {constrs: new_def_hash::(), - num_constraints: 0u, - cf: return_val, - i_return: ninit(0, ""), - i_diverge: ninit(0, ""), - used_vars: v}, - id: 0, - name: "", - ccx: ccx}; - find_pre_post_expr(fake_fcx, e); + // do nothing -- item_consts don't refer to local vars } item_fn(_, _, body) { assert (ccx.fm.contains_key(i.id)); diff --git a/src/test/run-pass/issue-1660.rs b/src/test/run-pass/issue-1660.rs new file mode 100644 index 00000000000..0f4958e6ae1 --- /dev/null +++ b/src/test/run-pass/issue-1660.rs @@ -0,0 +1,3 @@ +fn main() { + const _x: int = 1<<2; +}