From 00784248db804fbc1b0e6fa24a25f627a7666ff8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20H=C3=B8rl=C3=BCck=20Berg?= <36937807+henrikhorluck@users.noreply.github.com> Date: Wed, 22 Oct 2025 18:56:03 +0200 Subject: [PATCH] Update to rust 2024 edition This bravely avoids changing expr to expr_2021 in macros, which seems extremely unlikely to be silently breaking anything. See: https://doc.rust-lang.org/edition-guide/rust-2024/macro-fragment-specifiers.html I do not believe we have any macros where this is relevant Part of #11990 --- Cargo.toml | 2 +- build.rs | 9 ++++--- src/ast.rs | 6 ++--- src/builtins/bg.rs | 6 ++--- src/builtins/function.rs | 6 ++--- src/builtins/jobs.rs | 6 ++--- src/complete.rs | 2 +- src/env/environment_impl.rs | 6 ++--- src/env_dispatch.rs | 4 +-- src/event.rs | 6 ++--- src/expand.rs | 24 ++++++++--------- src/fallback.rs | 4 +-- src/locale.rs | 45 ++++++++++++++++++------------- src/parse_util.rs | 8 +++--- src/reader.rs | 8 +++--- src/signal.rs | 12 ++++----- src/tests/topic_monitor.rs | 4 +-- src/threads.rs | 6 ++--- src/topic_monitor.rs | 10 +++---- src/universal_notifier/notifyd.rs | 8 +++--- src/wutil/tests.rs | 2 +- 21 files changed, 96 insertions(+), 88 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index daf557dc5..2c2d30fa2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,7 @@ members = ["crates/*"] [workspace.package] # To build revisions that use Corrosion (those before 2024-01), use CMake 3.19, Rustc 1.78 and Rustup 1.27. rust-version = "1.85" -edition = "2021" +edition = "2024" repository = "https://github.com/fish-shell/fish-shell" [workspace.dependencies] diff --git a/build.rs b/build.rs index dd4a3416f..9dacdb103 100644 --- a/build.rs +++ b/build.rs @@ -37,7 +37,8 @@ fn main() { // the source directory is the current working directory of the build script rsconf::set_env_value("FISH_BUILD_VERSION", version); - std::env::set_var("FISH_BUILD_VERSION", version); + // safety: single-threaded code. + unsafe { std::env::set_var("FISH_BUILD_VERSION", version) }; // These are necessary if built with embedded functions, // but only in release builds (because rust-embed in debug builds reads from the filesystem). @@ -159,9 +160,9 @@ fn has_small_stack(_: &Target) -> bool { { use core::ffi; - extern "C" { - fn pthread_get_stacksize_np(thread: *const ffi::c_void) -> usize; - fn pthread_self() -> *const ffi::c_void; + unsafe extern "C" { + unsafe fn pthread_get_stacksize_np(thread: *const ffi::c_void) -> usize; + unsafe fn pthread_self() -> *const ffi::c_void; } // build.rs is executed on the main thread, so we are getting the main thread's stack size. diff --git a/src/ast.rs b/src/ast.rs index e11191ba9..e5fb4e6cd 100644 --- a/src/ast.rs +++ b/src/ast.rs @@ -2350,7 +2350,7 @@ fn populate_list(&mut self, list: &mut List, exhaust_stream: boo self.chomp_extras(list.kind()); // Now try parsing a node. - if let Some(node) = self.try_parse::() { + match self.try_parse::() { Some(node) => { // #7201: Minimize reallocations of contents vector // Empirically, 99.97% of cases are 16 elements or fewer, // with 75% being empty, so this works out best. @@ -2358,14 +2358,14 @@ fn populate_list(&mut self, list: &mut List, exhaust_stream: boo contents.reserve(16); } contents.push(node); - } else if exhaust_stream && self.peek_type(0) != ParseTokenType::terminate { + } _ => if exhaust_stream && self.peek_type(0) != ParseTokenType::terminate { // We aren't allowed to stop. Produce an error and keep going. self.consume_excess_token_generating_error() } else { // We either stop once we can't parse any more of this contents node, or we // exhausted the stream as requested. break; - } + }} } // Populate our list from our contents. diff --git a/src/builtins/bg.rs b/src/builtins/bg.rs index 9955d6a50..cf3c70cfc 100644 --- a/src/builtins/bg.rs +++ b/src/builtins/bg.rs @@ -96,15 +96,15 @@ pub fn bg(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) -> Built // Non-existent jobs aren't an error, but information about them is useful. let mut seen = HashSet::new(); for pid in pids { - if let Some((job_pos, job)) = parser.job_get_with_index_from_pid(pid) { + match parser.job_get_with_index_from_pid(pid) { Some((job_pos, job)) => { if seen.insert(&*job as *const _) { send_to_bg(parser, streams, cmd, job_pos)?; } - } else { + } _ => { streams .err .append(wgettext_fmt!("%s: Could not find job '%d'\n", cmd, pid)); - } + }} } return Ok(SUCCESS); diff --git a/src/builtins/function.rs b/src/builtins/function.rs index 477fcf4cb..2d700ede3 100644 --- a/src/builtins/function.rs +++ b/src/builtins/function.rs @@ -59,14 +59,14 @@ fn default() -> Self { /// Return the internal_job_id for a pid, or None if none. /// This looks through both active and finished jobs. fn job_id_for_pid(pid: Pid, parser: &Parser) -> Option { - if let Some(job) = parser.job_get_from_pid(pid) { + match parser.job_get_from_pid(pid) { Some(job) => { Some(job.internal_job_id) - } else { + } _ => { parser .get_wait_handles() .get_by_pid(pid) .map(|h| h.internal_job_id) - } + }} } /// Parses options to builtin function, populating opts. diff --git a/src/builtins/jobs.rs b/src/builtins/jobs.rs index d43d0a704..e72e043a6 100644 --- a/src/builtins/jobs.rs +++ b/src/builtins/jobs.rs @@ -218,17 +218,17 @@ pub fn jobs(parser: &Parser, streams: &mut IoStreams, argv: &mut [&wstr]) -> Bui j = parser.job_get_from_pid(pid) } - if let Some(j) = j.filter(|j| !j.is_completed() && j.is_constructed()) { + match j.filter(|j| !j.is_completed() && j.is_constructed()) { Some(j) => { builtin_jobs_print(&j, mode, false, streams); found = true; - } else { + } _ => { if mode != JobsPrintMode::PrintNothing { streams .err .append(wgettext_fmt!("%s: No suitable job: %s\n", cmd, arg)); } return Err(STATUS_CMD_ERROR); - } + }} } } else { for j in &parser.jobs()[..] { diff --git a/src/complete.rs b/src/complete.rs index de20bc3c9..10a2da511 100644 --- a/src/complete.rs +++ b/src/complete.rs @@ -1855,7 +1855,7 @@ fn getpwent_name() -> Option { fn apply_var_assignments>( &mut self, var_assignments: &[T], - ) -> Option> { + ) -> Option>> { if !self.ctx.has_parser() || var_assignments.is_empty() { return None; } diff --git a/src/env/environment_impl.rs b/src/env/environment_impl.rs index 477b4c463..3ef6f4b1e 100644 --- a/src/env/environment_impl.rs +++ b/src/env/environment_impl.rs @@ -585,8 +585,8 @@ fn export_array_needs_regeneration(&self) -> bool { let mut cursor = self.export_array_generations.iter().fuse(); let mut mismatch = false; - self.enumerate_generations(|gen| { - if cursor.next().cloned() != Some(gen) { + self.enumerate_generations(|r#gen| { + if cursor.next().cloned() != Some(r#gen) { mismatch = true; } }); @@ -657,7 +657,7 @@ pub fn export_array(&mut self) -> Arc { // Have to pull this into a local to satisfy the borrow checker. let mut generations = std::mem::take(&mut self.export_array_generations); - self.enumerate_generations(|gen| generations.push(gen)); + self.enumerate_generations(|r#gen| generations.push(r#gen)); self.export_array_generations = generations; } return self.export_array.as_ref().unwrap().clone(); diff --git a/src/env_dispatch.rs b/src/env_dispatch.rs index ce5264f4d..bc03cf765 100644 --- a/src/env_dispatch.rs +++ b/src/env_dispatch.rs @@ -148,8 +148,8 @@ fn handle_timezone(var_name: &wstr, vars: &EnvStack) { unsetenv_lock(var_name); } - extern "C" { - fn tzset(); + unsafe extern "C" { + unsafe fn tzset(); } unsafe { diff --git a/src/event.rs b/src/event.rs index 4faa75748..708b665d8 100644 --- a/src/event.rs +++ b/src/event.rs @@ -386,11 +386,11 @@ pub fn get_desc(parser: &Parser, evt: &Event) -> WString { } EventDescription::JobExit { pid, .. } => { if let Some(pid) = pid { - if let Some(job) = parser.job_get_from_pid(*pid) { + match parser.job_get_from_pid(*pid) { Some(job) => { format!("exit handler for job {}, '{}'", job.job_id(), job.command()) - } else { + } _ => { format!("exit handler for job with pid {pid}") - } + }} } else { "exit handler for any job".to_string() } diff --git a/src/expand.rs b/src/expand.rs index 6a25262d1..1f5f19e2d 100644 --- a/src/expand.rs +++ b/src/expand.rs @@ -8,27 +8,27 @@ STATUS_INVALID_ARGS, STATUS_NOT_EXECUTABLE, STATUS_READ_TOO_MUCH, STATUS_UNMATCHED_WILDCARD, }; use crate::common::{ - EXPAND_RESERVED_BASE, EXPAND_RESERVED_END, EscapeFlags, EscapeStringStyle, UnescapeFlags, - UnescapeStringStyle, char_offset, charptr2wcstring, escape, escape_string, - escape_string_for_double_quotes, unescape_string, valid_var_name_char, wcs2zstring, + char_offset, charptr2wcstring, escape, escape_string, escape_string_for_double_quotes, + unescape_string, valid_var_name_char, wcs2zstring, EscapeFlags, EscapeStringStyle, + UnescapeFlags, UnescapeStringStyle, EXPAND_RESERVED_BASE, EXPAND_RESERVED_END, }; use crate::complete::{CompleteFlags, Completion, CompletionList, CompletionReceiver}; use crate::env::{EnvVar, Environment}; use crate::exec::exec_subshell_for_expand; -use crate::future_feature_flags::{FeatureFlag, feature_test}; -use crate::history::{History, history_session_id}; +use crate::future_feature_flags::{feature_test, FeatureFlag}; +use crate::history::{history_session_id, History}; use crate::operation_context::OperationContext; use crate::parse_constants::{ParseError, ParseErrorCode, ParseErrorList, SOURCE_LOCATION_UNKNOWN}; use crate::parse_util::{ - MaybeParentheses, parse_util_expand_variable_error, parse_util_locate_cmdsubst_range, + parse_util_expand_variable_error, parse_util_locate_cmdsubst_range, MaybeParentheses, }; use crate::path::path_apply_working_directory; use crate::util::wcsfilecmp_glob; use crate::wchar::prelude::*; use crate::wcstringutil::{join_strings, trim}; -use crate::wildcard::{ANY_CHAR, ANY_STRING, ANY_STRING_RECURSIVE, WildcardResult}; use crate::wildcard::{wildcard_expand_string, wildcard_has_internal}; -use crate::wutil::{Options, normalize_path, wcstoi_partial}; +use crate::wildcard::{WildcardResult, ANY_CHAR, ANY_STRING, ANY_STRING_RECURSIVE}; +use crate::wutil::{normalize_path, wcstoi_partial, Options}; use bitflags::bitflags; use std::mem::MaybeUninit; @@ -356,7 +356,7 @@ macro_rules! append_syntax_error { $errors:expr, $source_start:expr, $fmt:expr $(, $arg:expr )* $(,)? ) => { - if let Some(ref mut errors) = $errors { + if let Some(ref mut errors) = $errors.as_mut() { let mut error = ParseError::default(); error.source_start = $source_start; error.source_length = 0; @@ -386,7 +386,7 @@ macro_rules! append_cmdsub_error_formatted { $errors:expr, $source_start:expr, $source_end:expr, $text:expr $(,)? ) => { - if let Some(ref mut errors) = $errors { + if let Some(ref mut errors) = $errors.as_mut() { let mut error = ParseError::default(); error.source_start = $source_start; error.source_length = $source_end - $source_start + 1; @@ -404,7 +404,7 @@ fn append_overflow_error( errors: &mut Option<&mut ParseErrorList>, source_start: Option, ) -> ExpandResult { - if let Some(ref mut errors) = errors { + if let Some(errors) = errors { errors.push(ParseError { source_start: source_start.unwrap_or(SOURCE_LOCATION_UNKNOWN), source_length: 0, @@ -623,7 +623,7 @@ fn expand_variables( // It's an error if the name is empty. if var_name.is_empty() { - if let Some(ref mut errors) = errors { + if let Some(errors) = errors { parse_util_expand_variable_error( &instr, 0, /* global_token_pos */ diff --git a/src/fallback.rs b/src/fallback.rs index 9c820716a..5a5499c4c 100644 --- a/src/fallback.rs +++ b/src/fallback.rs @@ -30,8 +30,8 @@ /// A safe wrapper around the system `wcwidth()` function #[cfg(not(cygwin))] pub fn wcwidth(c: char) -> isize { - extern "C" { - pub fn wcwidth(c: libc::wchar_t) -> libc::c_int; + unsafe extern "C" { + pub unsafe fn wcwidth(c: libc::wchar_t) -> libc::c_int; } const _: () = assert!(std::mem::size_of::() >= std::mem::size_of::()); diff --git a/src/locale.rs b/src/locale.rs index 788e14eb2..8404f6810 100644 --- a/src/locale.rs +++ b/src/locale.rs @@ -10,18 +10,20 @@ /// Return the first character of a C string, or None if null, empty, has a length more than 1, or negative. unsafe fn first_char(s: *const libc::c_char) -> Option { - #[allow(unused_comparisons, clippy::absurd_extreme_comparisons)] - if !s.is_null() && *s > 0 && *s <= 127 && *s.offset(1) == 0 { - Some((*s as u8) as char) - } else { - None + unsafe { + #[allow(unused_comparisons, clippy::absurd_extreme_comparisons)] + if !s.is_null() && *s > 0 && *s <= 127 && *s.offset(1) == 0 { + Some((*s as u8) as char) + } else { + None + } } } /// Convert a libc lconv to a Locale. unsafe fn lconv_to_locale(lconv: &libc::lconv) -> Locale { - let decimal_point = first_char(lconv.decimal_point).unwrap_or('.'); - let thousands_sep = first_char(lconv.thousands_sep); + let decimal_point = unsafe { first_char(lconv.decimal_point).unwrap_or('.') }; + let thousands_sep = unsafe { first_char(lconv.thousands_sep) }; let empty = &[0 as libc::c_char]; // Up to 4 groups. @@ -35,7 +37,7 @@ unsafe fn lconv_to_locale(lconv: &libc::lconv) -> Locale { let mut last_group: u8 = 0; let mut group_repeat = false; for group in grouping.iter_mut() { - let gc = *group_cursor; + let gc = unsafe { *group_cursor }; if gc == 0 { // Preserve last_group, do not advance cursor. group_repeat = true; @@ -46,7 +48,7 @@ unsafe fn lconv_to_locale(lconv: &libc::lconv) -> Locale { } else { // Record last group, advance cursor. last_group = gc as u8; - group_cursor = group_cursor.offset(1); + group_cursor = unsafe { group_cursor.offset(1) }; } *group = last_group; } @@ -61,8 +63,8 @@ unsafe fn lconv_to_locale(lconv: &libc::lconv) -> Locale { /// Read the numeric locale, or None on any failure. #[cfg(localeconv_l)] unsafe fn read_locale() -> Option { - extern "C" { - fn localeconv_l(loc: libc::locale_t) -> *const libc::lconv; + unsafe extern "C" { + unsafe fn localeconv_l(loc: libc::locale_t) -> *const libc::lconv; } const empty: [libc::c_char; 1] = [0]; @@ -70,19 +72,20 @@ unsafe fn read_locale() -> Option { // We create a new locale (pass 0 locale_t base) // and pass no "locale", so everything else is taken from the environment. // This is fine because we're only using this for numbers. - let loc = libc::newlocale(libc::LC_NUMERIC_MASK, empty.as_ptr(), 0 as libc::locale_t); + let loc = + unsafe { libc::newlocale(libc::LC_NUMERIC_MASK, empty.as_ptr(), 0 as libc::locale_t) }; if loc.is_null() { return None; } - let lconv = localeconv_l(loc); + let lconv = unsafe { localeconv_l(loc) }; let result = if lconv.is_null() { None } else { - Some(lconv_to_locale(&*lconv)) + Some(unsafe { lconv_to_locale(&*lconv) }) }; - libc::freelocale(loc); + unsafe { libc::freelocale(loc) }; result } @@ -94,16 +97,20 @@ unsafe fn read_locale() -> Option { const empty: [libc::c_char; 1] = [0]; const c_loc_str: [libc::c_char; 2] = [b'C' as libc::c_char, 0]; - libc::setlocale(libc::LC_NUMERIC, empty.as_ptr()); + unsafe { + libc::setlocale(libc::LC_NUMERIC, empty.as_ptr()); + } - let lconv = libc::localeconv(); + let lconv = unsafe { libc::localeconv() }; let result = if lconv.is_null() { None } else { - Some(lconv_to_locale(&*lconv)) + Some(unsafe { lconv_to_locale(&*lconv) }) }; // Note we *always* use a C-locale for numbers, because we always want "." except for in printf. - libc::setlocale(libc::LC_NUMERIC, c_loc_str.as_ptr()); + unsafe { + libc::setlocale(libc::LC_NUMERIC, c_loc_str.as_ptr()); + } result } diff --git a/src/parse_util.rs b/src/parse_util.rs index f70974094..59fb56ef0 100644 --- a/src/parse_util.rs +++ b/src/parse_util.rs @@ -1368,7 +1368,7 @@ macro_rules! append_syntax_error_formatted { $errors:expr, $source_location:expr, $source_length:expr, $text:expr ) => {{ - if let Some(ref mut errors) = $errors { + if let Some(ref mut errors) = $errors.as_mut() { let mut error = ParseError::default(); error.source_start = $source_location; error.source_length = $source_length; @@ -1441,7 +1441,7 @@ pub fn parse_util_detect_errors_in_argument( && !valid_var_name_char(next_char) { err = ParserTestErrorBits::ERROR; - if let Some(ref mut out_errors) = out_errors { + if let Some(out_errors) = out_errors { let mut first_dollar = idx; while first_dollar > 0 && [VARIABLE_EXPAND, VARIABLE_EXPAND_SINGLE] @@ -1504,7 +1504,7 @@ pub fn parse_util_detect_errors_in_argument( // within the string, and the offset of the node. let error_offset = parens.start() + 1 + source_start; parse_error_offset_source_start(&mut subst_errors, error_offset); - if let Some(ref mut out_errors) = out_errors { + if let Some(out_errors) = out_errors { out_errors.extend(subst_errors); } @@ -1817,7 +1817,7 @@ fn detect_errors_in_decorated_statement( } } - if let Some(ref mut parse_errors) = parse_errors { + if let Some(parse_errors) = parse_errors { // The expansion errors here go from the *command* onwards, // so we need to offset them by the *command* offset, // excluding the decoration. diff --git a/src/reader.rs b/src/reader.rs index 315770595..a387a0e48 100644 --- a/src/reader.rs +++ b/src/reader.rs @@ -4844,7 +4844,7 @@ fn get_autosuggestion_performer( command_line: WString, cursor_pos: usize, history: Arc, -) -> impl FnOnce() -> AutosuggestionResult { +) -> impl FnOnce() -> AutosuggestionResult + use<> { let generation_count = read_generation_count(); let vars = parser.vars().snapshot(); let working_directory = parser.vars().get_pwd_slash(); @@ -5207,7 +5207,7 @@ fn get_highlight_performer( parser: &Parser, el: &EditableLine, io_ok: bool, -) -> impl FnOnce() -> HighlightResult { +) -> impl FnOnce() -> HighlightResult + use<> { let vars = parser.vars().snapshot(); let generation_count = read_generation_count(); let position = el.position(); @@ -5794,8 +5794,8 @@ fn check_for_orphaned_process(loop_count: usize, shell_pgid: libc::pid_t) -> boo // Try reading from the tty; if we get EIO we are orphaned. This is sort of bad because it // may block. if !we_think_we_are_orphaned && loop_count % 128 == 0 { - extern "C" { - fn ctermid(buf: *mut c_char) -> *mut c_char; + unsafe extern "C" { + unsafe fn ctermid(buf: *mut c_char) -> *mut c_char; } let tty = unsafe { ctermid(std::ptr::null_mut()) }; if tty.is_null() { diff --git a/src/signal.rs b/src/signal.rs index f776c633f..4973a97a2 100644 --- a/src/signal.rs +++ b/src/signal.rs @@ -310,13 +310,13 @@ pub fn signal_unblock_all() { /// A Sigchecker can be used to check if a SIGINT (or SIGHUP) has been delivered. pub struct SigChecker { topic: Topic, - gen: Generation, + r#gen: Generation, } impl SigChecker { /// Create a new checker for the given topic. pub fn new(topic: Topic) -> Self { - let mut res = SigChecker { topic, gen: 0 }; + let mut res = SigChecker { topic, r#gen: 0 }; // Call check() to update our generation. res.check(); res @@ -331,9 +331,9 @@ pub fn new_sighupint() -> Self { /// was created. pub fn check(&mut self) -> bool { let tm = topic_monitor_principal(); - let gen = tm.generation_for_topic(self.topic); - let changed = self.gen != gen; - self.gen = gen; + let r#gen = tm.generation_for_topic(self.topic); + let changed = self.r#gen != r#gen; + self.r#gen = r#gen; changed } @@ -341,7 +341,7 @@ pub fn check(&mut self) -> bool { pub fn wait(&self) { let tm = topic_monitor_principal(); let gens = GenerationsList::invalid(); - gens.set(self.topic, self.gen); + gens.set(self.topic, self.r#gen); tm.check(&gens, true /* wait */); } } diff --git a/src/tests/topic_monitor.rs b/src/tests/topic_monitor.rs index 06e1135ad..505efa7ec 100644 --- a/src/tests/topic_monitor.rs +++ b/src/tests/topic_monitor.rs @@ -45,8 +45,8 @@ fn test_topic_monitor_torture() { let t2 = Topic::sighupint; let mut gens_list = vec![GenerationsList::invalid(); THREAD_COUNT]; let post_count = Arc::new(AtomicU64::new(0)); - for gen in &mut gens_list { - *gen = monitor.current_generations(); + for r#gen in &mut gens_list { + *r#gen = monitor.current_generations(); post_count.fetch_add(1, Ordering::Relaxed); monitor.post(t1); } diff --git a/src/threads.rs b/src/threads.rs index 56b5178af..2eea141d5 100644 --- a/src/threads.rs +++ b/src/threads.rs @@ -585,16 +585,16 @@ pub fn new(timeout: Duration) -> Self { fn run_next(&self, token: NonZeroU64) -> bool { let request = { let mut data = self.data.lock().expect("Mutex poisoned!"); - if let Some(req) = data.next_req.take() { + match data.next_req.take() { Some(req) => { data.start_time = Instant::now(); req - } else { + } _ => { // There is no pending request. Mark this token as no longer running. if Some(token) == data.active_token { data.active_token = None; } return false; - } + }} }; // Execute request after unlocking the mutex. diff --git a/src/topic_monitor.rs b/src/topic_monitor.rs index 884416b7d..7c08cbc20 100644 --- a/src/topic_monitor.rs +++ b/src/topic_monitor.rs @@ -90,14 +90,14 @@ pub fn invalid() -> GenerationsList { #[allow(dead_code)] fn describe(&self) -> WString { let mut result = WString::new(); - for gen in self.as_array() { + for r#gen in self.as_array() { if !result.is_empty() { result.push(','); } - if gen == INVALID_GENERATION { + if r#gen == INVALID_GENERATION { result.push_str("-1"); } else { - result.push_str(&gen.to_string()); + result.push_str(&r#gen.to_string()); } } return result; @@ -145,8 +145,8 @@ pub fn is_valid(&self, topic: Topic) -> bool { /// Return whether any topic is valid. pub fn any_valid(&self) -> bool { let mut valid = false; - for gen in self.as_array() { - if gen != INVALID_GENERATION { + for r#gen in self.as_array() { + if r#gen != INVALID_GENERATION { valid = true; } } diff --git a/src/universal_notifier/notifyd.rs b/src/universal_notifier/notifyd.rs index df4277b23..2b10d57f6 100644 --- a/src/universal_notifier/notifyd.rs +++ b/src/universal_notifier/notifyd.rs @@ -7,17 +7,17 @@ use std::ffi::CString; use std::os::fd::{BorrowedFd, RawFd}; -extern "C" { - fn notify_register_file_descriptor( +unsafe extern "C" { + unsafe fn notify_register_file_descriptor( name: *const c_char, fd: *mut c_int, flags: c_int, token: *mut c_int, ) -> u32; - fn notify_post(name: *const c_char) -> u32; + unsafe fn notify_post(name: *const c_char) -> u32; - fn notify_cancel(token: c_int) -> c_int; + unsafe fn notify_cancel(token: c_int) -> c_int; } const NOTIFY_STATUS_OK: u32 = 0; diff --git a/src/wutil/tests.rs b/src/wutil/tests.rs index 0cfc139f3..1e362f34b 100644 --- a/src/wutil/tests.rs +++ b/src/wutil/tests.rs @@ -72,7 +72,7 @@ fn test_wwrite_to_fd() { assert!(fd.is_valid()); let mut input = WString::new(); for _i in 0..size { - input.push(rng.gen()); + input.push(rng.r#gen()); } let amt = wwrite_to_fd(&input, fd.fd()).unwrap();