Skip to content

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

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

Merged
merged 3 commits into from
May 2, 2014
Merged
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
2 changes: 1 addition & 1 deletion src/compiletest/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ fn parse_compile_flags(line: &str) -> Option<~str> {
}

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

fn parse_debugger_cmd(line: &str) -> Option<~str> {
Expand Down
4 changes: 2 additions & 2 deletions src/libcollections/hashmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -698,13 +698,13 @@ static INITIAL_LOAD_FACTOR: Fraction = (9, 10);
/// book_reviews.insert("The Adventures of Sherlock Holmes", "Eye lyked it alot.");
///
/// // check for a specific one.
/// if !book_reviews.contains_key(& &"Les Misérables") {
/// if !book_reviews.contains_key(&("Les Misérables")) {
/// println!("We've got {} reviews, but Les Misérables ain't one.",
/// book_reviews.len());
/// }
///
/// // oops, this review has a lot of spelling mistakes, let's delete it.
/// book_reviews.remove(& &"The Adventures of Sherlock Holmes");
/// book_reviews.remove(&("The Adventures of Sherlock Holmes"));
///
/// // look up the values associated with some keys.
/// let to_find = ["Pride and Prejudice", "Alice's Adventure in Wonderland"];
Expand Down
4 changes: 2 additions & 2 deletions src/libcollections/treemap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1651,10 +1651,10 @@ mod test_set {

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

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

let result: Option<(&uint, & &'static str)> = z.next();
assert!(result.is_none());
Expand Down
12 changes: 6 additions & 6 deletions src/libgetopts/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1441,7 +1441,7 @@ mod tests {
optmulti("l", "", "Desc", "VAL"));

let expected =
~"Usage: fruits
"Usage: fruits

Options:
-b --banana VAL Desc
Expand All @@ -1450,7 +1450,7 @@ Options:
-k --kiwi Desc
-p [VAL] Desc
-l VAL Desc
";
".to_owned();

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

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

let expected =
~"Usage: fruits
"Usage: fruits

Options:
-k --kiwi This is a long description which won't be wrapped..+..
-a --apple This is a long description which _will_ be
wrapped..+..
";
".to_owned();

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

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

let expected =
~"Usage: fruits
"Usage: fruits

Options:
-k --k–w– The word kiwi is normally spelled with two i's
-a --apple This “description” has some characters that could
confuse the line wrapping; an apple costs 0.51€ in
some parts of Europe.
";
".to_owned();

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

Expand Down
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
4 changes: 2 additions & 2 deletions src/libregex_macros/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ impl<'a> NfaGen<'a> {
|cx, name| match name {
&Some(ref name) => {
let name = name.as_slice();
quote_expr!(cx, Some(~$name))
quote_expr!(cx, Some($name.to_owned()))
}
&None => quote_expr!(cx, None),
}
Expand Down Expand Up @@ -306,7 +306,7 @@ fn exec<'t>(which: ::regex::native::MatchKind, input: &'t str,
}

::regex::Regex {
original: ~$regex,
original: $regex.to_owned(),
names: vec!$cap_names,
p: ::regex::native::Native(exec),
}
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
126 changes: 65 additions & 61 deletions src/librustc/middle/typeck/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2564,70 +2564,74 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
let tcx = fcx.ccx.tcx;
let id = expr.id;
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,
_ => ast::MutImmutable,
};
let mut any_error = false;
let mut any_bot = false;
let t: ty::t = fcx.infcx().next_ty_var();
for e in args.iter() {
check_expr_has_type(fcx, *e, t);
let arg_t = fcx.expr_ty(*e);
if ty::type_is_error(arg_t) {
any_error = true;
ast::ExprVstore(ev, vst) => {
let typ = match ev.node {
ast::ExprVec(ref args) => {
let mutability = match vst {
ast::ExprVstoreMutSlice => ast::MutMutable,
_ => ast::MutImmutable,
};
let mut any_error = false;
let mut any_bot = false;
let t: ty::t = fcx.infcx().next_ty_var();
for e in args.iter() {
check_expr_has_type(fcx, *e, t);
let arg_t = fcx.expr_ty(*e);
if ty::type_is_error(arg_t) {
any_error = true;
}
else if ty::type_is_bot(arg_t) {
any_bot = true;
}
}
if any_error {
ty::mk_err()
} else if any_bot {
ty::mk_bot()
} else {
ast_expr_vstore_to_ty(fcx, ev, vst, ||
ty::mt{ ty: ty::mk_vec(tcx,
ty::mt {ty: t, mutbl: mutability},
None),
mutbl: mutability })
}
}
else if ty::type_is_bot(arg_t) {
any_bot = true;
ast::ExprRepeat(element, count_expr) => {
check_expr_with_hint(fcx, count_expr, ty::mk_uint());
let _ = ty::eval_repeat_count(fcx, count_expr);
let mutability = match vst {
ast::ExprVstoreMutSlice => ast::MutMutable,
_ => ast::MutImmutable,
};
let t = fcx.infcx().next_ty_var();
check_expr_has_type(fcx, element, t);
let arg_t = fcx.expr_ty(element);
if ty::type_is_error(arg_t) {
ty::mk_err()
} else if ty::type_is_bot(arg_t) {
ty::mk_bot()
} else {
ast_expr_vstore_to_ty(fcx, ev, vst, ||
ty::mt{ ty: ty::mk_vec(tcx,
ty::mt {ty: t, mutbl: mutability},
None),
mutbl: mutability})
}
}
}
if any_error {
ty::mk_err()
} else if any_bot {
ty::mk_bot()
} else {
ast_expr_vstore_to_ty(fcx, ev, vst, ||
ty::mt{ ty: ty::mk_vec(tcx,
ty::mt {ty: t, mutbl: mutability},
None),
mutbl: mutability })
}
}
ast::ExprRepeat(element, count_expr) => {
check_expr_with_hint(fcx, count_expr, ty::mk_uint());
let _ = ty::eval_repeat_count(fcx, count_expr);
let mutability = match vst {
ast::ExprVstoreMutSlice => ast::MutMutable,
_ => ast::MutImmutable,
ast::ExprLit(_) => {
let error = if vst == ast::ExprVstoreSlice {
"`&\"string\"` has been removed; use `\"string\"` instead"
} else {
"`~\"string\"` has been removed; use `\"string\".to_owned()` instead"
};
tcx.sess.span_err(expr.span, error);
ty::mk_err()
}
_ => tcx.sess.span_bug(expr.span, "vstore modifier on non-sequence"),
};
let t = fcx.infcx().next_ty_var();
check_expr_has_type(fcx, element, t);
let arg_t = fcx.expr_ty(element);
if ty::type_is_error(arg_t) {
ty::mk_err()
} else if ty::type_is_bot(arg_t) {
ty::mk_bot()
} else {
ast_expr_vstore_to_ty(fcx, ev, vst, ||
ty::mt{ ty: ty::mk_vec(tcx,
ty::mt {ty: t, mutbl: mutability},
None),
mutbl: mutability})
}
}
_ =>
tcx.sess.span_bug(expr.span, "vstore modifier on non-sequence")
};
fcx.write_ty(ev.id, typ);
fcx.write_ty(id, typ);
}
fcx.write_ty(ev.id, typ);
fcx.write_ty(id, typ);
}

ast::ExprBox(place, subexpr) => {
check_expr(fcx, place);
Expand Down
Loading