diff options
| author | Michael Sullivan <sully@msully.net> | 2012-07-14 13:55:41 -0700 |
|---|---|---|
| committer | Michael Sullivan <sully@msully.net> | 2012-07-14 14:30:48 -0700 |
| commit | 6822ec3eb4cb39a3a075b8373fcc974424ef63e8 (patch) | |
| tree | 44f2e14581a43c52e77f45f9101f39e999537b88 /src/rustc | |
| parent | 7b2f4755f3de2af6a8038ca960801853b86eb7ad (diff) | |
| download | rust-6822ec3eb4cb39a3a075b8373fcc974424ef63e8.tar.gz rust-6822ec3eb4cb39a3a075b8373fcc974424ef63e8.zip | |
Treat bare vector and string literals as fixed length vecs. Closes #2922.
Diffstat (limited to 'src/rustc')
| -rw-r--r-- | src/rustc/middle/check_const.rs | 3 | ||||
| -rw-r--r-- | src/rustc/middle/lint.rs | 76 | ||||
| -rw-r--r-- | src/rustc/middle/trans/alt.rs | 1 | ||||
| -rw-r--r-- | src/rustc/middle/trans/base.rs | 6 | ||||
| -rw-r--r-- | src/rustc/middle/typeck/check.rs | 4 |
5 files changed, 9 insertions, 81 deletions
diff --git a/src/rustc/middle/check_const.rs b/src/rustc/middle/check_const.rs index 287c701d7d0..2ae17721e99 100644 --- a/src/rustc/middle/check_const.rs +++ b/src/rustc/middle/check_const.rs @@ -38,14 +38,13 @@ fn check_item(sess: session, ast_map: ast_map::map, def_map: resolve::def_map, fn check_pat(p: @pat, &&_is_const: bool, v: visit::vt<bool>) { fn is_str(e: @expr) -> bool { alt e.node { - expr_lit(@{node: lit_str(_), _}) | expr_vstore(@{node: expr_lit(@{node: lit_str(_), _}), _}, vstore_uniq) { true } _ { false } } } alt p.node { - // Let through plain string literals here + // Let through plain ~-string literals here pat_lit(a) { if !is_str(a) { v.visit_expr(a, true, v); } } pat_range(a, b) { if !is_str(a) { v.visit_expr(a, true, v); } diff --git a/src/rustc/middle/lint.rs b/src/rustc/middle/lint.rs index b448cefd242..08eabe493c7 100644 --- a/src/rustc/middle/lint.rs +++ b/src/rustc/middle/lint.rs @@ -43,12 +43,10 @@ enum lint { unused_imports, while_true, path_statement, - old_vecs, + implicit_copies, unrecognized_warning, non_implicitly_copyable_typarams, vecs_not_implicitly_copyable, - implicit_copies, - old_strs, } // This is pretty unfortunate. We really want some sort of "deriving Enum" @@ -59,12 +57,10 @@ fn int_to_lint(i: int) -> lint { 1 { unused_imports } 2 { while_true } 3 { path_statement } - 4 { old_vecs } + 4 { implicit_copies } 5 { unrecognized_warning } 6 { non_implicitly_copyable_typarams } 7 { vecs_not_implicitly_copyable } - 8 { implicit_copies } - 9 { old_strs } } } @@ -104,16 +100,6 @@ fn get_lint_dict() -> lint_dict { desc: ~"path statements with no effect", default: warn}), - (~"old_vecs", - @{lint: old_vecs, - desc: ~"old (deprecated) vectors", - default: error}), - - (~"old_strs", - @{lint: old_strs, - desc: ~"old (deprecated) strings", - default: error}), - (~"unrecognized_warning", @{lint: unrecognized_warning, desc: ~"unrecognized warning attribute", @@ -321,7 +307,6 @@ fn check_item(i: @ast::item, cx: ty::ctxt) { check_item_ctypes(cx, i); check_item_while_true(cx, i); check_item_path_statement(cx, i); - check_item_old_vecs(cx, i); } // Take a visitor, and modify it so that it will not proceed past subitems. @@ -422,63 +407,6 @@ fn check_item_path_statement(cx: ty::ctxt, it: @ast::item) { visit::visit_item(it, (), visit); } -fn check_item_old_vecs(cx: ty::ctxt, it: @ast::item) { - let uses_vstore = int_hash(); - - let visit = item_stopping_visitor(visit::mk_simple_visitor(@{ - - visit_expr:fn@(e: @ast::expr) { - alt e.node { - ast::expr_vec(_, _) - if ! uses_vstore.contains_key(e.id) { - cx.sess.span_lint( - old_vecs, e.id, it.id, - e.span, ~"deprecated vec expr"); - } - ast::expr_lit(@{node: ast::lit_str(_), span:_}) - if ! uses_vstore.contains_key(e.id) { - cx.sess.span_lint( - old_strs, e.id, it.id, - e.span, ~"deprecated str expr"); - } - - ast::expr_vstore(@inner, _) { - uses_vstore.insert(inner.id, true); - } - _ { } - } - }, - - visit_ty: fn@(t: @ast::ty) { - alt t.node { - ast::ty_vec(_) - if ! uses_vstore.contains_key(t.id) { - cx.sess.span_lint( - old_vecs, t.id, it.id, - t.span, ~"deprecated vec type"); - } - ast::ty_path(@{span: _, global: _, idents: ids, - rp: none, types: _}, _) - if ids == ~[@~"str"] && (! uses_vstore.contains_key(t.id)) { - cx.sess.span_lint( - old_strs, t.id, it.id, - t.span, ~"deprecated str type"); - } - ast::ty_fixed_length(inner, _) | - ast::ty_box({ty: inner, _}) | - ast::ty_uniq({ty: inner, _}) | - ast::ty_rptr(_, {ty: inner, _}) { - uses_vstore.insert(inner.id, true); - } - _ { } - } - } - - with *visit::default_simple_visitor() - })); - visit::visit_item(it, (), visit); -} - fn check_crate(tcx: ty::ctxt, crate: @ast::crate) { let v = visit::mk_simple_visitor(@{ diff --git a/src/rustc/middle/trans/alt.rs b/src/rustc/middle/trans/alt.rs index 4e71231da26..55715433d5c 100644 --- a/src/rustc/middle/trans/alt.rs +++ b/src/rustc/middle/trans/alt.rs @@ -47,7 +47,6 @@ fn trans_opt(bcx: block, o: opt) -> opt_result { alt o { lit(l) { alt l.node { - ast::expr_lit(@{node: ast::lit_str(s), _}) | ast::expr_vstore(@{node: ast::expr_lit( @{node: ast::lit_str(s), _}), _}, ast::vstore_uniq) { diff --git a/src/rustc/middle/trans/base.rs b/src/rustc/middle/trans/base.rs index e82e20b9b9c..02b3733eaf7 100644 --- a/src/rustc/middle/trans/base.rs +++ b/src/rustc/middle/trans/base.rs @@ -1447,7 +1447,8 @@ fn trans_lit(cx: block, e: @ast::expr, lit: ast::lit, dest: dest) -> block { let _icx = cx.insn_ctxt(~"trans_lit"); if dest == ignore { ret cx; } alt lit.node { - ast::lit_str(s) { tvec::trans_estr(cx, s, ast::vstore_uniq, dest) } + ast::lit_str(s) { tvec::trans_estr(cx, s, + ast::vstore_fixed(none), dest) } _ { store_in_dest(cx, trans_crate_lit(cx.ccx(), e, lit), dest) } @@ -3542,7 +3543,8 @@ fn trans_expr(bcx: block, e: @ast::expr, dest: dest) -> block { ast::expr_vstore(e, v) { ret tvec::trans_vstore(bcx, e, v, dest); } ast::expr_lit(lit) { ret trans_lit(bcx, e, *lit, dest); } ast::expr_vec(args, _) { - ret tvec::trans_evec(bcx, args, ast::vstore_uniq, e.id, dest); + ret tvec::trans_evec(bcx, args, ast::vstore_fixed(none), + e.id, dest); } ast::expr_binary(op, lhs, rhs) { ret trans_binary(bcx, op, lhs, rhs, dest, e); diff --git a/src/rustc/middle/typeck/check.rs b/src/rustc/middle/typeck/check.rs index 4df32eb662d..c09616c264a 100644 --- a/src/rustc/middle/typeck/check.rs +++ b/src/rustc/middle/typeck/check.rs @@ -611,7 +611,7 @@ fn check_lit(fcx: @fn_ctxt, lit: @ast::lit) -> ty::t { let tcx = fcx.ccx.tcx; alt lit.node { - ast::lit_str(_) { ty::mk_estr(tcx, ty::vstore_uniq) } + ast::lit_str(s) { ty::mk_estr(tcx, ty::vstore_fixed(s.len())) } ast::lit_int(_, t) { ty::mk_mach_int(tcx, t) } ast::lit_uint(_, t) { ty::mk_mach_uint(tcx, t) } ast::lit_int_unsuffixed(_) { @@ -1524,7 +1524,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, let t: ty::t = fcx.infcx.next_ty_var(); for args.each |e| { bot |= check_expr_with(fcx, e, t); } let typ = ty::mk_evec(tcx, {ty: t, mutbl: mutbl}, - ty::vstore_uniq); + ty::vstore_fixed(args.len())); fcx.write_ty(id, typ); } ast::expr_tup(elts) { |
