Skip to content

Commit befe105

Browse files
authored
chore: update to Rust 2024 edition (#10114)
### Description update to 2024 edition: - force 2021 style formatting to avoid huge formatting changes (>1000) lines (this still doesn't disable all 2024 edition formatting things) - exclude turborepo-lib from edition bump as tracing macros are not ready for `use<>` syntax required in several places; exclude turborepo-filewatch because I don't have macos machine to properly address failures - edition 2024 lints: - impl Trait lifetimes: https://doc.rust-lang.org/edition-guide/rust-2024/rpit-lifetime-capture.html - various ref/ref mut cleanups: https://doc.rust-lang.org/edition-guide/rust-2024/match-ergonomics.html - `gen` is now a keyword, use `r#gen` to fix compile error: https://doc.rust-lang.org/edition-guide/rust-2024/gen-keyword.html - env::set_var is unsafe: https://doc.rust-lang.org/edition-guide/rust-2024/newly-unsafe-functions.html - extern blocks are unsafe: https://doc.rust-lang.org/edition-guide/rust-2024/unsafe-extern.html <!-- ✍️ Write a short summary of your work. If necessary, include relevant screenshots. --> ### Testing Instructions CI <!-- Give a quick description of steps to test your changes. -->
1 parent 32f4f53 commit befe105

File tree

55 files changed

+309
-252
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+309
-252
lines changed

.rustfmt.toml

+3
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,6 @@ wrap_comments = true
99

1010
imports_granularity = "Crate"
1111
group_imports = "StdExternalCrate"
12+
13+
# do not apply 2024 edition formatting
14+
style_edition = "2021"

crates/tower-uds/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "tower-uds"
33
version = "0.1.0"
4-
edition = "2021"
4+
edition = "2024"
55
license = "MPL-2.0"
66

77
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

crates/turbo-trace/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "turbo-trace"
33
version = "0.1.0"
4-
edition = "2021"
4+
edition = "2024"
55
license = "MIT"
66

77
[dependencies]

crates/turborepo-analytics/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "turborepo-analytics"
33
version = "0.1.0"
4-
edition = "2021"
4+
edition = "2024"
55
license = "MIT"
66

77
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

crates/turborepo-api-client/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "turborepo-api-client"
33
version = "0.1.0"
4-
edition = "2021"
4+
edition = "2024"
55
license = "MIT"
66

77
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

crates/turborepo-auth/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "turborepo-auth"
33
version = "0.1.0"
4-
edition = "2021"
4+
edition = "2024"
55
license = "MIT"
66

77
[lints]

crates/turborepo-cache/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "turborepo-cache"
33
version = "0.1.0"
44
license = "MIT"
5-
edition = "2021"
5+
edition = "2024"
66

77
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
88
[features]

crates/turborepo-cache/src/signature_authentication.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ mod tests {
244244
}
245245

246246
fn test_signature(test_case: TestCase) -> Result<()> {
247-
env::set_var("TURBO_REMOTE_CACHE_SIGNATURE_KEY", test_case.secret_key);
247+
unsafe { env::set_var("TURBO_REMOTE_CACHE_SIGNATURE_KEY", test_case.secret_key) };
248248
let signature = ArtifactSignatureAuthenticator {
249249
team_id: test_case.team_id.to_vec(),
250250
secret_key_override: None,
@@ -261,7 +261,7 @@ mod tests {
261261
assert!(!signature.validate(hash, artifact_body, &bad_tag)?);
262262

263263
// Change the key
264-
env::set_var("TURBO_REMOTE_CACHE_SIGNATURE_KEY", "some other key");
264+
unsafe { env::set_var("TURBO_REMOTE_CACHE_SIGNATURE_KEY", "some other key") };
265265

266266
// Confirm that the tag is no longer valid
267267
assert!(!signature.validate_tag(hash, artifact_body, tag.as_ref())?);

crates/turborepo-cache/src/upload_progress.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,13 @@ where
5656
// same as `curr_gen_index` but we can't borrow `self` twice
5757
let (curr_gen, index) = {
5858
// usize fits 570 million years of milliseconds since start on 64 bit
59-
let gen = (this.start.elapsed().as_millis() as usize) / INTERVAL;
60-
(gen, gen % BUCKETS)
59+
let r#gen = (this.start.elapsed().as_millis() as usize) / INTERVAL;
60+
(r#gen, r#gen % BUCKETS)
6161
};
6262
let mut state = this.state.lock().unwrap();
63-
let (gen, value) = &mut state.1[index];
64-
if *gen != curr_gen {
65-
*gen = curr_gen;
63+
let (r#gen, value) = &mut state.1[index];
64+
if *r#gen != curr_gen {
65+
*r#gen = curr_gen;
6666
*value = item.len();
6767
} else {
6868
*value += item.len();
@@ -149,7 +149,7 @@ impl<const BUCKETS: usize, const INTERVAL: usize> UploadProgressQuery<BUCKETS, I
149149
let s = s.lock().unwrap();
150150
let total_bytes =
151151
s.1.iter()
152-
.filter(|(gen, _)| *gen >= min_gen)
152+
.filter(|(r#gen, _)| *r#gen >= min_gen)
153153
.map(|(_, bytes)| *bytes)
154154
.sum::<usize>();
155155

crates/turborepo-ci/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "turborepo-ci"
33
version = "0.1.0"
4-
edition = "2021"
4+
edition = "2024"
55
license = "MIT"
66

77
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

crates/turborepo-ci/src/lib.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ mod tests {
177177

178178
let live_ci = if Vendor::get_name() == Some("GitHub Actions") {
179179
let live_ci = std::env::var("GITHUB_ACTIONS").unwrap_or_default();
180-
env::remove_var("GITHUB_ACTIONS");
180+
unsafe { env::remove_var("GITHUB_ACTIONS") };
181181
Some(live_ci)
182182
} else {
183183
None
@@ -187,23 +187,23 @@ mod tests {
187187
let mut env_parts = env.split('=');
188188
let key = env_parts.next().unwrap();
189189
let val = env_parts.next().unwrap_or("some value");
190-
env::set_var(key, val);
190+
unsafe { env::set_var(key, val) };
191191
}
192192

193193
assert_eq!(Vendor::infer_inner(), want.as_ref());
194194

195195
if Vendor::get_name() == Some("GitHub Actions") {
196196
if let Some(live_ci) = live_ci {
197-
env::set_var("GITHUB_ACTIONS", live_ci);
197+
unsafe { env::set_var("GITHUB_ACTIONS", live_ci) };
198198
} else {
199-
env::remove_var("GITHUB_ACTIONS");
199+
unsafe { env::remove_var("GITHUB_ACTIONS") };
200200
}
201201
}
202202

203203
for env in set_env {
204204
let mut env_parts = env.split('=');
205205
let key = env_parts.next().unwrap();
206-
env::remove_var(key);
206+
unsafe { env::remove_var(key) };
207207
}
208208
}
209209
}

crates/turborepo-dirs/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "turborepo-dirs"
33
version = "0.1.0"
4-
edition = "2021"
4+
edition = "2024"
55
license = "MIT"
66

77
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

crates/turborepo-env/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "turborepo-env"
33
version = "0.1.0"
4-
edition = "2021"
4+
edition = "2024"
55
license = "MIT"
66

77
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

crates/turborepo-errors/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "turborepo-errors"
33
version = "0.1.0"
4-
edition = "2021"
4+
edition = "2024"
55
license = "MIT"
66

77
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

crates/turborepo-fixed-map/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "turborepo-fixed-map"
33
version = "0.1.0"
4-
edition = "2021"
4+
edition = "2024"
55
license = "MIT"
66

77
[dependencies]

crates/turborepo-fs/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "turborepo-fs"
33
version = "0.1.0"
44
license = "MIT"
5-
edition = "2021"
5+
edition = "2024"
66

77
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
88

crates/turborepo-globwalk/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "globwalk"
33
version = "0.1.0"
4-
edition = "2021"
4+
edition = "2024"
55
license = "MIT"
66

77
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

crates/turborepo-globwatch/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "globwatch"
33
version = "0.1.0"
4-
edition = "2021"
4+
edition = "2024"
55
description = "Watch a set of globs efficiently"
66
license = "MIT OR Apache-2.0"
77

crates/turborepo-graph-utils/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "turborepo-graph-utils"
33
version = "0.1.0"
4-
edition = "2021"
4+
edition = "2024"
55
license = "MIT"
66

77
[lints]

crates/turborepo-lockfiles/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "turborepo-lockfiles"
33
version = "0.1.0"
4-
edition = "2021"
4+
edition = "2024"
55
license = "MIT"
66

77
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

crates/turborepo-lsp/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "turborepo-lsp"
33
version = "0.1.0"
4-
edition = "2021"
4+
edition = "2024"
55
license = "MIT"
66

77
[features]

crates/turborepo-microfrontends/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "turborepo-microfrontends"
33
version = "0.1.0"
4-
edition = "2021"
4+
edition = "2024"
55
license = "MIT"
66

77
[dependencies]

crates/turborepo-paths/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "turbopath"
33
version = "0.1.0"
44
license = "MIT"
5-
edition = "2021"
5+
edition = "2024"
66

77
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
88

crates/turborepo-pidlock/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "pidlock"
33
version = "0.1.4"
44
authors = ["Paul Hummer <[email protected]>"]
55
license = "MIT"
6-
edition = "2021"
6+
edition = "2024"
77
description = "A library for using pidfiles as resource locks"
88
repository = "https://github.com/rockstar/pidlock"
99
keywords = ["pidfile", "file", "filelock", "server", "lock"]

crates/turborepo-pidlock/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ mod tests {
354354
.open(path.clone())
355355
.expect("Could not open file for writing");
356356

357-
file.write_all(&format!("{}", thread_rng().gen::<i32>()).into_bytes()[..])
357+
file.write_all(&format!("{}", thread_rng().r#gen::<i32>()).into_bytes()[..])
358358
.unwrap();
359359

360360
drop(file);

crates/turborepo-repository/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "turborepo-repository"
33
version = "0.1.0"
4-
edition = "2021"
4+
edition = "2024"
55
license = "MIT"
66

77
[lints]

crates/turborepo-repository/src/package_manager/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ impl PackageManager {
435435
pub fn get_package_jsons(
436436
&self,
437437
repo_root: &AbsoluteSystemPath,
438-
) -> Result<impl Iterator<Item = AbsoluteSystemPathBuf>, Error> {
438+
) -> Result<impl Iterator<Item = AbsoluteSystemPathBuf> + use<>, Error> {
439439
let globs = self.get_workspace_globs(repo_root)?;
440440
Ok(globs.get_package_jsons(repo_root)?)
441441
}

crates/turborepo-repository/src/workspaces.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ impl WorkspaceGlobs {
147147
pub fn get_package_jsons(
148148
&self,
149149
repo_root: &AbsoluteSystemPath,
150-
) -> Result<impl Iterator<Item = AbsoluteSystemPathBuf>, Error> {
150+
) -> Result<impl Iterator<Item = AbsoluteSystemPathBuf> + use<>, Error> {
151151
let files = globwalk::globwalk(
152152
repo_root,
153153
&self.package_json_inclusions,

crates/turborepo-scm/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "turborepo-scm"
33
version = "0.1.0"
4-
edition = "2021"
4+
edition = "2024"
55
license = "MIT"
66

77
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

crates/turborepo-signals/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "turborepo-signals"
33
version = "0.1.0"
4-
edition = "2021"
4+
edition = "2024"
55
license = "MIT"
66

77
[dependencies]

crates/turborepo-telemetry/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "turborepo-telemetry"
33
version = "0.1.0"
4-
edition = "2021"
4+
edition = "2024"
55
license = "MIT"
66

77
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

crates/turborepo-ui/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "turborepo-ui"
33
version = "0.1.0"
4-
edition = "2021"
4+
edition = "2024"
55
license = "MIT"
66

77
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

crates/turborepo-unescape/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "turborepo-unescape"
33
version = "0.1.0"
4-
edition = "2021"
4+
edition = "2024"
55
license = "MPL-2.0"
66

77
[dependencies]

crates/turborepo-updater/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "turbo-updater"
33
version = "0.1.0"
4-
edition = "2021"
4+
edition = "2024"
55
description = "Minimal wrapper around update-informer to provide npm registry support and consistent UI"
66
license = "MIT"
77
publish = false

crates/turborepo-vercel-api-mock/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "turborepo-vercel-api-mock"
33
version = "0.1.0"
4-
edition = "2021"
4+
edition = "2024"
55
license = "MIT"
66

77
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

crates/turborepo-vercel-api/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "turborepo-vercel-api"
33
version = "0.1.0"
4-
edition = "2021"
4+
edition = "2024"
55
license = "MIT"
66

77
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

crates/turborepo-vt100/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "turborepo-vt100"
33
version = "0.15.2"
44
authors = ["Jesse Luehrs <[email protected]>"]
5-
edition = "2021"
5+
edition = "2024"
66

77
description = "Library for parsing terminal data"
88
homepage = "https://github.com/doy/vt100-rust"

crates/turborepo-vt100/src/perform.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,7 @@ impl vte::Perform for WrappedScreen {
165165

166166
fn canonicalize_params_1(params: &vte::Params, default: u16) -> u16 {
167167
let first = params.iter().next().map_or(0, |x| *x.first().unwrap_or(&0));
168-
if first == 0 {
169-
default
170-
} else {
171-
first
172-
}
168+
if first == 0 { default } else { first }
173169
}
174170

175171
fn canonicalize_params_2(

0 commit comments

Comments
 (0)