Update rust edition to 2024 Change-Id: Idc593023ad973d0ec09f4528f22e3d6d6a6a6964 Reviewed-on: https://gn-review.googlesource.com/c/gn/+/27540 Commit-Queue: Matt Stark <msta@google.com> Reviewed-by: Takuto Ikuta <tikuta@google.com>
diff --git a/src/gn/starlark/Cargo.toml b/src/gn/starlark/Cargo.toml index fd70dfb..e9954a4 100644 --- a/src/gn/starlark/Cargo.toml +++ b/src/gn/starlark/Cargo.toml
@@ -1,7 +1,7 @@ [package] name = "gn_starlark" version = "0.1.0" -edition = "2021" +edition = "2024" [lints] workspace = true
diff --git a/src/gn/starlark/crates/args/Cargo.toml b/src/gn/starlark/crates/args/Cargo.toml index aee2b9d..75410e7 100644 --- a/src/gn/starlark/crates/args/Cargo.toml +++ b/src/gn/starlark/crates/args/Cargo.toml
@@ -1,7 +1,7 @@ [package] name = "args" version = "0.1.0" -edition = "2021" +edition = "2024" [lints] workspace = true
diff --git a/src/gn/starlark/crates/args/src/args.rs b/src/gn/starlark/crates/args/src/args.rs index 446ee1b..2963c2f 100644 --- a/src/gn/starlark/crates/args/src/args.rs +++ b/src/gn/starlark/crates/args/src/args.rs
@@ -11,9 +11,9 @@ starlark_complex_value, values::{Freeze, FreezeResult, Freezer, ProvidesStaticType, StarlarkValue, Trace, Value}, }; -use starlark_derive::{starlark_module, starlark_value, NoSerialize}; +use starlark_derive::{NoSerialize, starlark_module, starlark_value}; -use crate::{formatter::Formatter, Error}; +use crate::{Error, formatter::Formatter}; /// Internal representation of individual arguments stored in `Args`. #[derive(Allocative, Clone, Debug, Freeze, NoSerialize, ProvidesStaticType, Trace)]
diff --git a/src/gn/starlark/crates/args/src/expand.rs b/src/gn/starlark/crates/args/src/expand.rs index 9880add..b86be77 100644 --- a/src/gn/starlark/crates/args/src/expand.rs +++ b/src/gn/starlark/crates/args/src/expand.rs
@@ -5,13 +5,13 @@ use depset::Depset; use starlark::{ eval::Evaluator, - values::{list::ListRef, tuple::TupleRef, Value}, + values::{Value, list::ListRef, tuple::TupleRef}, }; use crate::{ + Error, args::{ArgValue, FrozenArgs}, formatter::Formatter, - Error, }; /// Helper to process and append a specific `FrozenArgs` object to the action's
diff --git a/src/gn/starlark/crates/args/src/formatter.rs b/src/gn/starlark/crates/args/src/formatter.rs index e03e4f4..82a6d57 100644 --- a/src/gn/starlark/crates/args/src/formatter.rs +++ b/src/gn/starlark/crates/args/src/formatter.rs
@@ -5,7 +5,7 @@ use allocative::Allocative; use starlark::{ typing::Ty, - values::{type_repr::StarlarkTypeRepr, Freeze}, + values::{Freeze, type_repr::StarlarkTypeRepr}, }; use crate::errors::Error;
diff --git a/src/gn/starlark/crates/args/src/lib.rs b/src/gn/starlark/crates/args/src/lib.rs index 739db6c..0e15341 100644 --- a/src/gn/starlark/crates/args/src/lib.rs +++ b/src/gn/starlark/crates/args/src/lib.rs
@@ -9,7 +9,7 @@ #[cfg(test)] mod tests; pub mod unpack; -pub use args::{args_methods, Args, FrozenArgs}; +pub use args::{Args, FrozenArgs, args_methods}; pub(crate) use errors::Error; pub use formatter::Formatter; pub use unpack::FrozenArgsSequence;
diff --git a/src/gn/starlark/crates/args/src/unpack.rs b/src/gn/starlark/crates/args/src/unpack.rs index 40e1a00..dce56a7 100644 --- a/src/gn/starlark/crates/args/src/unpack.rs +++ b/src/gn/starlark/crates/args/src/unpack.rs
@@ -2,10 +2,10 @@ use starlark::{ eval::Evaluator, typing::Ty, - values::{list::ListRef, type_repr::StarlarkTypeRepr, UnpackValue, Value, ValueTyped}, + values::{UnpackValue, Value, ValueTyped, list::ListRef, type_repr::StarlarkTypeRepr}, }; -use crate::{formatter::Formatter, FrozenArgs}; +use crate::{FrozenArgs, formatter::Formatter}; impl<'v> UnpackValue<'v> for Formatter { type Error = starlark::Error;
diff --git a/src/gn/starlark/crates/attr/Cargo.toml b/src/gn/starlark/crates/attr/Cargo.toml index e5a8ce5..970dbe2 100644 --- a/src/gn/starlark/crates/attr/Cargo.toml +++ b/src/gn/starlark/crates/attr/Cargo.toml
@@ -1,7 +1,7 @@ [package] name = "attr" version = "0.1.0" -edition = "2021" +edition = "2024" [lints] workspace = true
diff --git a/src/gn/starlark/crates/attr/src/allow_files.rs b/src/gn/starlark/crates/attr/src/allow_files.rs index 1806c99..63bc6a7 100644 --- a/src/gn/starlark/crates/attr/src/allow_files.rs +++ b/src/gn/starlark/crates/attr/src/allow_files.rs
@@ -5,7 +5,7 @@ use allocative::Allocative; use starlark::{ typing::Ty, - values::{list::UnpackList, type_repr::StarlarkTypeRepr, Freeze, UnpackValue, Value}, + values::{Freeze, UnpackValue, Value, list::UnpackList, type_repr::StarlarkTypeRepr}, }; use types::{Label, PackageRef, PathResolver}; @@ -100,9 +100,9 @@ mod tests { use super::*; use crate::{ + Attr, cfg::AttrCfg, schema::{AllowFilesSchema, AttrKind, AttrSchema}, - Attr, }; #[test]
diff --git a/src/gn/starlark/crates/attr/src/attr.rs b/src/gn/starlark/crates/attr/src/attr.rs index 375a1b5..fa47f28 100644 --- a/src/gn/starlark/crates/attr/src/attr.rs +++ b/src/gn/starlark/crates/attr/src/attr.rs
@@ -7,7 +7,7 @@ use allocative::Allocative; use starlark::{ collections::{SmallMap, SmallSet}, - values::{list::UnpackList, none::NoneOr, Freeze, Heap, UnpackValue as _, Value}, + values::{Freeze, Heap, UnpackValue as _, Value, list::UnpackList, none::NoneOr}, }; use types::{File, Label, LabelRef, PackageRef, PathResolver}; @@ -427,22 +427,26 @@ }; // Test same string label duplicate - assert!(Attr::create( - &schema_list, - Some(heap.alloc(vec![":bar", ":bar"])), - pkg, - &path_resolver, - ) - .is_err()); + assert!( + Attr::create( + &schema_list, + Some(heap.alloc(vec![":bar", ":bar"])), + pkg, + &path_resolver, + ) + .is_err() + ); // Test different string representations resolving to same Label - assert!(Attr::create( - &schema_list, - Some(heap.alloc(vec![":bar", "//foo:bar"])), - pkg, - &path_resolver, - ) - .is_err()); + assert!( + Attr::create( + &schema_list, + Some(heap.alloc(vec![":bar", "//foo:bar"])), + pkg, + &path_resolver, + ) + .is_err() + ); }); } @@ -474,13 +478,15 @@ heap.alloc("//foo:bar").get_hashed().unwrap(), heap.alloc("val2"), ); - assert!(Attr::create( - &schema_dict, - Some(heap.alloc(Dict::new(map))), - pkg, - &path_resolver, - ) - .is_err()); + assert!( + Attr::create( + &schema_dict, + Some(heap.alloc(Dict::new(map))), + pkg, + &path_resolver, + ) + .is_err() + ); }); } }
diff --git a/src/gn/starlark/crates/attr/src/cfg.rs b/src/gn/starlark/crates/attr/src/cfg.rs index e7df82a..ce139a5 100644 --- a/src/gn/starlark/crates/attr/src/cfg.rs +++ b/src/gn/starlark/crates/attr/src/cfg.rs
@@ -5,7 +5,7 @@ use allocative::Allocative; use starlark::{ typing::Ty, - values::{type_repr::StarlarkTypeRepr, Freeze, UnpackValue, Value}, + values::{Freeze, UnpackValue, Value, type_repr::StarlarkTypeRepr}, }; /// The rust type for the starlark value passed to attr.label(cfg = ...)
diff --git a/src/gn/starlark/crates/attr/src/ctx.rs b/src/gn/starlark/crates/attr/src/ctx.rs index 7726682..6490559 100644 --- a/src/gn/starlark/crates/attr/src/ctx.rs +++ b/src/gn/starlark/crates/attr/src/ctx.rs
@@ -9,9 +9,9 @@ any::ProvidesStaticType, collections::SmallMap, values::{ + Freeze, FrozenHeap, FrozenValueTyped, Heap, Trace, Value, record::{Field, FrozenRecordType, Record}, typing::{TypeIdDomain, TypeInstanceId}, - Freeze, FrozenHeap, FrozenValueTyped, Heap, Trace, Value, }, }; use types::{LabelRef, OutputType}; @@ -26,9 +26,9 @@ } use crate::{ + Attr, Session, schema::{AllowFilesSchema, AttrKind, AttrSchema}, value::AttrValue, - Attr, Session, }; /// Contains ctx.attr, ctx.files, and ctx.file.
diff --git a/src/gn/starlark/crates/attr/src/errors.rs b/src/gn/starlark/crates/attr/src/errors.rs index 9c60497..2bbcd22 100644 --- a/src/gn/starlark/crates/attr/src/errors.rs +++ b/src/gn/starlark/crates/attr/src/errors.rs
@@ -26,7 +26,9 @@ StringNotAllowed(String), #[error("allow_files and allow_single_file are mutually exclusive")] AllowFilesMutuallyExclusive, - #[error("allow_empty = False requires the attribute to be mandatory or have a non-empty default value")] + #[error( + "allow_empty = False requires the attribute to be mandatory or have a non-empty default value" + )] AllowEmptyRequiresMandatoryOrDefault, #[error("value `{0}` is not a label")] NotALabel(String),
diff --git a/src/gn/starlark/crates/attr/src/globals.rs b/src/gn/starlark/crates/attr/src/globals.rs index e167b0c..406a08c 100644 --- a/src/gn/starlark/crates/attr/src/globals.rs +++ b/src/gn/starlark/crates/attr/src/globals.rs
@@ -8,11 +8,11 @@ use starlark::{ environment::{Methods, MethodsBuilder}, eval::Evaluator, - values::{list::UnpackList, none::NoneOr, ProvidesStaticType, StarlarkValue, Value}, + values::{ProvidesStaticType, StarlarkValue, Value, list::UnpackList, none::NoneOr}, }; -use starlark_derive::{starlark_module, starlark_value, NoSerialize}; +use starlark_derive::{NoSerialize, starlark_module, starlark_value}; -use crate::{allow_files::AllowFiles, cfg::AttrCfg, AttrKind}; +use crate::{AttrKind, allow_files::AllowFiles, cfg::AttrCfg}; /// The type that all parameters of attr.* get converted to. /// Mostly used because rust doesn't have default parameters,
diff --git a/src/gn/starlark/crates/attr/src/schema.rs b/src/gn/starlark/crates/attr/src/schema.rs index 33554cc..2edfb00 100644 --- a/src/gn/starlark/crates/attr/src/schema.rs +++ b/src/gn/starlark/crates/attr/src/schema.rs
@@ -11,12 +11,12 @@ use starlark::{ eval::ParametersSpecParam, starlark_simple_value, - values::{none::NoneOr, Freeze, Heap, ProvidesStaticType, StarlarkValue, Trace, Value}, + values::{Freeze, Heap, ProvidesStaticType, StarlarkValue, Trace, Value, none::NoneOr}, }; -use starlark_derive::{starlark_value, NoSerialize}; +use starlark_derive::{NoSerialize, starlark_value}; use types::{PackageRef, PathResolver}; -use crate::{allow_files::AllowFiles, cfg::AttrCfg, globals::AttrSpecArgs, Attr}; +use crate::{Attr, allow_files::AllowFiles, cfg::AttrCfg, globals::AttrSpecArgs}; /// The underlying data type of a target attribute (e.g. Bool, String, /// LabelList). @@ -215,7 +215,7 @@ use types::Label; use super::*; - use crate::{globals::tests::new_attr_assert, LabelOrFile}; + use crate::{LabelOrFile, globals::tests::new_attr_assert}; #[track_caller] fn assert_eq_schema(
diff --git a/src/gn/starlark/crates/attr/src/value.rs b/src/gn/starlark/crates/attr/src/value.rs index df0f6f7..b51153c 100644 --- a/src/gn/starlark/crates/attr/src/value.rs +++ b/src/gn/starlark/crates/attr/src/value.rs
@@ -5,11 +5,11 @@ use allocative::Allocative; use starlark::{ collections::{SmallMap, SmallSet}, - values::{dict::Dict, Heap, Value}, + values::{Heap, Value, dict::Dict}, }; use types::{File, LabelRef, TargetRef as _}; -use crate::{schema::AttrSchema, Attr, Session}; +use crate::{Attr, Session, schema::AttrSchema}; /// AttrValue is the value that will appear in ctx.(attr|file|files).foo #[derive(Clone, Debug, Allocative)] @@ -202,17 +202,16 @@ match lf { crate::LabelOrFile::Label(lbl) => { let target = session.get_target(lbl.as_ref(), *current_toolchain); - if let Some(matcher) = schema.file_matcher() { - if let crate::allow_files::AllowFiles::Some(exts) = matcher { - if !target.outputs().iter().any(|f| matcher.matches(f.as_str())) { - return Err(starlark::Error::new_other( - crate::Error::NoMatchingOutputs { - target: lbl.clone(), - allowed: exts.clone(), - }, - )); - } - } + if let Some(matcher) = schema.file_matcher() + && let crate::allow_files::AllowFiles::Some(exts) = matcher + && !target.outputs().iter().any(|f| matcher.matches(f.as_str())) + { + return Err(starlark::Error::new_other( + crate::Error::NoMatchingOutputs { + target: lbl.clone(), + allowed: exts.clone(), + }, + )); } for f in target.outputs() { files.insert(f.clone()); @@ -234,7 +233,7 @@ mod tests { use starlark::{ environment::Module, - values::{list::UnpackList, UnpackValue as _}, + values::{UnpackValue as _, list::UnpackList}, }; use testutils::{FakeSession, FakeTarget, FakeTargetRef}; use types::PackageRef;
diff --git a/src/gn/starlark/crates/depset/Cargo.toml b/src/gn/starlark/crates/depset/Cargo.toml index cf0def1..4f688f2 100644 --- a/src/gn/starlark/crates/depset/Cargo.toml +++ b/src/gn/starlark/crates/depset/Cargo.toml
@@ -1,7 +1,7 @@ [package] name = "depset" version = "0.1.0" -edition = "2021" +edition = "2024" [lints] workspace = true
diff --git a/src/gn/starlark/crates/depset/src/depset.rs b/src/gn/starlark/crates/depset/src/depset.rs index 8ea0f88..c575604 100644 --- a/src/gn/starlark/crates/depset/src/depset.rs +++ b/src/gn/starlark/crates/depset/src/depset.rs
@@ -13,11 +13,11 @@ starlark_complex_value, typing::Ty, values::{ - type_repr::StarlarkTypeRepr, Heap, ProvidesStaticType, StarlarkValue, Trace, UnpackValue, - Value, + Heap, ProvidesStaticType, StarlarkValue, Trace, UnpackValue, Value, + type_repr::StarlarkTypeRepr, }, }; -use starlark_derive::{starlark_module, starlark_value, Freeze, NoSerialize}; +use starlark_derive::{Freeze, NoSerialize, starlark_module, starlark_value}; use types::File; /// All orderings are guaranteed to be deterministic. @@ -227,7 +227,7 @@ use testutils::Assert; use super::*; - use crate::{globals::tests::new_assert, UnpackFileDepset}; + use crate::{UnpackFileDepset, globals::tests::new_assert}; #[test] fn test_depset_deduplication() {
diff --git a/src/gn/starlark/crates/depset/src/errors.rs b/src/gn/starlark/crates/depset/src/errors.rs index dfb3ada..365c90d 100644 --- a/src/gn/starlark/crates/depset/src/errors.rs +++ b/src/gn/starlark/crates/depset/src/errors.rs
@@ -9,7 +9,9 @@ pub enum Error { #[error("Invalid order: {0}")] InvalidOrder(String), - #[error("conflicting orders: depset has order {order}, but transitive child has order {child_order}")] + #[error( + "conflicting orders: depset has order {order}, but transitive child has order {child_order}" + )] ConflictingOrders { order: Order, child_order: Order }, #[error("depset elements must be of the same type, expected {expected}, got {got}")] DepsetTypeMismatch { expected: Kind, got: Kind },
diff --git a/src/gn/starlark/crates/depset/src/globals.rs b/src/gn/starlark/crates/depset/src/globals.rs index 3c8a929..1180ac1 100644 --- a/src/gn/starlark/crates/depset/src/globals.rs +++ b/src/gn/starlark/crates/depset/src/globals.rs
@@ -4,7 +4,7 @@ use starlark::{ collections::SmallSet, - values::{list::UnpackList, Heap, UnpackValue as _, Value}, + values::{Heap, UnpackValue as _, Value, list::UnpackList}, }; use types::File;
diff --git a/src/gn/starlark/crates/depset/src/unpack.rs b/src/gn/starlark/crates/depset/src/unpack.rs index a5d42c3..6eb32cd 100644 --- a/src/gn/starlark/crates/depset/src/unpack.rs +++ b/src/gn/starlark/crates/depset/src/unpack.rs
@@ -4,7 +4,7 @@ use starlark::{ typing::Ty, - values::{type_repr::StarlarkTypeRepr, UnpackValue, Value}, + values::{UnpackValue, Value, type_repr::StarlarkTypeRepr}, }; use types::File;
diff --git a/src/gn/starlark/crates/ffi/Cargo.toml b/src/gn/starlark/crates/ffi/Cargo.toml index c9e0211..f0f8baa 100644 --- a/src/gn/starlark/crates/ffi/Cargo.toml +++ b/src/gn/starlark/crates/ffi/Cargo.toml
@@ -1,7 +1,7 @@ [package] name = "ffi" version = "0.1.0" -edition = "2021" +edition = "2024" [lints] workspace = true
diff --git a/src/gn/starlark/crates/ffi/src/eval_context.rs b/src/gn/starlark/crates/ffi/src/eval_context.rs index 18416c3..059876e 100644 --- a/src/gn/starlark/crates/ffi/src/eval_context.rs +++ b/src/gn/starlark/crates/ffi/src/eval_context.rs
@@ -8,7 +8,7 @@ use starlark::values::ProvidesStaticType; use types::{CtxState, LabelRef, PackageRef, PathResolver}; -use crate::{errors::Error, target::Target, Scope, TargetRef}; +use crate::{Scope, TargetRef, errors::Error, target::Target}; enum EvalContextKind { BzlFile, @@ -116,7 +116,7 @@ #[allow(clippy::mut_from_ref)] fn require_macro(&self) -> starlark::Result<std::pin::Pin<&mut Self::Scope>> { match &self.kind { - EvalContextKind::Macro { mut scope, .. } => { + &EvalContextKind::Macro { mut scope, .. } => { // Safety: The eval context is single-threaded, so we cannot have multiple // references at the same time. Ok(unsafe { std::pin::Pin::new_unchecked(scope.as_mut()) })
diff --git a/src/gn/starlark/crates/ffi/src/scope.rs b/src/gn/starlark/crates/ffi/src/scope.rs index 5214ec4..9ac729e 100644 --- a/src/gn/starlark/crates/ffi/src/scope.rs +++ b/src/gn/starlark/crates/ffi/src/scope.rs
@@ -5,9 +5,9 @@ use std::pin::Pin; use starlark::values::{Heap, Value as StarlarkValue}; -use types::{intern_string, PackageRef}; +use types::{PackageRef, intern_string}; -use crate::{bridge::Value, Immutable, OwnedSlice, Scope}; +use crate::{Immutable, OwnedSlice, Scope, bridge::Value}; impl Scope { fn new<'b>(
diff --git a/src/gn/starlark/crates/ffi/src/session.rs b/src/gn/starlark/crates/ffi/src/session.rs index 3c04e99..1044c4a 100644 --- a/src/gn/starlark/crates/ffi/src/session.rs +++ b/src/gn/starlark/crates/ffi/src/session.rs
@@ -3,7 +3,7 @@ // found in the LICENSE file. use std::{ - collections::{hash_map::Entry, HashMap}, + collections::{HashMap, hash_map::Entry}, pin::Pin, sync::RwLock, }; @@ -11,7 +11,7 @@ use loader::FileLoader; use starlark::environment::{FrozenModule, Globals}; use types::{ - util::extend_lifetime, Label, LabelRef, PackageRef, PathResolver, Session as TypesSession, + Label, LabelRef, PackageRef, PathResolver, Session as TypesSession, util::extend_lifetime, }; use crate::{errors::Error, target::Target};
diff --git a/src/gn/starlark/crates/ffi/src/target.rs b/src/gn/starlark/crates/ffi/src/target.rs index ed6db76..291d035 100644 --- a/src/gn/starlark/crates/ffi/src/target.rs +++ b/src/gn/starlark/crates/ffi/src/target.rs
@@ -7,7 +7,7 @@ use providers::Providers; use starlark::values::FrozenValueTyped; -use crate::{eval_context::EvalContext, TargetRef}; +use crate::{TargetRef, eval_context::EvalContext}; pub(crate) struct StarlarkTarget { pub(crate) rule: FrozenValueTyped<'static, rule::Rule<'static, EvalContext>>,
diff --git a/src/gn/starlark/crates/ffi/src/target_ref.rs b/src/gn/starlark/crates/ffi/src/target_ref.rs index fab1741..9648fe2 100644 --- a/src/gn/starlark/crates/ffi/src/target_ref.rs +++ b/src/gn/starlark/crates/ffi/src/target_ref.rs
@@ -4,7 +4,7 @@ use allocative::Allocative; use starlark::values::{AllocValue, Heap, ProvidesStaticType, StarlarkValue, Value}; -use starlark_derive::{starlark_value, NoSerialize}; +use starlark_derive::{NoSerialize, starlark_value}; use types::{LabelRef, TargetRef as _}; use crate::target::Target;
diff --git a/src/gn/starlark/crates/ffi/src/value.rs b/src/gn/starlark/crates/ffi/src/value.rs index f183940..6916f53 100644 --- a/src/gn/starlark/crates/ffi/src/value.rs +++ b/src/gn/starlark/crates/ffi/src/value.rs
@@ -4,13 +4,12 @@ use std::pin::Pin; -use starlark::values::{list::ListRef, structs::StructRef, OwnedFrozen}; +use starlark::values::{OwnedFrozen, list::ListRef, structs::StructRef}; use crate::{ - bridge, + Immutable, Scope, Settings, Slice, bridge, bridge::{SliceAny, Value, ValueType}, errors::Error, - Immutable, Scope, Settings, Slice, }; impl Value {
diff --git a/src/gn/starlark/crates/loader/Cargo.toml b/src/gn/starlark/crates/loader/Cargo.toml index 67ddb92..c1c9a76 100644 --- a/src/gn/starlark/crates/loader/Cargo.toml +++ b/src/gn/starlark/crates/loader/Cargo.toml
@@ -1,7 +1,7 @@ [package] name = "loader" version = "0.1.0" -edition = "2021" +edition = "2024" [lints] workspace = true
diff --git a/src/gn/starlark/crates/loader/src/loader.rs b/src/gn/starlark/crates/loader/src/loader.rs index 1381d69..3ce01d2 100644 --- a/src/gn/starlark/crates/loader/src/loader.rs +++ b/src/gn/starlark/crates/loader/src/loader.rs
@@ -3,7 +3,7 @@ // found in the LICENSE file. use std::{ - collections::{hash_map::Entry, HashMap}, + collections::{HashMap, hash_map::Entry}, fs, pin::Pin, sync::{Arc, Condvar, Mutex, RwLock}, @@ -204,7 +204,7 @@ // other after the fact. { let mut status = current.lock().unwrap(); - let FileStatus::Loading { ref mut needs, .. } = &mut *status else { + let FileStatus::Loading { needs, .. } = &mut *status else { // find_cycle_path should only be called from the thing you're // currently trying to load. unreachable!();
diff --git a/src/gn/starlark/crates/providers/Cargo.toml b/src/gn/starlark/crates/providers/Cargo.toml index 80a0dcc..62e2373 100644 --- a/src/gn/starlark/crates/providers/Cargo.toml +++ b/src/gn/starlark/crates/providers/Cargo.toml
@@ -1,7 +1,7 @@ [package] name = "providers" version = "0.1.0" -edition = "2021" +edition = "2024" [lints] workspace = true
diff --git a/src/gn/starlark/crates/providers/src/provider_instance.rs b/src/gn/starlark/crates/providers/src/provider_instance.rs index f571cec..5bf5774 100644 --- a/src/gn/starlark/crates/providers/src/provider_instance.rs +++ b/src/gn/starlark/crates/providers/src/provider_instance.rs
@@ -11,7 +11,7 @@ starlark_complex_value, values::{Freeze, Heap, StarlarkValue, StringValue, Value, ValueTyped}, }; -use starlark_derive::{starlark_value, NoSerialize, Trace}; +use starlark_derive::{NoSerialize, Trace, starlark_value}; use crate::provider_type::ProviderType; @@ -152,7 +152,7 @@ mod tests { use starlark::values::UnpackValue as _; - use crate::{register_providers, ProviderInstance}; + use crate::{ProviderInstance, register_providers}; fn new_assert() -> testutils::Assert { let mut a = testutils::Assert::default();
diff --git a/src/gn/starlark/crates/providers/src/provider_type.rs b/src/gn/starlark/crates/providers/src/provider_type.rs index 3d27644..cdeee4b 100644 --- a/src/gn/starlark/crates/providers/src/provider_type.rs +++ b/src/gn/starlark/crates/providers/src/provider_type.rs
@@ -6,8 +6,8 @@ fmt, fmt::{Debug, Display}, sync::{ - atomic::{AtomicU64, Ordering}, OnceLock, + atomic::{AtomicU64, Ordering}, }, }; @@ -22,7 +22,7 @@ StringValue, Value, ValueTyped, }, }; -use starlark_derive::{starlark_value, NoSerialize, Trace}; +use starlark_derive::{NoSerialize, Trace, starlark_value}; use crate::{Error, ProviderInstance};
diff --git a/src/gn/starlark/crates/providers/src/providers.rs b/src/gn/starlark/crates/providers/src/providers.rs index e29783c..218da86 100644 --- a/src/gn/starlark/crates/providers/src/providers.rs +++ b/src/gn/starlark/crates/providers/src/providers.rs
@@ -8,8 +8,8 @@ collections::SmallMap, typing::Ty, values::{ - list::ListRef, structs::StructRef, type_repr::StarlarkTypeRepr, Heap, OwnedFrozen, - ProvidesStaticType, StarlarkValue, UnpackValue as _, Value, + Heap, OwnedFrozen, ProvidesStaticType, StarlarkValue, UnpackValue as _, Value, + list::ListRef, structs::StructRef, type_repr::StarlarkTypeRepr, }, }; use types::File;
diff --git a/src/gn/starlark/crates/rule/Cargo.toml b/src/gn/starlark/crates/rule/Cargo.toml index b38ce3f..49e1adc 100644 --- a/src/gn/starlark/crates/rule/Cargo.toml +++ b/src/gn/starlark/crates/rule/Cargo.toml
@@ -1,7 +1,7 @@ [package] name = "rule" version = "0.1.0" -edition = "2021" +edition = "2024" [lints] workspace = true
diff --git a/src/gn/starlark/crates/rule/src/actions.rs b/src/gn/starlark/crates/rule/src/actions.rs index 0360557..f20a233 100644 --- a/src/gn/starlark/crates/rule/src/actions.rs +++ b/src/gn/starlark/crates/rule/src/actions.rs
@@ -8,13 +8,13 @@ }; use allocative::Allocative; -use attr::{traits::EvalContextAttrExt, TargetAttrExt}; +use attr::{TargetAttrExt, traits::EvalContextAttrExt}; use starlark::{ any::ProvidesStaticType, environment::Methods, values::{AllocValue, Freeze, FreezeResult, Freezer, Heap, StarlarkValue, Trace, Value}, }; -use starlark_derive::{starlark_value, NoSerialize}; +use starlark_derive::{NoSerialize, starlark_value}; use types::{CtxMethods, Session}; /// The `ctx.actions` object which provides APIs to declare output files and
diff --git a/src/gn/starlark/crates/rule/src/ctx.rs b/src/gn/starlark/crates/rule/src/ctx.rs index 35ca4f6..e0c090c 100644 --- a/src/gn/starlark/crates/rule/src/ctx.rs +++ b/src/gn/starlark/crates/rule/src/ctx.rs
@@ -5,13 +5,13 @@ use std::{cell::RefCell, fmt}; use allocative::Allocative; -use attr::{traits::EvalContextAttrExt, CtxAttr, TargetAttrExt}; +use attr::{CtxAttr, TargetAttrExt, traits::EvalContextAttrExt}; use starlark::{ any::ProvidesStaticType, environment::Methods, values::{AllocValue, Freeze, FreezeResult, Freezer, Heap, StarlarkValue, Value}, }; -use starlark_derive::{starlark_value, NoSerialize}; +use starlark_derive::{NoSerialize, starlark_value}; use types::{CtxMethods, Session}; use crate::Rule;
diff --git a/src/gn/starlark/crates/rule/src/globals.rs b/src/gn/starlark/crates/rule/src/globals.rs index 53ec952..ea65910 100644 --- a/src/gn/starlark/crates/rule/src/globals.rs +++ b/src/gn/starlark/crates/rule/src/globals.rs
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -use attr::{traits::EvalContextAttrExt, TargetAttrExt}; +use attr::{TargetAttrExt, traits::EvalContextAttrExt}; use starlark::{ environment::{FrozenModule, Module}, values::FrozenHeapName,
diff --git a/src/gn/starlark/crates/rule/src/implementation.rs b/src/gn/starlark/crates/rule/src/implementation.rs index 14b0bb4..8f1864e 100644 --- a/src/gn/starlark/crates/rule/src/implementation.rs +++ b/src/gn/starlark/crates/rule/src/implementation.rs
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -use attr::{traits::EvalContextAttrExt, TargetAttrExt}; +use attr::{TargetAttrExt, traits::EvalContextAttrExt}; use starlark::{ environment::Module, eval::Evaluator,
diff --git a/src/gn/starlark/crates/rule/src/rule.rs b/src/gn/starlark/crates/rule/src/rule.rs index ac6781d..2903248 100644 --- a/src/gn/starlark/crates/rule/src/rule.rs +++ b/src/gn/starlark/crates/rule/src/rule.rs
@@ -5,7 +5,7 @@ use std::{cell::OnceCell, fmt, marker::PhantomData}; use allocative::Allocative; -use attr::{traits::EvalContextAttrExt, Attr, AttrSchema, CtxAttrSchema}; +use attr::{Attr, AttrSchema, CtxAttrSchema, traits::EvalContextAttrExt}; use starlark::{ any::ProvidesStaticType, collections::SmallMap, @@ -15,7 +15,7 @@ StarlarkValue, Trace, Value, ValueTyped, }, }; -use starlark_derive::{starlark_value, NoSerialize}; +use starlark_derive::{NoSerialize, starlark_value}; pub use types::OutputType; use types::{EvaluatorContextExt as _, Scope as _};
diff --git a/src/gn/starlark/crates/testutils/Cargo.toml b/src/gn/starlark/crates/testutils/Cargo.toml index 97f92b8..de204d8 100644 --- a/src/gn/starlark/crates/testutils/Cargo.toml +++ b/src/gn/starlark/crates/testutils/Cargo.toml
@@ -1,7 +1,7 @@ [package] name = "testutils" version = "0.1.0" -edition = "2021" +edition = "2024" [lints] workspace = true
diff --git a/src/gn/starlark/crates/testutils/src/assert.rs b/src/gn/starlark/crates/testutils/src/assert.rs index 6338515..ad77dba 100644 --- a/src/gn/starlark/crates/testutils/src/assert.rs +++ b/src/gn/starlark/crates/testutils/src/assert.rs
@@ -10,7 +10,7 @@ }; use types::{EvalContext as _, EvaluatorContextExt as _, Label, PathResolver}; -use crate::{register_globals, FakeEvalContext, FakeSession}; +use crate::{FakeEvalContext, FakeSession, register_globals}; type GlobalsConfig = Box<dyn Fn(&mut GlobalsBuilder)>;
diff --git a/src/gn/starlark/crates/testutils/src/eval_context.rs b/src/gn/starlark/crates/testutils/src/eval_context.rs index d42bcef..9b80110 100644 --- a/src/gn/starlark/crates/testutils/src/eval_context.rs +++ b/src/gn/starlark/crates/testutils/src/eval_context.rs
@@ -9,8 +9,8 @@ use attr::{Attr, EvalContext as AttrEvalContext, EvalContextAttrExt}; use starlark::{ - values::{FrozenValueTyped, Heap, ProvidesStaticType, Value}, Result, + values::{FrozenValueTyped, Heap, ProvidesStaticType, Value}, }; use types::{ CtxState, Label, LabelRef, OutputType, Package, PackageRef, PathResolver, Scope, Session,
diff --git a/src/gn/starlark/crates/testutils/src/target.rs b/src/gn/starlark/crates/testutils/src/target.rs index 3ea3a04..10df867 100644 --- a/src/gn/starlark/crates/testutils/src/target.rs +++ b/src/gn/starlark/crates/testutils/src/target.rs
@@ -14,7 +14,7 @@ starlark_simple_value, values::{Heap, ProvidesStaticType, StarlarkValue, Value}, }; -use starlark_derive::{starlark_value, NoSerialize}; +use starlark_derive::{NoSerialize, starlark_value}; use types::{File, IPromiseToImplementStarlarkEqAndHash, Label, LabelRef, OutputType, TargetRef}; use crate::FakeEvalContext;
diff --git a/src/gn/starlark/crates/types/Cargo.toml b/src/gn/starlark/crates/types/Cargo.toml index e1280a3..ffb6514 100644 --- a/src/gn/starlark/crates/types/Cargo.toml +++ b/src/gn/starlark/crates/types/Cargo.toml
@@ -1,7 +1,7 @@ [package] name = "types" version = "0.1.0" -edition = "2021" +edition = "2024" [lints] workspace = true
diff --git a/src/gn/starlark/crates/types/src/file.rs b/src/gn/starlark/crates/types/src/file.rs index 3638bde..59ea81e 100644 --- a/src/gn/starlark/crates/types/src/file.rs +++ b/src/gn/starlark/crates/types/src/file.rs
@@ -11,7 +11,7 @@ starlark_simple_value, values::{ProvidesStaticType, StarlarkValue}, }; -use starlark_derive::{starlark_module, starlark_value, Freeze, NoSerialize, Trace}; +use starlark_derive::{Freeze, NoSerialize, Trace, starlark_module, starlark_value}; /// File is equivalent to GN's OutputFile. Like OutputFile, its path is relative /// to the root_build_dir (which is also the execution directory). @@ -40,7 +40,7 @@ /// Interns a string for the duration of the program. pub fn intern_string(s: &str) -> &'static str { - extern "C" { + unsafe extern "C" { fn intern_string(s: &str) -> &'static str; } // Safety: Just an ffi function
diff --git a/src/gn/starlark/crates/types/src/label.rs b/src/gn/starlark/crates/types/src/label.rs index 8a0ce88..960a5c9 100644 --- a/src/gn/starlark/crates/types/src/label.rs +++ b/src/gn/starlark/crates/types/src/label.rs
@@ -9,7 +9,7 @@ starlark_simple_value, values::{ProvidesStaticType, StarlarkValue}, }; -use starlark_derive::{starlark_module, starlark_value, Freeze, NoSerialize, Trace}; +use starlark_derive::{Freeze, NoSerialize, Trace, starlark_module, starlark_value}; use crate::{LabelRef, Package, PackageRef};
diff --git a/src/gn/starlark/crates/types/src/lib.rs b/src/gn/starlark/crates/types/src/lib.rs index 5131c5e..413138b 100644 --- a/src/gn/starlark/crates/types/src/lib.rs +++ b/src/gn/starlark/crates/types/src/lib.rs
@@ -20,7 +20,7 @@ pub use ctx_state::CtxState; pub(crate) use errors::Error; pub use eval_context::{CtxMethods, EvalContext, EvaluatorContextExt}; -pub use file::{intern_string, File}; +pub use file::{File, intern_string}; pub use label::Label; pub use label_ref::LabelRef; pub use output_type::OutputType;
diff --git a/src/gn/starlark/rustfmt-nightly.toml b/src/gn/starlark/rustfmt-nightly.toml index d6142ae..9842cf3 100644 --- a/src/gn/starlark/rustfmt-nightly.toml +++ b/src/gn/starlark/rustfmt-nightly.toml
@@ -20,6 +20,8 @@ # Stable formatter features. # LINT.IfChange +edition = "2024" + # Automatically wrap comments and documentation at the line limit wrap_comments = true
diff --git a/src/gn/starlark/rustfmt.toml b/src/gn/starlark/rustfmt.toml index aec90bc..a8fb5a6 100644 --- a/src/gn/starlark/rustfmt.toml +++ b/src/gn/starlark/rustfmt.toml
@@ -1,5 +1,7 @@ # LINT.IfChange +edition = "2024" + # Automatically wrap comments and documentation at the line limit wrap_comments = true
diff --git a/tools/jj/rustfmt.sh b/tools/jj/rustfmt.sh index 1313a72..cd0a7c7 100755 --- a/tools/jj/rustfmt.sh +++ b/tools/jj/rustfmt.sh
@@ -7,8 +7,8 @@ # Use nightly rustfmt if available to get advanced formatting (import sorting, etc.) if rustup run nightly rustfmt --version >/dev/null 2>&1; then - rustup run nightly rustfmt --edition=2021 --config-path=src/gn/starlark/rustfmt-nightly.toml + rustup run nightly rustfmt --config-path=src/gn/starlark/rustfmt-nightly.toml else # Otherwise fallback to stable rustfmt with standard stable formatting rules - rustfmt --edition=2021 --config-path=src/gn/starlark/rustfmt.toml + rustfmt --config-path=src/gn/starlark/rustfmt.toml fi