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

build: update to rust 1.84.0 #394

Merged
merged 2 commits into from
Jan 10, 2025
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 .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: Install dependencies (macOS)
if: runner.os == 'Macos'
run: brew install protobuf fish shellcheck
- uses: dtolnay/rust-toolchain@1.83.0
- uses: dtolnay/rust-toolchain@1.84.0
id: toolchain
with:
components: clippy
Expand Down
7 changes: 2 additions & 5 deletions crates/alacritty_terminal/src/ansi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,7 @@ fn parse_number(input: &[u8]) -> Option<u8> {
for c in input {
let c = *c as char;
if let Some(digit) = c.to_digit(10) {
num = match num.checked_mul(10).and_then(|v| v.checked_add(digit as u8)) {
Some(v) => v,
None => return None,
}
num = num.checked_mul(10).and_then(|v| v.checked_add(digit as u8))?;
} else {
return None;
}
Expand Down Expand Up @@ -1012,7 +1009,7 @@ where
match (action, intermediates) {
('s', [b'=']) => {
// Start a synchronized update. The end is handled with a separate parser.
if params.iter().next().map_or(false, |param| param[0] == 1) {
if params.iter().next().is_some_and(|param| param[0] == 1) {
self.state.dcs = Some(Dcs::SyncStart);
}
},
Expand Down
1 change: 0 additions & 1 deletion crates/amzn-toolkit-telemetry/src/config/endpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ pub use ::aws_smithy_runtime_api::client::endpoint::{
};
pub use ::aws_smithy_types::endpoint::Endpoint;

///
#[cfg(test)]
mod test {}

Expand Down
12 changes: 6 additions & 6 deletions crates/fig_api_client/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ impl Error {
pub fn is_throttling_error(&self) -> bool {
match self {
Error::Credentials(_) => false,
Error::GenerateCompletions(e) => e.as_service_error().map_or(false, |e| e.is_throttling_error()),
Error::GenerateRecommendations(e) => e.as_service_error().map_or(false, |e| e.is_throttling_error()),
Error::ListAvailableCustomizations(e) => e.as_service_error().map_or(false, |e| e.is_throttling_error()),
Error::ListAvailableServices(e) => e.as_service_error().map_or(false, |e| e.is_throttling_error()),
Error::GenerateCompletions(e) => e.as_service_error().is_some_and(|e| e.is_throttling_error()),
Error::GenerateRecommendations(e) => e.as_service_error().is_some_and(|e| e.is_throttling_error()),
Error::ListAvailableCustomizations(e) => e.as_service_error().is_some_and(|e| e.is_throttling_error()),
Error::ListAvailableServices(e) => e.as_service_error().is_some_and(|e| e.is_throttling_error()),
Error::CodewhispererGenerateAssistantResponse(e) => {
e.as_service_error().map_or(false, |e| e.is_throttling_error())
e.as_service_error().is_some_and(|e| e.is_throttling_error())
},
Error::QDeveloperSendMessage(e) => e.as_service_error().map_or(false, |e| e.is_throttling_error()),
Error::QDeveloperSendMessage(e) => e.as_service_error().is_some_and(|e| e.is_throttling_error()),
Error::CodewhispererChatResponseStream(_)
| Error::QDeveloperChatResponseStream(_)
| Error::SmithyBuild(_)
Expand Down
2 changes: 1 addition & 1 deletion crates/fig_auth/src/builder_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ pub async fn refresh_token() -> Result<Option<BuilderIdToken>> {
}

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

pub async fn is_logged_in() -> bool {
Expand Down
100 changes: 52 additions & 48 deletions crates/fig_desktop/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ mod utils;
mod webview;

use std::path::Path;
use std::process::exit;
use std::process::ExitCode;
use std::sync::{
Arc,
RwLock,
Expand Down Expand Up @@ -84,7 +84,7 @@ pub type EventLoopProxy = WryEventLoopProxy<Event>;
pub type EventLoopWindowTarget = WryEventLoopWindowTarget<Event>;

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

let _log_guard = initialize_logging(LogArgs {
Expand All @@ -109,33 +109,13 @@ async fn main() {
}

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

let page = cli
.url_link
.as_ref()
.and_then(|url| match Url::parse(url) {
Ok(url) => Some(url),
Err(err) => {
error!(%err, %url, "Failed to parse url");
exit(1)
},
})
.and_then(|url| {
if url.scheme() != URL_SCHEMA {
error!(scheme = %url.scheme(), %url, "Invalid scheme");
exit(1)
}

url.host_str().and_then(|s| match s {
"dashboard" => Some(url.path().to_owned()),
_ => {
error!("Invalid deep link");
None
},
})
});
let page = match parse_url_page(cli.url_link.as_deref()) {
Ok(page) => page,
Err(exit_code) => return exit_code,
};

if !cli.allow_multiple {
match get_current_pid() {
Expand All @@ -157,22 +137,11 @@ async fn main() {
)
.show();

return;
return ExitCode::FAILURE;
}
}
}

// tokio::spawn(async {
// fig_telemetry::emit_track(fig_telemetry::TrackEvent::new(
// fig_telemetry::TrackEventType::LaunchedApp,
// fig_telemetry::TrackSource::Desktop,
// env!("CARGO_PKG_VERSION").into(),
// empty::<(&str, &str)>(),
// ))
// .await
// .ok();
// });

let ctx = Context::new();
install::run_install(Arc::clone(&ctx), cli.ignore_immediate_update).await;

Expand Down Expand Up @@ -226,18 +195,49 @@ async fn main() {

webview_manager.run().await.unwrap();
fig_telemetry::finish_telemetry().await;
ExitCode::SUCCESS
}

fn parse_url_page(url: Option<&str>) -> Result<Option<String>, ExitCode> {
let Some(url) = url else {
return Ok(None);
};

let url = match Url::parse(url) {
Ok(url) => url,
Err(err) => {
error!(%err, %url, "Failed to parse url");
return Err(ExitCode::FAILURE);
},
};

if url.scheme() != URL_SCHEMA {
error!(scheme = %url.scheme(), %url, "Invalid scheme");
return Err(ExitCode::FAILURE);
}

Ok(url.host_str().and_then(|s| match s {
"dashboard" => Some(url.path().to_owned()),
_ => {
error!("Invalid deep link");
None
},
}))
}

#[cfg(target_os = "linux")]
async fn allow_multiple_running_check(current_pid: sysinfo::Pid, kill_old: bool, page: Option<String>) {
async fn allow_multiple_running_check(
current_pid: sysinfo::Pid,
kill_old: bool,
page: Option<String>,
) -> Option<ExitCode> {
use std::ffi::OsString;

use tracing::debug;

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

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

#[allow(clippy::exit)]
exit(0);
return Some(ExitCode::SUCCESS);
},
_ => (),
}
}
None
}

#[cfg(target_os = "macos")]
async fn allow_multiple_running_check(current_pid: sysinfo::Pid, kill_old: bool, page: Option<String>) {
async fn allow_multiple_running_check(
current_pid: sysinfo::Pid,
kill_old: bool,
page: Option<String>,
) -> Option<ExitCode> {
use std::ffi::OsString;

let app_process_name = OsString::from(APP_PROCESS_NAME);
Expand Down Expand Up @@ -341,21 +345,21 @@ async fn allow_multiple_running_check(current_pid: sysinfo::Pid, kill_old: bool,
{
eprintln!("Failed to open Fig: {err}");
}

#[allow(clippy::exit)]
exit(0);
};

match (process.user_id().map(|uid| uid as &u32), current_user_id.as_ref()) {
(Some(uid), Some(current_uid)) if uid == current_uid => {
on_match.await;
return Some(ExitCode::SUCCESS);
},
(_, None) => {
on_match.await;
return Some(ExitCode::SUCCESS);
},
_ => {},
}
}
}
}
None
}
4 changes: 2 additions & 2 deletions crates/fig_desktop/src/platform/macos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ impl PlatformStateImpl {
// Checking if IME is installed is async :(
let enabled_proxy = self.proxy.clone();
tokio::spawn(async move {
let is_terminal_disabled = current_terminal.as_ref().map_or(false, |terminal| {
let is_terminal_disabled = current_terminal.as_ref().is_some_and(|terminal| {
fig_settings::settings::get_bool_or(
format!("integrations.{}.disabled", terminal.internal_id()),
false,
Expand Down Expand Up @@ -558,7 +558,7 @@ impl PlatformStateImpl {
let dashboard_visible = dashboard_visible.unwrap_or_else(|| {
window_map
.get(&DASHBOARD_ID)
.map_or(false, |window| window.window.is_visible())
.is_some_and(|window| window.window.is_visible())
});

if dashboard_visible {
Expand Down
2 changes: 1 addition & 1 deletion crates/fig_desktop/src/protocol/icons.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ pub async fn process_asset(path: PathBuf) -> Result<ProcessedAsset> {
let is_svg = path
.extension()
.and_then(OsStr::to_str)
.map_or(true, |ext| ext.to_lowercase() == "svg");
.is_none_or(|ext| ext.to_lowercase() == "svg");

let built = if is_svg {
(Arc::new(tokio::fs::read(&path).await?.into()), AssetKind::Svg)
Expand Down
2 changes: 1 addition & 1 deletion crates/fig_desktop/src/remote_ipc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ impl fig_remote_ipc::RemoteHookHandler for RemoteHook {
let current_session_expired = session
.current_session_metrics
.as_ref()
.map_or(false, |metrics| received_at > metrics.end_time + Duration::from_secs(5));
.is_some_and(|metrics| received_at > metrics.end_time + Duration::from_secs(5));

if current_session_expired {
let previous = session.current_session_metrics.clone();
Expand Down
3 changes: 1 addition & 2 deletions crates/fig_desktop/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ where
.headers()
.get("Accept")
.and_then(|accept| accept.to_str().ok())
.and_then(|accept| accept.split('/').last())
.map_or(false, |accept| accept == "json");
.is_some_and(|accept| accept.split('/').last() == Some("json"));

let mut response = match f(ctx_clone, req, window_id.window_id()).in_current_span().await {
Ok(res) => res,
Expand Down
2 changes: 1 addition & 1 deletion crates/fig_desktop_api/src/init_script.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ impl Constants {
new_uri_format: true,
support_api_proto,
api_proto_url: "api://localhost".to_string(),
midway: midway_cookie_path().map_or(false, |p| p.is_file()),
midway: midway_cookie_path().is_ok_and(|p| p.is_file()),
#[cfg(target_os = "macos")]
macos_version: macos_utils::os::OperatingSystemVersion::get().to_string(),
#[cfg(target_os = "linux")]
Expand Down
2 changes: 1 addition & 1 deletion crates/fig_os_shim/src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ impl Env {

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

pub fn in_ssh(&self) -> bool {
Expand Down
6 changes: 3 additions & 3 deletions crates/fig_util/src/terminal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ impl Terminal {
| Terminal::Zed
| Terminal::Rio
| Terminal::Ghostty
) || self.as_custom().map_or(false, |c| c.macos.input_method)
) || self.as_custom().is_some_and(|c| c.macos.input_method)
}

pub fn supports_macos_accessibility(&self) -> bool {
Expand All @@ -451,7 +451,7 @@ impl Terminal {
| Terminal::VSCodium
| Terminal::Hyper
| Terminal::Tabby
) || self.as_custom().map_or(false, |c| c.macos.accessibility)
) || self.as_custom().is_some_and(|c| c.macos.accessibility)
}

pub fn is_xterm(&self) -> bool {
Expand All @@ -465,7 +465,7 @@ impl Terminal {
| Terminal::Cursor
| Terminal::CursorNightly
| Terminal::Windsurf
) || self.as_custom().map_or(false, |c| c.macos.xterm)
) || self.as_custom().is_some_and(|c| c.macos.xterm)
}

pub fn executable_names(&self) -> &'static [&'static str] {
Expand Down
6 changes: 3 additions & 3 deletions crates/figterm/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,9 +320,9 @@ where
Some(at) => {
let lock_expired = at.elapsed().unwrap_or(Duration::ZERO) > Duration::from_millis(16);
let should_unlock = lock_expired
|| term.get_current_buffer().map_or(true, |buff| {
&buff.buffer == (&EXPECTED_BUFFER.lock().unwrap() as &String)
});
|| term
.get_current_buffer()
.is_none_or(|buff| &buff.buffer == (&EXPECTED_BUFFER.lock().unwrap() as &String));
if should_unlock {
handle.take();
if lock_expired {
Expand Down
2 changes: 1 addition & 1 deletion crates/q_cli/src/util/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ pub async fn is_brew_reinstall() -> bool {
.args(["aux", "-o", "args"])
.output()
.await
.map_or(false, |output| regex.is_match(&output.stdout))
.is_ok_and(|output| regex.is_match(&output.stdout))
}

#[cfg(test)]
Expand Down
4 changes: 2 additions & 2 deletions crates/shell-color/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ pub struct SuggestionColor {

impl SuggestionColor {
pub fn fg(&self) -> Option<VTermColor> {
self.fg.clone().map(VTermColor::from)
self.fg.clone()
}

pub fn bg(&self) -> Option<VTermColor> {
self.bg.clone().map(VTermColor::from)
self.bg.clone()
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/zbus/src/abstractions/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub struct Executor<'a> {
phantom: PhantomData<&'a ()>,
}

impl<'a> Executor<'a> {
impl Executor<'_> {
/// Spawns a task onto the executor.
#[doc(hidden)]
pub fn spawn<T: Send + 'static>(
Expand Down
4 changes: 2 additions & 2 deletions crates/zbus/src/address/transport/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,10 +267,10 @@ pub(crate) fn decode_percents(value: &str) -> Result<Vec<u8>> {
decoded.push(c as u8);
} else if c == '%' {
decoded.push(
decode_hex(
(decode_hex(
iter.next()
.ok_or_else(|| Error::Address("incomplete percent-encoded sequence".to_owned()))?,
)? << 4
)? << 4)
| decode_hex(
iter.next()
.ok_or_else(|| Error::Address("incomplete percent-encoded sequence".to_owned()))?,
Expand Down
Loading
Loading