Skip to content

Commit 4baff4e

Browse files
committed
librustc: Remove ~"string" and &"string" from the language
1 parent a3f9f37 commit 4baff4e

File tree

11 files changed

+58
-72
lines changed

11 files changed

+58
-72
lines changed

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: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2566,10 +2566,6 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
25662566
match expr.node {
25672567
ast::ExprVstore(ev, vst) => {
25682568
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-
}
25732569
ast::ExprVec(ref args) => {
25742570
let mutability = match vst {
25752571
ast::ExprVstoreMutSlice => ast::MutMutable,
@@ -2622,8 +2618,13 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
26222618
mutbl: mutability})
26232619
}
26242620
}
2625-
_ =>
2626-
tcx.sess.span_bug(expr.span, "vstore modifier on non-sequence")
2621+
ast::ExprLit(_) => {
2622+
tcx.sess.span_err(expr.span,
2623+
"`~\"string\"` has been removed; use `\"string\".to_owned()` \
2624+
instead");
2625+
ty::mk_err()
2626+
}
2627+
_ => tcx.sess.span_bug(expr.span, "vstore modifier on non-sequence"),
26272628
};
26282629
fcx.write_ty(ev.id, typ);
26292630
fcx.write_ty(id, typ);

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/libsyntax/ext/base.rs

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -270,22 +270,22 @@ pub fn syntax_expander_table() -> SyntaxEnv {
270270
}
271271

