diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index eb67706035..49283b6879 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,12 +12,12 @@ repos: - id: buildifier-lint args: [--version, "v8.2.0", --warnings=all] - repo: https://github.com/crate-ci/typos - rev: v1.33.1 + rev: v1.34.0 hooks: - id: typos exclude: | (?x)^( - crate_universe| + crate_universe/test_data| examples| extensions| ffi| diff --git a/.typos.toml b/.typos.toml index a8a1fde16f..e5c532bcb4 100644 --- a/.typos.toml +++ b/.typos.toml @@ -1,2 +1,3 @@ [default.extend-words] nto = "nto" # For toolchains +flate = "flate" # https://crates.io/crates/flate2 diff --git a/crate_universe/BUILD.bazel b/crate_universe/BUILD.bazel index 85f7611ee2..3f8a594dfc 100644 --- a/crate_universe/BUILD.bazel +++ b/crate_universe/BUILD.bazel @@ -70,7 +70,7 @@ rust_library( # This target embeds additional, stamping related information (see # https://docs.bazel.build/versions/main/user-manual.html#workspace_status # for more information). Set stamp = -1 to indicate that it should respect - # the value of the --stamp comandline flag. + # the value of the --stamp commandline flag. stamp = -1, version = VERSION, visibility = ["//visibility:public"], diff --git a/crate_universe/defs.bzl b/crate_universe/defs.bzl index 6d2979ad79..2d5f219ebd 100644 --- a/crate_universe/defs.bzl +++ b/crate_universe/defs.bzl @@ -99,7 +99,7 @@ rust_test( ### Direct Packages -In cases where Rust targets have heavy interractions with other Bazel targests ([Cc][cc], [Proto][proto], etc.), +In cases where Rust targets have heavy interractions with other Bazel targets ([Cc][cc], [Proto][proto], etc.), maintaining `Cargo.toml` files may have deminishing returns as things like [rust-analyzer][ra] begin to be confused about missing targets or environment variables defined only in Bazel. In workspaces like this, it may be desirable to have a "Cargo free" setup. `crates_repository` supports this through the `packages` attribute. @@ -124,7 +124,7 @@ crates_repository( }, # Setting the default package name to `""` forces the use of the macros defined in this repository # to always use the root package when looking for dependencies or aliases. This should be considered - # optional as the repository also exposes alises for easy access to all dependencies. + # optional as the repository also exposes aliases for easy access to all dependencies. render_config = render_config( default_package_name = "" ), diff --git a/crate_universe/extensions.bzl b/crate_universe/extensions.bzl index 3327bbede6..79c2ea94a5 100644 --- a/crate_universe/extensions.bzl +++ b/crate_universe/extensions.bzl @@ -1047,7 +1047,7 @@ _FROM_COMMON_ATTRS = { "order to prevent other uses of Cargo from impacting having any effect on the generated targets " + "produced by this rule. For users who either have multiple `crate_repository` definitions in a " + "WORKSPACE or rapidly re-pin dependencies, setting this to false may improve build times. This " + - "variable is also controled by `CARGO_BAZEL_ISOLATED` environment variable." + "variable is also controlled by `CARGO_BAZEL_ISOLATED` environment variable." ), default = True, ), @@ -1342,7 +1342,7 @@ can be found below where the supported keys for each template can be found in th default = True, ), "generate_rules_license_metadata": attr.bool( - doc = "Whether to generate rules license metedata.", + doc = "Whether to generate rules license metadata.", default = False, ), "generate_target_compatible_with": attr.bool( diff --git a/crate_universe/private/common_utils.bzl b/crate_universe/private/common_utils.bzl index 4c4af014d6..da070da004 100644 --- a/crate_universe/private/common_utils.bzl +++ b/crate_universe/private/common_utils.bzl @@ -30,7 +30,7 @@ STDERR ------------------------------------------------------------------------ """ def execute(repository_ctx, args, env = {}, allow_fail = False, quiet = True): - """A heler macro for executing some arguments and displaying nicely formatted errors + """A helper macro for executing some arguments and displaying nicely formatted errors Args: repository_ctx (repository_ctx): The rule's context object. @@ -159,7 +159,7 @@ def _cargo_home_path(repository_ctx): return repository_ctx.path(".cargo_home") def cargo_environ(repository_ctx, isolated = True): - """Define Cargo environment varables for use with `cargo-bazel` + """Define Cargo environment variables for use with `cargo-bazel` Args: repository_ctx (repository_ctx): The rules context object diff --git a/crate_universe/private/crate.bzl b/crate_universe/private/crate.bzl index 9aabec7070..0ce27f4b8a 100644 --- a/crate_universe/private/crate.bzl +++ b/crate_universe/private/crate.bzl @@ -159,7 +159,7 @@ def _annotation( gen_binaries (list or bool, optional): As a list, the subset of the crate's bins that should get `rust_binary` targets produced. Or `True` to generate all, `False` to generate none. disable_pipelining (bool, optional): If True, disables pipelining for library targets for this crate. - gen_build_script (bool, optional): An authorative flag to determine whether or not to produce + gen_build_script (bool, optional): An authoritative flag to determine whether or not to produce `cargo_build_script` targets for the current crate. patch_args (list, optional): The `patch_args` attribute of a Bazel repository rule. See [http_archive.patch_args](https://docs.bazel.build/versions/main/repo/http.html#http_archive-patch_args) diff --git a/crate_universe/private/crates_repository.bzl b/crate_universe/private/crates_repository.bzl index 64d6e3802e..7fbf3423ed 100644 --- a/crate_universe/private/crates_repository.bzl +++ b/crate_universe/private/crates_repository.bzl @@ -219,7 +219,7 @@ CARGO_BAZEL_REPIN=1 bazel sync --only=crate_index This will result in all dependencies being updated for a project. The `CARGO_BAZEL_REPIN` environment variable can also be used to customize how dependencies are updated. The following table shows translations from environment -variable values to the equivilant [cargo update](https://doc.rust-lang.org/cargo/commands/cargo-update.html) command +variable values to the equivalent [cargo update](https://doc.rust-lang.org/cargo/commands/cargo-update.html) command that is called behind the scenes to update dependencies. | Value | Cargo command | @@ -259,7 +259,7 @@ CARGO_BAZEL_REPIN=1 CARGO_BAZEL_REPIN_ONLY=crate_index bazel sync --only=crate_i mandatory = True, ), "compressed_windows_toolchain_names": attr.bool( - doc = "Wether or not the toolchain names of windows toolchains are expected to be in a `compressed` format.", + doc = "Whether or not the toolchain names of windows toolchains are expected to be in a `compressed` format.", default = True, ), "generate_binaries": attr.bool( @@ -303,7 +303,7 @@ CARGO_BAZEL_REPIN=1 CARGO_BAZEL_REPIN_ONLY=crate_index bazel sync --only=crate_i "order to prevent other uses of Cargo from impacting having any effect on the generated targets " + "produced by this rule. For users who either have multiple `crate_repository` definitions in a " + "WORKSPACE or rapidly re-pin dependencies, setting this to false may improve build times. This " + - "variable is also controled by `CARGO_BAZEL_ISOLATED` environment variable." + "variable is also controlled by `CARGO_BAZEL_ISOLATED` environment variable." ), default = True, ), diff --git a/crate_universe/private/generate_utils.bzl b/crate_universe/private/generate_utils.bzl index e69014e78b..a59f4a96cb 100644 --- a/crate_universe/private/generate_utils.bzl +++ b/crate_universe/private/generate_utils.bzl @@ -144,7 +144,7 @@ def render_config( keys are [`{triple}`]. regen_command (str, optional): An optional command to demonstrate how generated files should be regenerated. vendor_mode (str, optional): An optional configuration for rendirng content to be rendered into repositories. - generate_rules_license_metadata (bool, optional): Whether to generate rules license metedata + generate_rules_license_metadata (bool, optional): Whether to generate rules license metadata Returns: string: A json encoded struct to match the Rust `config::RenderConfig` struct diff --git a/crate_universe/private/local_crate_mirror.bzl b/crate_universe/private/local_crate_mirror.bzl index 4298e5d8b7..06fed9571f 100644 --- a/crate_universe/private/local_crate_mirror.bzl +++ b/crate_universe/private/local_crate_mirror.bzl @@ -29,7 +29,7 @@ def _local_crate_mirror_impl(repository_ctx): local_crate_mirror = repository_rule( doc = """This is a private implementation detail of crate_universe, and should not be relied on in manually written code. -This is effectively a `local_repository` rule impementation, but where the BUILD.bazel file is generated using the `cargo-bazel render` command.""", +This is effectively a `local_repository` rule implementation, but where the `BUILD.bazel` file is generated using the `cargo-bazel render` command.""", implementation = _local_crate_mirror_impl, attrs = { "generator": attr.string( diff --git a/crate_universe/private/splicing_utils.bzl b/crate_universe/private/splicing_utils.bzl index ea6f4ae5d4..49d1acd829 100644 --- a/crate_universe/private/splicing_utils.bzl +++ b/crate_universe/private/splicing_utils.bzl @@ -49,7 +49,7 @@ def compile_splicing_manifest(splicing_config, manifests, cargo_config_path, pac dict: A dictionary representation of a `cargo_bazel::splicing::SplicingManifest` """ - # Deserialize information about direct packges + # Deserialize information about direct packages direct_packages_info = { # Ensure the data is using kebab-case as that's what `cargo_toml::DependencyDetail` expects. pkg: kebab_case_keys(dict(json.decode(data))) @@ -66,7 +66,7 @@ def compile_splicing_manifest(splicing_config, manifests, cargo_config_path, pac return splicing_config | splicing_manifest_content def _no_at_label(label): - """Strips leading '@'s for stringified labels in the main repository for backwards-comaptibility reasons.""" + """Strips leading '@'s for stringified labels in the main repository for backwards-compatibility reasons.""" s = str(label) if s.startswith("@@//"): return s[2:] diff --git a/crate_universe/src/cli/vendor.rs b/crate_universe/src/cli/vendor.rs index 926dfe8ec6..b2ebf71139 100644 --- a/crate_universe/src/cli/vendor.rs +++ b/crate_universe/src/cli/vendor.rs @@ -260,7 +260,7 @@ pub fn vendor(opt: VendorOptions) -> anyhow::Result<()> { &opt.nonhermetic_root_bazel_workspace_dir, )?; - // Generate renderable contexts for earch package + // Generate renderable contexts for search package let context = Context::new(annotations, config.rendering.are_sources_present())?; // Render build files diff --git a/crate_universe/src/config.rs b/crate_universe/src/config.rs index 5f9b14822e..3a5fb81483 100644 --- a/crate_universe/src/config.rs +++ b/crate_universe/src/config.rs @@ -110,7 +110,7 @@ pub(crate) struct RenderConfig { } // Default is manually implemented so that the default values match the default -// values when deserializing, which involves calling the vairous `default_x()` +// values when deserializing, which involves calling the various `default_x()` // functions specified in `#[serde(default = "default_x")]`. impl Default for RenderConfig { fn default() -> Self { @@ -240,7 +240,7 @@ pub(crate) struct CrateAnnotations { /// Which subset of the crate's bins should get produced as `rust_binary` targets. pub(crate) gen_binaries: Option, - /// Determins whether or not Cargo build scripts should be generated for the current package + /// Determines whether or not Cargo build scripts should be generated for the current package pub(crate) gen_build_script: Option, /// Additional data to pass to diff --git a/crate_universe/src/context/platforms.rs b/crate_universe/src/context/platforms.rs index 7ea36f2f0f..22573a5610 100644 --- a/crate_universe/src/context/platforms.rs +++ b/crate_universe/src/context/platforms.rs @@ -51,9 +51,9 @@ pub(crate) fn resolve_cfg_platforms( .collect::>>()?; // `cfg-expr` does not understand configurations that are simply platform triples - // (`x86_64-unknown-linux-gnu` vs `cfg(target = "x86_64-unkonwn-linux-gnu")`). So + // (`x86_64-unknown-linux-gnu` vs `cfg(target = "x86_64-unknown-linux-gnu")`). So // in order to parse configurations, the text is renamed for the check but the - // original is retained for comaptibility with the manifest. + // original is retained for compatibility with the manifest. let rename = |cfg: &str| -> String { format!("cfg(target = \"{cfg}\")") }; let original_cfgs: BTreeMap = configurations .iter() diff --git a/crate_universe/src/metadata/metadata_annotation.rs b/crate_universe/src/metadata/metadata_annotation.rs index b386d9b6f9..bf98d9e16a 100644 --- a/crate_universe/src/metadata/metadata_annotation.rs +++ b/crate_universe/src/metadata/metadata_annotation.rs @@ -281,7 +281,7 @@ impl LockfileAnnotation { path.parent() .context("unexpected empty lockfile path")?, ) - .context("unxpected non-Unicode lockfile path")?; + .context("unexpected non-Unicode lockfile path")?; if p.starts_with(nonhermetic_root_bazel_workspace_dir) { // If path in lockfile is under Bazel root, strip Bazel // root to get the actual path. @@ -523,7 +523,7 @@ fn find_workspace_metadata(cargo_metadata: &CargoMetadata) -> Option bool { if cargo_metadata.workspace_members.contains(id) { diff --git a/crate_universe/src/rendering/template_engine.rs b/crate_universe/src/rendering/template_engine.rs index ae1c3c6ec5..d9356c4f41 100644 --- a/crate_universe/src/rendering/template_engine.rs +++ b/crate_universe/src/rendering/template_engine.rs @@ -180,7 +180,7 @@ impl TemplateEngine { } } -/// A convienience wrapper for parsing parameters to tera functions +/// A convenience wrapper for parsing parameters to tera functions macro_rules! parse_tera_param { ($param:literal, $param_type:ty, $args:ident) => { match $args.get($param) { @@ -188,7 +188,7 @@ macro_rules! parse_tera_param { Ok(v) => v, Err(_) => { return Err(tera::Error::msg(format!( - "The `{}` paramater could not be parsed as a String.", + "The `{}` parameter could not be parsed as a String.", $param ))) } diff --git a/crate_universe/src/splicing.rs b/crate_universe/src/splicing.rs index 4417386bea..96b0e1aaf8 100644 --- a/crate_universe/src/splicing.rs +++ b/crate_universe/src/splicing.rs @@ -228,7 +228,7 @@ impl WorkspaceMetadata { }) .collect(); - // It is invald for toml maps to use empty strings as keys. In the case + // It is invalid for toml maps to use empty strings as keys. In the case // the empty key is expected to be the root package. If the root package // has a prefix, then all other packages will as well (even if no other // manifest represents them). The value is then saved as a separate value @@ -472,7 +472,7 @@ pub(crate) fn generate_lockfile( let root_lockfile_path = manifest_dir.join("Cargo.lock"); - // Remove the file so it's not overwitten if it happens to be a symlink. + // Remove the file so it's not overwritten if it happens to be a symlink. if root_lockfile_path.exists() { fs::remove_file(&root_lockfile_path)?; } diff --git a/crate_universe/src/splicing/splicer.rs b/crate_universe/src/splicing/splicer.rs index 11b7fd088b..9de96f0c5b 100644 --- a/crate_universe/src/splicing/splicer.rs +++ b/crate_universe/src/splicing/splicer.rs @@ -506,7 +506,7 @@ const DEFAULT_SPLICING_PACKAGE_VERSION: &str = "0.0.1"; pub(crate) fn default_cargo_package_manifest() -> cargo_toml::Manifest { // A manifest is generated with a fake workspace member so the [cargo_toml::Manifest::Workspace] - // member is deseralized and is not `None`. + // member is deserialized and is not `None`. cargo_toml::Manifest::from_str( &toml::toml! { [package] @@ -536,7 +536,7 @@ pub(crate) fn default_cargo_workspace_manifest( resolver_version: &cargo_toml::Resolver, ) -> cargo_toml::Manifest { // A manifest is generated with a fake workspace member so the [cargo_toml::Manifest::Workspace] - // member is deseralized and is not `None`. + // member is deserialized and is not `None`. let mut manifest = cargo_toml::Manifest::from_str(&textwrap::dedent(&format!( r#" [workspace] @@ -1379,7 +1379,7 @@ mod test { ) .unwrap(); - // Due to the addition of direct deps for splicing, this package should have been added to the root manfiest. + // Due to the addition of direct deps for splicing, this package should have been added to the root manifest. assert!(cargo_manifest.package.unwrap().name == DEFAULT_SPLICING_PACKAGE_NAME); } diff --git a/crate_universe/tools/urls_generator/src/main.rs b/crate_universe/tools/urls_generator/src/main.rs index f72a3ddf7a..a5e6aa97a9 100644 --- a/crate_universe/tools/urls_generator/src/main.rs +++ b/crate_universe/tools/urls_generator/src/main.rs @@ -38,7 +38,7 @@ fn calculate_sha256(file_path: &Path) -> String { let mut hasher = Sha256::new(); loop { - let consummed = { + let consumed = { let buffer = reader.fill_buf().unwrap(); if buffer.is_empty() { break; @@ -46,7 +46,7 @@ fn calculate_sha256(file_path: &Path) -> String { hasher.update(buffer); buffer.len() }; - reader.consume(consummed); + reader.consume(consumed); } let digest = hasher.finalize();