Skip to content

Commit 524eec6

Browse files
authored
build: update to rust 1.84.0 (#394)
* build: update to rust 1.84.0 * fix more lints
1 parent 87ee68e commit 524eec6

File tree

22 files changed

+88
-93
lines changed

22 files changed

+88
-93
lines changed

.github/workflows/rust.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
- name: Install dependencies (macOS)
3030
if: runner.os == 'Macos'
3131
run: brew install protobuf fish shellcheck
32-
- uses: dtolnay/rust-toolchain@1.83.0
32+
- uses: dtolnay/rust-toolchain@1.84.0
3333
id: toolchain
3434
with:
3535
components: clippy

crates/alacritty_terminal/src/ansi.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,7 @@ fn parse_number(input: &[u8]) -> Option<u8> {
109109
for c in input {
110110
let c = *c as char;
111111
if let Some(digit) = c.to_digit(10) {
112-
num = match num.checked_mul(10).and_then(|v| v.checked_add(digit as u8)) {
113-
Some(v) => v,
114-
None => return None,
115-
}
112+
num = num.checked_mul(10).and_then(|v| v.checked_add(digit as u8))?;
116113
} else {
117114
return None;
118115
}
@@ -1012,7 +1009,7 @@ where
10121009
match (action, intermediates) {
10131010
('s', [b'=']) => {
10141011
// Start a synchronized update. The end is handled with a separate parser.
1015-
if params.iter().next().map_or(false, |param| param[0] == 1) {
1012+
if params.iter().next().is_some_and(|param| param[0] == 1) {
10161013
self.state.dcs = Some(Dcs::SyncStart);
10171014
}
10181015
},

crates/amzn-toolkit-telemetry/src/config/endpoint.rs

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ pub use ::aws_smithy_runtime_api::client::endpoint::{
55
};
66
pub use ::aws_smithy_types::endpoint::Endpoint;
77

8-
///
98
#[cfg(test)]
109
mod test {}
1110

crates/fig_api_client/src/error.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,14 @@ impl Error {
5555
pub fn is_throttling_error(&self) -> bool {
5656
match self {
5757
Error::Credentials(_) => false,
58-
Error::GenerateCompletions(e) => e.as_service_error().map_or(false, |e| e.is_throttling_error()),
59-
Error::GenerateRecommendations(e) => e.as_service_error().map_or(false, |e| e.is_throttling_error()),
60-
Error::ListAvailableCustomizations(e) => e.as_service_error().map_or(false, |e| e.is_throttling_error()),
61-
Error::ListAvailableServices(e) => e.as_service_error().map_or(false, |e| e.is_throttling_error()),
58+
Error::GenerateCompletions(e) => e.as_service_error().is_some_and(|e| e.is_throttling_error()),
59+
Error::GenerateRecommendations(e) => e.as_service_error().is_some_and(|e| e.is_throttling_error()),
60+
Error::ListAvailableCustomizations(e) => e.as_service_error().is_some_and(|e| e.is_throttling_error()),
61+
Error::ListAvailableServices(e) => e.as_service_error().is_some_and(|e| e.is_throttling_error()),
6262
Error::CodewhispererGenerateAssistantResponse(e) => {
63-
e.as_service_error().map_or(false, |e| e.is_throttling_error())
63+
e.as_service_error().is_some_and(|e| e.is_throttling_error())
6464
},
65-
Error::QDeveloperSendMessage(e) => e.as_service_error().map_or(false, |e| e.is_throttling_error()),
65+
Error::QDeveloperSendMessage(e) => e.as_service_error().is_some_and(|e| e.is_throttling_error()),
6666
Error::CodewhispererChatResponseStream(_)
6767
| Error::QDeveloperChatResponseStream(_)
6868
| Error::SmithyBuild(_)

crates/fig_auth/src/builder_id.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ pub async fn refresh_token() -> Result<Option<BuilderIdToken>> {
547547
}
548548

549549
pub async fn is_amzn_user() -> Result<bool> {
550-
Ok(builder_id_token().await?.map_or(false, |t| t.is_amzn_user()))
550+
Ok(builder_id_token().await?.is_some_and(|t| t.is_amzn_user()))
551551
}
552552

553553
pub async fn is_logged_in() -> bool {

crates/fig_desktop/src/main.rs

+52-48
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ mod utils;
1616
mod webview;
1717

1818
use std::path::Path;
19-
use std::process::exit;
19+
use std::process::ExitCode;
2020
use std::sync::{
2121
Arc,
2222
RwLock,
@@ -84,7 +84,7 @@ pub type EventLoopProxy = WryEventLoopProxy<Event>;
8484
pub type EventLoopWindowTarget = WryEventLoopWindowTarget<Event>;
8585

8686
#[tokio::main]
87-
async fn main() {
87+
async fn main() -> ExitCode {
8888
let cli = cli::Cli::parse();
8989

9090
let _log_guard = initialize_logging(LogArgs {
@@ -109,33 +109,13 @@ async fn main() {
109109
}
110110

111111
if cli.is_startup && !fig_settings::settings::get_bool_or("app.launchOnStartup", true) {
112-
std::process::exit(0);
112+
return ExitCode::SUCCESS;
113113
}
114114

115-
let page = cli
116-
.url_link
117-
.as_ref()
118-
.and_then(|url| match Url::parse(url) {
119-
Ok(url) => Some(url),
120-
Err(err) => {
121-
error!(%err, %url, "Failed to parse url");
122-
exit(1)
123-
},
124-
})
125-
.and_then(|url| {
126-
if url.scheme() != URL_SCHEMA {
127-
error!(scheme = %url.scheme(), %url, "Invalid scheme");
128-
exit(1)
129-
}
130-
131-
url.host_str().and_then(|s| match s {
132-
"dashboard" => Some(url.path().to_owned()),
133-
_ => {
134-
error!("Invalid deep link");
135-
None
136-
},
137-
})
138-
});
115+
let page = match parse_url_page(cli.url_link.as_deref()) {
116+
Ok(page) => page,
117+
Err(exit_code) => return exit_code,
118+
};
139119

140120
if !cli.allow_multiple {
141121
match get_current_pid() {
@@ -157,22 +137,11 @@ async fn main() {
157137
)
158138
.show();
159139

160-
return;
140+
return ExitCode::FAILURE;
161141
}
162142
}
163143
}
164144

165-
// tokio::spawn(async {
166-
// fig_telemetry::emit_track(fig_telemetry::TrackEvent::new(
167-
// fig_telemetry::TrackEventType::LaunchedApp,
168-
// fig_telemetry::TrackSource::Desktop,
169-
// env!("CARGO_PKG_VERSION").into(),
170-
// empty::<(&str, &str)>(),
171-
// ))
172-
// .await
173-
// .ok();
174-
// });
175-
176145
let ctx = Context::new();
177146
install::run_install(Arc::clone(&ctx), cli.ignore_immediate_update).await;
178147

@@ -226,18 +195,49 @@ async fn main() {
226195

227196
webview_manager.run().await.unwrap();
228197
fig_telemetry::finish_telemetry().await;
198+
ExitCode::SUCCESS
199+
}
200+
201+
fn parse_url_page(url: Option<&str>) -> Result<Option<String>, ExitCode> {
202+
let Some(url) = url else {
203+
return Ok(None);
204+
};
205+
206+
let url = match Url::parse(url) {
207+
Ok(url) => url,
208+
Err(err) => {
209+
error!(%err, %url, "Failed to parse url");
210+
return Err(ExitCode::FAILURE);
211+
},
212+
};
213+
214+
if url.scheme() != URL_SCHEMA {
215+
error!(scheme = %url.scheme(), %url, "Invalid scheme");
216+
return Err(ExitCode::FAILURE);
217+
}
218+
219+
Ok(url.host_str().and_then(|s| match s {
220+
"dashboard" => Some(url.path().to_owned()),
221+
_ => {
222+
error!("Invalid deep link");
223+
None
224+
},
225+
}))
229226
}
230227

231228
#[cfg(target_os = "linux")]
232-
async fn allow_multiple_running_check(current_pid: sysinfo::Pid, kill_old: bool, page: Option<String>) {
229+
async fn allow_multiple_running_check(
230+
current_pid: sysinfo::Pid,
231+
kill_old: bool,
232+
page: Option<String>,
233+
) -> Option<ExitCode> {
233234
use std::ffi::OsString;
234235

235236
use tracing::debug;
236237

237238
if kill_old {
238239
eprintln!("Option kill-old is not supported on Linux.");
239-
#[allow(clippy::exit)]
240-
exit(0);
240+
return Some(ExitCode::SUCCESS);
241241
}
242242

243243
let system = System::new_with_specifics(
@@ -278,16 +278,20 @@ async fn allow_multiple_running_check(current_pid: sysinfo::Pid, kill_old: bool,
278278
eprintln!("Failed to open Fig: {err}");
279279
}
280280

281-
#[allow(clippy::exit)]
282-
exit(0);
281+
return Some(ExitCode::SUCCESS);
283282
},
284283
_ => (),
285284
}
286285
}
286+
None
287287
}
288288

289289
#[cfg(target_os = "macos")]
290-
async fn allow_multiple_running_check(current_pid: sysinfo::Pid, kill_old: bool, page: Option<String>) {
290+
async fn allow_multiple_running_check(
291+
current_pid: sysinfo::Pid,
292+
kill_old: bool,
293+
page: Option<String>,
294+
) -> Option<ExitCode> {
291295
use std::ffi::OsString;
292296

293297
let app_process_name = OsString::from(APP_PROCESS_NAME);
@@ -341,21 +345,21 @@ async fn allow_multiple_running_check(current_pid: sysinfo::Pid, kill_old: bool,
341345
{
342346
eprintln!("Failed to open Fig: {err}");
343347
}
344-
345-
#[allow(clippy::exit)]
346-
exit(0);
347348
};
348349

349350
match (process.user_id().map(|uid| uid as &u32), current_user_id.as_ref()) {
350351
(Some(uid), Some(current_uid)) if uid == current_uid => {
351352
on_match.await;
353+
return Some(ExitCode::SUCCESS);
352354
},
353355
(_, None) => {
354356
on_match.await;
357+
return Some(ExitCode::SUCCESS);
355358
},
356359
_ => {},
357360
}
358361
}
359362
}
360363
}
364+
None
361365
}

crates/fig_desktop/src/platform/macos.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ impl PlatformStateImpl {
489489
// Checking if IME is installed is async :(
490490
let enabled_proxy = self.proxy.clone();
491491
tokio::spawn(async move {
492-
let is_terminal_disabled = current_terminal.as_ref().map_or(false, |terminal| {
492+
let is_terminal_disabled = current_terminal.as_ref().is_some_and(|terminal| {
493493
fig_settings::settings::get_bool_or(
494494
format!("integrations.{}.disabled", terminal.internal_id()),
495495
false,
@@ -558,7 +558,7 @@ impl PlatformStateImpl {
558558
let dashboard_visible = dashboard_visible.unwrap_or_else(|| {
559559
window_map
560560
.get(&DASHBOARD_ID)
561-
.map_or(false, |window| window.window.is_visible())
561+
.is_some_and(|window| window.window.is_visible())
562562
});
563563

564564
if dashboard_visible {

crates/fig_desktop/src/protocol/icons.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ pub async fn process_asset(path: PathBuf) -> Result<ProcessedAsset> {
114114
let is_svg = path
115115
.extension()
116116
.and_then(OsStr::to_str)
117-
.map_or(true, |ext| ext.to_lowercase() == "svg");
117+
.is_none_or(|ext| ext.to_lowercase() == "svg");
118118

119119
let built = if is_svg {
120120
(Arc::new(tokio::fs::read(&path).await?.into()), AssetKind::Svg)

crates/fig_desktop/src/remote_ipc/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ impl fig_remote_ipc::RemoteHookHandler for RemoteHook {
8080
let current_session_expired = session
8181
.current_session_metrics
8282
.as_ref()
83-
.map_or(false, |metrics| received_at > metrics.end_time + Duration::from_secs(5));
83+
.is_some_and(|metrics| received_at > metrics.end_time + Duration::from_secs(5));
8484

8585
if current_session_expired {
8686
let previous = session.current_session_metrics.clone();

crates/fig_desktop/src/utils.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,7 @@ where
7676
.headers()
7777
.get("Accept")
7878
.and_then(|accept| accept.to_str().ok())
79-
.and_then(|accept| accept.split('/').last())
80-
.map_or(false, |accept| accept == "json");
79+
.is_some_and(|accept| accept.split('/').last() == Some("json"));
8180

8281
let mut response = match f(ctx_clone, req, window_id.window_id()).in_current_span().await {
8382
Ok(res) => res,

crates/fig_desktop_api/src/init_script.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ impl Constants {
113113
new_uri_format: true,
114114
support_api_proto,
115115
api_proto_url: "api://localhost".to_string(),
116-
midway: midway_cookie_path().map_or(false, |p| p.is_file()),
116+
midway: midway_cookie_path().is_ok_and(|p| p.is_file()),
117117
#[cfg(target_os = "macos")]
118118
macos_version: macos_utils::os::OperatingSystemVersion::get().to_string(),
119119
#[cfg(target_os = "linux")]

crates/fig_os_shim/src/env.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ impl Env {
142142

143143
pub fn in_cloudshell(&self) -> bool {
144144
self.get("AWS_EXECUTION_ENV")
145-
.map_or(false, |v| v.trim().eq_ignore_ascii_case("cloudshell"))
145+
.is_ok_and(|v| v.trim().eq_ignore_ascii_case("cloudshell"))
146146
}
147147

148148
pub fn in_ssh(&self) -> bool {

crates/fig_util/src/terminal.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ impl Terminal {
446446
| Terminal::Zed
447447
| Terminal::Rio
448448
| Terminal::Ghostty
449-
) || self.as_custom().map_or(false, |c| c.macos.input_method)
449+
) || self.as_custom().is_some_and(|c| c.macos.input_method)
450450
}
451451

452452
pub fn supports_macos_accessibility(&self) -> bool {
@@ -459,7 +459,7 @@ impl Terminal {
459459
| Terminal::VSCodium
460460
| Terminal::Hyper
461461
| Terminal::Tabby
462-
) || self.as_custom().map_or(false, |c| c.macos.accessibility)
462+
) || self.as_custom().is_some_and(|c| c.macos.accessibility)
463463
}
464464

465465
pub fn is_xterm(&self) -> bool {
@@ -473,7 +473,7 @@ impl Terminal {
473473
| Terminal::Cursor
474474
| Terminal::CursorNightly
475475
| Terminal::Windsurf
476-
) || self.as_custom().map_or(false, |c| c.macos.xterm)
476+
) || self.as_custom().is_some_and(|c| c.macos.xterm)
477477
}
478478

479479
pub fn executable_names(&self) -> &'static [&'static str] {

crates/figterm/src/main.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -320,9 +320,9 @@ where
320320
Some(at) => {
321321
let lock_expired = at.elapsed().unwrap_or(Duration::ZERO) > Duration::from_millis(16);
322322
let should_unlock = lock_expired
323-
|| term.get_current_buffer().map_or(true, |buff| {
324-
&buff.buffer == (&EXPECTED_BUFFER.lock().unwrap() as &String)
325-
});
323+
|| term
324+
.get_current_buffer()
325+
.is_none_or(|buff| &buff.buffer == (&EXPECTED_BUFFER.lock().unwrap() as &String));
326326
if should_unlock {
327327
handle.take();
328328
if lock_expired {

crates/q_cli/src/util/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ pub async fn is_brew_reinstall() -> bool {
310310
.args(["aux", "-o", "args"])
311311
.output()
312312
.await
313-
.map_or(false, |output| regex.is_match(&output.stdout))
313+
.is_ok_and(|output| regex.is_match(&output.stdout))
314314
}
315315

316316
#[cfg(test)]

crates/shell-color/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ pub struct SuggestionColor {
1010

1111
impl SuggestionColor {
1212
pub fn fg(&self) -> Option<VTermColor> {
13-
self.fg.clone().map(VTermColor::from)
13+
self.fg.clone()
1414
}
1515

1616
pub fn bg(&self) -> Option<VTermColor> {
17-
self.bg.clone().map(VTermColor::from)
17+
self.bg.clone()
1818
}
1919
}
2020

crates/zbus/src/abstractions/executor.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ pub struct Executor<'a> {
3737
phantom: PhantomData<&'a ()>,
3838
}
3939

40-
impl<'a> Executor<'a> {
40+
impl Executor<'_> {
4141
/// Spawns a task onto the executor.
4242
#[doc(hidden)]
4343
pub fn spawn<T: Send + 'static>(

crates/zbus/src/address/transport/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -267,10 +267,10 @@ pub(crate) fn decode_percents(value: &str) -> Result<Vec<u8>> {
267267
decoded.push(c as u8);
268268
} else if c == '%' {
269269
decoded.push(
270-
decode_hex(
270+
(decode_hex(
271271
iter.next()
272272
.ok_or_else(|| Error::Address("incomplete percent-encoded sequence".to_owned()))?,
273-
)? << 4
273+
)? << 4)
274274
| decode_hex(
275275
iter.next()
276276
.ok_or_else(|| Error::Address("incomplete percent-encoded sequence".to_owned()))?,

0 commit comments

Comments
 (0)