Skip to content

Commit 985b52b

Browse files
committed
Support prefix notation for vstore strings. Closes #2906.
1 parent e4de160 commit 985b52b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+252
-237
lines changed

src/cargo/cargo.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ fn load_crate(filename: str) -> option<crate> {
283283
ast::view_item_use(ident, metas, id) {
284284
let name_items = attr::find_meta_items_by_name(metas, "name");
285285
let m = if name_items.is_empty() {
286-
metas + ~[attr::mk_name_value_item_str(@"name", *ident)]
286+
metas + ~[attr::mk_name_value_item_str(@"name"/~, *ident)]
287287
} else {
288288
metas
289289
};

src/fuzzer/fuzzer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ fn common_exprs() -> ~[ast::expr] {
4545
dse(ast::expr_again),
4646
dse(ast::expr_fail(option::none)),
4747
dse(ast::expr_fail(option::some(
48-
@dse(ast::expr_lit(@dsl(ast::lit_str(@"boo"))))))),
48+
@dse(ast::expr_lit(@dsl(ast::lit_str(@"boo"/~))))))),
4949
dse(ast::expr_ret(option::none)),
5050
dse(ast::expr_lit(@dsl(ast::lit_nil))),
5151
dse(ast::expr_lit(@dsl(ast::lit_bool(false)))),

