Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
gpui: Make MacPlatform::os_version infallible (#29008)
tidely1e0ae35f6964
diff --git a/crates/gpui/src/platform/mac/platform.rs b/crates/gpui/src/platform/mac/platform.rsindex 759e5462d0b..02c12ab8c25 100644--- a/crates/gpui/src/platform/mac/platform.rs+++ b/crates/gpui/src/platform/mac/platform.rs@@ -353,8 +353,7 @@ impl MacPlatform {ns_string(key_to_native(&keystroke.key).as_ref()),).autorelease();- if MacPlatform::os_version().unwrap() >= SemanticVersion::new(12, 0, 0)- {+ if Self::os_version() >= SemanticVersion::new(12, 0, 0) {let _: () = msg_send![item, setAllowsAutomaticKeyEquivalentLocalization: NO];}item.setKeyEquivalentModifierMask_(mask);@@ -402,16 +401,16 @@ impl MacPlatform {}}- fn os_version() -> Result<SemanticVersion> {- unsafe {+ fn os_version() -> SemanticVersion {+ let version = unsafe {let process_info = NSProcessInfo::processInfo(nil);- let version = process_info.operatingSystemVersion();- Ok(SemanticVersion::new(- version.majorVersion as usize,- version.minorVersion as usize,- version.patchVersion as usize,- ))- }+ process_info.operatingSystemVersion()+ };+ SemanticVersion::new(+ version.majorVersion as usize,+ version.minorVersion as usize,+ version.patchVersion as usize,+ )}}@@ -609,7 +608,7 @@ impl Platform for MacPlatform {// API only available post Monterey// https://developer.apple.com/documentation/appkit/nsworkspace/3753004-setdefaultapplicationaturllet (done_tx, done_rx) = oneshot::channel();- if Self::os_version().ok() < Some(SemanticVersion::new(12, 0, 0)) {+ if Self::os_version() < SemanticVersion::new(12, 0, 0) {return Task::ready(Err(anyhow!("macOS 12.0 or later is required to register URL schemes")));@@ -736,9 +735,7 @@ impl Platform for MacPlatform {// you can manually create a file called `a.sql.s`. That said it seems better// to break that use-case than breaking `a.sql`.if chunks.len() == 3 && chunks[1].starts_with(chunks[2]) {- if Self::os_version()- .is_ok_and(|v| v >= SemanticVersion::new(15, 0, 0))- {+ if Self::os_version() >= SemanticVersion::new(15, 0, 0) {let new_filename = OsStr::from_bytes(&filename.as_bytes()[..chunks[0].len() + 1 + chunks[1].len()],