summaryrefslogtreecommitdiffstats
path: root/src/tools/cargo/crates
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 18:31:44 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 18:31:44 +0000
commitc23a457e72abe608715ac76f076f47dc42af07a5 (patch)
tree2772049aaf84b5c9d0ed12ec8d86812f7a7904b6 /src/tools/cargo/crates
parentReleasing progress-linux version 1.73.0+dfsg1-1~progress7.99u1. (diff)
downloadrustc-c23a457e72abe608715ac76f076f47dc42af07a5.tar.xz
rustc-c23a457e72abe608715ac76f076f47dc42af07a5.zip
Merging upstream version 1.74.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/tools/cargo/crates')
-rw-r--r--src/tools/cargo/crates/cargo-platform/Cargo.toml2
-rw-r--r--src/tools/cargo/crates/cargo-platform/examples/matches.rs4
-rw-r--r--src/tools/cargo/crates/cargo-platform/src/error.rs4
-rw-r--r--src/tools/cargo/crates/cargo-platform/src/lib.rs3
-rw-r--r--src/tools/cargo/crates/cargo-test-macro/Cargo.toml1
-rw-r--r--src/tools/cargo/crates/cargo-test-macro/src/lib.rs2
-rw-r--r--src/tools/cargo/crates/cargo-test-support/Cargo.toml5
-rw-r--r--src/tools/cargo/crates/cargo-test-support/src/compare.rs1
-rw-r--r--src/tools/cargo/crates/cargo-test-support/src/diff.rs48
-rw-r--r--src/tools/cargo/crates/cargo-test-support/src/git.rs21
-rw-r--r--src/tools/cargo/crates/cargo-test-support/src/lib.rs77
-rw-r--r--src/tools/cargo/crates/cargo-test-support/src/publish.rs7
-rw-r--r--src/tools/cargo/crates/cargo-test-support/src/registry.rs44
-rw-r--r--src/tools/cargo/crates/cargo-util/Cargo.toml3
-rw-r--r--src/tools/cargo/crates/cargo-util/src/paths.rs31
-rw-r--r--src/tools/cargo/crates/crates-io/Cargo.toml3
-rw-r--r--src/tools/cargo/crates/crates-io/lib.rs12
-rw-r--r--src/tools/cargo/crates/mdman/Cargo.toml1
-rw-r--r--src/tools/cargo/crates/mdman/src/format/mod.rs (renamed from src/tools/cargo/crates/mdman/src/format.rs)0
-rw-r--r--src/tools/cargo/crates/mdman/src/hbs.rs12
-rw-r--r--src/tools/cargo/crates/mdman/src/lib.rs2
-rw-r--r--src/tools/cargo/crates/mdman/src/main.rs19
-rw-r--r--src/tools/cargo/crates/resolver-tests/Cargo.toml2
-rw-r--r--src/tools/cargo/crates/resolver-tests/src/lib.rs30
-rw-r--r--src/tools/cargo/crates/resolver-tests/tests/resolve.rs33
-rw-r--r--src/tools/cargo/crates/semver-check/Cargo.toml1
-rw-r--r--src/tools/cargo/crates/semver-check/src/main.rs4
-rw-r--r--src/tools/cargo/crates/xtask-build-man/Cargo.toml1
-rw-r--r--src/tools/cargo/crates/xtask-bump-check/Cargo.toml1
-rw-r--r--src/tools/cargo/crates/xtask-bump-check/src/main.rs1
-rw-r--r--src/tools/cargo/crates/xtask-bump-check/src/xtask.rs12
-rw-r--r--src/tools/cargo/crates/xtask-stale-label/Cargo.toml1
32 files changed, 232 insertions, 156 deletions
diff --git a/src/tools/cargo/crates/cargo-platform/Cargo.toml b/src/tools/cargo/crates/cargo-platform/Cargo.toml
index e7f22cf87..016ead686 100644
--- a/src/tools/cargo/crates/cargo-platform/Cargo.toml
+++ b/src/tools/cargo/crates/cargo-platform/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "cargo-platform"
-version = "0.1.4"
+version = "0.1.5"
edition.workspace = true
license.workspace = true
homepage = "https://github.com/rust-lang/cargo"
diff --git a/src/tools/cargo/crates/cargo-platform/examples/matches.rs b/src/tools/cargo/crates/cargo-platform/examples/matches.rs
index 9ad5d10dd..1b438fb11 100644
--- a/src/tools/cargo/crates/cargo-platform/examples/matches.rs
+++ b/src/tools/cargo/crates/cargo-platform/examples/matches.rs
@@ -35,8 +35,8 @@ fn get_target() -> String {
.expect("rustc failed to run");
let stdout = String::from_utf8(output.stdout).unwrap();
for line in stdout.lines() {
- if line.starts_with("host: ") {
- return String::from(&line[6..]);
+ if let Some(line) = line.strip_prefix("host: ") {
+ return String::from(line);
}
}
panic!("Failed to find host: {}", stdout);
diff --git a/src/tools/cargo/crates/cargo-platform/src/error.rs b/src/tools/cargo/crates/cargo-platform/src/error.rs
index bf4b35f27..2d5b315f9 100644
--- a/src/tools/cargo/crates/cargo-platform/src/error.rs
+++ b/src/tools/cargo/crates/cargo-platform/src/error.rs
@@ -21,7 +21,7 @@ pub enum ParseErrorKind {
}
impl fmt::Display for ParseError {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
"failed to parse `{}` as a cfg expression: {}",
@@ -31,7 +31,7 @@ impl fmt::Display for ParseError {
}
impl fmt::Display for ParseErrorKind {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
use ParseErrorKind::*;
match self {
UnterminatedString => write!(f, "unterminated string in cfg"),
diff --git a/src/tools/cargo/crates/cargo-platform/src/lib.rs b/src/tools/cargo/crates/cargo-platform/src/lib.rs
index 0a3dcf1af..7911e484e 100644
--- a/src/tools/cargo/crates/cargo-platform/src/lib.rs
+++ b/src/tools/cargo/crates/cargo-platform/src/lib.rs
@@ -126,8 +126,7 @@ impl FromStr for Platform {
type Err = ParseError;
fn from_str(s: &str) -> Result<Platform, ParseError> {
- if s.starts_with("cfg(") && s.ends_with(')') {
- let s = &s[4..s.len() - 1];
+ if let Some(s) = s.strip_prefix("cfg(").and_then(|s| s.strip_suffix(')')) {
s.parse().map(Platform::Cfg)
} else {
Platform::validate_named_platform(s)?;
diff --git a/src/tools/cargo/crates/cargo-test-macro/Cargo.toml b/src/tools/cargo/crates/cargo-test-macro/Cargo.toml
index b5da0522f..1e81ab314 100644
--- a/src/tools/cargo/crates/cargo-test-macro/Cargo.toml
+++ b/src/tools/cargo/crates/cargo-test-macro/Cargo.toml
@@ -1,6 +1,7 @@
[package]
name = "cargo-test-macro"
version = "0.1.0"
+rust-version.workspace = true
edition.workspace = true
license.workspace = true
homepage = "https://github.com/rust-lang/cargo"
diff --git a/src/tools/cargo/crates/cargo-test-macro/src/lib.rs b/src/tools/cargo/crates/cargo-test-macro/src/lib.rs
index aa06f477d..937fbce6b 100644
--- a/src/tools/cargo/crates/cargo-test-macro/src/lib.rs
+++ b/src/tools/cargo/crates/cargo-test-macro/src/lib.rs
@@ -1,5 +1,3 @@
-extern crate proc_macro;
-
use proc_macro::*;
use std::process::Command;
use std::sync::Once;
diff --git a/src/tools/cargo/crates/cargo-test-support/Cargo.toml b/src/tools/cargo/crates/cargo-test-support/Cargo.toml
index 085041aff..fc32e1c9c 100644
--- a/src/tools/cargo/crates/cargo-test-support/Cargo.toml
+++ b/src/tools/cargo/crates/cargo-test-support/Cargo.toml
@@ -1,6 +1,7 @@
[package]
name = "cargo-test-support"
version = "0.1.0"
+rust-version.workspace = true
license.workspace = true
edition.workspace = true
publish = false
@@ -9,6 +10,8 @@ publish = false
doctest = false
[dependencies]
+anstream.workspace = true
+anstyle.workspace = true
anyhow.workspace = true
cargo-test-macro.workspace = true
cargo-util.workspace = true
@@ -18,13 +21,11 @@ flate2.workspace = true
git2.workspace = true
glob.workspace = true
itertools.workspace = true
-lazy_static.workspace = true
pasetors.workspace = true
serde = { workspace = true, features = ["derive"] }
serde_json.workspace = true
snapbox.workspace = true
tar.workspace = true
-termcolor.workspace = true
time.workspace = true
toml.workspace = true
url.workspace = true
diff --git a/src/tools/cargo/crates/cargo-test-support/src/compare.rs b/src/tools/cargo/crates/cargo-test-support/src/compare.rs
index 21eb64d28..09e3a5a0c 100644
--- a/src/tools/cargo/crates/cargo-test-support/src/compare.rs
+++ b/src/tools/cargo/crates/cargo-test-support/src/compare.rs
@@ -206,6 +206,7 @@ fn substitute_macros(input: &str) -> String {
("[UPDATING]", " Updating"),
("[ADDING]", " Adding"),
("[REMOVING]", " Removing"),
+ ("[REMOVED]", " Removed"),
("[DOCTEST]", " Doc-tests"),
("[PACKAGING]", " Packaging"),
("[PACKAGED]", " Packaged"),
diff --git a/src/tools/cargo/crates/cargo-test-support/src/diff.rs b/src/tools/cargo/crates/cargo-test-support/src/diff.rs
index f3b283b10..3fedc839b 100644
--- a/src/tools/cargo/crates/cargo-test-support/src/diff.rs
+++ b/src/tools/cargo/crates/cargo-test-support/src/diff.rs
@@ -7,7 +7,6 @@
use std::fmt;
use std::io::Write;
-use termcolor::{Ansi, Color, ColorSpec, NoColor, WriteColor};
/// A single line change to be applied to the original.
#[derive(Debug, Eq, PartialEq)]
@@ -111,42 +110,35 @@ where
}
pub fn render_colored_changes<T: fmt::Display>(changes: &[Change<T>]) -> String {
- // termcolor is not very ergonomic, but I don't want to bring in another dependency.
- let mut red = ColorSpec::new();
- red.set_fg(Some(Color::Red));
- let mut green = ColorSpec::new();
- green.set_fg(Some(Color::Green));
- let mut dim = ColorSpec::new();
- dim.set_dimmed(true);
- let mut v = Vec::new();
- let mut result: Box<dyn WriteColor> = if crate::is_ci() {
+ // anstyle is not very ergonomic, but I don't want to bring in another dependency.
+ let red = anstyle::AnsiColor::Red.on_default().render();
+ let green = anstyle::AnsiColor::Green.on_default().render();
+ let dim = (anstyle::Style::new() | anstyle::Effects::DIMMED).render();
+ let bold = (anstyle::Style::new() | anstyle::Effects::BOLD).render();
+ let reset = anstyle::Reset.render();
+
+ let choice = if crate::is_ci() {
// Don't use color on CI. Even though GitHub can display colors, it
// makes reading the raw logs more difficult.
- Box::new(NoColor::new(&mut v))
+ anstream::ColorChoice::Never
} else {
- Box::new(Ansi::new(&mut v))
+ anstream::AutoStream::choice(&std::io::stdout())
};
+ let mut buffer = anstream::AutoStream::new(Vec::new(), choice);
for change in changes {
let (nums, sign, color, text) = match change {
- Change::Add(i, s) => (format!(" {:<4} ", i), '+', &green, s),
- Change::Remove(i, s) => (format!("{:<4} ", i), '-', &red, s),
- Change::Keep(x, y, s) => (format!("{:<4}{:<4} ", x, y), ' ', &dim, s),
+ Change::Add(i, s) => (format!(" {:<4} ", i), '+', green, s),
+ Change::Remove(i, s) => (format!("{:<4} ", i), '-', red, s),
+ Change::Keep(x, y, s) => (format!("{:<4}{:<4} ", x, y), ' ', dim, s),
};
- result.set_color(&dim).unwrap();
- write!(result, "{}", nums).unwrap();
- let mut bold = color.clone();
- bold.set_bold(true);
- result.set_color(&bold).unwrap();
- write!(result, "{}", sign).unwrap();
- result.reset().unwrap();
- result.set_color(&color).unwrap();
- write!(result, "{}", text).unwrap();
- result.reset().unwrap();
- writeln!(result).unwrap();
+ write!(
+ buffer,
+ "{dim}{nums}{reset}{bold}{sign}{reset}{color}{text}{reset}"
+ )
+ .unwrap();
}
- drop(result);
- String::from_utf8(v).unwrap()
+ String::from_utf8(buffer.into_inner()).unwrap()
}
#[cfg(test)]
diff --git a/src/tools/cargo/crates/cargo-test-support/src/git.rs b/src/tools/cargo/crates/cargo-test-support/src/git.rs
index 6fde96467..236011ca1 100644
--- a/src/tools/cargo/crates/cargo-test-support/src/git.rs
+++ b/src/tools/cargo/crates/cargo-test-support/src/git.rs
@@ -10,7 +10,7 @@ Example:
```
let git_project = git::new("dep1", |project| {
project
- .file("Cargo.toml", &basic_manifest("dep1"))
+ .file("Cargo.toml", &basic_manifest("dep1", "1.0.0"))
.file("src/lib.rs", r#"pub fn f() { println!("hi!"); } "#)
});
@@ -177,25 +177,8 @@ where
/// Add all files in the working directory to the git index.
pub fn add(repo: &git2::Repository) {
- // FIXME(libgit2/libgit2#2514): apparently, `add_all` will add all submodules
- // as well, and then fail because they're directories. As a stop-gap, we just
- // ignore all submodules.
- let mut s = t!(repo.submodules());
- for submodule in s.iter_mut() {
- t!(submodule.add_to_index(false));
- }
let mut index = t!(repo.index());
- t!(index.add_all(
- ["*"].iter(),
- git2::IndexAddOption::DEFAULT,
- Some(
- &mut (|a, _b| if s.iter().any(|s| a.starts_with(s.path())) {
- 1
- } else {
- 0
- })
- )
- ));
+ t!(index.add_all(["*"].iter(), git2::IndexAddOption::DEFAULT, None));
t!(index.write());
}
diff --git a/src/tools/cargo/crates/cargo-test-support/src/lib.rs b/src/tools/cargo/crates/cargo-test-support/src/lib.rs
index a2fa54c60..1a8742720 100644
--- a/src/tools/cargo/crates/cargo-test-support/src/lib.rs
+++ b/src/tools/cargo/crates/cargo-test-support/src/lib.rs
@@ -12,6 +12,7 @@ use std::os;
use std::path::{Path, PathBuf};
use std::process::{Command, Output};
use std::str;
+use std::sync::OnceLock;
use std::time::{self, Duration};
use anyhow::{bail, Result};
@@ -569,6 +570,7 @@ pub struct Execs {
expect_stdout_contains_n: Vec<(String, usize)>,
expect_stdout_not_contains: Vec<String>,
expect_stderr_not_contains: Vec<String>,
+ expect_stdout_unordered: Vec<String>,
expect_stderr_unordered: Vec<String>,
expect_stderr_with_without: Vec<(Vec<String>, Vec<String>)>,
expect_json: Option<String>,
@@ -670,6 +672,15 @@ impl Execs {
self
}
+ /// Verifies that all of the stdout output is equal to the given lines,
+ /// ignoring the order of the lines.
+ ///
+ /// See [`Execs::with_stderr_unordered`] for more details.
+ pub fn with_stdout_unordered<S: ToString>(&mut self, expected: S) -> &mut Self {
+ self.expect_stdout_unordered.push(expected.to_string());
+ self
+ }
+
/// Verifies that all of the stderr output is equal to the given lines,
/// ignoring the order of the lines.
///
@@ -838,7 +849,7 @@ impl Execs {
/// Enables nightly features for testing
///
/// The list of reasons should be why nightly cargo is needed. If it is
- /// becuase of an unstable feature put the name of the feature as the reason,
+ /// because of an unstable feature put the name of the feature as the reason,
/// e.g. `&["print-im-a-teapot"]`
pub fn masquerade_as_nightly_cargo(&mut self, reasons: &[&str]) -> &mut Self {
if let Some(ref mut p) = self.process_builder {
@@ -931,6 +942,7 @@ impl Execs {
&& self.expect_stdout_contains_n.is_empty()
&& self.expect_stdout_not_contains.is_empty()
&& self.expect_stderr_not_contains.is_empty()
+ && self.expect_stdout_unordered.is_empty()
&& self.expect_stderr_unordered.is_empty()
&& self.expect_stderr_with_without.is_empty()
&& self.expect_json.is_none()
@@ -1035,6 +1047,9 @@ impl Execs {
for expect in self.expect_stderr_not_contains.iter() {
compare::match_does_not_contain(expect, stderr, cwd)?;
}
+ for expect in self.expect_stdout_unordered.iter() {
+ compare::match_unordered(expect, stdout, cwd)?;
+ }
for expect in self.expect_stderr_unordered.iter() {
compare::match_unordered(expect, stderr, cwd)?;
}
@@ -1074,6 +1089,7 @@ pub fn execs() -> Execs {
expect_stdout_contains_n: Vec::new(),
expect_stdout_not_contains: Vec::new(),
expect_stderr_not_contains: Vec::new(),
+ expect_stdout_unordered: Vec::new(),
expect_stderr_unordered: Vec::new(),
expect_stderr_with_without: Vec::new(),
expect_json: None,
@@ -1157,13 +1173,14 @@ impl RustcInfo {
}
}
-lazy_static::lazy_static! {
- static ref RUSTC_INFO: RustcInfo = RustcInfo::new();
+fn rustc_info() -> &'static RustcInfo {
+ static RUSTC_INFO: OnceLock<RustcInfo> = OnceLock::new();
+ RUSTC_INFO.get_or_init(RustcInfo::new)
}
/// The rustc host such as `x86_64-unknown-linux-gnu`.
pub fn rustc_host() -> &'static str {
- &RUSTC_INFO.host
+ &rustc_info().host
}
/// The host triple suitable for use in a cargo environment variable (uppercased).
@@ -1172,7 +1189,7 @@ pub fn rustc_host_env() -> String {
}
pub fn is_nightly() -> bool {
- let vv = &RUSTC_INFO.verbose_version;
+ let vv = &rustc_info().verbose_version;
// CARGO_TEST_DISABLE_NIGHTLY is set in rust-lang/rust's CI so that all
// nightly-only tests are disabled there. Otherwise, it could make it
// difficult to land changes which would need to be made simultaneously in
@@ -1194,7 +1211,7 @@ fn _process(t: &OsStr) -> ProcessBuilder {
/// Enable nightly features for testing
pub trait ChannelChanger {
/// The list of reasons should be why nightly cargo is needed. If it is
- /// becuase of an unstable feature put the name of the feature as the reason,
+ /// because of an unstable feature put the name of the feature as the reason,
/// e.g. `&["print-im-a-teapot"]`.
fn masquerade_as_nightly_cargo(self, _reasons: &[&str]) -> Self;
}
@@ -1225,28 +1242,27 @@ pub trait TestEnv: Sized {
if env::var_os("RUSTUP_TOOLCHAIN").is_some() {
// Override the PATH to avoid executing the rustup wrapper thousands
// of times. This makes the testsuite run substantially faster.
- lazy_static::lazy_static! {
- static ref RUSTC_DIR: PathBuf = {
- match ProcessBuilder::new("rustup")
- .args(&["which", "rustc"])
- .exec_with_output()
- {
- Ok(output) => {
- let s = str::from_utf8(&output.stdout).expect("utf8").trim();
- let mut p = PathBuf::from(s);
- p.pop();
- p
- }
- Err(e) => {
- panic!("RUSTUP_TOOLCHAIN was set, but could not run rustup: {}", e);
- }
+ static RUSTC_DIR: OnceLock<PathBuf> = OnceLock::new();
+ let rustc_dir = RUSTC_DIR.get_or_init(|| {
+ match ProcessBuilder::new("rustup")
+ .args(&["which", "rustc"])
+ .exec_with_output()
+ {
+ Ok(output) => {
+ let s = str::from_utf8(&output.stdout).expect("utf8").trim();
+ let mut p = PathBuf::from(s);
+ p.pop();
+ p
}
- };
- }
+ Err(e) => {
+ panic!("RUSTUP_TOOLCHAIN was set, but could not run rustup: {}", e);
+ }
+ }
+ });
let path = env::var_os("PATH").unwrap_or_default();
let paths = env::split_paths(&path);
let new_path =
- env::join_paths(std::iter::once(RUSTC_DIR.clone()).chain(paths)).unwrap();
+ env::join_paths(std::iter::once(rustc_dir.clone()).chain(paths)).unwrap();
self = self.env("PATH", new_path);
}
@@ -1408,11 +1424,14 @@ pub fn is_coarse_mtime() -> bool {
/// Architectures that do not have a modern processor, hardware emulation, etc.
/// This provides a way for those setups to increase the cut off for all the time based test.
pub fn slow_cpu_multiplier(main: u64) -> Duration {
- lazy_static::lazy_static! {
- static ref SLOW_CPU_MULTIPLIER: u64 =
- env::var("CARGO_TEST_SLOW_CPU_MULTIPLIER").ok().and_then(|m| m.parse().ok()).unwrap_or(1);
- }
- Duration::from_secs(*SLOW_CPU_MULTIPLIER * main)
+ static SLOW_CPU_MULTIPLIER: OnceLock<u64> = OnceLock::new();
+ let slow_cpu_multiplier = SLOW_CPU_MULTIPLIER.get_or_init(|| {
+ env::var("CARGO_TEST_SLOW_CPU_MULTIPLIER")
+ .ok()
+ .and_then(|m| m.parse().ok())
+ .unwrap_or(1)
+ });
+ Duration::from_secs(slow_cpu_multiplier * main)
}
#[cfg(windows)]
diff --git a/src/tools/cargo/crates/cargo-test-support/src/publish.rs b/src/tools/cargo/crates/cargo-test-support/src/publish.rs
index dccc8356d..f850330c1 100644
--- a/src/tools/cargo/crates/cargo-test-support/src/publish.rs
+++ b/src/tools/cargo/crates/cargo-test-support/src/publish.rs
@@ -131,8 +131,11 @@ pub fn validate_crate_contents(
(name, contents)
})
.collect();
- assert!(expected_crate_name.ends_with(".crate"));
- let base_crate_name = Path::new(&expected_crate_name[..expected_crate_name.len() - 6]);
+ let base_crate_name = Path::new(
+ expected_crate_name
+ .strip_suffix(".crate")
+ .expect("must end with .crate"),
+ );
let actual_files: HashSet<PathBuf> = files.keys().cloned().collect();
let expected_files: HashSet<PathBuf> = expected_files
.iter()
diff --git a/src/tools/cargo/crates/cargo-test-support/src/registry.rs b/src/tools/cargo/crates/cargo-test-support/src/registry.rs
index 27c319656..853829c56 100644
--- a/src/tools/cargo/crates/cargo-test-support/src/registry.rs
+++ b/src/tools/cargo/crates/cargo-test-support/src/registry.rs
@@ -549,7 +549,9 @@ pub struct Dependency {
name: String,
vers: String,
kind: String,
- artifact: Option<(String, Option<String>)>,
+ artifact: Option<String>,
+ bindep_target: Option<String>,
+ lib: bool,
target: Option<String>,
features: Vec<String>,
registry: Option<String>,
@@ -779,6 +781,7 @@ impl HttpServer {
let buf = buf.get_mut();
write!(buf, "HTTP/1.1 {}\r\n", response.code).unwrap();
write!(buf, "Content-Length: {}\r\n", response.body.len()).unwrap();
+ write!(buf, "Connection: close\r\n").unwrap();
for header in response.headers {
write!(buf, "{}\r\n", header).unwrap();
}
@@ -788,7 +791,7 @@ impl HttpServer {
}
}
- fn check_authorized(&self, req: &Request, mutation: Option<Mutation>) -> bool {
+ fn check_authorized(&self, req: &Request, mutation: Option<Mutation<'_>>) -> bool {
let (private_key, private_key_subject) = if mutation.is_some() || self.auth_required {
match &self.token {
Token::Plaintext(token) => return Some(token) == req.authorization.as_ref(),
@@ -830,7 +833,8 @@ impl HttpServer {
url: &'a str,
kip: &'a str,
}
- let footer: Footer = t!(serde_json::from_slice(untrusted_token.untrusted_footer()).ok());
+ let footer: Footer<'_> =
+ t!(serde_json::from_slice(untrusted_token.untrusted_footer()).ok());
if footer.kip != paserk_pub_key_id {
return false;
}
@@ -844,7 +848,6 @@ impl HttpServer {
if footer.url != "https://github.com/rust-lang/crates.io-index"
&& footer.url != &format!("sparse+http://{}/index/", self.addr.to_string())
{
- dbg!(footer.url);
return false;
}
@@ -860,20 +863,18 @@ impl HttpServer {
_challenge: Option<&'a str>, // todo: PASETO with challenges
v: Option<u8>,
}
- let message: Message = t!(serde_json::from_str(trusted_token.payload()).ok());
+ let message: Message<'_> = t!(serde_json::from_str(trusted_token.payload()).ok());
let token_time = t!(OffsetDateTime::parse(message.iat, &Rfc3339).ok());
let now = OffsetDateTime::now_utc();
if (now - token_time) > Duration::MINUTE {
return false;
}
if private_key_subject.as_deref() != message.sub {
- dbg!(message.sub);
return false;
}
// - If the claim v is set, that it has the value of 1.
if let Some(v) = message.v {
if v != 1 {
- dbg!(message.v);
return false;
}
}
@@ -883,22 +884,18 @@ impl HttpServer {
if let Some(mutation) = mutation {
// - That the operation matches the mutation field and is one of publish, yank, or unyank.
if message.mutation != Some(mutation.mutation) {
- dbg!(message.mutation);
return false;
}
// - That the package, and version match the request.
if message.name != mutation.name {
- dbg!(message.name);
return false;
}
if message.vers != mutation.vers {
- dbg!(message.vers);
return false;
}
// - If the mutation is publish, that the version has not already been published, and that the hash matches the request.
if mutation.mutation == "publish" {
if message.cksum != mutation.cksum {
- dbg!(message.cksum);
return false;
}
}
@@ -1409,13 +1406,20 @@ impl Package {
(true, Some("alternative")) => None,
_ => panic!("registry_dep currently only supports `alternative`"),
};
+ let artifact = if let Some(artifact) = &dep.artifact {
+ serde_json::json!([artifact])
+ } else {
+ serde_json::json!(null)
+ };
serde_json::json!({
"name": dep.name,
"req": dep.vers,
"features": dep.features,
"default_features": true,
"target": dep.target,
- "artifact": dep.artifact,
+ "artifact": artifact,
+ "bindep_target": dep.bindep_target,
+ "lib": dep.lib,
"optional": dep.optional,
"kind": dep.kind,
"registry": registry_url,
@@ -1536,11 +1540,14 @@ impl Package {
"#,
target, kind, dep.name, dep.vers
));
- if let Some((artifact, target)) = &dep.artifact {
+ if let Some(artifact) = &dep.artifact {
manifest.push_str(&format!("artifact = \"{}\"\n", artifact));
- if let Some(target) = &target {
- manifest.push_str(&format!("target = \"{}\"\n", target))
- }
+ }
+ if let Some(target) = &dep.bindep_target {
+ manifest.push_str(&format!("target = \"{}\"\n", target));
+ }
+ if dep.lib {
+ manifest.push_str("lib = true\n");
}
if let Some(registry) = &dep.registry {
assert_eq!(registry, "alternative");
@@ -1617,6 +1624,8 @@ impl Dependency {
vers: vers.to_string(),
kind: "normal".to_string(),
artifact: None,
+ bindep_target: None,
+ lib: false,
target: None,
features: Vec::new(),
package: None,
@@ -1646,7 +1655,8 @@ impl Dependency {
/// Change the artifact to be of the given kind, like "bin", or "staticlib",
/// along with a specific target triple if provided.
pub fn artifact(&mut self, kind: &str, target: Option<String>) -> &mut Self {
- self.artifact = Some((kind.to_string(), target));
+ self.artifact = Some(kind.to_string());
+ self.bindep_target = target;
self
}
diff --git a/src/tools/cargo/crates/cargo-util/Cargo.toml b/src/tools/cargo/crates/cargo-util/Cargo.toml
index 99a59422d..cba00f917 100644
--- a/src/tools/cargo/crates/cargo-util/Cargo.toml
+++ b/src/tools/cargo/crates/cargo-util/Cargo.toml
@@ -1,6 +1,7 @@
[package]
name = "cargo-util"
-version = "0.2.6"
+version = "0.2.7"
+rust-version.workspace = true
edition.workspace = true
license.workspace = true
homepage = "https://github.com/rust-lang/cargo"
diff --git a/src/tools/cargo/crates/cargo-util/src/paths.rs b/src/tools/cargo/crates/cargo-util/src/paths.rs
index ce6755859..888ca1af5 100644
--- a/src/tools/cargo/crates/cargo-util/src/paths.rs
+++ b/src/tools/cargo/crates/cargo-util/src/paths.rs
@@ -4,7 +4,7 @@ use anyhow::{Context, Result};
use filetime::FileTime;
use std::env;
use std::ffi::{OsStr, OsString};
-use std::fs::{self, File, OpenOptions};
+use std::fs::{self, File, Metadata, OpenOptions};
use std::io;
use std::io::prelude::*;
use std::iter;
@@ -136,6 +136,24 @@ pub fn resolve_executable(exec: &Path) -> Result<PathBuf> {
}
}
+/// Returns metadata for a file (follows symlinks).
+///
+/// Equivalent to [`std::fs::metadata`] with better error messages.
+pub fn metadata<P: AsRef<Path>>(path: P) -> Result<Metadata> {
+ let path = path.as_ref();
+ std::fs::metadata(path)
+ .with_context(|| format!("failed to load metadata for path `{}`", path.display()))
+}
+
+/// Returns metadata for a file without following symlinks.
+///
+/// Equivalent to [`std::fs::metadata`] with better error messages.
+pub fn symlink_metadata<P: AsRef<Path>>(path: P) -> Result<Metadata> {
+ let path = path.as_ref();
+ std::fs::symlink_metadata(path)
+ .with_context(|| format!("failed to load metadata for path `{}`", path.display()))
+}
+
/// Reads a file to a string.
///
/// Equivalent to [`std::fs::read_to_string`] with better error messages.
@@ -216,16 +234,14 @@ pub fn open<P: AsRef<Path>>(path: P) -> Result<File> {
/// Returns the last modification time of a file.
pub fn mtime(path: &Path) -> Result<FileTime> {
- let meta =
- fs::metadata(path).with_context(|| format!("failed to stat `{}`", path.display()))?;
+ let meta = metadata(path)?;
Ok(FileTime::from_last_modification_time(&meta))
}
/// Returns the maximum mtime of the given path, recursing into
/// subdirectories, and following symlinks.
pub fn mtime_recursive(path: &Path) -> Result<FileTime> {
- let meta =
- fs::metadata(path).with_context(|| format!("failed to stat `{}`", path.display()))?;
+ let meta = metadata(path)?;
if !meta.is_dir() {
return Ok(FileTime::from_last_modification_time(&meta));
}
@@ -432,10 +448,7 @@ pub fn remove_dir_all<P: AsRef<Path>>(p: P) -> Result<()> {
}
fn _remove_dir_all(p: &Path) -> Result<()> {
- if p.symlink_metadata()
- .with_context(|| format!("could not get metadata for `{}` to remove", p.display()))?
- .is_symlink()
- {
+ if symlink_metadata(p)?.is_symlink() {
return remove_file(p);
}
let entries = p
diff --git a/src/tools/cargo/crates/crates-io/Cargo.toml b/src/tools/cargo/crates/crates-io/Cargo.toml
index 139b8aa97..d06dacdfa 100644
--- a/src/tools/cargo/crates/crates-io/Cargo.toml
+++ b/src/tools/cargo/crates/crates-io/Cargo.toml
@@ -1,6 +1,7 @@
[package]
name = "crates-io"
-version = "0.38.0"
+version = "0.39.0"
+rust-version.workspace = true
edition.workspace = true
license.workspace = true
repository = "https://github.com/rust-lang/cargo"
diff --git a/src/tools/cargo/crates/crates-io/lib.rs b/src/tools/cargo/crates/crates-io/lib.rs
index 6ce39cefd..757241fd3 100644
--- a/src/tools/cargo/crates/crates-io/lib.rs
+++ b/src/tools/cargo/crates/crates-io/lib.rs
@@ -73,6 +73,16 @@ pub struct NewCrateDependency {
pub registry: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub explicit_name_in_toml: Option<String>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub artifact: Option<Vec<String>>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub bindep_target: Option<String>,
+ #[serde(default, skip_serializing_if = "is_false")]
+ pub lib: bool,
+}
+
+fn is_false(x: &bool) -> bool {
+ *x == false
}
#[derive(Deserialize)]
@@ -132,7 +142,7 @@ pub enum Error {
#[error(transparent)]
Curl(#[from] curl::Error),
- /// Error from seriailzing the request payload and deserialzing the
+ /// Error from seriailzing the request payload and deserializing the
/// response body (like response body didn't match expected structure).
#[error(transparent)]
Json(#[from] serde_json::Error),
diff --git a/src/tools/cargo/crates/mdman/Cargo.toml b/src/tools/cargo/crates/mdman/Cargo.toml
index ba1d4b462..fd33da3c2 100644
--- a/src/tools/cargo/crates/mdman/Cargo.toml
+++ b/src/tools/cargo/crates/mdman/Cargo.toml
@@ -1,6 +1,7 @@
[package]
name = "mdman"
version = "0.0.0"
+rust-version.workspace = true
edition.workspace = true
license.workspace = true
description = "Creates a man page page from markdown."
diff --git a/src/tools/cargo/crates/mdman/src/format.rs b/src/tools/cargo/crates/mdman/src/format/mod.rs
index 7bc9781b9..7bc9781b9 100644
--- a/src/tools/cargo/crates/mdman/src/format.rs
+++ b/src/tools/cargo/crates/mdman/src/format/mod.rs
diff --git a/src/tools/cargo/crates/mdman/src/hbs.rs b/src/tools/cargo/crates/mdman/src/hbs.rs
index 81ad7ee45..055eb3f28 100644
--- a/src/tools/cargo/crates/mdman/src/hbs.rs
+++ b/src/tools/cargo/crates/mdman/src/hbs.rs
@@ -12,7 +12,7 @@ use std::path::Path;
type FormatterRef<'a> = &'a (dyn Formatter + Send + Sync);
/// Processes the handlebars template at the given file.
-pub fn expand(file: &Path, formatter: FormatterRef) -> Result<String, Error> {
+pub fn expand(file: &Path, formatter: FormatterRef<'_>) -> Result<String, Error> {
let mut handlebars = Handlebars::new();
handlebars.set_strict_mode(true);
handlebars.register_helper("lower", Box::new(lower));
@@ -174,10 +174,10 @@ impl HelperDef for ManLinkHelper<'_> {
///
/// This sets a variable to a value within the template context.
fn set_decorator(
- d: &Decorator,
- _: &Handlebars,
+ d: &Decorator<'_, '_>,
+ _: &Handlebars<'_>,
_ctx: &Context,
- rc: &mut RenderContext,
+ rc: &mut RenderContext<'_, '_>,
) -> Result<(), RenderError> {
let data_to_set = d.hash();
for (k, v) in data_to_set {
@@ -187,7 +187,7 @@ fn set_decorator(
}
/// Sets a variable to a value within the context.
-fn set_in_context(rc: &mut RenderContext, key: &str, value: serde_json::Value) {
+fn set_in_context(rc: &mut RenderContext<'_, '_>, key: &str, value: serde_json::Value) {
let mut ctx = match rc.context() {
Some(c) => (*c).clone(),
None => Context::wraps(serde_json::Value::Object(serde_json::Map::new())).unwrap(),
@@ -201,7 +201,7 @@ fn set_in_context(rc: &mut RenderContext, key: &str, value: serde_json::Value) {
}
/// Removes a variable from the context.
-fn remove_from_context(rc: &mut RenderContext, key: &str) {
+fn remove_from_context(rc: &mut RenderContext<'_, '_>, key: &str) {
let ctx = rc.context().expect("cannot remove from null context");
let mut ctx = (*ctx).clone();
if let serde_json::Value::Object(m) = ctx.data_mut() {
diff --git a/src/tools/cargo/crates/mdman/src/lib.rs b/src/tools/cargo/crates/mdman/src/lib.rs
index 01c3c8d31..5cfb3f4ca 100644
--- a/src/tools/cargo/crates/mdman/src/lib.rs
+++ b/src/tools/cargo/crates/mdman/src/lib.rs
@@ -64,7 +64,7 @@ pub fn convert(
type EventIter<'a> = Box<dyn Iterator<Item = (Event<'a>, Range<usize>)> + 'a>;
/// Creates a new markdown parser with the given input.
-pub(crate) fn md_parser(input: &str, url: Option<Url>) -> EventIter {
+pub(crate) fn md_parser(input: &str, url: Option<Url>) -> EventIter<'_> {
let mut options = Options::empty();
options.insert(Options::ENABLE_TABLES);
options.insert(Options::ENABLE_FOOTNOTES);
diff --git a/src/tools/cargo/crates/mdman/src/main.rs b/src/tools/cargo/crates/mdman/src/main.rs
index 2bdf96d72..facaa5120 100644
--- a/src/tools/cargo/crates/mdman/src/main.rs
+++ b/src/tools/cargo/crates/mdman/src/main.rs
@@ -48,7 +48,7 @@ fn run() -> Result<(), Error> {
if same_file::is_same_file(source, &out_path).unwrap_or(false) {
bail!("cannot output to the same file as the source");
}
- println!("Converting {} -> {}", source.display(), out_path.display());
+ eprintln!("Converting {} -> {}", source.display(), out_path.display());
let result = mdman::convert(&source, opts.format, opts.url.clone(), opts.man_map.clone())
.with_context(|| format!("failed to translate {}", source.display()))?;
@@ -98,15 +98,16 @@ fn process_args() -> Result<Options, Error> {
let man = args
.next()
.ok_or_else(|| format_err!("--man requires a value"))?;
- let parts: Vec<_> = man.splitn(2, '=').collect();
- let key_parts: Vec<_> = parts[0].splitn(2, ':').collect();
- if parts.len() != 2 || key_parts.len() != 2 {
- bail!("--man expected value with form name:1=link");
- }
- let section: u8 = key_parts[1].parse().with_context(|| {
- format!("expected unsigned integer for section, got `{}`", parts[1])
+ let parts = man.split_once('=').ok_or_else(|| {
+ anyhow::format_err!("--man expected value with form name:1=link")
+ })?;
+ let key_parts = parts.0.split_once(':').ok_or_else(|| {
+ anyhow::format_err!("--man expected value with form name:1=link")
+ })?;
+ let section: u8 = key_parts.1.parse().with_context(|| {
+ format!("expected unsigned integer for section, got `{}`", parts.1)
})?;
- man_map.insert((key_parts[0].to_string(), section), parts[1].to_string());
+ man_map.insert((key_parts.0.to_string(), section), parts.1.to_string());
}
s => {
sources.push(PathBuf::from(s));
diff --git a/src/tools/cargo/crates/resolver-tests/Cargo.toml b/src/tools/cargo/crates/resolver-tests/Cargo.toml
index 5e69d7367..8750a3d97 100644
--- a/src/tools/cargo/crates/resolver-tests/Cargo.toml
+++ b/src/tools/cargo/crates/resolver-tests/Cargo.toml
@@ -1,12 +1,12 @@
[package]
name = "resolver-tests"
version = "0.0.0"
+rust-version.workspace = true
edition.workspace = true
publish = false
[dependencies]
cargo.workspace = true
cargo-util.workspace = true
-lazy_static.workspace = true
proptest.workspace = true
varisat.workspace = true
diff --git a/src/tools/cargo/crates/resolver-tests/src/lib.rs b/src/tools/cargo/crates/resolver-tests/src/lib.rs
index ab34e8663..9bdeb8674 100644
--- a/src/tools/cargo/crates/resolver-tests/src/lib.rs
+++ b/src/tools/cargo/crates/resolver-tests/src/lib.rs
@@ -7,15 +7,17 @@ use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet};
use std::fmt;
use std::fmt::Write;
use std::rc::Rc;
+use std::sync::OnceLock;
use std::task::Poll;
use std::time::Instant;
use cargo::core::dependency::DepKind;
use cargo::core::resolver::{self, ResolveOpts, VersionPreferences};
-use cargo::core::source::{GitReference, QueryKind, SourceId};
use cargo::core::Resolve;
use cargo::core::{Dependency, PackageId, Registry, Summary};
-use cargo::util::{CargoResult, Config, Graph, IntoUrl};
+use cargo::core::{GitReference, SourceId};
+use cargo::sources::source::QueryKind;
+use cargo::util::{CargoResult, Config, Graph, IntoUrl, RustVersion};
use proptest::collection::{btree_map, vec};
use proptest::prelude::*;
@@ -161,8 +163,8 @@ pub fn resolve_with_config_raw(
if std::thread::panicking() && self.list.len() != self.used.len() {
// we found a case that causes a panic and did not use all of the input.
// lets print the part of the input that was used for minimization.
- println!(
- "{:?}",
+ eprintln!(
+ "Part used befor drop: {:?}",
PrettyPrintRegistry(
self.list
.iter()
@@ -183,11 +185,12 @@ pub fn resolve_with_config_raw(
deps,
&BTreeMap::new(),
None::<&String>,
- None::<&String>,
+ None::<RustVersion>,
)
.unwrap();
let opts = ResolveOpts::everything();
let start = Instant::now();
+ let max_rust_version = None;
let resolve = resolver::resolve(
&[(summary, opts)],
&[],
@@ -195,6 +198,7 @@ pub fn resolve_with_config_raw(
&VersionPreferences::default(),
Some(config),
true,
+ max_rust_version,
);
// The largest test in our suite takes less then 30 sec.
@@ -561,11 +565,11 @@ macro_rules! pkg {
}
fn registry_loc() -> SourceId {
- lazy_static::lazy_static! {
- static ref EXAMPLE_DOT_COM: SourceId =
- SourceId::for_registry(&"https://example.com".into_url().unwrap()).unwrap();
- }
- *EXAMPLE_DOT_COM
+ static EXAMPLE_DOT_COM: OnceLock<SourceId> = OnceLock::new();
+ let example_dot = EXAMPLE_DOT_COM.get_or_init(|| {
+ SourceId::for_registry(&"https://example.com".into_url().unwrap()).unwrap()
+ });
+ *example_dot
}
pub fn pkg<T: ToPkgId>(name: T) -> Summary {
@@ -584,7 +588,7 @@ pub fn pkg_dep<T: ToPkgId>(name: T, dep: Vec<Dependency>) -> Summary {
dep,
&BTreeMap::new(),
link,
- None::<&String>,
+ None::<RustVersion>,
)
.unwrap()
}
@@ -612,7 +616,7 @@ pub fn pkg_loc(name: &str, loc: &str) -> Summary {
Vec::new(),
&BTreeMap::new(),
link,
- None::<&String>,
+ None::<RustVersion>,
)
.unwrap()
}
@@ -626,7 +630,7 @@ pub fn remove_dep(sum: &Summary, ind: usize) -> Summary {
deps,
&BTreeMap::new(),
sum.links().map(|a| a.as_str()),
- None::<&String>,
+ None::<RustVersion>,
)
.unwrap()
}
diff --git a/src/tools/cargo/crates/resolver-tests/tests/resolve.rs b/src/tools/cargo/crates/resolver-tests/tests/resolve.rs
index 02486bfb5..dd21502d8 100644
--- a/src/tools/cargo/crates/resolver-tests/tests/resolve.rs
+++ b/src/tools/cargo/crates/resolver-tests/tests/resolve.rs
@@ -1562,3 +1562,36 @@ package `A v0.0.0 (registry `https://example.com/`)`
... which satisfies dependency `C = \"*\"` of package `A v0.0.0 (registry `https://example.com/`)`\
", error.to_string());
}
+
+#[test]
+fn shortest_path_in_error_message() {
+ let input = vec![
+ pkg!(("F", "0.1.2")),
+ pkg!(("F", "0.1.1") => [dep("bad"),]),
+ pkg!(("F", "0.1.0") => [dep("bad"),]),
+ pkg!("E" => [dep_req("F", "^0.1.2"),]),
+ pkg!("D" => [dep_req("F", "^0.1.2"),]),
+ pkg!("C" => [dep("D"),]),
+ pkg!("A" => [dep("C"),dep("E"),dep_req("F", "<=0.1.1"),]),
+ ];
+ let error = resolve(vec![dep("A")], &registry(input)).unwrap_err();
+ println!("{}", error);
+ assert_eq!(
+ "\
+failed to select a version for `F`.
+ ... required by package `A v1.0.0 (registry `https://example.com/`)`
+ ... which satisfies dependency `A = \"*\"` of package `root v1.0.0 (registry `https://example.com/`)`
+versions that meet the requirements `<=0.1.1` are: 0.1.1, 0.1.0
+
+all possible versions conflict with previously selected packages.
+
+ previously selected package `F v0.1.2 (registry `https://example.com/`)`
+ ... which satisfies dependency `F = \"^0.1.2\"` of package `E v1.0.0 (registry `https://example.com/`)`
+ ... which satisfies dependency `E = \"*\"` of package `A v1.0.0 (registry `https://example.com/`)`
+ ... which satisfies dependency `A = \"*\"` of package `root v1.0.0 (registry `https://example.com/`)`
+
+failed to select a version for `F` which could resolve this conflict\
+ ",
+ error.to_string()
+ );
+}
diff --git a/src/tools/cargo/crates/semver-check/Cargo.toml b/src/tools/cargo/crates/semver-check/Cargo.toml
index 17e696566..7387c3091 100644
--- a/src/tools/cargo/crates/semver-check/Cargo.toml
+++ b/src/tools/cargo/crates/semver-check/Cargo.toml
@@ -2,6 +2,7 @@
name = "semver-check"
version = "0.0.0"
authors = ["Eric Huss"]
+rust-version.workspace = true
edition.workspace = true
publish = false
diff --git a/src/tools/cargo/crates/semver-check/src/main.rs b/src/tools/cargo/crates/semver-check/src/main.rs
index 1ba405f57..9ea0d1244 100644
--- a/src/tools/cargo/crates/semver-check/src/main.rs
+++ b/src/tools/cargo/crates/semver-check/src/main.rs
@@ -20,7 +20,7 @@ use std::process::{Command, Output};
fn main() {
if let Err(e) = doit() {
- println!("error: {}", e);
+ eprintln!("error: {}", e);
std::process::exit(1);
}
}
@@ -103,7 +103,7 @@ fn doit() -> Result<(), Box<dyn Error>> {
result
};
let expect_success = parts[0][0].contains("MINOR");
- println!("Running test from line {}", block_start);
+ eprintln!("Running test from line {}", block_start);
let result = run_test(
join(parts[1]),
diff --git a/src/tools/cargo/crates/xtask-build-man/Cargo.toml b/src/tools/cargo/crates/xtask-build-man/Cargo.toml
index bec10c48c..9e92125a1 100644
--- a/src/tools/cargo/crates/xtask-build-man/Cargo.toml
+++ b/src/tools/cargo/crates/xtask-build-man/Cargo.toml
@@ -1,6 +1,7 @@
[package]
name = "xtask-build-man"
version = "0.0.0"
+rust-version.workspace = true
edition.workspace = true
publish = false
diff --git a/src/tools/cargo/crates/xtask-bump-check/Cargo.toml b/src/tools/cargo/crates/xtask-bump-check/Cargo.toml
index e965ad09e..e878f7dda 100644
--- a/src/tools/cargo/crates/xtask-bump-check/Cargo.toml
+++ b/src/tools/cargo/crates/xtask-bump-check/Cargo.toml
@@ -1,6 +1,7 @@
[package]
name = "xtask-bump-check"
version = "0.0.0"
+rust-version.workspace = true
edition.workspace = true
publish = false
diff --git a/src/tools/cargo/crates/xtask-bump-check/src/main.rs b/src/tools/cargo/crates/xtask-bump-check/src/main.rs
index 0461ab91a..11242696f 100644
--- a/src/tools/cargo/crates/xtask-bump-check/src/main.rs
+++ b/src/tools/cargo/crates/xtask-bump-check/src/main.rs
@@ -20,6 +20,7 @@ fn setup_logger() {
let env = tracing_subscriber::EnvFilter::from_env("CARGO_LOG");
tracing_subscriber::fmt()
+ .with_timer(tracing_subscriber::fmt::time::Uptime::default())
.with_ansi(std::io::IsTerminal::is_terminal(&std::io::stderr()))
.with_writer(std::io::stderr)
.with_env_filter(env)
diff --git a/src/tools/cargo/crates/xtask-bump-check/src/xtask.rs b/src/tools/cargo/crates/xtask-bump-check/src/xtask.rs
index f89152331..4bf3f03d5 100644
--- a/src/tools/cargo/crates/xtask-bump-check/src/xtask.rs
+++ b/src/tools/cargo/crates/xtask-bump-check/src/xtask.rs
@@ -18,10 +18,10 @@ use std::task;
use cargo::core::dependency::Dependency;
use cargo::core::registry::PackageRegistry;
use cargo::core::Package;
-use cargo::core::QueryKind;
use cargo::core::Registry;
use cargo::core::SourceId;
use cargo::core::Workspace;
+use cargo::sources::source::QueryKind;
use cargo::util::command_prelude::*;
use cargo::util::ToSemver;
use cargo::CargoResult;
@@ -105,7 +105,7 @@ fn config_configure(config: &mut Config, args: &ArgMatches) -> CliResult {
/// Main entry of `xtask-bump-check`.
///
/// Assumption: version number are incremental. We never have point release for old versions.
-fn bump_check(args: &clap::ArgMatches, config: &mut cargo::util::Config) -> CargoResult<()> {
+fn bump_check(args: &clap::ArgMatches, config: &cargo::util::Config) -> CargoResult<()> {
let ws = args.workspace(config)?;
let repo = git2::Repository::open(ws.root())?;
let base_commit = get_base_commit(config, args, &repo)?;
@@ -161,7 +161,7 @@ fn bump_check(args: &clap::ArgMatches, config: &mut cargo::util::Config) -> Carg
];
// Even when we test against baseline-rev, we still need to make sure a
- // change doesn't violate SemVer rules aginst crates.io releases. The
+ // change doesn't violate SemVer rules against crates.io releases. The
// possibility of this happening is nearly zero but no harm to check twice.
let mut cmd = ProcessBuilder::new("cargo");
cmd.arg("semver-checks")
@@ -184,7 +184,7 @@ fn bump_check(args: &clap::ArgMatches, config: &mut cargo::util::Config) -> Carg
status("no version bump needed for member crates.")?;
- return Ok(());
+ Ok(())
}
/// Returns the commit of upstream `master` branch if `base-rev` is missing.
@@ -256,7 +256,7 @@ fn get_referenced_commit<'a>(
repo: &'a git2::Repository,
base: &git2::Commit<'a>,
) -> CargoResult<Option<git2::Commit<'a>>> {
- let [beta, stable] = beta_and_stable_branch(&repo)?;
+ let [beta, stable] = beta_and_stable_branch(repo)?;
let rev_id = base.id();
let stable_commit = stable.get().peel_to_commit()?;
let beta_commit = beta.get().peel_to_commit()?;
@@ -397,7 +397,7 @@ fn check_crates_io<'a>(
Ok(())
}
-/// Checkouts a temporary workspace to do further version comparsions.
+/// Checkouts a temporary workspace to do further version comparisons.
fn checkout_ws<'cfg, 'a>(
ws: &Workspace<'cfg>,
repo: &'a git2::Repository,
diff --git a/src/tools/cargo/crates/xtask-stale-label/Cargo.toml b/src/tools/cargo/crates/xtask-stale-label/Cargo.toml
index b1f54a2f1..8d68536d2 100644
--- a/src/tools/cargo/crates/xtask-stale-label/Cargo.toml
+++ b/src/tools/cargo/crates/xtask-stale-label/Cargo.toml
@@ -1,6 +1,7 @@
[package]
name = "xtask-stale-label"
version = "0.0.0"
+rust-version.workspace = true
edition.workspace = true
publish = false