272272
let mut syntax_expanders = SyntaxEnv::new();
273-
syntax_expanders.insert(intern(&"macro_rules"),
273+
syntax_expanders.insert(intern("macro_rules"),
274274
IdentTT(~BasicIdentMacroExpander {
275275
expander: ext::tt::macro_rules::add_new_extension,
276276
span: None,
277277
},
278278
None));
279-
syntax_expanders.insert(intern(&"fmt"),
279+
syntax_expanders.insert(intern("fmt"),
280280
builtin_normal_expander(
281281
ext::fmt::expand_syntax_ext));
282-
syntax_expanders.insert(intern(&"format_args"),
282+
syntax_expanders.insert(intern("format_args"),
283283
builtin_normal_expander(
284284
ext::format::expand_args));
285-
syntax_expanders.insert(intern(&"env"),
285+
syntax_expanders.insert(intern("env"),
286286
builtin_normal_expander(
287287
ext::env::expand_env));
288-
syntax_expanders.insert(intern(&"option_env"),
288+
syntax_expanders.insert(intern("option_env"),
289289
builtin_normal_expander(
290290
ext::env::expand_option_env));
291291
syntax_expanders.insert(intern("bytes"),
@@ -297,63 +297,63 @@ pub fn syntax_expander_table() -> SyntaxEnv {
297297
syntax_expanders.insert(intern("concat"),
298298
builtin_normal_expander(
299299
ext::concat::expand_syntax_ext));
300-
syntax_expanders.insert(intern(&"log_syntax"),
300+
syntax_expanders.insert(intern("log_syntax"),
301301
builtin_normal_expander(
302302
ext::log_syntax::expand_syntax_ext));
303-
syntax_expanders.insert(intern(&"deriving"),
303+
syntax_expanders.insert(intern("deriving"),
304304
ItemDecorator(ext::deriving::expand_meta_deriving));
305305

306306
// Quasi-quoting expanders
307-
syntax_expanders.insert(intern(&"quote_tokens"),
307+
syntax_expanders.insert(intern("quote_tokens"),
308308
builtin_normal_expander(
309309
ext::quote::expand_quote_tokens));
310-
syntax_expanders.insert(intern(&"quote_expr"),
310+
syntax_expanders.insert(intern("quote_expr"),
311311
builtin_normal_expander(
312312
ext::quote::expand_quote_expr));
313-
syntax_expanders.insert(intern(&"quote_ty"),
313+
syntax_expanders.insert(intern("quote_ty"),
314314
builtin_normal_expander(
315315
ext::quote::expand_quote_ty));
316-
syntax_expanders.insert(intern(&"quote_item"),
316+
syntax_expanders.insert(intern("quote_item"),
317317
builtin_normal_expander(
318318
ext::quote::expand_quote_item));
319-
syntax_expanders.insert(intern(&"quote_pat"),
319+
syntax_expanders.insert(intern("quote_pat"),
320320
builtin_normal_expander(
321321
ext::quote::expand_quote_pat));
322-
syntax_expanders.insert(intern(&"quote_stmt"),
322+
syntax_expanders.insert(intern("quote_stmt"),
323323
builtin_normal_expander(
324324
ext::quote::expand_quote_stmt));
325325

326-
syntax_expanders.insert(intern(&"line"),
326+
syntax_expanders.insert(intern("line"),
327327
builtin_normal_expander(
328328
ext::source_util::expand_line));
329-
syntax_expanders.insert(intern(&"col"),
329+
syntax_expanders.insert(intern("col"),
330330
builtin_normal_expander(
331331
ext::source_util::expand_col));
332-
syntax_expanders.insert(intern(&"file"),
332+
syntax_expanders.insert(intern("file"),
333333
builtin_normal_expander(
334334
ext::source_util::expand_file));
335-
syntax_expanders.insert(intern(&"stringify"),
335+
syntax_expanders.insert(intern("stringify"),
336336
builtin_normal_expander(
337337
ext::source_util::expand_stringify));
338-
syntax_expanders.insert(intern(&"include"),
338+
syntax_expanders.insert(intern("include"),
339339
builtin_normal_expander(
340340
ext::source_util::expand_include));
341-
syntax_expanders.insert(intern(&"include_str"),
341+
syntax_expanders.insert(intern("include_str"),
342342
builtin_normal_expander(
343343
ext::source_util::expand_include_str));
344-
syntax_expanders.insert(intern(&"include_bin"),
344+
syntax_expanders.insert(intern("include_bin"),
345345
builtin_normal_expander(
346346
ext::source_util::expand_include_bin));
347-
syntax_expanders.insert(intern(&"module_path"),
347+
syntax_expanders.insert(intern("module_path"),
348348
builtin_normal_expander(
349349
ext::source_util::expand_mod));
350-
syntax_expanders.insert(intern(&"asm"),
350+
syntax_expanders.insert(intern("asm"),
351351
builtin_normal_expander(
352352
ext::asm::expand_asm));
353-
syntax_expanders.insert(intern(&"cfg"),
353+
syntax_expanders.insert(intern("cfg"),
354354
builtin_normal_expander(
355355
ext::cfg::expand_cfg));
356-
syntax_expanders.insert(intern(&"trace_macros"),
356+
syntax_expanders.insert(intern("trace_macros"),
357357
builtin_normal_expander(
358358
ext::trace_macros::expand_trace_macros));
359359
syntax_expanders

src/libsyntax/parse/parser.rs

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2779,28 +2779,11 @@ impl<'a> Parser<'a> {
27792779
}
27802780
}
27812781
token::BINOP(token::AND) | token::ANDAND => {
2782-
// parse &pat
2783-
let lo = self.span.lo;
2784-
self.expect_and();
2785-
let sub = self.parse_pat();
2786-
hi = sub.span.hi;
2787-
// HACK: parse &"..." as a literal of a borrowed str
2788-
pat = match sub.node {
2789-
PatLit(e) => {
2790-
match e.node {
2791-
ExprLit(lit) if lit_is_str(lit) => {
2792-
let vst = @Expr {
2793-
id: ast::DUMMY_NODE_ID,
2794-
node: ExprVstore(e, ExprVstoreSlice),
2795-
span: mk_sp(lo, hi)
2796-
};
2797-
PatLit(vst)
2798-
}
2799-
_ => PatRegion(sub),
2800-
}
2801-
}
2802-
_ => PatRegion(sub),
2803-
};
2782+
// parse &pat
2783+
let lo = self.span.lo;
2784+
self.expect_and();
2785+
let sub = self.parse_pat();
2786+
pat = PatRegion(sub);
28042787
hi = self.last_span.hi;
28052788
return @ast::Pat {
28062789
id: ast::DUMMY_NODE_ID,

src/libtest/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ impl<T: Writer> ConsoleTestState<T> {
534534

535535
pub fn write_run_start(&mut self, len: uint) -> io::IoResult<()> {
536536
self.total = len;
537-
let noun = if len != 1 { &"tests" } else { &"test" };
537+
let noun = if len != 1 { "tests" } else { "test" };
538538
self.write_plain(format!("\nrunning {} {}\n", len, noun))
539539
}
540540

0 commit comments

Comments
 (0)