Skip to content

Commit a92d689

Browse files
authored
Rollup merge of #59371 - dlrobertson:rename_va_list_copy, r=joshtriplett
ffi: rename VaList::copy to VaList::with_copy Rename `VaList::copy` to `VaList::with_copy` r? @joshtriplett
2 parents f591d25 + 8ea435c commit a92d689

File tree

6 files changed

+21
-21
lines changed

6 files changed

+21
-21
lines changed

src/libcore/ffi.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ impl<'a> VaList<'a> {
190190
reason = "the `c_variadic` feature has not been properly tested on \
191191
all supported platforms",
192192
issue = "44930")]
193-
pub unsafe fn copy<F, R>(&self, f: F) -> R
193+
pub unsafe fn with_copy<F, R>(&self, f: F) -> R
194194
where F: for<'copy> FnOnce(VaList<'copy>) -> R {
195195
#[cfg(any(all(not(target_arch = "aarch64"), not(target_arch = "powerpc"),
196196
not(target_arch = "x86_64")),

src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/checkrust.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ pub unsafe extern "C" fn check_list_copy_0(mut ap: VaList) -> usize {
6262
continue_if!(ap.arg::<c_int>() == 16);
6363
continue_if!(ap.arg::<c_char>() == 'A' as c_char);
6464
continue_if!(compare_c_str(ap.arg::<*const c_char>(), "Skip Me!"));
65-
ap.copy(|mut ap| {
65+
ap.with_copy(|mut ap| {
6666
if compare_c_str(ap.arg::<*const c_char>(), "Correct") {
6767
0
6868
} else {

src/test/ui/c-variadic/variadic-ffi-4.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ pub unsafe extern "C" fn no_escape1(_: usize, ap: ...) -> VaList<'static> {
1313
}
1414

1515
pub unsafe extern "C" fn no_escape2(_: usize, ap: ...) {
16-
let _ = ap.copy(|ap| { ap }); //~ ERROR: cannot infer an appropriate lifetime
16+
let _ = ap.with_copy(|ap| { ap }); //~ ERROR: cannot infer an appropriate lifetime
1717
}
1818

1919
pub unsafe extern "C" fn no_escape3(_: usize, mut ap0: &mut VaList, mut ap1: ...) {

src/test/ui/c-variadic/variadic-ffi-4.stderr

+11-11
Original file line numberDiff line numberDiff line change
@@ -15,29 +15,29 @@ LL | ap
1515
| ^^ lifetime `'static` required
1616

1717
error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements
18-
--> $DIR/variadic-ffi-4.rs:16:28
18+
--> $DIR/variadic-ffi-4.rs:16:33
1919
|
20-
LL | let _ = ap.copy(|ap| { ap });
21-
| ^^
20+
LL | let _ = ap.with_copy(|ap| { ap });
21+
| ^^
2222
|
23-
note: first, the lifetime cannot outlive the anonymous lifetime #2 defined on the body at 16:21...
24-
--> $DIR/variadic-ffi-4.rs:16:21
23+
note: first, the lifetime cannot outlive the anonymous lifetime #2 defined on the body at 16:26...
24+
--> $DIR/variadic-ffi-4.rs:16:26
2525
|
26-
LL | let _ = ap.copy(|ap| { ap });
27-
| ^^^^^^^^^^^
26+
LL | let _ = ap.with_copy(|ap| { ap });
27+
| ^^^^^^^^^^^
2828
= note: ...so that the expression is assignable:
2929
expected core::ffi::VaList<'_>
3030
found core::ffi::VaList<'_>
3131
note: but, the lifetime must be valid for the method call at 16:13...
3232
--> $DIR/variadic-ffi-4.rs:16:13
3333
|
34-
LL | let _ = ap.copy(|ap| { ap });
35-
| ^^^^^^^^^^^^^^^^^^^^
34+
LL | let _ = ap.with_copy(|ap| { ap });
35+
| ^^^^^^^^^^^^^^^^^^^^^^^^^
3636
note: ...so type `core::ffi::VaList<'_>` of expression is valid during the expression
3737
--> $DIR/variadic-ffi-4.rs:16:13
3838
|
39-
LL | let _ = ap.copy(|ap| { ap });
40-
| ^^^^^^^^^^^^^^^^^^^^
39+
LL | let _ = ap.with_copy(|ap| { ap });
40+
| ^^^^^^^^^^^^^^^^^^^^^^^^^
4141

4242
error[E0308]: mismatched types
4343
--> $DIR/variadic-ffi-4.rs:20:12

src/test/ui/c-variadic/variadic-ffi-5.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub unsafe extern "C" fn no_escape1(_: usize, ap: ...) -> VaList<'static> {
1616
}
1717

1818
pub unsafe extern "C" fn no_escape2(_: usize, ap: ...) {
19-
let _ = ap.copy(|ap| { ap }); //~ ERROR: lifetime may not live long enough
19+
let _ = ap.with_copy(|ap| { ap }); //~ ERROR: lifetime may not live long enough
2020
}
2121

2222
pub unsafe extern "C" fn no_escape3(_: usize, ap0: &mut VaList, mut ap1: ...) {

src/test/ui/c-variadic/variadic-ffi-5.stderr

+6-6
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ LL | ap
1515
| ^^ lifetime `'static` required
1616

1717
error: lifetime may not live long enough
18-
--> $DIR/variadic-ffi-5.rs:19:28
18+
--> $DIR/variadic-ffi-5.rs:19:33
1919
|
20-
LL | let _ = ap.copy(|ap| { ap });
21-
| --- ^^ returning this value requires that `'1` must outlive `'2`
22-
| | |
23-
| | return type of closure is core::ffi::VaList<'2>
24-
| has type `core::ffi::VaList<'1>`
20+
LL | let _ = ap.with_copy(|ap| { ap });
21+
| --- ^^ returning this value requires that `'1` must outlive `'2`
22+
| | |
23+
| | return type of closure is core::ffi::VaList<'2>
24+
| has type `core::ffi::VaList<'1>`
2525

2626
error: lifetime may not live long enough
2727
--> $DIR/variadic-ffi-5.rs:23:5

0 commit comments

Comments
 (0)