Skip to content

librustc: Remove ~"string" and &"string" from the language #13870

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/libregex/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,9 @@ impl<'a> Parser<'a> {
try!(self.parse_group_opts())
} else {
self.caps += 1;
self.stack.push(Paren(self.flags, self.caps, ~""))
self.stack.push(Paren(self.flags,
self.caps,
"".to_owned()))
}
}
')' => {
Expand Down Expand Up @@ -769,7 +771,7 @@ impl<'a> Parser<'a> {
}
if self.cur() == ':' {
// Save the old flags with the opening paren.
self.stack.push(Paren(self.flags, 0, ~""));
self.stack.push(Paren(self.flags, 0, "".to_owned()));
}
self.flags = flags;
return Ok(())
Expand Down
20 changes: 10 additions & 10 deletions src/librustc/driver/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1070,16 +1070,16 @@ pub fn build_session_(sopts: session::Options,

pub fn parse_pretty(sess: &Session, name: &str) -> PpMode {
match name {
&"normal" => PpmNormal,
&"expanded" => PpmExpanded,
&"typed" => PpmTyped,
&"expanded,identified" => PpmExpandedIdentified,
&"identified" => PpmIdentified,
_ => {
sess.fatal("argument to `pretty` must be one of `normal`, \
`expanded`, `typed`, `identified`, \
or `expanded,identified`");
}
"normal" => PpmNormal,
"expanded" => PpmExpanded,
"typed" => PpmTyped,
"expanded,identified" => PpmExpandedIdentified,
"identified" => PpmIdentified,
_ => {
sess.fatal("argument to `pretty` must be one of `normal`, \
`expanded`, `typed`, `identified`, \
or `expanded,identified`");
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ pub fn run_compiler(args: &[~str]) {
None::<d::PpMode> => {/* continue */ }
}

if r.contains(&~"ls") {
if r.contains(&("ls".to_owned())) {
match input {
d::FileInput(ref ifile) => {
let mut stdout = io::stdout();
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1036,7 +1036,7 @@ fn check_crate_attrs_usage(cx: &Context, attrs: &[ast::Attribute]) {
if !iter.any(|other_attr| { name.equiv(other_attr) }) {
cx.span_lint(AttributeUsage, attr.span, "unknown crate attribute");
}
if name.equiv(& &"link") {
if name.equiv(&("link")) {
cx.tcx.sess.span_err(attr.span,
"obsolete crate `link` attribute");
cx.tcx.sess.note("the link attribute has been superceded by the crate_id \
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/trans/reflect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,9 @@ impl<'a, 'b> Reflector<'a, 'b> {
ty::ty_rptr(_, ref mt) => {
match ty::get(mt.ty).sty {
ty::ty_vec(ref mt, None) => {
let (name, extra) = (~"slice", Vec::new());
let (name, extra) = ("slice".to_owned(), Vec::new());
let extra = extra.append(self.c_mt(mt).as_slice());
self.visit(~"evec_" + name, extra.as_slice())
self.visit("evec_".to_owned() + name, extra.as_slice())
}
ty::ty_str => self.visit("estr_slice".to_owned(), &[]),
_ => {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/typeck/check/_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -647,8 +647,8 @@ pub fn check_pat(pcx: &pat_ctxt, pat: &ast::Pat, expected: ty::t) {
ty::ty_vec(mt, None) => {
fcx.type_error_message(pat.span,
|_| {
~"unique vector patterns are no \
longer supported"
"unique vector patterns are no \
longer supported".to_owned()
},
expected,
None);
Expand Down
13 changes: 7 additions & 6 deletions src/librustc/middle/typeck/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2566,10 +2566,6 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
match expr.node {
ast::ExprVstore(ev, vst) => {
let typ = match ev.node {
ast::ExprLit(lit) if ast_util::lit_is_str(lit) => {
ast_expr_vstore_to_ty(fcx, ev, vst, || ty::mt{ ty: ty::mk_str(tcx),
mutbl: ast::MutImmutable })
}
ast::ExprVec(ref args) => {
let mutability = match vst {
ast::ExprVstoreMutSlice => ast::MutMutable,
Expand Down Expand Up @@ -2622,8 +2618,13 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
mutbl: mutability})
}
}
_ =>
tcx.sess.span_bug(expr.span, "vstore modifier on non-sequence")
ast::ExprLit(_) => {
tcx.sess.span_err(expr.span,
"`~\"string\"` has been removed; use `\"string\".to_owned()` \
instead");
ty::mk_err()
}
_ => tcx.sess.span_bug(expr.span, "vstore modifier on non-sequence"),
};
fcx.write_ty(ev.id, typ);
fcx.write_ty(id, typ);
Expand Down
2 changes: 1 addition & 1 deletion src/libserialize/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1740,7 +1740,7 @@ impl<T: Iterator<char>> Builder<T> {
Some(NumberValue(n)) => { Ok(Number(n)) }
Some(BooleanValue(b)) => { Ok(Boolean(b)) }
Some(StringValue(ref mut s)) => {
let mut temp = ~"";
let mut temp = "".to_owned();
swap(s, &mut temp);
Ok(String(temp))
}
Expand Down
48 changes: 24 additions & 24 deletions src/libsyntax/ext/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,22 +270,22 @@ pub fn syntax_expander_table() -> SyntaxEnv {
}

let mut syntax_expanders = SyntaxEnv::new();
syntax_expanders.insert(intern(&"macro_rules"),
syntax_expanders.insert(intern("macro_rules"),
IdentTT(~BasicIdentMacroExpander {
expander: ext::tt::macro_rules::add_new_extension,
span: None,
},
None));
syntax_expanders.insert(intern(&"fmt"),
syntax_expanders.insert(intern("fmt"),
builtin_normal_expander(
ext::fmt::expand_syntax_ext));
syntax_expanders.insert(intern(&"format_args"),
syntax_expanders.insert(intern("format_args"),
builtin_normal_expander(
ext::format::expand_args));
syntax_expanders.insert(intern(&"env"),
syntax_expanders.insert(intern("env"),
builtin_normal_expander(
ext::env::expand_env));
syntax_expanders.insert(intern(&"option_env"),
syntax_expanders.insert(intern("option_env"),
builtin_normal_expander(
ext::env::expand_option_env));
syntax_expanders.insert(intern("bytes"),
Expand All @@ -297,63 +297,63 @@ pub fn syntax_expander_table() -> SyntaxEnv {
syntax_expanders.insert(intern("concat"),
builtin_normal_expander(
ext::concat::expand_syntax_ext));
syntax_expanders.insert(intern(&"log_syntax"),
syntax_expanders.insert(intern("log_syntax"),
builtin_normal_expander(
ext::log_syntax::expand_syntax_ext));
syntax_expanders.insert(intern(&"deriving"),
syntax_expanders.insert(intern("deriving"),
ItemDecorator(ext::deriving::expand_meta_deriving));

// Quasi-quoting expanders
syntax_expanders.insert(intern(&"quote_tokens"),
syntax_expanders.insert(intern("quote_tokens"),
builtin_normal_expander(
ext::quote::expand_quote_tokens));
syntax_expanders.insert(intern(&"quote_expr"),
syntax_expanders.insert(intern("quote_expr"),
builtin_normal_expander(
ext::quote::expand_quote_expr));
syntax_expanders.insert(intern(&"quote_ty"),
syntax_expanders.insert(intern("quote_ty"),
builtin_normal_expander(
ext::quote::expand_quote_ty));
syntax_expanders.insert(intern(&"quote_item"),
syntax_expanders.insert(intern("quote_item"),
builtin_normal_expander(
ext::quote::expand_quote_item));
syntax_expanders.insert(intern(&"quote_pat"),
syntax_expanders.insert(intern("quote_pat"),
builtin_normal_expander(
ext::quote::expand_quote_pat));
syntax_expanders.insert(intern(&"quote_stmt"),
syntax_expanders.insert(intern("quote_stmt"),
builtin_normal_expander(
ext::quote::expand_quote_stmt));

syntax_expanders.insert(intern(&"line"),
syntax_expanders.insert(intern("line"),
builtin_normal_expander(
ext::source_util::expand_line));
syntax_expanders.insert(intern(&"col"),
syntax_expanders.insert(intern("col"),
builtin_normal_expander(
ext::source_util::expand_col));
syntax_expanders.insert(intern(&"file"),
syntax_expanders.insert(intern("file"),
builtin_normal_expander(
ext::source_util::expand_file));
syntax_expanders.insert(intern(&"stringify"),
syntax_expanders.insert(intern("stringify"),
builtin_normal_expander(
ext::source_util::expand_stringify));
syntax_expanders.insert(intern(&"include"),
syntax_expanders.insert(intern("include"),
builtin_normal_expander(
ext::source_util::expand_include));
syntax_expanders.insert(intern(&"include_str"),
syntax_expanders.insert(intern("include_str"),
builtin_normal_expander(
ext::source_util::expand_include_str));
syntax_expanders.insert(intern(&"include_bin"),
syntax_expanders.insert(intern("include_bin"),
builtin_normal_expander(
ext::source_util::expand_include_bin));
syntax_expanders.insert(intern(&"module_path"),
syntax_expanders.insert(intern("module_path"),
builtin_normal_expander(
ext::source_util::expand_mod));
syntax_expanders.insert(intern(&"asm"),
syntax_expanders.insert(intern("asm"),
builtin_normal_expander(
ext::asm::expand_asm));
syntax_expanders.insert(intern(&"cfg"),
syntax_expanders.insert(intern("cfg"),
builtin_normal_expander(
ext::cfg::expand_cfg));
syntax_expanders.insert(intern(&"trace_macros"),
syntax_expanders.insert(intern("trace_macros"),
builtin_normal_expander(
ext::trace_macros::expand_trace_macros));
syntax_expanders
Expand Down
27 changes: 5 additions & 22 deletions src/libsyntax/parse/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2779,28 +2779,11 @@ impl<'a> Parser<'a> {
}
}
token::BINOP(token::AND) | token::ANDAND => {
// parse &pat
let lo = self.span.lo;
self.expect_and();
let sub = self.parse_pat();
hi = sub.span.hi;
// HACK: parse &"..." as a literal of a borrowed str
pat = match sub.node {
PatLit(e) => {
match e.node {
ExprLit(lit) if lit_is_str(lit) => {
let vst = @Expr {
id: ast::DUMMY_NODE_ID,
node: ExprVstore(e, ExprVstoreSlice),
span: mk_sp(lo, hi)
};
PatLit(vst)
}
_ => PatRegion(sub),
}
}
_ => PatRegion(sub),
};
// parse &pat
let lo = self.span.lo;
self.expect_and();
let sub = self.parse_pat();
pat = PatRegion(sub);
hi = self.last_span.hi;
return @ast::Pat {
id: ast::DUMMY_NODE_ID,
Expand Down
2 changes: 1 addition & 1 deletion src/libtest/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ impl<T: Writer> ConsoleTestState<T> {

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

Expand Down