Skip to content

Commit 9f836d5

Browse files
committed
auto merge of #13877 : thestinger/rust/de-tilde-str-vec, r=alexcrichton
2 parents fb72d7c + e93cb04 commit 9f836d5

File tree

31 files changed

+186
-197
lines changed

31 files changed

+186
-197
lines changed

src/compiletest/header.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ fn parse_compile_flags(line: &str) -> Option<~str> {
170170
}
171171

172172
fn parse_run_flags(line: &str) -> Option<~str> {
173-
parse_name_value_directive(line, ~"run-flags")
173+
parse_name_value_directive(line, "run-flags".to_owned())
174174
}
175175

176176
fn parse_debugger_cmd(line: &str) -> Option<~str> {

src/libcollections/hashmap.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -698,13 +698,13 @@ static INITIAL_LOAD_FACTOR: Fraction = (9, 10);
698698
/// book_reviews.insert("The Adventures of Sherlock Holmes", "Eye lyked it alot.");
699699
///
700700
/// // check for a specific one.
701-
/// if !book_reviews.contains_key(& &"Les Misérables") {
701+
/// if !book_reviews.contains_key(&("Les Misérables")) {
702702
/// println!("We've got {} reviews, but Les Misérables ain't one.",
703703
/// book_reviews.len());
704704
/// }
705705
///
706706
/// // oops, this review has a lot of spelling mistakes, let's delete it.
707-
/// book_reviews.remove(& &"The Adventures of Sherlock Holmes");
707+
/// book_reviews.remove(&("The Adventures of Sherlock Holmes"));
708708
///
709709
/// // look up the values associated with some keys.
710710
/// let to_find = ["Pride and Prejudice", "Alice's Adventure in Wonderland"];

src/libcollections/treemap.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1651,10 +1651,10 @@ mod test_set {
16511651

16521652
// FIXME: #5801: this needs a type hint to compile...
16531653
let result: Option<(&uint, & &'static str)> = z.next();
1654-
assert_eq!(result.unwrap(), (&5u, & &"bar"));
1654+
assert_eq!(result.unwrap(), (&5u, &("bar")));
16551655

16561656
let result: Option<(&uint, & &'static str)> = z.next();
1657-
assert_eq!(result.unwrap(), (&11u, & &"foo"));
1657+
assert_eq!(result.unwrap(), (&11u, &("foo")));
16581658

16591659
let result: Option<(&uint, & &'static str)> = z.next();
16601660
assert!(result.is_none());

src/libgetopts/lib.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -1441,7 +1441,7 @@ mod tests {
14411441
optmulti("l", "", "Desc", "VAL"));
14421442

14431443
let expected =
1444-
~"Usage: fruits
1444+
"Usage: fruits
14451445
14461446
Options:
14471447
-b --banana VAL Desc
@@ -1450,7 +1450,7 @@ Options:
14501450
-k --kiwi Desc
14511451
-p [VAL] Desc
14521452
-l VAL Desc
1453-
";
1453+
".to_owned();
14541454

14551455
let generated_usage = usage("Usage: fruits", optgroups.as_slice());
14561456

@@ -1471,13 +1471,13 @@ Options:
14711471
"This is a long description which _will_ be wrapped..+.."));
14721472

14731473
let expected =
1474-
~"Usage: fruits
1474+
"Usage: fruits
14751475
14761476
Options:
14771477
-k --kiwi This is a long description which won't be wrapped..+..
14781478
-a --apple This is a long description which _will_ be
14791479
wrapped..+..
1480-
";
1480+
".to_owned();
14811481

14821482
let usage = usage("Usage: fruits", optgroups.as_slice());
14831483

@@ -1496,14 +1496,14 @@ Options:
14961496
confuse the line wrapping; an apple costs 0.51€ in some parts of Europe."));
14971497

14981498
let expected =
1499-
~"Usage: fruits
1499+
"Usage: fruits
15001500
15011501
Options:
15021502
-k --k–w– The word kiwi is normally spelled with two i's
15031503
-a --apple This “description” has some characters that could
15041504
confuse the line wrapping; an apple costs 0.51€ in
15051505
some parts of Europe.
1506-
";
1506+
".to_owned();
15071507

15081508
let usage = usage("Usage: fruits", optgroups.as_slice());
15091509

src/libregex/parse.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,9 @@ impl<'a> Parser<'a> {
220220
try!(self.parse_group_opts())
221221
} else {
222222
self.caps += 1;
223-
self.stack.push(Paren(self.flags, self.caps, ~""))
223+
self.stack.push(Paren(self.flags,
224+
self.caps,
225+
"".to_owned()))
224226
}
225227
}
226228
')' => {
@@ -769,7 +771,7 @@ impl<'a> Parser<'a> {
769771
}
770772
if self.cur() == ':' {
771773
// Save the old flags with the opening paren.
772-
self.stack.push(Paren(self.flags, 0, ~""));
774+
self.stack.push(Paren(self.flags, 0, "".to_owned()));
773775
}
774776
self.flags = flags;
775777
return Ok(())

src/libregex_macros/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ impl<'a> NfaGen<'a> {
116116
|cx, name| match name {
117117
&Some(ref name) => {
118118
let name = name.as_slice();
119-
quote_expr!(cx, Some(~$name))
119+
quote_expr!(cx, Some($name.to_owned()))
120120
}
121121
&None => quote_expr!(cx, None),
122122
}
@@ -306,7 +306,7 @@ fn exec<'t>(which: ::regex::native::MatchKind, input: &'t str,
306306
}
307307

308308
::regex::Regex {
309-
original: ~$regex,
309+
original: $regex.to_owned(),
310310
names: vec!$cap_names,
311311
p: ::regex::native::Native(exec),
312312
}

src/librustc/driver/driver.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -1059,16 +1059,16 @@ pub fn build_session_(sopts: session::Options,
10591059

10601060
pub fn parse_pretty(sess: &Session, name: &str) -> PpMode {
10611061
match name {
1062-
&"normal" => PpmNormal,
1063-
&"expanded" => PpmExpanded,
1064-
&"typed" => PpmTyped,
1065-
&"expanded,identified" => PpmExpandedIdentified,
1066-
&"identified" => PpmIdentified,
1067-
_ => {
1068-
sess.fatal("argument to `pretty` must be one of `normal`, \
1069-
`expanded`, `typed`, `identified`, \
1070-
or `expanded,identified`");
1071-
}
1062+
"normal" => PpmNormal,
1063+
"expanded" => PpmExpanded,
1064+
"typed" => PpmTyped,
1065+
"expanded,identified" => PpmExpandedIdentified,
1066+
"identified" => PpmIdentified,
1067+
_ => {
1068+
sess.fatal("argument to `pretty` must be one of `normal`, \
1069+
`expanded`, `typed`, `identified`, \
1070+
or `expanded,identified`");
1071+
}
10721072
}
10731073
}
10741074

src/librustc/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ pub fn run_compiler(args: &[~str]) {
300300
None::<d::PpMode> => {/* continue */ }
301301
}
302302

303-
if r.contains(&~"ls") {
303+
if r.contains(&("ls".to_owned())) {
304304
match input {
305305
d::FileInput(ref ifile) => {
306306
let mut stdout = io::stdout();

src/librustc/middle/lint.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1036,7 +1036,7 @@ fn check_crate_attrs_usage(cx: &Context, attrs: &[ast::Attribute]) {
10361036
if !iter.any(|other_attr| { name.equiv(other_attr) }) {
10371037
cx.span_lint(AttributeUsage, attr.span, "unknown crate attribute");
10381038
}
1039-
if name.equiv(& &"link") {
1039+
if name.equiv(&("link")) {
10401040
cx.tcx.sess.span_err(attr.span,
10411041
"obsolete crate `link` attribute");
10421042
cx.tcx.sess.note("the link attribute has been superceded by the crate_id \

src/librustc/middle/trans/reflect.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,9 @@ impl<'a, 'b> Reflector<'a, 'b> {
189189
ty::ty_rptr(_, ref mt) => {
190190
match ty::get(mt.ty).sty {
191191
ty::ty_vec(ref mt, None) => {
192-
let (name, extra) = (~"slice", Vec::new());
192+
let (name, extra) = ("slice".to_owned(), Vec::new());
193193
let extra = extra.append(self.c_mt(mt).as_slice());
194-
self.visit(~"evec_" + name, extra.as_slice())
194+
self.visit("evec_".to_owned() + name, extra.as_slice())
195195
}
196196
ty::ty_str => self.visit("estr_slice".to_owned(), &[]),
197197
_ => {

src/librustc/middle/typeck/check/_match.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -647,8 +647,8 @@ pub fn check_pat(pcx: &pat_ctxt, pat: &ast::Pat, expected: ty::t) {
647647
ty::ty_vec(mt, None) => {
648648
fcx.type_error_message(pat.span,
649649
|_| {
650-
~"unique vector patterns are no \
651-
longer supported"
650+
"unique vector patterns are no \
651+
longer supported".to_owned()
652652
},
653653
expected,
654654
None);

src/librustc/middle/typeck/check/mod.rs

+65-61
Original file line numberDiff line numberDiff line change
@@ -2564,70 +2564,74 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
25642564
let tcx = fcx.ccx.tcx;
25652565
let id = expr.id;
25662566
match expr.node {
2567-
ast::ExprVstore(ev, vst) => {
2568-
let typ = match ev.node {
2569-
ast::ExprLit(lit) if ast_util::lit_is_str(lit) => {
2570-
ast_expr_vstore_to_ty(fcx, ev, vst, || ty::mt{ ty: ty::mk_str(tcx),
2571-
mutbl: ast::MutImmutable })
2572-
}
2573-
ast::ExprVec(ref args) => {
2574-
let mutability = match vst {
2575-
ast::ExprVstoreMutSlice => ast::MutMutable,
2576-
_ => ast::MutImmutable,
2577-
};
2578-
let mut any_error = false;
2579-
let mut any_bot = false;
2580-
let t: ty::t = fcx.infcx().next_ty_var();
2581-
for e in args.iter() {
2582-
check_expr_has_type(fcx, *e, t);
2583-
let arg_t = fcx.expr_ty(*e);
2584-
if ty::type_is_error(arg_t) {
2585-
any_error = true;
2567+
ast::ExprVstore(ev, vst) => {
2568+
let typ = match ev.node {
2569+
ast::ExprVec(ref args) => {
2570+
let mutability = match vst {
2571+
ast::ExprVstoreMutSlice => ast::MutMutable,
2572+
_ => ast::MutImmutable,
2573+
};
2574+
let mut any_error = false;
2575+
let mut any_bot = false;
2576+
let t: ty::t = fcx.infcx().next_ty_var();
2577+
for e in args.iter() {
2578+
check_expr_has_type(fcx, *e, t);
2579+
let arg_t = fcx.expr_ty(*e);
2580+
if ty::type_is_error(arg_t) {
2581+
any_error = true;
2582+
}
2583+
else if ty::type_is_bot(arg_t) {
2584+
any_bot = true;
2585+
}
2586+
}
2587+
if any_error {
2588+
ty::mk_err()
2589+
} else if any_bot {
2590+
ty::mk_bot()
2591+
} else {
2592+
ast_expr_vstore_to_ty(fcx, ev, vst, ||
2593+
ty::mt{ ty: ty::mk_vec(tcx,
2594+
ty::mt {ty: t, mutbl: mutability},
2595+
None),
2596+
mutbl: mutability })
2597+
}
25862598
}
2587-
else if ty::type_is_bot(arg_t) {
2588-
any_bot = true;
2599+
ast::ExprRepeat(element, count_expr) => {
2600+
check_expr_with_hint(fcx, count_expr, ty::mk_uint());
2601+
let _ = ty::eval_repeat_count(fcx, count_expr);
2602+
let mutability = match vst {
2603+
ast::ExprVstoreMutSlice => ast::MutMutable,
2604+
_ => ast::MutImmutable,
2605+
};
2606+
let t = fcx.infcx().next_ty_var();
2607+
check_expr_has_type(fcx, element, t);
2608+
let arg_t = fcx.expr_ty(element);
2609+
if ty::type_is_error(arg_t) {
2610+
ty::mk_err()
2611+
} else if ty::type_is_bot(arg_t) {
2612+
ty::mk_bot()
2613+
} else {
2614+
ast_expr_vstore_to_ty(fcx, ev, vst, ||
2615+
ty::mt{ ty: ty::mk_vec(tcx,
2616+
ty::mt {ty: t, mutbl: mutability},
2617+
None),
2618+
mutbl: mutability})
2619+
}
25892620
}
2590-
}
2591-
if any_error {
2592-
ty::mk_err()
2593-
} else if any_bot {
2594-
ty::mk_bot()
2595-
} else {
2596-
ast_expr_vstore_to_ty(fcx, ev, vst, ||
2597-
ty::mt{ ty: ty::mk_vec(tcx,
2598-
ty::mt {ty: t, mutbl: mutability},
2599-
None),
2600-
mutbl: mutability })
2601-
}
2602-
}
2603-
ast::ExprRepeat(element, count_expr) => {
2604-
check_expr_with_hint(fcx, count_expr, ty::mk_uint());
2605-
let _ = ty::eval_repeat_count(fcx, count_expr);
2606-
let mutability = match vst {
2607-
ast::ExprVstoreMutSlice => ast::MutMutable,
2608-
_ => ast::MutImmutable,
2621+
ast::ExprLit(_) => {
2622+
let error = if vst == ast::ExprVstoreSlice {
2623+
"`&\"string\"` has been removed; use `\"string\"` instead"
2624+
} else {
2625+
"`~\"string\"` has been removed; use `\"string\".to_owned()` instead"
2626+
};
2627+
tcx.sess.span_err(expr.span, error);
2628+
ty::mk_err()
2629+
}
2630+
_ => tcx.sess.span_bug(expr.span, "vstore modifier on non-sequence"),
26092631
};
2610-
let t = fcx.infcx().next_ty_var();
2611-
check_expr_has_type(fcx, element, t);
2612-
let arg_t = fcx.expr_ty(element);
2613-
if ty::type_is_error(arg_t) {
2614-
ty::mk_err()
2615-
} else if ty::type_is_bot(arg_t) {
2616-
ty::mk_bot()
2617-
} else {
2618-
ast_expr_vstore_to_ty(fcx, ev, vst, ||
2619-
ty::mt{ ty: ty::mk_vec(tcx,
2620-
ty::mt {ty: t, mutbl: mutability},
2621-
None),
2622-
mutbl: mutability})
2623-
}
2624-
}
2625-
_ =>
2626-
tcx.sess.span_bug(expr.span, "vstore modifier on non-sequence")
2627-
};
2628-
fcx.write_ty(ev.id, typ);
2629-
fcx.write_ty(id, typ);
2630-
}
2632+
fcx.write_ty(ev.id, typ);
2633+
fcx.write_ty(id, typ);
2634+
}
26312635

26322636
ast::ExprBox(place, subexpr) => {
26332637
check_expr(fcx, place);

0 commit comments

Comments
 (0)