Skip to content

Commit

Permalink
auto merge of #13877 : thestinger/rust/de-tilde-str-vec, r=alexcrichton
Browse files Browse the repository at this point in the history
  • Loading branch information
bors committed May 1, 2014
2 parents 9f484e6 + 58e79d1 commit 8f4b839
Show file tree
Hide file tree
Showing 24 changed files with 145 additions and 156 deletions.
2 changes: 1 addition & 1 deletion src/compiletest/header.rs
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
6 changes: 4 additions & 2 deletions src/libregex/parse.rs
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
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
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
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
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
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
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
2 changes: 1 addition & 1 deletion src/libserialize/json.rs
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
2 changes: 1 addition & 1 deletion src/libstd/hash/mod.rs
Expand Up @@ -343,7 +343,7 @@ mod tests {

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

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

unsafe {
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/path/posix.rs
Expand Up @@ -555,7 +555,7 @@ mod tests {
($path:expr, $disp:ident, $exp:expr) => (
{
let path = Path::new($path);
assert!(path.$disp().to_str() == ~$exp);
assert!(path.$disp().to_str().as_slice() == $exp);
}
)
)
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/repr.rs
Expand Up @@ -637,7 +637,7 @@ fn test_repr() {
exact_test(&true, "true");
exact_test(&false, "false");
exact_test(&1.234, "1.234f64");
exact_test(&(&"hello"), "\"hello\"");
exact_test(&("hello"), "\"hello\"");
// FIXME What do I do about this one?
exact_test(&("he\u10f3llo".to_owned()), "~\"he\\u10f3llo\"");

Expand Down
12 changes: 6 additions & 6 deletions src/libstd/str.rs
Expand Up @@ -3604,11 +3604,11 @@ mod tests {

#[test]
fn test_total_ord() {
"1234".cmp(& &"123") == Greater;
"123".cmp(& &"1234") == Less;
"1234".cmp(& &"1234") == Equal;
"12345555".cmp(& &"123456") == Less;
"22".cmp(& &"1234") == Greater;
"1234".cmp(&("123")) == Greater;
"123".cmp(&("1234")) == Less;
"1234".cmp(&("1234")) == Equal;
"12345555".cmp(&("123456")) == Less;
"22".cmp(&("1234")) == Greater;
}

#[test]
Expand Down Expand Up @@ -4005,7 +4005,7 @@ mod tests {

#[test]
fn test_from_str() {
let owned: Option<~str> = from_str(&"string");
let owned: Option<~str> = from_str("string");
assert_eq!(owned, Some("string".to_owned()));
}

Expand Down

0 comments on commit 8f4b839

Please sign in to comment.