summaryrefslogtreecommitdiffstats
path: root/vendor/rustc_tools_util
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:03 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:03 +0000
commit64d98f8ee037282c35007b64c2649055c56af1db (patch)
tree5492bcf97fce41ee1c0b1cc2add283f3e66cdab0 /vendor/rustc_tools_util
parentAdding debian version 1.67.1+dfsg1-1. (diff)
downloadrustc-64d98f8ee037282c35007b64c2649055c56af1db.tar.xz
rustc-64d98f8ee037282c35007b64c2649055c56af1db.zip
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/rustc_tools_util')
-rw-r--r--vendor/rustc_tools_util/.cargo-checksum.json2
-rw-r--r--vendor/rustc_tools_util/CHANGELOG.md6
-rw-r--r--vendor/rustc_tools_util/Cargo.toml2
-rw-r--r--vendor/rustc_tools_util/README.md38
-rw-r--r--vendor/rustc_tools_util/src/lib.rs42
5 files changed, 55 insertions, 35 deletions
diff --git a/vendor/rustc_tools_util/.cargo-checksum.json b/vendor/rustc_tools_util/.cargo-checksum.json
index fa6b5aa1b..1532e41a1 100644
--- a/vendor/rustc_tools_util/.cargo-checksum.json
+++ b/vendor/rustc_tools_util/.cargo-checksum.json
@@ -1 +1 @@
-{"files":{"Cargo.toml":"19638c267dcbea07037fae9353aafa031a81bde979a48d3333d7400cabcb0560","LICENSE-APACHE":"7ce8f5804da3116a112112a3b6ace5f58977fccf878d48dc9b108cc5e26c298c","LICENSE-MIT":"f4acf81886b4abbe3b7938d279536763774b1f061cf25881652300726ada3bda","README.md":"f90d8251e2485a4a0b3ab1b136728e429fbde3b7d6ddb222dc58fd3bae169bd1","src/lib.rs":"d2a621ad6319d586b100f796dd3d2bac9624325df4fead4edf62f6486ac8f26a"},"package":"598f48ce2a421542b3e64828aa742b687cc1b91d2f96591cfdb7ac5988cd6366"} \ No newline at end of file
+{"files":{"CHANGELOG.md":"4f356bed427febe66265a3895b50099a6742e69016a11f9671d57b58cdca95c6","Cargo.toml":"2f5a9a4c73522585ec3dbafc1e2deb725d83751bd2e24f0dfa08a6f0d547a945","LICENSE-APACHE":"7ce8f5804da3116a112112a3b6ace5f58977fccf878d48dc9b108cc5e26c298c","LICENSE-MIT":"f4acf81886b4abbe3b7938d279536763774b1f061cf25881652300726ada3bda","README.md":"b4bfe0dfb67eaefa1e6d0fa20c6a47ceb713dade844d5a3ba7df270bf2099302","src/lib.rs":"bfec1d2f63a5815954e84d85e011521f76deeabff4e7963a60a0e4708b8e1958"},"package":"8ba09476327c4b70ccefb6180f046ef588c26a24cf5d269a9feba316eb4f029f"} \ No newline at end of file
diff --git a/vendor/rustc_tools_util/CHANGELOG.md b/vendor/rustc_tools_util/CHANGELOG.md
new file mode 100644
index 000000000..1b351da2e
--- /dev/null
+++ b/vendor/rustc_tools_util/CHANGELOG.md
@@ -0,0 +1,6 @@
+# Changelog
+
+## Version 0.3.0
+
+* Added `setup_version_info!();` macro for automated scripts.
+* `get_version_info!()` no longer requires the user to import `rustc_tools_util::VersionInfo` and `std::env`
diff --git a/vendor/rustc_tools_util/Cargo.toml b/vendor/rustc_tools_util/Cargo.toml
index 44a165131..3a2a0803e 100644
--- a/vendor/rustc_tools_util/Cargo.toml
+++ b/vendor/rustc_tools_util/Cargo.toml
@@ -12,7 +12,7 @@
[package]
edition = "2018"
name = "rustc_tools_util"
-version = "0.2.1"
+version = "0.3.0"
description = "small helper to generate version information for git packages"
readme = "README.md"
keywords = [
diff --git a/vendor/rustc_tools_util/README.md b/vendor/rustc_tools_util/README.md
index e947f9c7e..eefc661f9 100644
--- a/vendor/rustc_tools_util/README.md
+++ b/vendor/rustc_tools_util/README.md
@@ -13,43 +13,39 @@ build = "build.rs"
List rustc_tools_util as regular AND build dependency.
````toml
[dependencies]
-rustc_tools_util = "0.2.1"
+rustc_tools_util = "0.3.0"
[build-dependencies]
-rustc_tools_util = "0.2.1"
+rustc_tools_util = "0.3.0"
````
In `build.rs`, generate the data in your `main()`
-````rust
+
+```rust
fn main() {
- println!(
- "cargo:rustc-env=GIT_HASH={}",
- rustc_tools_util::get_commit_hash().unwrap_or_default()
- );
- println!(
- "cargo:rustc-env=COMMIT_DATE={}",
- rustc_tools_util::get_commit_date().unwrap_or_default()
- );
- println!(
- "cargo:rustc-env=RUSTC_RELEASE_CHANNEL={}",
- rustc_tools_util::get_channel().unwrap_or_default()
- );
+ rustc_tools_util::setup_version_info!();
}
-
-````
+```
Use the version information in your main.rs
-````rust
-use rustc_tools_util::*;
+```rust
fn show_version() {
let version_info = rustc_tools_util::get_version_info!();
println!("{}", version_info);
}
-````
+```
+
This gives the following output in clippy:
-`clippy 0.0.212 (a416c5e 2018-12-14)`
+`clippy 0.1.66 (a28f3c8 2022-11-20)`
+
+## Repository
+
+This project is part of the rust-lang/rust-clippy repository. The source code
+can be found under `./rustc_tools_util/`.
+The changelog for `rustc_tools_util` is available under:
+[`rustc_tools_util/CHANGELOG.md`](https://github.com/rust-lang/rust-clippy/blob/master/rustc_tools_util/CHANGELOG.md)
## License
diff --git a/vendor/rustc_tools_util/src/lib.rs b/vendor/rustc_tools_util/src/lib.rs
index 01d25c531..47c0f9bcb 100644
--- a/vendor/rustc_tools_util/src/lib.rs
+++ b/vendor/rustc_tools_util/src/lib.rs
@@ -1,20 +1,20 @@
#![cfg_attr(feature = "deny-warnings", deny(warnings))]
-use std::env;
-
+/// This macro creates the version string during compilation from the
+/// current environment
#[macro_export]
macro_rules! get_version_info {
() => {{
- let major = env!("CARGO_PKG_VERSION_MAJOR").parse::<u8>().unwrap();
- let minor = env!("CARGO_PKG_VERSION_MINOR").parse::<u8>().unwrap();
- let patch = env!("CARGO_PKG_VERSION_PATCH").parse::<u16>().unwrap();
- let crate_name = String::from(env!("CARGO_PKG_NAME"));
+ let major = std::env!("CARGO_PKG_VERSION_MAJOR").parse::<u8>().unwrap();
+ let minor = std::env!("CARGO_PKG_VERSION_MINOR").parse::<u8>().unwrap();
+ let patch = std::env!("CARGO_PKG_VERSION_PATCH").parse::<u16>().unwrap();
+ let crate_name = String::from(std::env!("CARGO_PKG_NAME"));
- let host_compiler = option_env!("RUSTC_RELEASE_CHANNEL").map(str::to_string);
- let commit_hash = option_env!("GIT_HASH").map(str::to_string);
- let commit_date = option_env!("COMMIT_DATE").map(str::to_string);
+ let host_compiler = std::option_env!("RUSTC_RELEASE_CHANNEL").map(str::to_string);
+ let commit_hash = std::option_env!("GIT_HASH").map(str::to_string);
+ let commit_date = std::option_env!("COMMIT_DATE").map(str::to_string);
- VersionInfo {
+ $crate::VersionInfo {
major,
minor,
patch,
@@ -26,6 +26,24 @@ macro_rules! get_version_info {
}};
}
+/// This macro can be used in `build.rs` to automatically set the needed
+/// environment values, namely `GIT_HASH`, `COMMIT_DATE` and
+/// `RUSTC_RELEASE_CHANNEL`
+#[macro_export]
+macro_rules! setup_version_info {
+ () => {{
+ println!(
+ "cargo:rustc-env=GIT_HASH={}",
+ $crate::get_commit_hash().unwrap_or_default()
+ );
+ println!(
+ "cargo:rustc-env=COMMIT_DATE={}",
+ $crate::get_commit_date().unwrap_or_default()
+ );
+ println!("cargo:rustc-env=RUSTC_RELEASE_CHANNEL={}", $crate::get_channel());
+ }};
+}
+
// some code taken and adapted from RLS and cargo
pub struct VersionInfo {
pub major: u8,
@@ -101,7 +119,7 @@ pub fn get_commit_date() -> Option<String> {
#[must_use]
pub fn get_channel() -> String {
- match env::var("CFG_RELEASE_CHANNEL") {
+ match std::env::var("CFG_RELEASE_CHANNEL") {
Ok(channel) => channel,
Err(_) => {
// if that failed, try to ask rustc -V, do some parsing and find out
@@ -147,7 +165,7 @@ mod test {
#[test]
fn test_display_local() {
let vi = get_version_info!();
- assert_eq!(vi.to_string(), "rustc_tools_util 0.2.1");
+ assert_eq!(vi.to_string(), "rustc_tools_util 0.3.0");
}
#[test]