Skip to content

Commit 8f4b839

Browse files
committed
auto merge of #13877 : thestinger/rust/de-tilde-str-vec, r=alexcrichton
2 parents 9f484e6 + 58e79d1 commit 8f4b839

24 files changed

+145
-156
lines changed

src/compiletest/header.rs

Lines changed: 1 addition & 1 deletion
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/libregex/parse.rs

Lines changed: 4 additions & 2 deletions
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/librustc/driver/driver.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,16 +1070,16 @@ pub fn build_session_(sopts: session::Options,
10701070

10711071
pub fn parse_pretty(sess: &Session, name: &str) -> PpMode {
10721072
match name {
1073-
&"normal" => PpmNormal,
1074-
&"expanded" => PpmExpanded,
1075-
&"typed" => PpmTyped,
1076-
&"expanded,identified" => PpmExpandedIdentified,
1077-
&"identified" => PpmIdentified,
1078-
_ => {
1079-
sess.fatal("argument to `pretty` must be one of `normal`, \
1080-
`expanded`, `typed`, `identified`, \
1081-
or `expanded,identified`");
1082-
}
1073+
"normal" => PpmNormal,
1074+
"expanded" => PpmExpanded,
1075+
"typed" => PpmTyped,
1076+
"expanded,identified" => PpmExpandedIdentified,
1077+
"identified" => PpmIdentified,
1078+
_ => {
1079+
sess.fatal("argument to `pretty` must be one of `normal`, \
1080+
`expanded`, `typed`, `identified`, \
1081+
or `expanded,identified`");
1082+
}
10831083
}
10841084
}
10851085

src/librustc/lib.rs

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 65 additions & 61 deletions
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);

src/libserialize/json.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1740,7 +1740,7 @@ impl<T: Iterator<char>> Builder<T> {
17401740
Some(NumberValue(n)) => { Ok(Number(n)) }
17411741
Some(BooleanValue(b)) => { Ok(Boolean(b)) }
17421742
Some(StringValue(ref mut s)) => {
1743-
let mut temp = ~"";
1743+
let mut temp = "".to_owned();
17441744
swap(s, &mut temp);
17451745
Ok(String(temp))
17461746
}

src/libstd/hash/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ mod tests {
343343

344344
assert_eq!(hasher.hash(&'a'), 97);
345345

346-
assert_eq!(hasher.hash(& &"a"), 97 + 0xFF);
346+
assert_eq!(hasher.hash(&("a")), 97 + 0xFF);
347347
assert_eq!(hasher.hash(& &[1u8, 2u8, 3u8]), 9);
348348

349349
unsafe {

src/libstd/path/posix.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ mod tests {
555555
($path:expr, $disp:ident, $exp:expr) => (
556556
{
557557
let path = Path::new($path);
558-
assert!(path.$disp().to_str() == ~$exp);
558+
assert!(path.$disp().to_str().as_slice() == $exp);
559559
}
560560
)
561561
)

src/libstd/repr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ fn test_repr() {
637637
exact_test(&true, "true");
638638
exact_test(&false, "false");
639639
exact_test(&1.234, "1.234f64");
640-
exact_test(&(&"hello"), "\"hello\"");
640+
exact_test(&("hello"), "\"hello\"");
641641
// FIXME What do I do about this one?
642642
exact_test(&("he\u10f3llo".to_owned()), "~\"he\\u10f3llo\"");
643643

src/libstd/str.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3604,11 +3604,11 @@ mod tests {
36043604

36053605
#[test]
36063606
fn test_total_ord() {
3607-
"1234".cmp(& &"123") == Greater;
3608-
"123".cmp(& &"1234") == Less;
3609-
"1234".cmp(& &"1234") == Equal;
3610-
"12345555".cmp(& &"123456") == Less;
3611-
"22".cmp(& &"1234") == Greater;
3607+
"1234".cmp(&("123")) == Greater;
3608+
"123".cmp(&("1234")) == Less;
3609+
"1234".cmp(&("1234")) == Equal;
3610+
"12345555".cmp(&("123456")) == Less;
3611+
"22".cmp(&("1234")) == Greater;
36123612
}
36133613

36143614
#[test]
@@ -4005,7 +4005,7 @@ mod tests {
40054005

40064006
#[test]
40074007
fn test_from_str() {
4008-
let owned: Option<~str> = from_str(&"string");
4008+
let owned: Option<~str> = from_str("string");
40094009
assert_eq!(owned, Some("string".to_owned()));
40104010
}
40114011

0 commit comments

Comments
 (0)