Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ffi: rename VaList::copy to VaList::with_copy #59371

Merged
merged 1 commit into from
Mar 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/libcore/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ impl<'a> VaList<'a> {
reason = "the `c_variadic` feature has not been properly tested on \
all supported platforms",
issue = "44930")]
pub unsafe fn copy<F, R>(&self, f: F) -> R
pub unsafe fn with_copy<F, R>(&self, f: F) -> R
where F: for<'copy> FnOnce(VaList<'copy>) -> R {
#[cfg(any(all(not(target_arch = "aarch64"), not(target_arch = "powerpc"),
not(target_arch = "x86_64")),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ pub unsafe extern "C" fn check_list_copy_0(mut ap: VaList) -> usize {
continue_if!(ap.arg::<c_int>() == 16);
continue_if!(ap.arg::<c_char>() == 'A' as c_char);
continue_if!(compare_c_str(ap.arg::<*const c_char>(), "Skip Me!"));
ap.copy(|mut ap| {
ap.with_copy(|mut ap| {
if compare_c_str(ap.arg::<*const c_char>(), "Correct") {
0
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/c-variadic/variadic-ffi-4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub unsafe extern "C" fn no_escape1(_: usize, ap: ...) -> VaList<'static> {
}

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

pub unsafe extern "C" fn no_escape3(_: usize, mut ap0: &mut VaList, mut ap1: ...) {
Expand Down
22 changes: 11 additions & 11 deletions src/test/ui/c-variadic/variadic-ffi-4.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,29 @@ LL | ap
| ^^ lifetime `'static` required

error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements
--> $DIR/variadic-ffi-4.rs:16:28
--> $DIR/variadic-ffi-4.rs:16:33
|
LL | let _ = ap.copy(|ap| { ap });
| ^^
LL | let _ = ap.with_copy(|ap| { ap });
| ^^
|
note: first, the lifetime cannot outlive the anonymous lifetime #2 defined on the body at 16:21...
--> $DIR/variadic-ffi-4.rs:16:21
note: first, the lifetime cannot outlive the anonymous lifetime #2 defined on the body at 16:26...
--> $DIR/variadic-ffi-4.rs:16:26
|
LL | let _ = ap.copy(|ap| { ap });
| ^^^^^^^^^^^
LL | let _ = ap.with_copy(|ap| { ap });
| ^^^^^^^^^^^
= note: ...so that the expression is assignable:
expected core::ffi::VaList<'_>
found core::ffi::VaList<'_>
note: but, the lifetime must be valid for the method call at 16:13...
--> $DIR/variadic-ffi-4.rs:16:13
|
LL | let _ = ap.copy(|ap| { ap });
| ^^^^^^^^^^^^^^^^^^^^
LL | let _ = ap.with_copy(|ap| { ap });
| ^^^^^^^^^^^^^^^^^^^^^^^^^
note: ...so type `core::ffi::VaList<'_>` of expression is valid during the expression
--> $DIR/variadic-ffi-4.rs:16:13
|
LL | let _ = ap.copy(|ap| { ap });
| ^^^^^^^^^^^^^^^^^^^^
LL | let _ = ap.with_copy(|ap| { ap });
| ^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0308]: mismatched types
--> $DIR/variadic-ffi-4.rs:20:12
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/c-variadic/variadic-ffi-5.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub unsafe extern "C" fn no_escape1(_: usize, ap: ...) -> VaList<'static> {
}

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

pub unsafe extern "C" fn no_escape3(_: usize, ap0: &mut VaList, mut ap1: ...) {
Expand Down
12 changes: 6 additions & 6 deletions src/test/ui/c-variadic/variadic-ffi-5.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ LL | ap
| ^^ lifetime `'static` required

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

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