Skip to content

Commit 4834661

Browse files
committed
std and rustc: Convert users of c_str to use .with_c_str
1 parent a94158c commit 4834661

File tree

6 files changed

+22
-22
lines changed

6 files changed

+22
-22
lines changed

src/librustc/middle/trans/base.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -524,13 +524,13 @@ pub fn set_always_inline(f: ValueRef) {
524524
}
525525

526526
pub fn set_fixed_stack_segment(f: ValueRef) {
527-
do "fixed-stack-segment".to_c_str().with_ref |buf| {
527+
do "fixed-stack-segment".with_c_str |buf| {
528528
unsafe { llvm::LLVMAddFunctionAttrString(f, buf); }
529529
}
530530
}
531531

532532
pub fn set_no_split_stack(f: ValueRef) {
533-
do "no-split-stack".to_c_str().with_ref |buf| {
533+
do "no-split-stack".with_c_str |buf| {
534534
unsafe { llvm::LLVMAddFunctionAttrString(f, buf); }
535535
}
536536
}

src/librustc/middle/trans/debuginfo.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,7 @@ pub fn create_function_debug_context(cx: &mut CrateContext,
781781

782782
let ident = special_idents::type_self;
783783

784-
let param_metadata = do token::ident_to_str(&ident).to_c_str().with_ref |name| {
784+
let param_metadata = do token::ident_to_str(&ident).with_c_str |name| {
785785
unsafe {
786786
llvm::LLVMDIBuilderCreateTemplateTypeParameter(
787787
DIB(cx),
@@ -819,7 +819,7 @@ pub fn create_function_debug_context(cx: &mut CrateContext,
819819
// Again, only create type information if extra_debuginfo is enabled
820820
if cx.sess.opts.extra_debuginfo {
821821
let actual_type_metadata = type_metadata(cx, actual_type, codemap::dummy_sp());
822-
let param_metadata = do token::ident_to_str(&ident).to_c_str().with_ref |name| {
822+
let param_metadata = do token::ident_to_str(&ident).with_c_str |name| {
823823
unsafe {
824824
llvm::LLVMDIBuilderCreateTemplateTypeParameter(
825825
DIB(cx),

src/librustc/middle/trans/foreign.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ pub fn trans_rust_fn_with_foreign_abi(ccx: @mut CrateContext,
465465
// }
466466

467467
let the_block =
468-
"the block".to_c_str().with_ref(
468+
"the block".with_c_str(
469469
|s| llvm::LLVMAppendBasicBlockInContext(ccx.llcx, llwrapfn, s));
470470

471471
let builder = ccx.builder.B;
@@ -519,7 +519,7 @@ pub fn trans_rust_fn_with_foreign_abi(ccx: @mut CrateContext,
519519

520520
None => {
521521
let slot = {
522-
"return_alloca".to_c_str().with_ref(
522+
"return_alloca".with_c_str(
523523
|s| llvm::LLVMBuildAlloca(builder,
524524
llrust_ret_ty.to_ref(),
525525
s))

src/libstd/rt/crate_map.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ fn iter_crate_map_follow_children() {
209209
let child_crate1 = CrateMapT2 {
210210
version: 1,
211211
entries: vec::raw::to_ptr([
212-
ModEntry { name: "t::f1".to_c_str().with_ref(|buf| buf), log_level: &mut 1},
212+
ModEntry { name: "t::f1".with_c_str(|buf| buf), log_level: &mut 1},
213213
ModEntry { name: ptr::null(), log_level: ptr::mut_null()}
214214
]),
215215
children: [&child_crate2 as *CrateMap, ptr::null()]
@@ -219,7 +219,7 @@ fn iter_crate_map_follow_children() {
219219
let root_crate = CrateMapT2 {
220220
version: 1,
221221
entries: vec::raw::to_ptr([
222-
ModEntry { name: "t::f1".to_c_str().with_ref(|buf| buf), log_level: &mut 0},
222+
ModEntry { name: "t::f1".with_c_str(|buf| buf), log_level: &mut 0},
223223
ModEntry { name: ptr::null(), log_level: ptr::mut_null()}
224224
]),
225225
children: [child_crate1_ptr, ptr::null()]

src/libstd/rt/logging.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ fn update_entry_match_full_path() {
294294
LogDirective {name: Some(~"crate2"), level: 3}];
295295
let level = &mut 0;
296296
unsafe {
297-
do "crate1::mod1".to_c_str().with_ref |ptr| {
297+
do "crate1::mod1".with_c_str |ptr| {
298298
let entry= &ModEntry {name: ptr, log_level: level};
299299
let m = update_entry(dirs, transmute(entry));
300300
assert!(*entry.log_level == 2);
@@ -310,7 +310,7 @@ fn update_entry_no_match() {
310310
LogDirective {name: Some(~"crate2"), level: 3}];
311311
let level = &mut 0;
312312
unsafe {
313-
do "crate3::mod1".to_c_str().with_ref |ptr| {
313+
do "crate3::mod1".with_c_str |ptr| {
314314
let entry= &ModEntry {name: ptr, log_level: level};
315315
let m = update_entry(dirs, transmute(entry));
316316
assert!(*entry.log_level == DEFAULT_LOG_LEVEL);
@@ -326,7 +326,7 @@ fn update_entry_match_beginning() {
326326
LogDirective {name: Some(~"crate2"), level: 3}];
327327
let level = &mut 0;
328328
unsafe {
329-
do "crate2::mod1".to_c_str().with_ref |ptr| {
329+
do "crate2::mod1".with_c_str |ptr| {
330330
let entry= &ModEntry {name: ptr, log_level: level};
331331
let m = update_entry(dirs, transmute(entry));
332332
assert!(*entry.log_level == 3);
@@ -343,7 +343,7 @@ fn update_entry_match_beginning_longest_match() {
343343
LogDirective {name: Some(~"crate2::mod"), level: 4}];
344344
let level = &mut 0;
345345
unsafe {
346-
do "crate2::mod1".to_c_str().with_ref |ptr| {
346+
do "crate2::mod1".with_c_str |ptr| {
347347
let entry = &ModEntry {name: ptr, log_level: level};
348348
let m = update_entry(dirs, transmute(entry));
349349
assert!(*entry.log_level == 4);
@@ -360,13 +360,13 @@ fn update_entry_match_default() {
360360
];
361361
let level = &mut 0;
362362
unsafe {
363-
do "crate1::mod1".to_c_str().with_ref |ptr| {
363+
do "crate1::mod1".with_c_str |ptr| {
364364
let entry= &ModEntry {name: ptr, log_level: level};
365365
let m = update_entry(dirs, transmute(entry));
366366
assert!(*entry.log_level == 2);
367367
assert!(m == 1);
368368
}
369-
do "crate2::mod2".to_c_str().with_ref |ptr| {
369+
do "crate2::mod2".with_c_str |ptr| {
370370
let entry= &ModEntry {name: ptr, log_level: level};
371371
let m = update_entry(dirs, transmute(entry));
372372
assert!(*entry.log_level == 3);

src/libstd/rt/uv/file.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ impl FsRequest {
4343
me.req_boilerplate(Some(cb))
4444
};
4545
path.path_as_str(|p| {
46-
p.to_c_str().with_ref(|p| unsafe {
46+
p.with_c_str(|p| unsafe {
4747
uvll::fs_open(loop_.native_handle(),
4848
self.native_handle(), p, flags, mode, complete_cb_ptr)
4949
})
@@ -57,7 +57,7 @@ impl FsRequest {
5757
me.req_boilerplate(None)
5858
};
5959
let result = path.path_as_str(|p| {
60-
p.to_c_str().with_ref(|p| unsafe {
60+
p.with_c_str(|p| unsafe {
6161
uvll::fs_open(loop_.native_handle(),
6262
self.native_handle(), p, flags, mode, complete_cb_ptr)
6363
})
@@ -71,7 +71,7 @@ impl FsRequest {
7171
me.req_boilerplate(Some(cb))
7272
};
7373
path.path_as_str(|p| {
74-
p.to_c_str().with_ref(|p| unsafe {
74+
p.with_c_str(|p| unsafe {
7575
uvll::fs_unlink(loop_.native_handle(),
7676
self.native_handle(), p, complete_cb_ptr)
7777
})
@@ -85,7 +85,7 @@ impl FsRequest {
8585
me.req_boilerplate(None)
8686
};
8787
let result = path.path_as_str(|p| {
88-
p.to_c_str().with_ref(|p| unsafe {
88+
p.with_c_str(|p| unsafe {
8989
uvll::fs_unlink(loop_.native_handle(),
9090
self.native_handle(), p, complete_cb_ptr)
9191
})
@@ -99,7 +99,7 @@ impl FsRequest {
9999
me.req_boilerplate(Some(cb))
100100
};
101101
path.path_as_str(|p| {
102-
p.to_c_str().with_ref(|p| unsafe {
102+
p.with_c_str(|p| unsafe {
103103
uvll::fs_stat(loop_.native_handle(),
104104
self.native_handle(), p, complete_cb_ptr)
105105
})
@@ -192,7 +192,7 @@ impl FsRequest {
192192
me.req_boilerplate(Some(cb))
193193
};
194194
path.path_as_str(|p| {
195-
p.to_c_str().with_ref(|p| unsafe {
195+
p.with_c_str(|p| unsafe {
196196
uvll::fs_mkdir(loop_.native_handle(),
197197
self.native_handle(), p, mode, complete_cb_ptr)
198198
})
@@ -205,7 +205,7 @@ impl FsRequest {
205205
me.req_boilerplate(Some(cb))
206206
};
207207
path.path_as_str(|p| {
208-
p.to_c_str().with_ref(|p| unsafe {
208+
p.with_c_str(|p| unsafe {
209209
uvll::fs_rmdir(loop_.native_handle(),
210210
self.native_handle(), p, complete_cb_ptr)
211211
})
@@ -219,7 +219,7 @@ impl FsRequest {
219219
me.req_boilerplate(Some(cb))
220220
};
221221
path.path_as_str(|p| {
222-
p.to_c_str().with_ref(|p| unsafe {
222+
p.with_c_str(|p| unsafe {
223223
uvll::fs_readdir(loop_.native_handle(),
224224
self.native_handle(), p, flags, complete_cb_ptr)
225225
})

0 commit comments

Comments
 (0)