Skip to content

Commit 6b4a11c

Browse files
committed
Fix build on 0.11pre: Change ~"foo" to "foo".to_owned()
[~"string" and &"string" literals are gone](rust-lang/rust#13877), and were replaced by "string".to_owned() and just "string", respectively. This commit was made by a simple `sed` to convert the existing instances of ~"string" on the codebase. For reference, the command used was this: sed -e 's/~\("[^"]*"\)/\1.to_owned()/g' -i *.rs That wouldn't work if for strings that contain the `\"` escape in them, but this codebase had none. Similar work is likely to be necessary after [~T is substituted by Box<T>](rust-lang/rust#13885).
1 parent 02cc483 commit 6b4a11c

File tree

3 files changed

+38
-38
lines changed

3 files changed

+38
-38
lines changed

gen.rs

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ fn empty_generics() -> ast::Generics {
5656
fn rust_id(ctx: &mut GenCtx, name: ~str) -> (~str, bool) {
5757
let token = parse::token::IDENT(ctx.ext_cx.ident_of(name), false);
5858
if parse::token::is_any_keyword(&token) || "bool" == name {
59-
(~"_" + name, true)
59+
("_".to_owned() + name, true)
6060
} else {
6161
(name, false)
6262
}
@@ -77,7 +77,7 @@ fn rust_type_id(ctx: &mut GenCtx, name: ~str) -> ~str {
7777
"i64" == name ||
7878
"Self" == name ||
7979
"str" == name {
80-
~"_" + name
80+
"_".to_owned() + name
8181
} else {
8282
let (n, _) = rust_id(ctx, name);
8383
n
@@ -134,7 +134,7 @@ pub fn gen_rs(out: ~io::Writer, abi: ~str, link: &Option<~str>, globs: Vec<Globa
134134
};
135135
ctx.ext_cx.bt_push(ExpnInfo {
136136
call_site: DUMMY_SP,
137-
callee: NameAndSpan { name: ~"", format: MacroBang, span: None }
137+
callee: NameAndSpan { name: "".to_owned(), format: MacroBang, span: None }
138138
});
139139
let uniq_globs = tag_dup_decl(globs);
140140

@@ -214,7 +214,7 @@ pub fn gen_rs(out: ~io::Writer, abi: ~str, link: &Option<~str>, globs: Vec<Globa
214214
let v = vi.borrow();
215215
cvar_to_rs(&mut ctx, v.name.clone(), &v.ty, v.is_const)
216216
},
217-
_ => { fail!(~"generate global variables") }
217+
_ => { fail!("generate global variables".to_owned()) }
218218
}
219219
}).collect();
220220

@@ -225,14 +225,14 @@ pub fn gen_rs(out: ~io::Writer, abi: ~str, link: &Option<~str>, globs: Vec<Globa
225225
match v.ty {
226226
TFunc(ref rty, ref aty, var) => cfunc_to_rs(&mut ctx, v.name.clone(),
227227
*rty, *aty, var),
228-
_ => { fail!(~"generate functions") }
228+
_ => { fail!("generate functions".to_owned()) }
229229
}
230230
},
231-
_ => { fail!(~"generate functions") }
231+
_ => { fail!("generate functions".to_owned()) }
232232
}
233233
}).collect();
234234

235-
let views = Vec::from_elem(1, mk_import(&mut ctx, &[~"libc"]));
235+
let views = Vec::from_elem(1, mk_import(&mut ctx, &["libc".to_owned()]));
236236
defs.push(mk_extern(&mut ctx, link, vars, funcs));
237237