src/libcore/task.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1301,10 +1301,10 @@ fn test_unkillable_nested() {
13011301
#[test]
13021302
fn test_tls_multitask() unsafe {
13031303
fn my_key(+_x: @str/~) { }
1304-
local_data_set(my_key, @"parent data");
1304+
local_data_set(my_key, @"parent data"/~);
13051305
do task::spawn {
13061306
assert local_data_get(my_key) == none; // TLS shouldn't carry over.
1307-
local_data_set(my_key, @"child data");
1307+
local_data_set(my_key, @"child data"/~);
13081308
assert *(local_data_get(my_key).get()) == "child data";
13091309
// should be cleaned up for us
13101310
}
@@ -1317,15 +1317,15 @@ fn test_tls_multitask() unsafe {
13171317
#[test]
13181318
fn test_tls_overwrite() unsafe {
13191319
fn my_key(+_x: @str/~) { }
1320-
local_data_set(my_key, @"first data");
1321-
local_data_set(my_key, @"next data"); // Shouldn't leak.
1320+
local_data_set(my_key, @"first data"/~);
1321+
local_data_set(my_key, @"next data"/~); // Shouldn't leak.
13221322
assert *(local_data_get(my_key).get()) == "next data";
13231323
}
13241324

13251325
#[test]
13261326
fn test_tls_pop() unsafe {
13271327
fn my_key(+_x: @str/~) { }
1328-
local_data_set(my_key, @"weasel");
1328+
local_data_set(my_key, @"weasel"/~);
13291329
assert *(local_data_pop(my_key).get()) == "weasel";
13301330
// Pop must remove the data from the map.
13311331
assert local_data_pop(my_key) == none;
@@ -1337,12 +1337,12 @@ fn test_tls_modify() unsafe {
13371337
local_data_modify(my_key, |data| {
13381338
alt data {
13391339
some(@val) { fail "unwelcome value: " + val }
1340-
none { some(@"first data") }
1340+
none { some(@"first data"/~) }
13411341
}
13421342
});
13431343
local_data_modify(my_key, |data| {
13441344
alt data {
1345-
some(@"first data") { some(@"next data") }
1345+
some(@"first data"/~) { some(@"next data"/~) }
13461346
some(@val) { fail "wrong value: " + val }
13471347
none { fail "missing value" }
13481348
}
@@ -1359,7 +1359,7 @@ fn test_tls_crust_automorestack_memorial_bug() unsafe {
13591359
// for logging, think vsnprintf) would run on a stack smaller than 1 MB.
13601360
fn my_key(+_x: @str/~) { }
13611361
do task::spawn {
1362-
unsafe { local_data_set(my_key, @"hax"); }
1362+
unsafe { local_data_set(my_key, @"hax"/~); }
13631363
}
13641364
}
13651365

@@ -1369,7 +1369,7 @@ fn test_tls_multiple_types() unsafe {
13691369
fn box_key(+_x: @@()) { }
13701370
fn int_key(+_x: @int) { }
13711371
do task::spawn {
1372-
local_data_set(str_key, @"string data");
1372+
local_data_set(str_key, @"string data"/~);
13731373
local_data_set(box_key, @@());
13741374
local_data_set(int_key, @42);
13751375
}
@@ -1381,7 +1381,7 @@ fn test_tls_overwrite_multiple_types() unsafe {
13811381
fn box_key(+_x: @@()) { }
13821382
fn int_key(+_x: @int) { }
13831383
do task::spawn {
1384-
local_data_set(str_key, @"string data");
1384+
local_data_set(str_key, @"string data"/~);
13851385
local_data_set(int_key, @42);
13861386
// This could cause a segfault if overwriting-destruction is done with
13871387
// the crazy polymorphic transmute rather than the provided finaliser.
@@ -1396,10 +1396,10 @@ fn test_tls_cleanup_on_failure() unsafe {
13961396
fn str_key(+_x: @str/~) { }
13971397
fn box_key(+_x: @@()) { }
13981398
fn int_key(+_x: @int) { }
1399-
local_data_set(str_key, @"parent data");
1399+
local_data_set(str_key, @"parent data"/~);
14001400
local_data_set(box_key, @@());
14011401
do task::spawn { // spawn_linked
1402-
local_data_set(str_key, @"string data");
1402+
local_data_set(str_key, @"string data"/~);
14031403
local_data_set(box_key, @@());
14041404
local_data_set(int_key, @42);
14051405
fail;

src/libcore/unsafe.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ mod tests {
5858
#[test]
5959
fn test_bump_box_refcount() {
6060
unsafe {
61-
let box = @"box box box"; // refcount 1
61+
let box = @"box box box"/~; // refcount 1
6262
bump_box_refcount(box); // refcount 2
6363
let ptr: *int = transmute(box); // refcount 2
6464
let _box1: @str/~ = reinterpret_cast(ptr);

src/libstd/json.rs

Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -659,8 +659,8 @@ mod tests {
659659

660660
#[test]
661661
fn test_write_str() {
662-
assert to_str(string(@"")) == "\"\"";
663-
assert to_str(string(@"foo")) == "\"foo\"";
662+
assert to_str(string(@""/~)) == "\"\""/~;
663+
assert to_str(string(@"foo"/~)) == "\"foo\""/~;
664664
}
665665

666666
#[test]
@@ -676,7 +676,7 @@ mod tests {
676676
assert to_str(list(@~[
677677
boolean(false),
678678
null,
679-
list(@~[string(@"foo\nbar"), num(3.5f)])
679+
list(@~[string(@"foo\nbar"/~), num(3.5f)])
680680
])) == "[false, null, [\"foo\\nbar\", 3.5]]";
681681
}
682682

@@ -687,8 +687,8 @@ mod tests {
687687
assert to_str(mk_dict(~[
688688
("a", boolean(true)),
689689
("b", list(@~[
690-
mk_dict(~[("c", string(@"\x0c\r"))]),
691-
mk_dict(~[("d", string(@""))])
690+
mk_dict(~[("c", string(@"\x0c\r"/~))]),
691+
mk_dict(~[("d", string(@""/~))])
692692
]))
693693
])) ==
694694
"{ " +
@@ -703,35 +703,35 @@ mod tests {
703703
#[test]
704704
fn test_trailing_characters() {
705705
assert from_str("nulla") ==
706-
err({line: 1u, col: 5u, msg: @"trailing characters"});
706+
err({line: 1u, col: 5u, msg: @"trailing characters"/~});
707707
assert from_str("truea") ==
708-
err({line: 1u, col: 5u, msg: @"trailing characters"});
708+
err({line: 1u, col: 5u, msg: @"trailing characters"/~});
709709
assert from_str("falsea") ==
710-
err({line: 1u, col: 6u, msg: @"trailing characters"});
710+
err({line: 1u, col: 6u, msg: @"trailing characters"/~});
711711
assert from_str("1a") ==
712-
err({line: 1u, col: 2u, msg: @"trailing characters"});
712+
err({line: 1u, col: 2u, msg: @"trailing characters"/~});
713713
assert from_str("[]a") ==
714-
err({line: 1u, col: 3u, msg: @"trailing characters"});
714+
err({line: 1u, col: 3u, msg: @"trailing characters"/~});
715715
assert from_str("{}a") ==
716-
err({line: 1u, col: 3u, msg: @"trailing characters"});
716+
err({line: 1u, col: 3u, msg: @"trailing characters"/~});
717717
}
718718

719719
#[test]
720720
fn test_read_identifiers() {
721721
assert from_str("n") ==
722-
err({line: 1u, col: 2u, msg: @"invalid syntax"});
722+
err({line: 1u, col: 2u, msg: @"invalid syntax"/~});
723723
assert from_str("nul") ==
724-
err({line: 1u, col: 4u, msg: @"invalid syntax"});
724+
err({line: 1u, col: 4u, msg: @"invalid syntax"/~});
725725

726726
assert from_str("t") ==
727-
err({line: 1u, col: 2u, msg: @"invalid syntax"});
727+
err({line: 1u, col: 2u, msg: @"invalid syntax"/~});
728728
assert from_str("truz") ==
729-
err({line: 1u, col: 4u, msg: @"invalid syntax"});
729+
err({line: 1u, col: 4u, msg: @"invalid syntax"/~});
730730

731731
assert from_str("f") ==
732-
err({line: 1u, col: 2u, msg: @"invalid syntax"});
732+
err({line: 1u, col: 2u, msg: @"invalid syntax"/~});
733733
assert from_str("faz") ==
734-
err({line: 1u, col: 3u, msg: @"invalid syntax"});
734+
err({line: 1u, col: 3u, msg: @"invalid syntax"/~});
735735

736736
assert from_str("null") == ok(null);
737737
assert from_str("true") == ok(boolean(true));
@@ -744,20 +744,20 @@ mod tests {
744744
#[test]
745745
fn test_read_num() {
746746
assert from_str("+") ==
747-
err({line: 1u, col: 1u, msg: @"invalid syntax"});
747+
err({line: 1u, col: 1u, msg: @"invalid syntax"/~});
748748
assert from_str(".") ==
749-
err({line: 1u, col: 1u, msg: @"invalid syntax"});
749+
err({line: 1u, col: 1u, msg: @"invalid syntax"/~});
750750

751751
assert from_str("-") ==
752-
err({line: 1u, col: 2u, msg: @"invalid number"});
752+
err({line: 1u, col: 2u, msg: @"invalid number"/~});
753753
assert from_str("00") ==
754-
err({line: 1u, col: 2u, msg: @"invalid number"});
754+
err({line: 1u, col: 2u, msg: @"invalid number"/~});
755755
assert from_str("1.") ==
756-
err({line: 1u, col: 3u, msg: @"invalid number"});
756+
err({line: 1u, col: 3u, msg: @"invalid number"/~});
757757
assert from_str("1e") ==
758-
err({line: 1u, col: 3u, msg: @"invalid number"});
758+
err({line: 1u, col: 3u, msg: @"invalid number"/~});
759759
assert from_str("1e+") ==
760-
err({line: 1u, col: 4u, msg: @"invalid number"});
760+
err({line: 1u, col: 4u, msg: @"invalid number"/~});
761761

762762
assert from_str("3") == ok(num(3f));
763763
assert from_str("3.1") == ok(num(3.1f));
@@ -772,32 +772,32 @@ mod tests {
772772
#[test]
773773
fn test_read_str() {
774774
assert from_str("\"") ==
775-
err({line: 1u, col: 2u, msg: @"EOF while parsing string"});
775+
err({line: 1u, col: 2u, msg: @"EOF while parsing string"/~});
776776
assert from_str("\"lol") ==
777-
err({line: 1u, col: 5u, msg: @"EOF while parsing string"});
777+
err({line: 1u, col: 5u, msg: @"EOF while parsing string"/~});
778778

779-
assert from_str("\"\"") == ok(string(@""));
780-
assert from_str("\"foo\"") == ok(string(@"foo"));
781-
assert from_str("\"\\\"\"") == ok(string(@"\""));
782-
assert from_str("\"\\b\"") == ok(string(@"\x08"));
783-
assert from_str("\"\\n\"") == ok(string(@"\n"));
784-
assert from_str("\"\\r\"") == ok(string(@"\r"));
785-
assert from_str("\"\\t\"") == ok(string(@"\t"));
786-
assert from_str(" \"foo\" ") == ok(string(@"foo"));
779+
assert from_str("\"\"") == ok(string(@""/~));
780+
assert from_str("\"foo\"") == ok(string(@"foo"/~));
781+
assert from_str("\"\\\"\"") == ok(string(@"\""/~));
782+
assert from_str("\"\\b\"") == ok(string(@"\x08"/~));
783+
assert from_str("\"\\n\"") == ok(string(@"\n"/~));
784+
assert from_str("\"\\r\"") == ok(string(@"\r"/~));
785+
assert from_str("\"\\t\"") == ok(string(@"\t"/~));
786+
assert from_str(" \"foo\" ") == ok(string(@"foo"/~));
787787
}
788788

789789
#[test]
790790
fn test_read_list() {
791791
assert from_str("[") ==
792-
err({line: 1u, col: 2u, msg: @"EOF while parsing value"});
792+
err({line: 1u, col: 2u, msg: @"EOF while parsing value"/~});
793793
assert from_str("[1") ==
794-
err({line: 1u, col: 3u, msg: @"EOF while parsing list"});
794+
err({line: 1u, col: 3u, msg: @"EOF while parsing list"/~});
795795
assert from_str("[1,") ==
796-
err({line: 1u, col: 4u, msg: @"EOF while parsing value"});
796+
err({line: 1u, col: 4u, msg: @"EOF while parsing value"/~});
797797
assert from_str("[1,]") ==
798-
err({line: 1u, col: 4u, msg: @"invalid syntax"});
798+
err({line: 1u, col: 4u, msg: @"invalid syntax"/~});
799799
assert from_str("[6 7]") ==
800-
err({line: 1u, col: 4u, msg: @"expected `,` or `]`"});
800+
err({line: 1u, col: 4u, msg: @"expected `,` or `]`"/~});
801801

802802
assert from_str("[]") == ok(list(@~[]));
803803
assert from_str("[ ]") == ok(list(@~[]));
@@ -813,28 +813,28 @@ mod tests {
813813
#[test]
814814
fn test_read_dict() {
815815
assert from_str("{") ==
816-
err({line: 1u, col: 2u, msg: @"EOF while parsing object"});
816+
err({line: 1u, col: 2u, msg: @"EOF while parsing object"/~});
817817
assert from_str("{ ") ==
818-
err({line: 1u, col: 3u, msg: @"EOF while parsing object"});
818+
err({line: 1u, col: 3u, msg: @"EOF while parsing object"/~});
819819
assert from_str("{1") ==
820-
err({line: 1u, col: 2u, msg: @"key must be a string"});
820+
err({line: 1u, col: 2u, msg: @"key must be a string"/~});
821821
assert from_str("{ \"a\"") ==
822-
err({line: 1u, col: 6u, msg: @"EOF while parsing object"});
822+
err({line: 1u, col: 6u, msg: @"EOF while parsing object"/~});
823823
assert from_str("{\"a\"") ==
824-
err({line: 1u, col: 5u, msg: @"EOF while parsing object"});
824+
err({line: 1u, col: 5u, msg: @"EOF while parsing object"/~});
825825
assert from_str("{\"a\" ") ==
826-
err({line: 1u, col: 6u, msg: @"EOF while parsing object"});
826+
err({line: 1u, col: 6u, msg: @"EOF while parsing object"/~});
827827

828828
assert from_str("{\"a\" 1") ==
829-
err({line: 1u, col: 6u, msg: @"expected `:`"});
829+
err({line: 1u, col: 6u, msg: @"expected `:`"/~});
830830
assert from_str("{\"a\":") ==
831-
err({line: 1u, col: 6u, msg: @"EOF while parsing value"});
831+
err({line: 1u, col: 6u, msg: @"EOF while parsing value"/~});
832832
assert from_str("{\"a\":1") ==
833-
err({line: 1u, col: 7u, msg: @"EOF while parsing object"});
833+
err({line: 1u, col: 7u, msg: @"EOF while parsing object"/~});
834834
assert from_str("{\"a\":1 1") ==
835-
err({line: 1u, col: 8u, msg: @"expected `,` or `}`"});
835+
err({line: 1u, col: 8u, msg: @"expected `,` or `}`"/~});
836836
assert from_str("{\"a\":1,") ==
837-
err({line: 1u, col: 8u, msg: @"EOF while parsing object"});
837+
err({line: 1u, col: 8u, msg: @"EOF while parsing object"/~});
838838

839839
assert eq(result::get(from_str("{}")), mk_dict(~[]));
840840
assert eq(result::get(from_str("{\"a\": 3}")),
@@ -866,7 +866,7 @@ mod tests {
866866
("a", num(1.0f)),
867867
("b", list(@~[
868868
boolean(true),
869-
string(@"foo\nbar"),
869+
string(@"foo\nbar"/~),
870870
mk_dict(~[
871871
("c", mk_dict(~[("d", null)]))
872872
])
@@ -877,6 +877,6 @@ mod tests {
877877
#[test]
878878
fn test_multiline_errors() {
879879
assert from_str("{\n \"foo\":\n \"bar\"") ==
880-
err({line: 3u, col: 8u, msg: @"EOF while parsing object"});
880+
err({line: 3u, col: 8u, msg: @"EOF while parsing object"/~});
881881
}
882882
}

src/libstd/rope.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1270,7 +1270,7 @@ mod tests {
12701270

12711271
#[test]
12721272
fn of_string1() {
1273-
let sample = @"0123456789ABCDE";
1273+
let sample = @"0123456789ABCDE"/~;
12741274
let r = of_str(sample);
12751275

12761276
assert char_len(r) == str::char_len(*sample);
@@ -1330,8 +1330,8 @@ mod tests {
13301330

13311331
#[test]
13321332
fn bal1() {
1333-
let init = @ "1234567890";
1334-
let buf = @ mut * init;
1333+
let init = @"1234567890"/~;
1334+
let buf = @mut * init;
13351335
let mut i = 0;
13361336
while i < 8 { *buf = *buf + *buf; i+=1;}
13371337
let sample = @*buf;
@@ -1352,7 +1352,7 @@ mod tests {
13521352
#[ignore]
13531353
fn char_at1() {
13541354
//Generate a large rope
1355-
let mut r = of_str(@ "123456789");
1355+
let mut r = of_str(@"123456789"/~);
13561356
for uint::range(0u, 10u) |_i| {
13571357
r = append_rope(r, r);
13581358
}
@@ -1384,7 +1384,7 @@ mod tests {
13841384
#[test]
13851385
fn concat1() {
13861386
//Generate a reasonable rope
1387-
let chunk = of_str(@ "123456789");
1387+
let chunk = of_str(@"123456789"/~);
13881388
let mut r = empty();
13891389
for uint::range(0u, 10u) |_i| {
13901390
r = append_rope(r, chunk);

src/libsyntax/ast_util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ fn dtor_dec() -> fn_decl {
381381
let nil_t = @{id: 0, node: ty_nil, span: dummy_sp()};
382382
// dtor has one argument, of type ()
383383
{inputs: ~[{mode: ast::expl(ast::by_ref),
384-
ty: nil_t, ident: @"_", id: 0}],
384+
ty: nil_t, ident: @"_"/~, id: 0}],
385385
output: nil_t, purity: impure_fn, cf: return_val, constraints: ~[]}
386386
}
387387

0 commit comments

Comments
 (0)