Skip to content

Commit

Permalink
Added Rust 1.77.0 (bazelbuild#2568)
Browse files Browse the repository at this point in the history
  • Loading branch information
UebelAndre authored and granaghan committed Mar 23, 2024
1 parent b0684bb commit 907264e
Show file tree
Hide file tree
Showing 40 changed files with 1,713 additions and 859 deletions.
1 change: 0 additions & 1 deletion crate_universe/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

use std::cmp::Ordering;
use std::collections::{BTreeMap, BTreeSet};
use std::convert::AsRef;
use std::fmt::Formatter;
use std::iter::Sum;
use std::ops::Add;
Expand Down
1 change: 0 additions & 1 deletion crate_universe/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use anyhow::Result;
use serde::{Deserialize, Serialize};

use crate::config::CrateId;
use crate::context::crate_context::{CrateContext, CrateDependency, Rule};
use crate::context::platforms::resolve_cfg_platforms;
use crate::lockfile::Digest;
use crate::metadata::{Annotations, Dependency};
Expand Down
14 changes: 7 additions & 7 deletions crate_universe/src/context/crate_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ impl CrateContext {

// Git shallow_since
if let Some(SourceAnnotation::Git { shallow_since, .. }) = &mut self.repository {
*shallow_since = crate_extra.shallow_since.clone()
shallow_since.clone_from(&crate_extra.shallow_since);
}

// Patch attributes
Expand All @@ -641,19 +641,19 @@ impl CrateContext {
patches,
..
} => {
*patch_args = crate_extra.patch_args.clone();
*patch_tool = crate_extra.patch_tool.clone();
*patches = crate_extra.patches.clone();
patch_args.clone_from(&crate_extra.patch_args);
patch_tool.clone_from(&crate_extra.patch_tool);
patches.clone_from(&crate_extra.patches);
}
SourceAnnotation::Http {
patch_args,
patch_tool,
patches,
..
} => {
*patch_args = crate_extra.patch_args.clone();
*patch_tool = crate_extra.patch_tool.clone();
*patches = crate_extra.patches.clone();
patch_args.clone_from(&crate_extra.patch_args);
patch_tool.clone_from(&crate_extra.patch_tool);
patches.clone_from(&crate_extra.patches);
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions crate_universe/src/lockfile.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//! Utility module for interacting with the cargo-bazel lockfile.

use std::collections::BTreeMap;
use std::convert::TryFrom;
use std::ffi::OsStr;
use std::fs;
use std::path::Path;
Expand Down Expand Up @@ -193,7 +192,7 @@ mod test {

use super::*;

use std::collections::{BTreeMap, BTreeSet};
use std::collections::BTreeSet;

#[test]
fn simple_digest() {
Expand Down
2 changes: 1 addition & 1 deletion crate_universe/src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ impl Cargo {
let version_str = full_version.split(' ').nth(1);
if let Some(version_str) = version_str {
let version = Version::parse(version_str).context("Failed to parse cargo version")?;
return Ok(version.major >= 1 && version.minor >= 78);
return Ok(version.major >= 1 && version.minor >= 77);
}
bail!("Couldn't parse cargo version");
}
Expand Down
2 changes: 0 additions & 2 deletions crate_universe/src/metadata/dependency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,6 @@ fn get_target_alias(target_name: &str, package: &Package) -> Option<String> {

#[cfg(test)]
mod test {
use std::collections::BTreeSet;

use super::*;

use crate::test::*;
Expand Down
1 change: 0 additions & 1 deletion crate_universe/src/metadata/metadata_annotation.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//! Collect and store information from Cargo metadata specific to Bazel's needs

use std::collections::{BTreeMap, BTreeSet};
use std::convert::TryFrom;
use std::path::PathBuf;

use anyhow::{bail, Result};
Expand Down
9 changes: 3 additions & 6 deletions crate_universe/src/rendering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ mod template_engine;

use std::collections::{BTreeMap, BTreeSet};
use std::fs;
use std::iter::FromIterator;
use std::path::{Path, PathBuf};
use std::str::FromStr;

Expand Down Expand Up @@ -902,11 +901,9 @@ mod test {
use super::*;

use indoc::indoc;
use std::collections::BTreeSet;

use crate::config::{Config, CrateId, VendorMode};
use crate::context::crate_context::{CrateContext, Rule};
use crate::context::{BuildScriptAttributes, CommonAttributes, Context, TargetAttributes};
use crate::config::{Config, CrateId};
use crate::context::{BuildScriptAttributes, CommonAttributes};
use crate::metadata::Annotations;
use crate::test;

Expand Down Expand Up @@ -1312,7 +1309,7 @@ mod test {
assert!(!defs_module.contains("def crate_repositories():"));

// Local vendoring does not produce a `crates.bzl` file.
assert!(output.get(&PathBuf::from("crates.bzl")).is_none());
assert!(!output.contains_key(&PathBuf::from("crates.bzl")));
}

#[test]
Expand Down
7 changes: 3 additions & 4 deletions crate_universe/src/rendering/template_engine.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
//! A template engine backed by [Tera] for rendering Files.
//! A template engine backed by [tera::Tera] for rendering Files.

use std::collections::HashMap;

use anyhow::{Context as AnyhowContext, Result};
use serde_json::{from_value, to_value, Value};
use tera::{self, Tera};

use crate::config::RenderConfig;
use crate::context::Context;
Expand All @@ -16,13 +15,13 @@ use crate::select::Select;
use crate::utils::sanitize_repository_name;

pub(crate) struct TemplateEngine {
engine: Tera,
engine: tera::Tera,
context: tera::Context,
}

impl TemplateEngine {
pub(crate) fn new(render_config: &RenderConfig) -> Self {
let mut tera = Tera::default();
let mut tera = tera::Tera::default();
tera.add_raw_templates(vec![
(
"partials/module/aliases_map.j2",
Expand Down
3 changes: 0 additions & 3 deletions crate_universe/src/splicing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ mod crate_index_lookup;
mod splicer;

use std::collections::{BTreeMap, BTreeSet};
use std::convert::TryFrom;
use std::fs;
use std::path::{Path, PathBuf};
use std::str::FromStr;
Expand Down Expand Up @@ -481,8 +480,6 @@ pub(crate) fn generate_lockfile(
mod test {
use super::*;

use std::path::PathBuf;

#[test]
fn deserialize_splicing_manifest() {
let runfiles = runfiles::Runfiles::create().unwrap();
Expand Down
2 changes: 0 additions & 2 deletions crate_universe/src/splicing/cargo_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,6 @@ impl CargoConfig {
mod test {
use super::*;

use std::fs;

#[test]
fn registry_settings() {
let temp_dir = tempfile::tempdir().unwrap();
Expand Down
4 changes: 1 addition & 3 deletions crate_universe/src/splicing/splicer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -747,15 +747,13 @@ pub(crate) fn symlink_roots(
mod test {
use super::*;

use std::fs;
use std::fs::File;
use std::str::FromStr;

use cargo_metadata::{MetadataCommand, PackageId};
use cargo_metadata::PackageId;
use maplit::btreeset;

use crate::splicing::Cargo;
use crate::utils::starlark::Label;

/// Clone and compare two items after calling `.sort()` on them.
macro_rules! assert_sort_eq {
Expand Down
1 change: 0 additions & 1 deletion crate_universe/src/utils/starlark/select.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::collections::BTreeSet;
use std::iter::FromIterator;

use serde::ser::Serializer;
use serde::Serialize;
Expand Down
2 changes: 1 addition & 1 deletion docs/cargo.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ A rule for bootstrapping a Rust binary using [Cargo](https://doc.rust-lang.org/c
| <a id="cargo_bootstrap_repository-rust_toolchain_rustc_template"></a>rust_toolchain_rustc_template | The template to use for finding the host <code>rustc</code> binary. <code>{version}</code> (eg. '1.53.0'), <code>{triple}</code> (eg. 'x86_64-unknown-linux-gnu'), <code>{arch}</code> (eg. 'aarch64'), <code>{vendor}</code> (eg. 'unknown'), <code>{system}</code> (eg. 'darwin'), <code>{channel}</code> (eg. 'stable'), and <code>{tool}</code> (eg. 'rustc.exe') will be replaced in the string if present. | String | optional | <code>"@rust_{system}_{arch}__{triple}__{channel}_tools//:bin/{tool}"</code> |
| <a id="cargo_bootstrap_repository-srcs"></a>srcs | Souce files of the crate to build. Passing source files here can be used to trigger rebuilds when changes are made | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | <code>[]</code> |
| <a id="cargo_bootstrap_repository-timeout"></a>timeout | Maximum duration of the Cargo build command in seconds | Integer | optional | <code>600</code> |
| <a id="cargo_bootstrap_repository-version"></a>version | The version of cargo the resolver should use | String | optional | <code>"1.76.0"</code> |
| <a id="cargo_bootstrap_repository-version"></a>version | The version of cargo the resolver should use | String | optional | <code>"1.77.0"</code> |


<a id="cargo_dep_env"></a>
Expand Down
4 changes: 2 additions & 2 deletions docs/crate_universe.md
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ CARGO_BAZEL_REPIN=1 CARGO_BAZEL_REPIN_ONLY=crate_index bazel sync --only=crate_i
| <a id="crates_repository-repo_mapping"></a>repo_mapping | A dictionary from local repository name to global repository name. This allows controls over workspace dependency resolution for dependencies of this repository.&lt;p&gt;For example, an entry <code>"@foo": "@bar"</code> declares that, for any time this repository depends on <code>@foo</code> (such as a dependency on <code>@foo//some:target</code>, it should actually resolve that dependency within globally-declared <code>@bar</code> (<code>@bar//some:target</code>). | <a href="https://bazel.build/rules/lib/dict">Dictionary: String -> String</a> | required | |
| <a id="crates_repository-rust_toolchain_cargo_template"></a>rust_toolchain_cargo_template | The template to use for finding the host <code>cargo</code> binary. <code>{version}</code> (eg. '1.53.0'), <code>{triple}</code> (eg. 'x86_64-unknown-linux-gnu'), <code>{arch}</code> (eg. 'aarch64'), <code>{vendor}</code> (eg. 'unknown'), <code>{system}</code> (eg. 'darwin'), <code>{cfg}</code> (eg. 'exec'), <code>{channel}</code> (eg. 'stable'), and <code>{tool}</code> (eg. 'rustc.exe') will be replaced in the string if present. | String | optional | <code>"@rust_{system}_{arch}__{triple}__{channel}_tools//:bin/{tool}"</code> |
| <a id="crates_repository-rust_toolchain_rustc_template"></a>rust_toolchain_rustc_template | The template to use for finding the host <code>rustc</code> binary. <code>{version}</code> (eg. '1.53.0'), <code>{triple}</code> (eg. 'x86_64-unknown-linux-gnu'), <code>{arch}</code> (eg. 'aarch64'), <code>{vendor}</code> (eg. 'unknown'), <code>{system}</code> (eg. 'darwin'), <code>{cfg}</code> (eg. 'exec'), <code>{channel}</code> (eg. 'stable'), and <code>{tool}</code> (eg. 'cargo.exe') will be replaced in the string if present. | String | optional | <code>"@rust_{system}_{arch}__{triple}__{channel}_tools//:bin/{tool}"</code> |
| <a id="crates_repository-rust_version"></a>rust_version | The version of Rust the currently registered toolchain is using. Eg. <code>1.56.0</code>, or <code>nightly/2021-09-08</code> | String | optional | <code>"1.76.0"</code> |
| <a id="crates_repository-rust_version"></a>rust_version | The version of Rust the currently registered toolchain is using. Eg. <code>1.56.0</code>, or <code>nightly/2021-09-08</code> | String | optional | <code>"1.77.0"</code> |
| <a id="crates_repository-splicing_config"></a>splicing_config | The configuration flags to use for splicing Cargo maniests. Use <code>//crate_universe:defs.bzl\%rsplicing_config</code> to generate the value for this field. If unset, the defaults defined there will be used. | String | optional | <code>""</code> |
| <a id="crates_repository-supported_platform_triples"></a>supported_platform_triples | A set of all platform triples to consider when generating dependencies. | List of strings | optional | <code>["aarch64-unknown-linux-gnu", "aarch64-unknown-nixos-gnu", "i686-apple-darwin", "i686-pc-windows-msvc", "i686-unknown-linux-gnu", "x86_64-apple-darwin", "x86_64-pc-windows-msvc", "x86_64-unknown-linux-gnu", "x86_64-unknown-nixos-gnu", "aarch64-apple-darwin", "aarch64-apple-ios-sim", "aarch64-apple-ios", "aarch64-fuchsia", "aarch64-linux-android", "aarch64-pc-windows-msvc", "arm-unknown-linux-gnueabi", "armv7-linux-androideabi", "armv7-unknown-linux-gnueabi", "i686-linux-android", "i686-unknown-freebsd", "powerpc-unknown-linux-gnu", "riscv32imc-unknown-none-elf", "riscv64gc-unknown-none-elf", "s390x-unknown-linux-gnu", "thumbv7em-none-eabi", "thumbv8m.main-none-eabi", "wasm32-unknown-unknown", "wasm32-wasi", "x86_64-apple-ios", "x86_64-fuchsia", "x86_64-linux-android", "x86_64-unknown-freebsd", "x86_64-unknown-none", "aarch64-unknown-nto-qnx710"]</code> |

Expand Down Expand Up @@ -760,7 +760,7 @@ Define dependencies of the `cargo-bazel` Rust target

| Name | Description | Default Value |
| :------------- | :------------- | :------------- |
| <a id="crate_universe_dependencies-rust_version"></a>rust_version | The version of rust to use when generating dependencies. | `"1.76.0"` |
| <a id="crate_universe_dependencies-rust_version"></a>rust_version | The version of rust to use when generating dependencies. | `"1.77.0"` |
| <a id="crate_universe_dependencies-bootstrap"></a>bootstrap | If true, a <code>cargo_bootstrap_repository</code> target will be generated. | `False` |
| <a id="crate_universe_dependencies-kwargs"></a>kwargs | Arguments to pass through to cargo_bazel_bootstrap. | none |

Expand Down
4 changes: 2 additions & 2 deletions docs/flatten.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ A rule for bootstrapping a Rust binary using [Cargo](https://doc.rust-lang.org/c
| <a id="cargo_bootstrap_repository-rust_toolchain_rustc_template"></a>rust_toolchain_rustc_template | The template to use for finding the host <code>rustc</code> binary. <code>{version}</code> (eg. '1.53.0'), <code>{triple}</code> (eg. 'x86_64-unknown-linux-gnu'), <code>{arch}</code> (eg. 'aarch64'), <code>{vendor}</code> (eg. 'unknown'), <code>{system}</code> (eg. 'darwin'), <code>{channel}</code> (eg. 'stable'), and <code>{tool}</code> (eg. 'rustc.exe') will be replaced in the string if present. | String | optional | <code>"@rust_{system}_{arch}__{triple}__{channel}_tools//:bin/{tool}"</code> |
| <a id="cargo_bootstrap_repository-srcs"></a>srcs | Souce files of the crate to build. Passing source files here can be used to trigger rebuilds when changes are made | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | <code>[]</code> |
| <a id="cargo_bootstrap_repository-timeout"></a>timeout | Maximum duration of the Cargo build command in seconds | Integer | optional | <code>600</code> |
| <a id="cargo_bootstrap_repository-version"></a>version | The version of cargo the resolver should use | String | optional | <code>"1.76.0"</code> |
| <a id="cargo_bootstrap_repository-version"></a>version | The version of cargo the resolver should use | String | optional | <code>"1.77.0"</code> |


<a id="cargo_dep_env"></a>
Expand Down Expand Up @@ -1953,7 +1953,7 @@ See `load_arbitrary_tool` in `@rules_rust//rust:repositories.bzl` for more detai
| <a id="rust_register_toolchains-global_allocator_library"></a>global_allocator_library | Target that provides allocator functions when global allocator is used with cc_common.link. | `None` |
| <a id="rust_register_toolchains-iso_date"></a>iso_date | **Deprecated**: Use <code>versions</code> instead. | `None` |
| <a id="rust_register_toolchains-register_toolchains"></a>register_toolchains | If true, repositories will be generated to produce and register <code>rust_toolchain</code> targets. | `True` |
| <a id="rust_register_toolchains-rustfmt_version"></a>rustfmt_version | The version of rustfmt. | `"nightly/2024-02-08"` |
| <a id="rust_register_toolchains-rustfmt_version"></a>rustfmt_version | The version of rustfmt. | `"nightly/2024-03-21"` |
| <a id="rust_register_toolchains-rust_analyzer_version"></a>rust_analyzer_version | The version of Rustc to pair with rust-analyzer. | `None` |
| <a id="rust_register_toolchains-sha256s"></a>sha256s | A dict associating tool subdirectories to sha256 hashes. | `None` |
| <a id="rust_register_toolchains-extra_target_triples"></a>extra_target_triples | Additional rust-style targets that rust toolchains should support. | `["wasm32-unknown-unknown", "wasm32-wasi"]` |
Expand Down
2 changes: 1 addition & 1 deletion docs/rust_repositories.md
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ See `load_arbitrary_tool` in `@rules_rust//rust:repositories.bzl` for more detai
| <a id="rust_register_toolchains-global_allocator_library"></a>global_allocator_library | Target that provides allocator functions when global allocator is used with cc_common.link. | `None` |
| <a id="rust_register_toolchains-iso_date"></a>iso_date | **Deprecated**: Use <code>versions</code> instead. | `None` |
| <a id="rust_register_toolchains-register_toolchains"></a>register_toolchains | If true, repositories will be generated to produce and register <code>rust_toolchain</code> targets. | `True` |
| <a id="rust_register_toolchains-rustfmt_version"></a>rustfmt_version | The version of rustfmt. | `"nightly/2024-02-08"` |
| <a id="rust_register_toolchains-rustfmt_version"></a>rustfmt_version | The version of rustfmt. | `"nightly/2024-03-21"` |
| <a id="rust_register_toolchains-rust_analyzer_version"></a>rust_analyzer_version | The version of Rustc to pair with rust-analyzer. | `None` |
| <a id="rust_register_toolchains-sha256s"></a>sha256s | A dict associating tool subdirectories to sha256 hashes. | `None` |
| <a id="rust_register_toolchains-extra_target_triples"></a>extra_target_triples | Additional rust-style targets that rust toolchains should support. | `["wasm32-unknown-unknown", "wasm32-wasi"]` |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"checksum": "29b3baa67c12dc0f5ff62bd02183029b2bb2b9894ee84774c77871de8c0023e1",
"checksum": "321addb0066d2b6a32371c493d556339e4795e57f00939494a659a48024b65e4",
"crates": {
"direct-cargo-bazel-deps 0.0.1": {
"name": "direct-cargo-bazel-deps",
Expand Down Expand Up @@ -47,7 +47,7 @@
"package_url": "https://github.com/bazelbuild/rules_rust",
"repository": {
"Http": {
"url": "https://crates.io/api/v1/crates/test_data_passing_crate/0.1.0/download",
"url": "https://static.crates.io/crates/test_data_passing_crate/0.1.0/download",
"sha256": "08c67aba3a29c3dc187eaf8080107404abfaee1ae893a02c43a362343ca73286"
}
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"checksum": "4991fe7d81e0ebe9a35949068c388a69d999ee729634d48b2be11820a8615e60",
"checksum": "db23cd49192fba2978c69f6e2693961a194225ff2b8a2f2b87ca817638249c86",
"crates": {
"direct-cargo-bazel-deps 0.0.1": {
"name": "direct-cargo-bazel-deps",
Expand Down Expand Up @@ -47,7 +47,7 @@
"package_url": "https://github.com/bazelbuild/rules_rust",
"repository": {
"Http": {
"url": "https://crates.io/api/v1/crates/test_data_passing_crate/0.1.0/download",
"url": "https://static.crates.io/crates/test_data_passing_crate/0.1.0/download",
"sha256": "08c67aba3a29c3dc187eaf8080107404abfaee1ae893a02c43a362343ca73286"
}
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"checksum": "b86b7a7cb303025c3eaff9cb49e779e55a9034b1892fb6cf2403e87803a3f6db",
"checksum": "2771336602fa7c8a0766382a476006842fd999fcbb9a23866dfe1c31083acccf",
"crates": {
"direct-cargo-bazel-deps 0.0.1": {
"name": "direct-cargo-bazel-deps",
Expand Down Expand Up @@ -47,7 +47,7 @@
"package_url": "https://github.com/bazelbuild/rules_rust",
"repository": {
"Http": {
"url": "https://crates.io/api/v1/crates/test_data_passing_crate/0.1.0/download",
"url": "https://static.crates.io/crates/test_data_passing_crate/0.1.0/download",
"sha256": "08c67aba3a29c3dc187eaf8080107404abfaee1ae893a02c43a362343ca73286"
}
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"checksum": "f0c92e0ffd9cc767600b88da2d1f670e32ecdf4a5919b799c2e2c13c707f231a",
"checksum": "c717f98603999e89b11893f1867f462d336d3fdef2209d1ad6957191704edfec",
"crates": {
"direct-cargo-bazel-deps 0.0.1": {
"name": "direct-cargo-bazel-deps",
Expand Down Expand Up @@ -47,7 +47,7 @@
"package_url": "https://github.com/bazelbuild/rules_rust",
"repository": {
"Http": {
"url": "https://crates.io/api/v1/crates/test_data_passing_crate/0.1.0/download",
"url": "https://static.crates.io/crates/test_data_passing_crate/0.1.0/download",
"sha256": "08c67aba3a29c3dc187eaf8080107404abfaee1ae893a02c43a362343ca73286"
}
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"checksum": "b0bb4ae2ee3d60a8962badb7f4cd08d3ae607e9488c73f2240d8b3b4aab2b042",
"checksum": "f83d83e7db1d2d9f75f3aed37ff6cea08f723c17c79aa16d07561e2d8b910f60",
"crates": {
"direct-cargo-bazel-deps 0.0.1": {
"name": "direct-cargo-bazel-deps",
Expand Down Expand Up @@ -47,7 +47,7 @@
"package_url": "https://github.com/bazelbuild/rules_rust",
"repository": {
"Http": {
"url": "https://crates.io/api/v1/crates/test_data_passing_crate/0.1.0/download",
"url": "https://static.crates.io/crates/test_data_passing_crate/0.1.0/download",
"sha256": "08c67aba3a29c3dc187eaf8080107404abfaee1ae893a02c43a362343ca73286"
}
},
Expand Down
Loading

0 comments on commit 907264e

Please sign in to comment.