238238
let crate_ = ast::Crate {
@@ -292,7 +292,7 @@ fn mk_extern(ctx: &mut GenCtx, link: &Option<~str>,
292292
None => attrs = Vec::new(),
293293
Some(ref l) => {
294294
let link_name = @dummy_spanned(ast::MetaNameValue(
295-
to_intern_str(ctx, ~"name"),
295+
to_intern_str(ctx, "name".to_owned()),
296296
dummy_spanned(ast::LitStr(
297297
to_intern_str(ctx, l.to_owned()),
298298
ast::CookedStr
@@ -301,7 +301,7 @@ fn mk_extern(ctx: &mut GenCtx, link: &Option<~str>,
301301
let link_args = dummy_spanned(ast::Attribute_ {
302302
style: ast::AttrOuter,
303303
value: @dummy_spanned(ast::MetaList(
304-
to_intern_str(ctx, ~"link"),
304+
to_intern_str(ctx, "link".to_owned()),
305305
Vec::from_elem(1, link_name))
306306
),
307307
is_sugared_doc: false
@@ -623,7 +623,7 @@ fn cunion_to_rs(ctx: &mut GenCtx, name: ~str, layout: Layout, fields: Vec<FieldI
623623

624624
return vec!(
625625
union_def,
626-
mk_item(ctx, ~"", methods, ast::Inherited)
626+
mk_item(ctx, "".to_owned(), methods, ast::Inherited)
627627
);
628628
}
629629

@@ -663,7 +663,7 @@ fn mk_link_name_attr(ctx: &mut GenCtx, name: ~str) -> ast::Attribute {
663663
ast::CookedStr
664664
));
665665
let attr_val = @dummy_spanned(ast::MetaNameValue(
666-
to_intern_str(ctx, ~"link_name"), lit
666+
to_intern_str(ctx, "link_name".to_owned()), lit
667667
));
668668
let attr = ast::Attribute_ {
669669
style: ast::AttrOuter,
@@ -782,23 +782,23 @@ fn cfunc_to_rs(ctx: &mut GenCtx, name: ~str, rty: &Type,
782782

783783
fn cty_to_rs(ctx: &mut GenCtx, ty: &Type) -> ast::Ty {
784784
return match *ty {
785-
TVoid => mk_ty(ctx, ~"c_void"),
785+
TVoid => mk_ty(ctx, "c_void".to_owned()),
786786
TInt(i, _) => match i {
787-
IBool => mk_ty(ctx, ~"c_int"),
788-
ISChar => mk_ty(ctx, ~"c_char"),
789-
IUChar => mk_ty(ctx, ~"c_uchar"),
790-
IInt => mk_ty(ctx, ~"c_int"),
791-
IUInt => mk_ty(ctx, ~"c_uint"),
792-
IShort => mk_ty(ctx, ~"c_short"),
793-
IUShort => mk_ty(ctx, ~"c_ushort"),
794-
ILong => mk_ty(ctx, ~"c_long"),
795-
IULong => mk_ty(ctx, ~"c_ulong"),
796-
ILongLong => mk_ty(ctx, ~"c_longlong"),
797-
IULongLong => mk_ty(ctx, ~"c_ulonglong")
787+
IBool => mk_ty(ctx, "c_int".to_owned()),
788+
ISChar => mk_ty(ctx, "c_char".to_owned()),
789+
IUChar => mk_ty(ctx, "c_uchar".to_owned()),
790+
IInt => mk_ty(ctx, "c_int".to_owned()),
791+
IUInt => mk_ty(ctx, "c_uint".to_owned()),
792+
IShort => mk_ty(ctx, "c_short".to_owned()),
793+
IUShort => mk_ty(ctx, "c_ushort".to_owned()),
794+
ILong => mk_ty(ctx, "c_long".to_owned()),
795+
IULong => mk_ty(ctx, "c_ulong".to_owned()),
796+
ILongLong => mk_ty(ctx, "c_longlong".to_owned()),
797+
IULongLong => mk_ty(ctx, "c_ulonglong".to_owned())
798798
},
799799
TFloat(f, _) => match f {
800-
FFloat => mk_ty(ctx, ~"c_float"),
801-
FDouble => mk_ty(ctx, ~"c_double")
800+
FFloat => mk_ty(ctx, "c_float".to_owned()),
801+
FDouble => mk_ty(ctx, "c_double".to_owned())
802802
},
803803
TPtr(ref t, is_const, _) => {
804804
let id = cty_to_rs(ctx, *t);

main.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ fn parse_args(args: &[~str]) -> ParseResult {
4040
let mut out = ~io::BufferedWriter::new(io::stdout()) as ~io::Writer;
4141
let mut pat = vec!();
4242
let mut link = None;
43-
let mut abi = ~"C";
43+
let mut abi = "C".to_owned();
4444
let mut builtins = false;
4545
let mut emit_ast = false;
4646
let mut fail_on_bitfield = true;
@@ -61,7 +61,7 @@ fn parse_args(args: &[~str]) -> ParseResult {
6161
}
6262
"-o" => {
6363
if ix + 1u >= args_len {
64-
return ParseErr(~"Missing output filename");
64+
return ParseErr("Missing output filename".to_owned());
6565
}
6666
let path = path::Path::new(args[ix + 1].clone());
6767
match fs::File::create(&path) {
@@ -72,14 +72,14 @@ fn parse_args(args: &[~str]) -> ParseResult {
7272
}
7373
"-l" => {
7474
if ix + 1u >= args_len {
75-
return ParseErr(~"Missing link name");
75+
return ParseErr("Missing link name".to_owned());
7676
}
7777
link = Some(args[ix + 1u].clone());
7878
ix += 2u;
7979
}
8080
"-match" => {
8181
if ix + 1u >= args_len {
82-
return ParseErr(~"Missing match pattern");
82+
return ParseErr("Missing match pattern".to_owned());
8383
}
8484
pat.push(args[ix + 1u].clone());
8585
ix += 2u;
@@ -122,8 +122,8 @@ fn parse_args(args: &[~str]) -> ParseResult {
122122
fn builtin_names() -> HashSet<~str> {
123123
let mut names = HashSet::new();
124124
let keys = ~[
125-
~"__va_list_tag",
126-
~"__va_list",
125+
"__va_list_tag".to_owned(),
126+
"__va_list".to_owned(),
127127
];
128128

129129
keys.move_iter().advance(|s| {
@@ -269,7 +269,7 @@ fn conv_ptr_ty(ctx: &mut BindGenCtx, ty: &cx::Type, cursor: &Cursor, layout: Lay
269269
let decl = ty.declaration();
270270
return if ret_ty.kind() != CXType_Invalid {
271271
let args_lst = ty.arg_types().iter().map(|arg| {
272-
(~"", conv_ty(ctx, arg, cursor))
272+
("".to_owned(), conv_ty(ctx, arg, cursor))
273273
}).collect();
274274
let ret_ty = ~conv_ty(ctx, &ret_ty, cursor);
275275

@@ -535,12 +535,12 @@ fn main() {
535535
ParseOk(clang_args, mut ctx, out) => {
536536
let ix = cx::Index::create(false, true);
537537
if ix.is_null() {
538-
fail!(~"clang failed to create index");
538+
fail!("clang failed to create index".to_owned());
539539
}
540540

541541
let unit = TranslationUnit::parse(&ix, "", clang_args, [], 0);
542542
if unit.is_null() {
543-
fail!(~"No input files given");
543+
fail!("No input files given".to_owned());
544544
}
545545

546546
let mut c_err = false;

types.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,30 +18,30 @@ impl Global {
1818
match *self {
1919
GComp(i) => return i,
2020
GCompDecl(i) => return i,
21-
_ => fail!(~"global_compinfo")
21+
_ => fail!("global_compinfo".to_owned())
2222
}
2323
}
2424

2525
pub fn enuminfo(&self) -> @RefCell<EnumInfo> {
2626
match *self {
2727
GEnum(i) => return i,
2828
GEnumDecl(i) => return i,
29-
_ => fail!(~"global_enuminfo")
29+
_ => fail!("global_enuminfo".to_owned())
3030
}
3131
}
3232

3333
pub fn typeinfo(&self) -> @RefCell<TypeInfo> {
3434
match *self {
3535
GType(i) => return i,
36-
_ => fail!(~"global_typeinfo")
36+
_ => fail!("global_typeinfo".to_owned())
3737
}
3838
}
3939

4040
pub fn varinfo(&self) -> @RefCell<VarInfo> {
4141
match *self {
4242
GVar(i) => i,
4343
GFunc(i) => i,
44-
_ => fail!(~"global_varinfo")
44+
_ => fail!("global_varinfo".to_owned())
4545
}
4646
}
4747
}

0 commit comments

Comments
 (0)