Skip to content

Commit 5be6c94

Browse files
cjlongoriafacebook-github-bot
authored andcommitted
rust edition 2024 compatibility changes for fbcode
Summary: X-link: meta-pytorch/monarch#84 X-link: meta-pytorch/monarch#71 applying changes to make the code compatible with both 2021 and 2024 rust editions Reviewed By: dtolnay Differential Revision: D75642573 fbshipit-source-id: 8b5606574940cddb60f35d2a6321412df2552868
1 parent 8c38e9a commit 5be6c94

File tree

12 files changed

+35
-12
lines changed

12 files changed

+35
-12
lines changed

eden/scm/exec/hgmain/src/buildinfo.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77

88
#[cfg(feature = "buildinfo")]
99
#[link(name = "buildinfo", kind = "static")]
10-
extern "C" {
10+
unsafe extern "C" {
1111
pub fn print_buildinfo();
1212
}

eden/scm/lib/commandserver/src/client.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,14 +153,14 @@ fn forward_signals(props: &ProcessProps) {
153153
static PID: AtomicU32 = AtomicU32::new(0);
154154
static PGID: AtomicU32 = AtomicU32::new(0);
155155

156-
extern "C" fn forward_signal_process(sig: libc::c_int) {
156+
unsafe extern "C" fn forward_signal_process(sig: libc::c_int) {
157157
let pid = PID.load(Ordering::Acquire);
158158
if pid > 0 {
159159
unsafe { libc::kill(pid as i32, sig) };
160160
}
161161
}
162162

163-
extern "C" fn forward_signal_group(sig: libc::c_int) {
163+
unsafe extern "C" fn forward_signal_group(sig: libc::c_int) {
164164
let pgid = PGID.load(Ordering::Acquire);
165165
if pgid > 1 {
166166
unsafe { libc::kill(-(pgid as i32), sig) };

eden/scm/lib/procinfo/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77

88
#[cfg(target_os = "macos")]
9-
extern "C" {
9+
unsafe extern "C" {
1010
fn darwin_ppid(pid: u32) -> u32;
1111
fn darwin_exepath(pid: u32) -> *const libc::c_char;
1212
}

eden/scm/lib/third-party/conch-parser/BUCK

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ rust_library(
1414
},
1515
},
1616
},
17+
edition = "2021",
1718
deps = [
1819
"fbsource//third-party/rust:serde",
1920
"fbsource//third-party/rust:void",

eden/scm/lib/third-party/streampager/BUCK

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ rust_library(
4343
"version": "0.11.0",
4444
},
4545
}},
46+
edition = "2021",
4647
features = ["toml_config"],
4748
deps = [
4849
"fbsource//third-party/rust:dirs",

eden/scm/lib/third-party/webview-sys/BUCK

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ rust_library(
5454
"ovr_config//os:macos",
5555
],
5656
doctests = False,
57+
edition = "2021",
5758
os_deps = [
5859
(
5960
"macos",
@@ -100,5 +101,6 @@ rust_binary(
100101
"ovr_config//os:macos",
101102
],
102103
crate_root = "examples/example.rs",
104+
edition = "2021",
103105
deps = [":webview-sys"],
104106
)

eden/scm/lib/webview-app/BUCK

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ rust_library(
1616
},
1717
}},
1818
crate_root = "src/lib.rs",
19+
edition = "2021",
1920
os_deps = [
2021
(
2122
"macos",

eden/scm/lib/xdiff-sys/src/bin/xdiff-sys-bin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use xdiff_sys::xdemitconf_t;
2222
use xdiff_sys::xdl_diff_vendored;
2323
use xdiff_sys::xpparam_t;
2424

25-
extern "C" fn hunk_func(a1: i64, a2: i64, b1: i64, b2: i64, _priv: *mut c_void) -> c_int {
25+
unsafe extern "C" fn hunk_func(a1: i64, a2: i64, b1: i64, b2: i64, _priv: *mut c_void) -> c_int {
2626
println!("@@ -{},{} +{},{} @@", a1, a2, b1, b2);
2727
0
2828
}

eden/scm/lib/xdiff-sys/src/lib.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,13 @@ mod tests {
2323

2424
#[test]
2525
fn test_xdl_diff_vendored() {
26-
extern "C" fn hunk_func(a1: i64, a2: i64, b1: i64, b2: i64, _priv: *mut c_void) -> c_int {
26+
unsafe extern "C" fn hunk_func(
27+
a1: i64,
28+
a2: i64,
29+
b1: i64,
30+
b2: i64,
31+
_priv: *mut c_void,
32+
) -> c_int {
2733
let mut _priv = unsafe { (_priv as *mut Vec<(i64, i64, i64, i64)>).as_mut() };
2834
if let Some(result) = _priv {
2935
result.push((a1, a2, b1, b2));

eden/scm/lib/xdiff/src/lib.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,13 @@ pub fn diff_hunks<T>(old_text: T, new_text: T) -> Vec<Hunk>
6868
where
6969
T: AsRef<[u8]>,
7070
{
71-
extern "C" fn hunk_consumer(a1: i64, a2: i64, b1: i64, b2: i64, _priv: *mut c_void) -> c_int {
71+
unsafe extern "C" fn hunk_consumer(
72+
a1: i64,
73+
a2: i64,
74+
b1: i64,
75+
b2: i64,
76+
_priv: *mut c_void,
77+
) -> c_int {
7278
let mut _priv = unsafe { (_priv as *mut Vec<Hunk>).as_mut() };
7379
let a1 = a1 as usize;
7480
let a2 = a2 as usize;
@@ -116,7 +122,13 @@ where
116122
/// Produce matching blocks, in (a1, a2, b1, b2) format.
117123
/// `a_lines[a1:a2]` matches `b_lines[b1:b2]`.
118124
pub fn blocks(a: &[u8], b: &[u8]) -> Vec<(u64, u64, u64, u64)> {
119-
extern "C" fn hunk_consumer(a1: i64, a2: i64, b1: i64, b2: i64, blocks: *mut c_void) -> c_int {
125+
unsafe extern "C" fn hunk_consumer(
126+
a1: i64,
127+
a2: i64,
128+
b1: i64,
129+
b2: i64,
130+
blocks: *mut c_void,
131+
) -> c_int {
120132
let blocks = unsafe { (blocks as *mut Vec<(u64, u64, u64, u64)>).as_mut() };
121133
if let Some(blocks) = blocks {
122134
blocks.push((a1 as _, a2 as _, b1 as _, b2 as _));

0 commit comments

Comments
 (0)