Skip to content

Commit 67182c8

Browse files
committed
---
yaml --- r: 143206 b: refs/heads/try2 c: 7af56bb h: refs/heads/master v: v3
1 parent 9e8593a commit 67182c8

File tree

24 files changed

+158
-197
lines changed

24 files changed

+158
-197
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 9fdec67a6761ae43d8fae80e10b5a7a1e0ca7c0d
8+
refs/heads/try2: 7af56bb92199eabcfee52c43739761b18872a2c1
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/libextra/rl.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub mod rustrt {
3232

3333
/// Add a line to history
3434
pub unsafe fn add_history(line: &str) -> bool {
35-
do str::as_c_str(line) |buf| {
35+
do line.as_c_str |buf| {
3636
rustrt::linenoiseHistoryAdd(buf) == 1 as c_int
3737
}
3838
}
@@ -44,21 +44,21 @@ pub unsafe fn set_history_max_len(len: int) -> bool {
4444

4545
/// Save line history to a file
4646
pub unsafe fn save_history(file: &str) -> bool {
47-
do str::as_c_str(file) |buf| {
47+
do file.as_c_str |buf| {
4848
rustrt::linenoiseHistorySave(buf) == 1 as c_int
4949
}
5050
}
5151

5252
/// Load line history from a file
5353
pub unsafe fn load_history(file: &str) -> bool {
54-
do str::as_c_str(file) |buf| {
54+
do file.as_c_str |buf| {
5555
rustrt::linenoiseHistoryLoad(buf) == 1 as c_int
5656
}
5757
}
5858

5959
/// Print out a prompt and then wait for input and return it
6060
pub unsafe fn read(prompt: &str) -> Option<~str> {
61-
do str::as_c_str(prompt) |buf| {
61+
do prompt.as_c_str |buf| {
6262
let line = rustrt::linenoise(buf);
6363

6464
if line.is_null() { None }
@@ -80,7 +80,7 @@ pub unsafe fn complete(cb: CompletionCb) {
8080

8181
unsafe {
8282
do cb(str::raw::from_c_str(line)) |suggestion| {
83-
do str::as_c_str(suggestion) |buf| {
83+
do suggestion.as_c_str |buf| {
8484
rustrt::linenoiseAddCompletion(completions, buf);
8585
}
8686
}

branches/try2/src/librustc/back/link.rs

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ pub fn WriteOutputFile(sess: Session,
7676
OptLevel: c_int,
7777
EnableSegmentedStacks: bool) {
7878
unsafe {
79-
do str::as_c_str(Triple) |Triple| {
80-
do str::as_c_str(Feature) |Feature| {
81-
do str::as_c_str(Output) |Output| {
79+
do Triple.as_c_str |Triple| {
80+
do Feature.as_c_str |Feature| {
81+
do Output.as_c_str |Output| {
8282
let result = llvm::LLVMRustWriteOutputFile(
8383
PM,
8484
M,
@@ -263,16 +263,16 @@ pub mod write {
263263
output_type_bitcode => {
264264
if opts.optimize != session::No {
265265
let filename = output.with_filetype("no-opt.bc");
266-
str::as_c_str(filename.to_str(), |buf| {
267-
llvm::LLVMWriteBitcodeToFile(llmod, buf)
268-
});
266+
do filename.to_str().as_c_str |buf| {
267+
llvm::LLVMWriteBitcodeToFile(llmod, buf);
268+
}
269269
}
270270
}
271271
_ => {
272272
let filename = output.with_filetype("bc");
273-
str::as_c_str(filename.to_str(), |buf| {
274-
llvm::LLVMWriteBitcodeToFile(llmod, buf)
275-
});
273+
do filename.to_str().as_c_str |buf| {
274+
llvm::LLVMWriteBitcodeToFile(llmod, buf);
275+
}
276276
}
277277
}
278278
}
@@ -333,9 +333,9 @@ pub mod write {
333333
// Always output the bitcode file with --save-temps
334334

335335
let filename = output.with_filetype("opt.bc");
336-
str::as_c_str(filename.to_str(), |buf| {
336+
do filename.to_str().as_c_str |buf| {
337337
llvm::LLVMWriteBitcodeToFile(llmod, buf)
338-
});
338+
};
339339
// Save the assembly file if -S is used
340340
if output_type == output_type_assembly {
341341
WriteOutputFile(
@@ -391,13 +391,15 @@ pub mod write {
391391

392392
if output_type == output_type_llvm_assembly {
393393
// Given options "-S --emit-llvm": output LLVM assembly
394-
str::as_c_str(output.to_str(), |buf_o| {
395-
llvm::LLVMRustAddPrintModulePass(pm.llpm, llmod, buf_o)});
394+
do output.to_str().as_c_str |buf_o| {
395+
llvm::LLVMRustAddPrintModulePass(pm.llpm, llmod, buf_o);
396+
}
396397
} else {
397398
// If only a bitcode file is asked for by using the
398399
// '--emit-llvm' flag, then output it here
399-
str::as_c_str(output.to_str(),
400-
|buf| llvm::LLVMWriteBitcodeToFile(llmod, buf) );
400+
do output.to_str().as_c_str |buf| {
401+
llvm::LLVMWriteBitcodeToFile(llmod, buf);
402+
}
401403
}
402404

403405
llvm::LLVMDisposeModule(llmod);

branches/try2/src/librustc/back/passes.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use std::str;
1211
use std::io;
1312

1413
use driver::session::{OptLevel, No, Less, Aggressive};
@@ -174,7 +173,7 @@ pub fn populate_pass_manager(sess: Session, pm: &mut PassManager, pass_list:&[~s
174173
}
175174

176175
pub fn create_pass(name:&str) -> Option<PassRef> {
177-
do str::as_c_str(name) |s| {
176+
do name.as_c_str |s| {
178177
unsafe {
179178
let p = llvm::LLVMCreatePass(s);
180179
if p.is_null() {

branches/try2/src/librustc/lib/llvm.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
use std::hashmap::HashMap;
1313
use std::libc::{c_uint, c_ushort};
1414
use std::option;
15-
use std::str;
1615

1716
use middle::trans::type_::Type;
1817

@@ -2287,10 +2286,9 @@ pub struct TargetData {
22872286
}
22882287

22892288
pub fn mk_target_data(string_rep: &str) -> TargetData {
2290-
let lltd =
2291-
str::as_c_str(string_rep, |buf| unsafe {
2292-
llvm::LLVMCreateTargetData(buf)
2293-
});
2289+
let lltd = do string_rep.as_c_str |buf| {
2290+
unsafe { llvm::LLVMCreateTargetData(buf) }
2291+
};
22942292

22952293
TargetData {
22962294
lltd: lltd,

branches/try2/src/librustc/metadata/loader.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,9 @@ pub fn metadata_matches(extern_metas: &[@ast::MetaItem],
186186
fn get_metadata_section(os: os,
187187
filename: &Path) -> Option<@~[u8]> {
188188
unsafe {
189-
let mb = str::as_c_str(filename.to_str(), |buf| {
189+
let mb = do filename.to_str().as_c_str |buf| {
190190
llvm::LLVMRustCreateMemoryBufferWithContentsOfFile(buf)
191-
});
191+
};
192192
if mb as int == 0 { return option::None::<@~[u8]>; }
193193
let of = match mk_object_file(mb) {
194194
option::Some(of) => of,

branches/try2/src/librustc/middle/trans/asm.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ use middle::ty;
2121

2222
use middle::trans::type_::Type;
2323

24-
use std::str;
2524
use syntax::ast;
2625

2726
// Take an inline assembly expression and splat it out via LLVM
@@ -123,8 +122,8 @@ pub fn trans_inline_asm(bcx: block, ia: &ast::inline_asm) -> block {
123122
ast::asm_intel => lib::llvm::AD_Intel
124123
};
125124

126-
let r = do str::as_c_str(ia.asm) |a| {
127-
do str::as_c_str(constraints) |c| {
125+
let r = do ia.asm.as_c_str |a| {
126+
do constraints.as_c_str |c| {
128127
InlineAsmCall(bcx, a, c, inputs, output, ia.volatile, ia.alignstack, dialect)
129128
}
130129
};

branches/try2/src/librustc/middle/trans/base.rs

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ use std::hashmap::{HashMap, HashSet};
7070
use std::int;
7171
use std::io;
7272
use std::libc::c_uint;
73-
use std::str;
7473
use std::uint;
7574
use std::vec;
7675
use std::local_data;
@@ -549,11 +548,11 @@ pub fn get_res_dtor(ccx: @mut CrateContext,
549548
// Structural comparison: a rather involved form of glue.
550549
pub fn maybe_name_value(cx: &CrateContext, v: ValueRef, s: &str) {
551550
if cx.sess.opts.save_temps {
552-
let _: () = str::as_c_str(s, |buf| {
551+
do s.as_c_str |buf| {
553552
unsafe {
554553
llvm::LLVMSetValueName(v, buf)
555554
}
556-
});
555+
}
557556
}
558557
}
559558

@@ -1577,16 +1576,18 @@ pub struct BasicBlocks {
15771576
pub fn mk_staticallocas_basic_block(llfn: ValueRef) -> BasicBlockRef {
15781577
unsafe {
15791578
let cx = task_llcx();
1580-
str::as_c_str("static_allocas",
1581-
|buf| llvm::LLVMAppendBasicBlockInContext(cx, llfn, buf))
1579+
do "static_allocas".as_c_str | buf| {
1580+
llvm::LLVMAppendBasicBlockInContext(cx, llfn, buf)
1581+
}
15821582
}
15831583
}
15841584

15851585
pub fn mk_return_basic_block(llfn: ValueRef) -> BasicBlockRef {
15861586
unsafe {
15871587
let cx = task_llcx();
1588-
str::as_c_str("return",
1589-
|buf| llvm::LLVMAppendBasicBlockInContext(cx, llfn, buf))
1588+
do "return".as_c_str |buf| {
1589+
llvm::LLVMAppendBasicBlockInContext(cx, llfn, buf)
1590+
}
15901591
}
15911592
}
15921593

@@ -2353,11 +2354,11 @@ pub fn create_entry_wrapper(ccx: @mut CrateContext,
23532354
};
23542355
decl_cdecl_fn(ccx.llmod, main_name, llfty)
23552356
};
2356-
let llbb = str::as_c_str("top", |buf| {
2357+
let llbb = do "top".as_c_str |buf| {
23572358
unsafe {
23582359
llvm::LLVMAppendBasicBlockInContext(ccx.llcx, llfn, buf)
23592360
}
2360-
});
2361+
};
23612362
let bld = ccx.builder.B;
23622363
unsafe {
23632364
llvm::LLVMPositionBuilderAtEnd(bld, llbb);
@@ -2457,9 +2458,9 @@ pub fn get_item_val(ccx: @mut CrateContext, id: ast::node_id) -> ValueRef {
24572458
exprt = m == ast::m_mutbl;
24582459
unsafe {
24592460
let llty = llvm::LLVMTypeOf(v);
2460-
let g = str::as_c_str(s, |buf| {
2461+
let g = do s.as_c_str |buf| {
24612462
llvm::LLVMAddGlobal(ccx.llmod, llty, buf)
2462-
});
2463+
};
24632464
ccx.item_symbols.insert(i.id, s);
24642465
g
24652466
}
@@ -2509,7 +2510,7 @@ pub fn get_item_val(ccx: @mut CrateContext, id: ast::node_id) -> ValueRef {
25092510
ast::foreign_item_static(*) => {
25102511
let typ = ty::node_id_to_type(ccx.tcx, ni.id);
25112512
let ident = token::ident_to_str(&ni.ident);
2512-
let g = do str::as_c_str(ident) |buf| {
2513+
let g = do ident.as_c_str |buf| {
25132514
unsafe {
25142515
let ty = type_of(ccx, typ);
25152516
llvm::LLVMAddGlobal(ccx.llmod, ty.to_ref(), buf)
@@ -2609,11 +2610,11 @@ pub fn trans_constant(ccx: &mut CrateContext, it: @ast::item) {
26092610
let s = mangle_exported_name(ccx, p, ty::mk_int()).to_managed();
26102611
let disr_val = vi[i].disr_val;
26112612
note_unique_llvm_symbol(ccx, s);
2612-
let discrim_gvar = str::as_c_str(s, |buf| {
2613+
let discrim_gvar = do s.as_c_str |buf| {
26132614
unsafe {
26142615
llvm::LLVMAddGlobal(ccx.llmod, ccx.int_type.to_ref(), buf)
26152616
}
2616-
});
2617+
};
26172618
unsafe {
26182619
llvm::LLVMSetInitializer(discrim_gvar, C_int(ccx, disr_val));
26192620
llvm::LLVMSetGlobalConstant(discrim_gvar, True);
@@ -2750,7 +2751,7 @@ pub fn decl_gc_metadata(ccx: &mut CrateContext, llmod_id: &str) {
27502751
}
27512752
27522753
let gc_metadata_name = ~"_gc_module_metadata_" + llmod_id;
2753-
let gc_metadata = do str::as_c_str(gc_metadata_name) |buf| {
2754+
let gc_metadata = do gc_metadata_name.as_c_str |buf| {
27542755
unsafe {
27552756
llvm::LLVMAddGlobal(ccx.llmod, Type::i32().to_ref(), buf)
27562757
}
@@ -2813,11 +2814,11 @@ pub fn decl_crate_map(sess: session::Session, mapmeta: LinkMeta,
28132814
let sym_name = ~"_rust_crate_map_" + mapname;
28142815
let arrtype = Type::array(&int_type, n_subcrates as u64);
28152816
let maptype = Type::struct_([Type::i32(), Type::i8p(), int_type, arrtype], false);
2816-
let map = str::as_c_str(sym_name, |buf| {
2817+
let map = do sym_name.as_c_str |buf| {
28172818
unsafe {
28182819
llvm::LLVMAddGlobal(llmod, maptype.to_ref(), buf)
28192820
}
2820-
});
2821+
};
28212822
lib::llvm::SetLinkage(map, lib::llvm::ExternalLinkage);
28222823
return map;
28232824
}
@@ -2832,11 +2833,11 @@ pub fn fill_crate_map(ccx: @mut CrateContext, map: ValueRef) {
28322833
cdata.name,
28332834
cstore::get_crate_vers(cstore, i),
28342835
cstore::get_crate_hash(cstore, i));
2835-
let cr = str::as_c_str(nm, |buf| {
2836+
let cr = do nm.as_c_str |buf| {
28362837
unsafe {
28372838
llvm::LLVMAddGlobal(ccx.llmod, ccx.int_type.to_ref(), buf)
28382839
}
2839-
});
2840+
};
28402841
subcrates.push(p2i(ccx, cr));
28412842
i += 1;
28422843
}
@@ -2895,16 +2896,16 @@ pub fn write_metadata(cx: &mut CrateContext, crate: &ast::Crate) {
28952896
let encode_parms = crate_ctxt_to_encode_parms(cx, encode_inlined_item);
28962897
let llmeta = C_bytes(encoder::encode_metadata(encode_parms, crate));
28972898
let llconst = C_struct([llmeta]);
2898-
let mut llglobal = str::as_c_str("rust_metadata", |buf| {
2899+
let mut llglobal = do "rust_metadata".as_c_str |buf| {
28992900
unsafe {
29002901
llvm::LLVMAddGlobal(cx.llmod, val_ty(llconst).to_ref(), buf)
29012902
}
2902-
});
2903+
};
29032904
unsafe {
29042905
llvm::LLVMSetInitializer(llglobal, llconst);
2905-
str::as_c_str(cx.sess.targ_cfg.target_strs.meta_sect_name, |buf| {
2906+
do cx.sess.targ_cfg.target_strs.meta_sect_name.as_c_str |buf| {
29062907
llvm::LLVMSetSection(llglobal, buf)
2907-
});
2908+
};
29082909
lib::llvm::SetLinkage(llglobal, lib::llvm::InternalLinkage);
29092910
29102911
let t_ptr_i8 = Type::i8p();
@@ -2923,7 +2924,7 @@ fn mk_global(ccx: &CrateContext,
29232924
internal: bool)
29242925
-> ValueRef {
29252926
unsafe {
2926-
let llglobal = do str::as_c_str(name) |buf| {
2927+
let llglobal = do name.as_c_str |buf| {
29272928
llvm::LLVMAddGlobal(ccx.llmod, val_ty(llval).to_ref(), buf)
29282929
};
29292930
llvm::LLVMSetInitializer(llglobal, llval);

branches/try2/src/librustc/middle/trans/builder.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ use middle::trans::type_::Type;
2020
use std::cast;
2121
use std::hashmap::HashMap;
2222
use std::libc::{c_uint, c_ulonglong, c_char};
23-
use std::str;
2423
use std::vec;
2524
use syntax::codemap::span;
2625

@@ -424,9 +423,9 @@ impl Builder {
424423
if name.is_empty() {
425424
llvm::LLVMBuildAlloca(self.llbuilder, ty.to_ref(), noname())
426425
} else {
427-
str::as_c_str(
428-
name,
429-
|c| llvm::LLVMBuildAlloca(self.llbuilder, ty.to_ref(), c))
426+
do name.as_c_str |c| {
427+
llvm::LLVMBuildAlloca(self.llbuilder, ty.to_ref(), c)
428+
}
430429
}
431430
}
432431
}
@@ -896,9 +895,9 @@ impl Builder {
896895
let BB: BasicBlockRef = llvm::LLVMGetInsertBlock(self.llbuilder);
897896
let FN: ValueRef = llvm::LLVMGetBasicBlockParent(BB);
898897
let M: ModuleRef = llvm::LLVMGetGlobalParent(FN);
899-
let T: ValueRef = str::as_c_str("llvm.trap", |buf| {
898+
let T: ValueRef = do "llvm.trap".as_c_str |buf| {
900899
llvm::LLVMGetNamedFunction(M, buf)
901-
});
900+
};
902901
assert!((T as int != 0));
903902
let args: &[ValueRef] = [];
904903
self.count_insn("trap");

0 commit comments

Comments
 (0)