Rustfmt 2024

This commit is contained in:
Eric Huss 2025-07-05 19:50:36 -07:00
parent fb0c7c99cf
commit 1ce8023626
498 changed files with 1310 additions and 1141 deletions

View File

@ -1,10 +1,10 @@
//! Benchmarks for the global cache tracker.
use cargo::core::global_cache_tracker::{self, DeferredGlobalLastUse, GlobalCacheTracker};
use cargo::util::GlobalContext;
use cargo::util::cache_lock::CacheLockMode;
use cargo::util::interning::InternedString;
use cargo::util::GlobalContext;
use criterion::{criterion_group, criterion_main, Criterion};
use criterion::{Criterion, criterion_group, criterion_main};
use std::fs;
use std::path::{Path, PathBuf};

View File

@ -1,11 +1,11 @@
use benchsuite::fixtures;
use cargo::GlobalContext;
use cargo::core::compiler::{CompileKind, RustcTargetData};
use cargo::core::resolver::features::{FeatureOpts, FeatureResolver};
use cargo::core::resolver::{CliFeatures, ForceAllTargets, HasDevUnits, ResolveBehavior};
use cargo::core::{PackageIdSpec, Workspace};
use cargo::ops::WorkspaceResolve;
use cargo::GlobalContext;
use criterion::{criterion_group, criterion_main, Criterion};
use criterion::{Criterion, criterion_group, criterion_main};
use std::path::Path;
struct ResolveInfo<'gctx> {

View File

@ -1,6 +1,6 @@
use benchsuite::fixtures;
use cargo::core::Workspace;
use criterion::{criterion_group, criterion_main, Criterion};
use criterion::{Criterion, criterion_group, criterion_main};
fn workspace_initialization(c: &mut Criterion) {
let fixtures = fixtures!();

View File

@ -12,9 +12,9 @@
//! The database is kept in git. It usually shouldn't need to be re-generated
//! unless there is a change in the schema or the benchmark.
use cargo::GlobalContext;
use cargo::core::global_cache_tracker::{self, DeferredGlobalLastUse, GlobalCacheTracker};
use cargo::util::cache_lock::CacheLockMode;
use cargo::GlobalContext;
use rand::prelude::*;
use std::collections::HashMap;
use std::fs;

View File

@ -261,11 +261,11 @@ impl<'a> Parser<'a> {
expected: "a string",
found: t.classify(),
},
))
));
}
Some(Err(e)) => return Err(e),
None => {
return Err(ParseError::new(self.t.orig, IncompleteExpr("a string")))
return Err(ParseError::new(self.t.orig, IncompleteExpr("a string")));
}
};
Cfg::KeyPair(

View File

@ -44,7 +44,7 @@
use crate::cross_compile::try_alternate;
use crate::paths;
use crate::rustc_host;
use anyhow::{bail, Result};
use anyhow::{Result, bail};
use snapbox::Data;
use snapbox::IntoData;
use std::fmt;

View File

@ -12,8 +12,8 @@ use std::collections::HashMap;
use std::io::Read;
use std::path::PathBuf;
use std::process::Command;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::Mutex;
use std::sync::atomic::{AtomicUsize, Ordering};
use tar::Header;
/// A builder for configuring a container to run.

View File

@ -40,7 +40,7 @@
//! tags), you can use `git2::Repository::open()` to open the repository and then
//! use some of the helper functions in this file to interact with the repository.
use crate::{paths::CargoPathExt, project, Project, ProjectBuilder, SymlinkBuilder};
use crate::{Project, ProjectBuilder, SymlinkBuilder, paths::CargoPathExt, project};
use std::fs;
use std::path::{Path, PathBuf};
use std::sync::Once;
@ -146,7 +146,7 @@ pub fn init(path: &Path) -> git2::Repository {
fn default_search_path() {
use crate::paths::global_root;
use git2::{opts::set_search_path, ConfigLevel};
use git2::{ConfigLevel, opts::set_search_path};
static INIT: Once = Once::new();
INIT.call_once(|| unsafe {

View File

@ -54,8 +54,8 @@ use std::sync::OnceLock;
use std::thread::JoinHandle;
use std::time::{self, Duration};
use anyhow::{bail, Result};
use cargo_util::{is_ci, ProcessError};
use anyhow::{Result, bail};
use cargo_util::{ProcessError, is_ci};
use snapbox::IntoData as _;
use url::Url;
@ -112,11 +112,11 @@ pub mod publish;
pub mod registry;
pub mod prelude {
pub use crate::cargo_test;
pub use crate::paths::CargoPathExt;
pub use crate::ArgLineCommandExt;
pub use crate::ChannelChangerCommandExt;
pub use crate::TestEnvCommandExt;
pub use crate::cargo_test;
pub use crate::paths::CargoPathExt;
pub use snapbox::IntoData;
}

View File

@ -8,9 +8,9 @@ use std::fs;
use std::io::{self, ErrorKind};
use std::path::{Path, PathBuf};
use std::process::Command;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::Mutex;
use std::sync::OnceLock;
use std::sync::atomic::{AtomicUsize, Ordering};
static CARGO_INTEGRATION_TEST_DIR: &str = "cit";

View File

@ -35,13 +35,13 @@
//! ```
use crate::compare::InMemoryDir;
use crate::registry::{self, alt_api_path, FeatureMap};
use crate::registry::{self, FeatureMap, alt_api_path};
use flate2::read::GzDecoder;
use snapbox::prelude::*;
use std::collections::HashSet;
use std::fs;
use std::fs::File;
use std::io::{self, prelude::*, SeekFrom};
use std::io::{self, SeekFrom, prelude::*};
use std::path::Path;
use tar::Archive;

View File

@ -45,10 +45,10 @@
use crate::git::repo;
use crate::paths;
use crate::publish::{create_index_line, write_to_index};
use cargo_util::paths::append;
use cargo_util::Sha256;
use flate2::write::GzEncoder;
use cargo_util::paths::append;
use flate2::Compression;
use flate2::write::GzEncoder;
use pasetors::keys::{AsymmetricPublicKey, AsymmetricSecretKey};
use pasetors::paserk::FormatAsPaserk;
use pasetors::token::UntrustedToken;

View File

@ -1151,7 +1151,7 @@ impl<'de> de::Deserialize<'de> for TomlDebugInfo {
return Err(serde_untagged::de::Error::invalid_value(
Unexpected::Signed(value),
&expecting,
))
));
}
};
Ok(debuginfo)
@ -1167,7 +1167,7 @@ impl<'de> de::Deserialize<'de> for TomlDebugInfo {
return Err(serde_untagged::de::Error::invalid_value(
Unexpected::Str(value),
&expecting,
))
));
}
};
Ok(debuginfo)

View File

@ -9,7 +9,7 @@
pub use self::read2::read2;
pub use du::du;
pub use process_builder::ProcessBuilder;
pub use process_error::{exit_status_to_string, is_simple_exit_code, ProcessError};
pub use process_error::{ProcessError, exit_status_to_string, is_simple_exit_code};
pub use sha256::Sha256;
mod du;

View File

@ -825,7 +825,7 @@ fn exclude_from_content_indexing(path: &Path) {
use std::iter::once;
use std::os::windows::prelude::OsStrExt;
use windows_sys::Win32::Storage::FileSystem::{
GetFileAttributesW, SetFileAttributesW, FILE_ATTRIBUTE_NOT_CONTENT_INDEXED,
FILE_ATTRIBUTE_NOT_CONTENT_INDEXED, GetFileAttributesW, SetFileAttributesW,
};
let path: Vec<u16> = path.as_os_str().encode_wide().chain(once(0)).collect();

View File

@ -1,7 +1,7 @@
use crate::process_error::ProcessError;
use crate::read2;
use anyhow::{bail, Context, Result};
use anyhow::{Context, Result, bail};
use jobserver::Client;
use shell_escape::escape;
use tempfile::NamedTempFile;
@ -564,7 +564,7 @@ fn close_tempfile_and_log_error(file: NamedTempFile) {
#[cfg(unix)]
mod imp {
use super::{close_tempfile_and_log_error, debug_force_argfile, ProcessBuilder, ProcessError};
use super::{ProcessBuilder, ProcessError, close_tempfile_and_log_error, debug_force_argfile};
use anyhow::Result;
use std::io;
use std::os::unix::process::CommandExt;
@ -606,9 +606,9 @@ mod imp {
use super::{ProcessBuilder, ProcessError};
use anyhow::Result;
use std::io;
use windows_sys::core::BOOL;
use windows_sys::Win32::Foundation::{FALSE, TRUE};
use windows_sys::Win32::System::Console::SetConsoleCtrlHandler;
use windows_sys::core::BOOL;
unsafe extern "system" fn ctrlc_handler(_: u32) -> BOOL {
// Do nothing; let the child process handle it.

View File

@ -2,7 +2,7 @@ pub use self::imp::read2;
#[cfg(unix)]
mod imp {
use libc::{c_int, fcntl, F_GETFL, F_SETFL, O_NONBLOCK};
use libc::{F_GETFL, F_SETFL, O_NONBLOCK, c_int, fcntl};
use std::io;
use std::io::prelude::*;
use std::mem;
@ -88,9 +88,9 @@ mod imp {
use std::process::{ChildStderr, ChildStdout};
use std::slice;
use miow::Overlapped;
use miow::iocp::{CompletionPort, CompletionStatus};
use miow::pipe::NamedPipe;
use miow::Overlapped;
use windows_sys::Win32::Foundation::ERROR_BROKEN_PIPE;
struct Pipe<'a> {

View File

@ -8,7 +8,7 @@ use std::io::{Cursor, SeekFrom};
use std::time::Instant;
use curl::easy::{Easy, List};
use percent_encoding::{percent_encode, NON_ALPHANUMERIC};
use percent_encoding::{NON_ALPHANUMERIC, percent_encode};
use serde::{Deserialize, Serialize};
use url::Url;

View File

@ -7,7 +7,7 @@ use std::slice;
use windows_sys::Win32::Foundation::S_OK;
use windows_sys::Win32::System::Com::CoTaskMemFree;
use windows_sys::Win32::UI::Shell::{FOLDERID_Profile, SHGetKnownFolderPath, KF_FLAG_DONT_VERIFY};
use windows_sys::Win32::UI::Shell::{FOLDERID_Profile, KF_FLAG_DONT_VERIFY, SHGetKnownFolderPath};
pub fn home_dir_inner() -> Option<PathBuf> {
env::var_os("USERPROFILE")

View File

@ -1,8 +1,8 @@
//! Man-page formatter.
use crate::util::{header_text, parse_name_and_section};
use crate::EventIter;
use anyhow::{bail, Error};
use crate::util::{header_text, parse_name_and_section};
use anyhow::{Error, bail};
use pulldown_cmark::{Alignment, Event, HeadingLevel, LinkType, Tag, TagEnd};
use std::fmt::Write;
use url::Url;

View File

@ -1,8 +1,8 @@
//! Markdown formatter.
use crate::util::unwrap;
use crate::ManMap;
use anyhow::{bail, format_err, Error};
use crate::util::unwrap;
use anyhow::{Error, bail, format_err};
use std::fmt::Write;
pub struct MdFormatter {

View File

@ -1,8 +1,8 @@
//! Text formatter.
use crate::util::{header_text, unwrap};
use crate::EventIter;
use anyhow::{bail, Error};
use crate::util::{header_text, unwrap};
use anyhow::{Error, bail};
use pulldown_cmark::{Alignment, Event, HeadingLevel, LinkType, Tag, TagEnd};
use std::fmt::Write;
use std::mem;

View File

@ -5,8 +5,8 @@ use std::path::Path;
use anyhow::Error;
use handlebars::{
handlebars_helper, Context, Decorator, DirectorySourceOptions, Handlebars, Helper, HelperDef,
HelperResult, Output, RenderContext, RenderError, RenderErrorReason, Renderable,
Context, Decorator, DirectorySourceOptions, Handlebars, Helper, HelperDef, HelperResult,
Output, RenderContext, RenderError, RenderErrorReason, Renderable, handlebars_helper,
};
use crate::format::Formatter;

View File

@ -4,7 +4,7 @@
//! > and not intended for external use (except as a transitive dependency). This
//! > crate may make major changes to its APIs or be deprecated without warning.
use anyhow::{bail, Context, Error};
use anyhow::{Context, Error, bail};
use pulldown_cmark::{CowStr, Event, LinkType, Options, Parser, Tag, TagEnd};
use std::collections::HashMap;
use std::fs;

View File

@ -1,6 +1,6 @@
#![allow(clippy::print_stderr)]
use anyhow::{bail, format_err, Context, Error};
use anyhow::{Context, Error, bail, format_err};
use mdman::{Format, ManMap};
use std::collections::HashMap;
use std::path::{Path, PathBuf};

View File

@ -1,6 +1,6 @@
///! General utilities.
use crate::EventIter;
use anyhow::{bail, format_err, Context, Error};
use anyhow::{Context, Error, bail, format_err};
use pulldown_cmark::{CowStr, Event, TagEnd};
/// Splits the text `foo(1)` into "foo" and `1`.

View File

@ -13,18 +13,18 @@ use std::fmt;
use std::task::Poll;
use std::time::Instant;
use cargo::core::dependency::DepKind;
use cargo::core::resolver::{self, ResolveOpts, VersionOrdering, VersionPreferences};
use cargo::core::Resolve;
use cargo::core::ResolveVersion;
use cargo::core::SourceId;
use cargo::core::dependency::DepKind;
use cargo::core::resolver::{self, ResolveOpts, VersionOrdering, VersionPreferences};
use cargo::core::{Dependency, PackageId, Registry, Summary};
use cargo::sources::source::QueryKind;
use cargo::sources::IndexSummary;
use cargo::sources::source::QueryKind;
use cargo::util::interning::InternedString;
use cargo::util::{CargoResult, GlobalContext};
use crate::helpers::{dep_req, dep_req_kind, pkg_dep, pkg_id, ToPkgId};
use crate::helpers::{ToPkgId, dep_req, dep_req_kind, pkg_dep, pkg_id};
use crate::sat::SatResolver;
use proptest::collection::{btree_map, vec};
@ -406,24 +406,24 @@ mod tests {
#[test]
fn meta_test_deep_pretty_print_registry() {
assert_eq!(
&format!(
"{:?}",
PrettyPrintRegistry(vec![
pkg!(("foo", "1.0.1") => [dep_req("bar", "1")]),
pkg!(("foo", "1.0.0") => [dep_req("bar", "2")]),
pkg!(("foo", "2.0.0") => [dep_req("bar", "*")]),
pkg!(("bar", "1.0.0") => [dep_req("baz", "=1.0.2"),
&format!(
"{:?}",
PrettyPrintRegistry(vec![
pkg!(("foo", "1.0.1") => [dep_req("bar", "1")]),
pkg!(("foo", "1.0.0") => [dep_req("bar", "2")]),
pkg!(("foo", "2.0.0") => [dep_req("bar", "*")]),
pkg!(("bar", "1.0.0") => [dep_req("baz", "=1.0.2"),
dep_req("other", "1")]),
pkg!(("bar", "2.0.0") => [dep_req("baz", "=1.0.1")]),
pkg!(("baz", "1.0.2") => [dep_req("other", "2")]),
pkg!(("baz", "1.0.1")),
pkg!(("cat", "1.0.2") => [dep_req_kind("other", "2", DepKind::Build)]),
pkg!(("cat", "1.0.3") => [dep_req_kind("other", "2", DepKind::Development)]),
pkg!(("dep_req", "1.0.0")),
pkg!(("dep_req", "2.0.0")),
])
),
"vec![pkg!((\"foo\", \"1.0.1\") => [dep_req(\"bar\", \"^1\"),]),\
pkg!(("bar", "2.0.0") => [dep_req("baz", "=1.0.1")]),
pkg!(("baz", "1.0.2") => [dep_req("other", "2")]),
pkg!(("baz", "1.0.1")),
pkg!(("cat", "1.0.2") => [dep_req_kind("other", "2", DepKind::Build)]),
pkg!(("cat", "1.0.3") => [dep_req_kind("other", "2", DepKind::Development)]),
pkg!(("dep_req", "1.0.0")),
pkg!(("dep_req", "2.0.0")),
])
),
"vec![pkg!((\"foo\", \"1.0.1\") => [dep_req(\"bar\", \"^1\"),]),\
pkg!((\"foo\", \"1.0.0\") => [dep_req(\"bar\", \"^2\"),]),\
pkg!((\"foo\", \"2.0.0\") => [dep(\"bar\"),]),\
pkg!((\"bar\", \"1.0.0\") => [dep_req(\"baz\", \"=1.0.2\"),dep_req(\"other\", \"^1\"),]),\
@ -434,7 +434,7 @@ mod tests {
pkg!((\"cat\", \"1.0.3\") => [dep_req_kind(\"other\", \"^2\", DepKind::Development, false),]),\
pkg!((\"dep_req\", \"1.0.0\")),\
pkg!((\"dep_req\", \"2.0.0\")),]"
)
)
}
/// This test is to test the generator to ensure

View File

@ -4,7 +4,7 @@ use std::fmt::Write;
use cargo::core::dependency::DepKind;
use cargo::core::{Dependency, FeatureMap, FeatureValue, PackageId, Summary};
use cargo::util::interning::{InternedString, INTERNED_DEFAULT};
use cargo::util::interning::{INTERNED_DEFAULT, InternedString};
use cargo_platform::Platform;
use varisat::ExtendFormula;

View File

@ -4,10 +4,10 @@ use cargo::util::GlobalContext;
use cargo_util::is_ci;
use resolver_tests::{
PrettyPrintRegistry,
helpers::{dep_req, registry, remove_dep},
registry_strategy, resolve, resolve_and_validated, resolve_with_global_context,
sat::SatResolver,
PrettyPrintRegistry,
};
use proptest::prelude::*;

View File

@ -1,9 +1,9 @@
use cargo::core::{dependency::DepKind, Dependency};
use cargo::core::{Dependency, dependency::DepKind};
use resolver_tests::{
helpers::{
dep, dep_kind, dep_req, dep_req_kind, pkg, pkg_dep, pkg_dep_link, pkg_dep_with,
pkg_id_source, registry, ToDep,
ToDep, dep, dep_kind, dep_req, dep_req_kind, pkg, pkg_dep, pkg_dep_link, pkg_dep_with,
pkg_id_source, registry,
},
pkg, resolve, resolve_and_validated, resolve_and_validated_raw,
sat::SatResolver,

View File

@ -1,11 +1,11 @@
use cargo::core::dependency::DepKind;
use cargo::core::Dependency;
use cargo::core::dependency::DepKind;
use cargo::util::GlobalContext;
use resolver_tests::{
helpers::{
assert_contains, assert_same, dep, dep_kind, dep_loc, dep_req, loc_names, names, pkg,
pkg_dep, pkg_dep_with, pkg_id, pkg_loc, registry, ToDep, ToPkgId,
ToDep, ToPkgId, assert_contains, assert_same, dep, dep_kind, dep_loc, dep_req, loc_names,
names, pkg, pkg_dep, pkg_dep_with, pkg_id, pkg_loc, registry,
},
pkg, resolve, resolve_with_global_context,
};

View File

@ -1,9 +1,9 @@
use cargo::core::{dependency::DepKind, Dependency};
use cargo::core::{Dependency, dependency::DepKind};
use resolver_tests::{
helpers::{
dep, dep_kind, dep_platform, dep_req, dep_req_kind, dep_req_platform, pkg, pkg_dep,
pkg_dep_with, registry, ToDep,
ToDep, dep, dep_kind, dep_platform, dep_req, dep_req_kind, dep_req_platform, pkg, pkg_dep,
pkg_dep_with, registry,
},
pkg, resolve, resolve_and_validated,
sat::SatResolver,

View File

@ -1,6 +1,6 @@
#![allow(clippy::print_stderr)]
use std::io::{stdin, BufReader, Read};
use std::io::{BufReader, Read, stdin};
use std::{collections::HashMap, collections::HashSet, env, fs};
use anyhow::Error;

View File

@ -175,8 +175,8 @@ pub fn collect_suggestions<S: ::std::hash::BuildHasher>(
.spans
.iter()
.filter(|span| {
use crate::diagnostics::Applicability::*;
use crate::Filter::*;
use crate::diagnostics::Applicability::*;
match (filter, &span.suggestion_applicability) {
(MachineApplicableOnly, Some(MachineApplicable)) => true,

View File

@ -14,7 +14,7 @@
#![allow(clippy::disallowed_methods, clippy::print_stdout, clippy::print_stderr)]
use anyhow::{anyhow, Context, Error};
use anyhow::{Context, Error, anyhow};
use rustfix::apply_suggestions;
use serde_json::Value;
use snapbox::data::DataFormat;

View File

@ -17,15 +17,15 @@ use std::fmt::Write;
use std::fs;
use std::task;
use cargo::core::dependency::Dependency;
use cargo::CargoResult;
use cargo::core::Package;
use cargo::core::Registry;
use cargo::core::SourceId;
use cargo::core::Workspace;
use cargo::core::dependency::Dependency;
use cargo::sources::source::QueryKind;
use cargo::util::cache_lock::CacheLockMode;
use cargo::util::command_prelude::*;
use cargo::CargoResult;
use cargo_util::ProcessBuilder;
const UPSTREAM_BRANCH: &str = "master";

View File

@ -1,4 +1,4 @@
use cargo::util::command_prelude::{flag, ArgMatchesExt};
use cargo::util::command_prelude::{ArgMatchesExt, flag};
use cargo::util::lints::{Lint, LintLevel};
use itertools::Itertools;
use std::fmt::Write;

View File

@ -8,8 +8,8 @@ mod linux {
use anyhow::Context;
use cargo_credential::{
read_token, Action, CacheControl, Credential, CredentialResponse, Error, RegistryInfo,
Secret,
Action, CacheControl, Credential, CredentialResponse, Error, RegistryInfo, Secret,
read_token,
};
use libloading::{Library, Symbol};
use std::ffi::{CStr, CString};

View File

@ -9,7 +9,7 @@
#[cfg(target_os = "macos")]
mod macos {
use cargo_credential::{
read_token, Action, CacheControl, Credential, CredentialResponse, Error, RegistryInfo,
Action, CacheControl, Credential, CredentialResponse, Error, RegistryInfo, read_token,
};
use security_framework::os::macos::keychain::SecKeychain;

View File

@ -6,22 +6,22 @@
#[cfg(windows)]
mod win {
use cargo_credential::{read_token, Action, CacheControl, CredentialResponse, RegistryInfo};
use cargo_credential::{Action, CacheControl, CredentialResponse, RegistryInfo, read_token};
use cargo_credential::{Credential, Error};
use std::ffi::OsStr;
use std::os::windows::ffi::OsStrExt;
use windows_sys::core::PWSTR;
use windows_sys::Win32::Foundation::ERROR_NOT_FOUND;
use windows_sys::Win32::Foundation::FILETIME;
use windows_sys::Win32::Foundation::TRUE;
use windows_sys::Win32::Security::Credentials::CredReadW;
use windows_sys::Win32::Security::Credentials::CredWriteW;
use windows_sys::Win32::Security::Credentials::CREDENTIALW;
use windows_sys::Win32::Security::Credentials::CRED_PERSIST_LOCAL_MACHINE;
use windows_sys::Win32::Security::Credentials::CRED_TYPE_GENERIC;
use windows_sys::Win32::Security::Credentials::CREDENTIALW;
use windows_sys::Win32::Security::Credentials::CredReadW;
use windows_sys::Win32::Security::Credentials::CredWriteW;
use windows_sys::Win32::Security::Credentials::{CredDeleteW, CredFree};
use windows_sys::core::PWSTR;
pub struct WindowsCredential;

View File

@ -102,7 +102,7 @@ mod error_serialize {
use std::error::Error as StdError;
use std::ops::Deref;
use serde::{ser::SerializeStruct, Deserialize, Deserializer, Serializer};
use serde::{Deserialize, Deserializer, Serializer, ser::SerializeStruct};
use crate::error::StringTypedError;

View File

@ -28,7 +28,7 @@ mod imp {
use windows_sys::Win32::{
Foundation::{HANDLE, INVALID_HANDLE_VALUE},
System::Console::{
GetStdHandle, SetStdHandle, STD_HANDLE, STD_INPUT_HANDLE, STD_OUTPUT_HANDLE,
GetStdHandle, STD_HANDLE, STD_INPUT_HANDLE, STD_OUTPUT_HANDLE, SetStdHandle,
},
};
pub const OUT_DEVICE: &str = "CONOUT$";
@ -82,7 +82,7 @@ mod imp {
#[cfg(unix)]
mod imp {
use super::Stdio;
use libc::{close, dup, dup2, STDIN_FILENO, STDOUT_FILENO};
use libc::{STDIN_FILENO, STDOUT_FILENO, close, dup, dup2};
use std::{fs::File, io::Error, os::fd::AsRawFd};
pub const IN_DEVICE: &str = "/dev/tty";
pub const OUT_DEVICE: &str = "/dev/tty";
@ -138,8 +138,8 @@ mod test {
use std::fs::OpenOptions;
use std::io::{Seek, Write};
use super::imp::ReplacementGuard;
use super::Stdio;
use super::imp::ReplacementGuard;
#[test]
fn stdin() {

1
rustfmt.toml Normal file
View File

@ -0,0 +1 @@
style_edition = "2024"

View File

@ -1,7 +1,7 @@
use anyhow::{anyhow, Context as _};
use cargo::core::{features, CliUnstable};
use anyhow::{Context as _, anyhow};
use cargo::core::{CliUnstable, features};
use cargo::util::context::TermConfig;
use cargo::{drop_print, drop_println, CargoResult};
use cargo::{CargoResult, drop_print, drop_println};
use clap::builder::UnknownArgumentValueParser;
use itertools::Itertools;
use std::collections::HashMap;
@ -556,9 +556,13 @@ pub fn cli(gctx: &GlobalContext) -> Command {
};
let usage = if is_rustup() {
color_print::cstr!("<cyan,bold>cargo</> <cyan>[+toolchain] [OPTIONS] [COMMAND]</>\n <cyan,bold>cargo</> <cyan>[+toolchain] [OPTIONS]</> <cyan,bold>-Zscript</> <cyan><<MANIFEST_RS>> [ARGS]...</>")
color_print::cstr!(
"<cyan,bold>cargo</> <cyan>[+toolchain] [OPTIONS] [COMMAND]</>\n <cyan,bold>cargo</> <cyan>[+toolchain] [OPTIONS]</> <cyan,bold>-Zscript</> <cyan><<MANIFEST_RS>> [ARGS]...</>"
)
} else {
color_print::cstr!("<cyan,bold>cargo</> <cyan>[OPTIONS] [COMMAND]</>\n <cyan,bold>cargo</> <cyan>[OPTIONS]</> <cyan,bold>-Zscript</> <cyan><<MANIFEST_RS>> [ARGS]...</>")
color_print::cstr!(
"<cyan,bold>cargo</> <cyan>[OPTIONS] [COMMAND]</>\n <cyan,bold>cargo</> <cyan>[OPTIONS]</> <cyan,bold>-Zscript</> <cyan><<MANIFEST_RS>> [ARGS]...</>"
)
};
let styles = {

View File

@ -3,15 +3,15 @@ use cargo::util::print_available_packages;
use indexmap::IndexMap;
use indexmap::IndexSet;
use cargo::core::dependency::DepKind;
use cargo::CargoResult;
use cargo::core::FeatureValue;
use cargo::ops::cargo_add::add;
use cargo::core::dependency::DepKind;
use cargo::ops::cargo_add::AddOptions;
use cargo::ops::cargo_add::DepOp;
use cargo::ops::cargo_add::add;
use cargo::ops::resolve_ws;
use cargo::util::command_prelude::*;
use cargo::util::toml_mut::manifest::DepTable;
use cargo::CargoResult;
pub fn cli() -> Command {
clap::Command::new("add")
@ -300,7 +300,10 @@ fn parse_dependencies(gctx: &GlobalContext, matches: &ArgMatches) -> CargoResult
)
})
.collect::<Vec<_>>();
anyhow::bail!("feature `{feature}` must be qualified by the dependency it's being activated for, like {}", candidates.join(", "));
anyhow::bail!(
"feature `{feature}` must be qualified by the dependency it's being activated for, like {}",
candidates.join(", ")
);
}
crates
.first_mut()
@ -318,7 +321,9 @@ fn parse_dependencies(gctx: &GlobalContext, matches: &ArgMatches) -> CargoResult
..
} => {
if infer_crate_name {
anyhow::bail!("`{feature}` is unsupported when inferring the crate name, use `{dep_feature}`");
anyhow::bail!(
"`{feature}` is unsupported when inferring the crate name, use `{dep_feature}`"
);
}
if dep_feature.contains('/') {
anyhow::bail!("multiple slashes in feature `{feature}` is not allowed");

View File

@ -1,7 +1,7 @@
use crate::command_prelude::*;
use crate::util::cache_lock::CacheLockMode;
use cargo::core::gc::Gc;
use cargo::core::gc::{parse_human_size, parse_time_span, GcOpts};
use cargo::core::gc::{GcOpts, parse_human_size, parse_time_span};
use cargo::core::global_cache_tracker::GlobalCacheTracker;
use cargo::ops::CleanContext;
use cargo::ops::{self, CleanOptions};

View File

@ -3,11 +3,11 @@ use crate::command_prelude::*;
use anyhow::anyhow;
use anyhow::bail;
use anyhow::format_err;
use cargo::CargoResult;
use cargo::core::{GitReference, SourceId, Workspace};
use cargo::ops;
use cargo::util::IntoUrl;
use cargo::util::VersionExt;
use cargo::CargoResult;
use cargo_util_schemas::manifest::PackageName;
use itertools::Itertools;
use semver::VersionReq;

View File

@ -1,6 +1,6 @@
use crate::command_prelude::*;
use anyhow::bail;
use cargo::{drop_println, CargoResult};
use cargo::{CargoResult, drop_println};
use serde::Serialize;
pub fn cli() -> Command {

View File

@ -1,10 +1,11 @@
use cargo::core::dependency::DepKind;
use cargo::CargoResult;
use cargo::core::PackageIdSpec;
use cargo::core::PackageIdSpecQuery;
use cargo::core::Resolve;
use cargo::core::Workspace;
use cargo::ops::cargo_remove::remove;
use cargo::core::dependency::DepKind;
use cargo::ops::cargo_remove::RemoveOptions;
use cargo::ops::cargo_remove::remove;
use cargo::ops::resolve_ws;
use cargo::util::command_prelude::*;
use cargo::util::print_available_packages;
@ -13,7 +14,6 @@ use cargo::util::toml_mut::dependency::MaybeWorkspace;
use cargo::util::toml_mut::dependency::Source;
use cargo::util::toml_mut::manifest::DepTable;
use cargo::util::toml_mut::manifest::LocalManifest;
use cargo::CargoResult;
pub fn cli() -> clap::Command {
clap::Command::new("remove")

View File

@ -121,7 +121,9 @@ pub fn exec_manifest_command(gctx: &mut GlobalContext, cmd: &str, args: &[OsStri
args.into_iter().map(|os| os.to_string_lossy()).join(" ")
)
};
format!("\nhelp: there is a command with a similar name: `{suggested_command} {actual_args}{args}`")
format!(
"\nhelp: there is a command with a similar name: `{suggested_command} {actual_args}{args}`"
)
} else {
"".to_owned()
};
@ -153,12 +155,16 @@ pub fn exec_manifest_command(gctx: &mut GlobalContext, cmd: &str, args: &[OsStri
args.into_iter().map(|os| os.to_string_lossy()).join(" ")
)
};
format!("\nhelp: there is a command with a similar name: `{suggested_command} {actual_args}{args}`")
format!(
"\nhelp: there is a command with a similar name: `{suggested_command} {actual_args}{args}`"
)
} else {
"".to_owned()
};
let suggested_script = if let Some(suggested_script) = suggested_script(cmd) {
format!("\nhelp: there is a script with a similar name: `{suggested_script}` (requires `-Zscript`)")
format!(
"\nhelp: there is a script with a similar name: `{suggested_script}` (requires `-Zscript`)"
)
} else {
"".to_owned()
};

View File

@ -2,10 +2,10 @@ use crate::cli;
use crate::command_prelude::*;
use anyhow::{bail, format_err};
use cargo::core::dependency::DepKind;
use cargo::ops::tree::{self, DisplayDepth, EdgeKind};
use cargo::ops::Packages;
use cargo::util::print_available_packages;
use cargo::ops::tree::{self, DisplayDepth, EdgeKind};
use cargo::util::CargoResult;
use cargo::util::print_available_packages;
use std::collections::HashSet;
use std::str::FromStr;

View File

@ -4,7 +4,7 @@ use cargo::core::features;
use cargo::core::shell::Shell;
use cargo::util::network::http::http_handle;
use cargo::util::network::http::needs_custom_http_transport;
use cargo::util::{self, closest_msg, command_prelude, CargoResult};
use cargo::util::{self, CargoResult, closest_msg, command_prelude};
use cargo_util::{ProcessBuilder, ProcessError};
use cargo_util_schemas::manifest::StringOrVec;
use std::collections::BTreeMap;
@ -278,15 +278,16 @@ fn execute_external_subcommand(gctx: &GlobalContext, cmd: &str, args: &[&OsStr])
let command = match path {
Some(command) => command,
None => {
let script_suggestion =
if gctx.cli_unstable().script && std::path::Path::new(cmd).is_file() {
let sep = std::path::MAIN_SEPARATOR;
format!(
let script_suggestion = if gctx.cli_unstable().script
&& std::path::Path::new(cmd).is_file()
{
let sep = std::path::MAIN_SEPARATOR;
format!(
"\nhelp: To run the file `{cmd}`, provide a relative path like `.{sep}{cmd}`"
)
} else {
"".to_owned()
};
} else {
"".to_owned()
};
let err = if cmd.starts_with('+') {
anyhow::format_err!(
"no such command: `{cmd}`\n\n\

View File

@ -1,10 +1,10 @@
//! Generate artifact information from unit dependencies for configuring the compiler environment.
use crate::CargoResult;
use crate::core::compiler::unit_graph::UnitDep;
use crate::core::compiler::{BuildRunner, CrateType, FileFlavor, Unit};
use crate::core::dependency::ArtifactKind;
use crate::core::{Dependency, Target, TargetKind};
use crate::CargoResult;
use std::collections::{HashMap, HashSet};
use std::ffi::OsString;

View File

@ -2,7 +2,7 @@ use crate::core::compiler::CompileKind;
use crate::util::context::JobsConfig;
use crate::util::interning::InternedString;
use crate::util::{CargoResult, GlobalContext, RustfixDiagnosticServer};
use anyhow::{bail, Context as _};
use anyhow::{Context as _, bail};
use cargo_util::ProcessBuilder;
use serde::ser;
use std::cell::RefCell;
@ -96,8 +96,9 @@ impl BuildConfig {
JobsConfig::String(j) => match j.as_str() {
"default" => default_parallelism()?,
_ => {
anyhow::bail!(
format!("could not parse `{j}`. Number of parallel jobs should be `default` or a number."))
anyhow::bail!(format!(
"could not parse `{j}`. Number of parallel jobs should be `default` or a number."
))
}
},
},

View File

@ -1,14 +1,14 @@
//! [`BuildContext`] is a (mostly) static information about a build task.
use crate::core::PackageSet;
use crate::core::Workspace;
use crate::core::compiler::unit_graph::UnitGraph;
use crate::core::compiler::{BuildConfig, CompileKind, Unit};
use crate::core::profiles::Profiles;
use crate::core::PackageSet;
use crate::core::Workspace;
use crate::util::Rustc;
use crate::util::context::GlobalContext;
use crate::util::errors::CargoResult;
use crate::util::interning::InternedString;
use crate::util::Rustc;
use std::collections::{HashMap, HashSet};
mod target_info;

View File

@ -15,7 +15,7 @@ use crate::util::interning::InternedString;
use crate::util::{CargoResult, Rustc};
use anyhow::Context as _;
use cargo_platform::{Cfg, CfgExpr};
use cargo_util::{paths, ProcessBuilder};
use cargo_util::{ProcessBuilder, paths};
use serde::{Deserialize, Serialize};
use std::cell::RefCell;
use std::collections::hash_map::{Entry, HashMap};
@ -214,9 +214,9 @@ impl TargetInfo {
let (output, error) = rustc
.cached_output(&process, extra_fingerprint)
.with_context(|| {
"failed to run `rustc` to learn about target-specific information"
})?;
.with_context(
|| "failed to run `rustc` to learn about target-specific information",
)?;
let mut lines = output.lines();
let mut map = HashMap::new();
@ -254,7 +254,7 @@ impl TargetInfo {
&process,
&output,
&error,
)
);
}
}
}

View File

@ -14,7 +14,7 @@ use serde::Serialize;
use super::build_runner::OutputFile;
use super::{BuildRunner, CompileKind, CompileMode, Unit};
use crate::core::TargetKind;
use crate::util::{internal, CargoResult, GlobalContext};
use crate::util::{CargoResult, GlobalContext, internal};
use cargo_util::ProcessBuilder;
#[derive(Debug, Serialize)]

View File

@ -4,12 +4,12 @@ use std::collections::{BTreeSet, HashMap, HashSet};
use std::path::{Path, PathBuf};
use std::sync::{Arc, Mutex};
use crate::core::compiler::compilation::{self, UnitOutput};
use crate::core::compiler::{self, artifact, Unit};
use crate::core::PackageId;
use crate::core::compiler::compilation::{self, UnitOutput};
use crate::core::compiler::{self, Unit, artifact};
use crate::util::cache_lock::CacheLockMode;
use crate::util::errors::CargoResult;
use anyhow::{bail, Context as _};
use anyhow::{Context as _, bail};
use filetime::FileTime;
use itertools::Itertools;
use jobserver::Client;
@ -507,12 +507,10 @@ impl<'a, 'gctx> BuildRunner<'a, 'gctx> {
path.display()
)
};
let suggestion =
"Consider changing their names to be unique or compiling them separately.\n\
let suggestion = "Consider changing their names to be unique or compiling them separately.\n\
This may become a hard error in the future; see \
<https://github.com/rust-lang/cargo/issues/6313>.";
let rustdoc_suggestion =
"This is a known bug where multiple crates with the same name use\n\
let rustdoc_suggestion = "This is a known bug where multiple crates with the same name use\n\
the same path; see <https://github.com/rust-lang/cargo/issues/6313>.";
let report_collision = |unit: &Unit,
other_unit: &Unit,

View File

@ -5,13 +5,13 @@ use std::ffi::{OsStr, OsString};
use std::path::PathBuf;
use cargo_platform::CfgExpr;
use cargo_util::{paths, ProcessBuilder};
use cargo_util::{ProcessBuilder, paths};
use crate::core::compiler::apply_env_config;
use crate::core::compiler::BuildContext;
use crate::core::compiler::{CompileKind, Unit, UnitHash};
use crate::core::Package;
use crate::util::{context, CargoResult, GlobalContext};
use crate::core::compiler::BuildContext;
use crate::core::compiler::apply_env_config;
use crate::core::compiler::{CompileKind, Unit, UnitHash};
use crate::util::{CargoResult, GlobalContext, context};
/// Represents the kind of process we are creating.
#[derive(Debug)]

View File

@ -3,7 +3,7 @@
use crate::core::Target;
use crate::util::errors::CargoResult;
use crate::util::interning::InternedString;
use crate::util::{try_canonicalize, GlobalContext, StableHasher};
use crate::util::{GlobalContext, StableHasher, try_canonicalize};
use anyhow::Context as _;
use serde::Serialize;
use std::collections::BTreeSet;

View File

@ -31,17 +31,17 @@
//! [`CompileMode::RunCustomBuild`]: crate::core::compiler::CompileMode::RunCustomBuild
//! [instructions]: https://doc.rust-lang.org/cargo/reference/build-scripts.html#outputs-of-the-build-script
use super::{fingerprint, get_dynamic_search_path, BuildRunner, Job, Unit, Work};
use super::{BuildRunner, Job, Unit, Work, fingerprint, get_dynamic_search_path};
use crate::core::compiler::CompileMode;
use crate::core::compiler::artifact;
use crate::core::compiler::build_runner::UnitHash;
use crate::core::compiler::fingerprint::DirtyReason;
use crate::core::compiler::job_queue::JobState;
use crate::core::compiler::CompileMode;
use crate::core::{profiles::ProfileRoot, PackageId, Target};
use crate::core::{PackageId, Target, profiles::ProfileRoot};
use crate::util::errors::CargoResult;
use crate::util::internal;
use crate::util::machine_message::{self, Message};
use anyhow::{bail, Context as _};
use anyhow::{Context as _, bail};
use cargo_platform::Cfg;
use cargo_util::paths;
use cargo_util_schemas::manifest::RustVersion;
@ -836,7 +836,9 @@ impl BuildOutput {
)
} else if flag.starts_with("metadata=") {
let old_format_flag = flag.strip_prefix("metadata=").unwrap();
format!("Switch to the old `cargo:{old_format_flag}` syntax instead of `cargo::{flag}` (note the single colon).\n")
format!(
"Switch to the old `cargo:{old_format_flag}` syntax instead of `cargo::{flag}` (note the single colon).\n"
)
} else {
String::new()
};
@ -1067,7 +1069,8 @@ impl BuildOutput {
} else {
// Setting RUSTC_BOOTSTRAP would change the behavior of the crate.
// Abort with an error.
bail!("Cannot set `RUSTC_BOOTSTRAP={}` from {}.\n\
bail!(
"Cannot set `RUSTC_BOOTSTRAP={}` from {}.\n\
note: Crates cannot set `RUSTC_BOOTSTRAP` themselves, as doing so would subvert the stability guarantees of Rust for your project.\n\
help: If you're sure you want to do this in your project, set the environment variable `RUSTC_BOOTSTRAP={}` before running cargo instead.",
val,

View File

@ -15,13 +15,13 @@ use std::str::FromStr;
use std::sync::Arc;
use anyhow::bail;
use cargo_util::paths;
use cargo_util::ProcessBuilder;
use cargo_util::Sha256;
use cargo_util::paths;
use crate::core::manifest::ManifestMetadata;
use crate::CargoResult;
use crate::CARGO_ENV;
use crate::CargoResult;
use crate::core::manifest::ManifestMetadata;
/// The current format version of [`EncodedDepInfo`].
const CURRENT_ENCODED_DEP_INFO_VERSION: u8 = 1;

View File

@ -383,8 +383,8 @@ use std::path::{Path, PathBuf};
use std::sync::{Arc, Mutex};
use std::time::SystemTime;
use anyhow::format_err;
use anyhow::Context as _;
use anyhow::format_err;
use cargo_util::paths;
use filetime::FileTime;
use serde::de;
@ -392,21 +392,21 @@ use serde::ser;
use serde::{Deserialize, Serialize};
use tracing::{debug, info};
use crate::core::compiler::unit_graph::UnitDep;
use crate::core::Package;
use crate::core::compiler::unit_graph::UnitDep;
use crate::util;
use crate::util::errors::CargoResult;
use crate::util::interning::InternedString;
use crate::util::{internal, path_args, StableHasher};
use crate::{GlobalContext, CARGO_ENV};
use crate::util::{StableHasher, internal, path_args};
use crate::{CARGO_ENV, GlobalContext};
use super::custom_build::BuildDeps;
use super::{BuildContext, BuildRunner, FileFlavor, Job, Unit, Work};
pub use self::dep_info::Checksum;
pub use self::dep_info::parse_dep_info;
pub use self::dep_info::parse_rustc_dep_info;
pub use self::dep_info::translate_dep_info;
pub use self::dep_info::Checksum;
pub use self::dirty_reason::DirtyReason;
/// Determines if a [`Unit`] is up-to-date, and if not prepares necessary work to
@ -1100,7 +1100,7 @@ impl Fingerprint {
return DirtyReason::LocalFingerprintTypeChanged {
old: b.kind(),
new: a.kind(),
}
};
}
}
}
@ -1557,7 +1557,7 @@ fn calculate_normal(
let compile_kind = unit.kind.fingerprint_hash();
let mut declared_features = unit.pkg.summary().features().keys().collect::<Vec<_>>();
declared_features.sort(); // to avoid useless rebuild if the user orders it's features
// differently
// differently
Ok(Fingerprint {
rustc: util::hash_u64(&build_runner.bcx.rustc().verbose_version),
target: util::hash_u64(&unit.target),

View File

@ -35,11 +35,11 @@
use crate::core::compiler::BuildContext;
use crate::core::{Dependency, PackageId, Workspace};
use crate::sources::source::QueryKind;
use crate::sources::SourceConfigMap;
use crate::util::cache_lock::CacheLockMode;
use crate::sources::source::QueryKind;
use crate::util::CargoResult;
use anyhow::{bail, format_err, Context};
use crate::util::cache_lock::CacheLockMode;
use anyhow::{Context, bail, format_err};
use serde::{Deserialize, Serialize};
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet};
use std::fmt::Write as _;

View File

@ -4,10 +4,10 @@ use std::{cell::Cell, marker, sync::Arc};
use cargo_util::ProcessBuilder;
use crate::CargoResult;
use crate::core::compiler::build_runner::OutputFile;
use crate::core::compiler::future_incompat::FutureBreakageItem;
use crate::util::Queue;
use crate::CargoResult;
use super::{Artifact, DiagDedupe, Job, JobId, Message};

View File

@ -122,7 +122,7 @@ use std::sync::Arc;
use std::thread::{self, Scope};
use std::time::Duration;
use anyhow::{format_err, Context as _};
use anyhow::{Context as _, format_err};
use cargo_util::ProcessBuilder;
use jobserver::{Acquired, HelperThread};
use semver::Version;
@ -141,11 +141,11 @@ use crate::core::compiler::future_incompat::{
};
use crate::core::resolver::ResolveBehavior;
use crate::core::{PackageId, Shell, TargetKind};
use crate::util::CargoResult;
use crate::util::context::WarningHandling;
use crate::util::diagnostic_server::{self, DiagnosticPrinter};
use crate::util::errors::AlreadyPrintedError;
use crate::util::machine_message::{self, Message as _};
use crate::util::CargoResult;
use crate::util::{self, internal};
use crate::util::{DependencyQueue, GlobalContext, Progress, ProgressStyle, Queue};

View File

@ -101,8 +101,8 @@
//! When cross-compiling, the layout is the same, except it appears in
//! `target/$TRIPLE`.
use crate::core::compiler::CompileTarget;
use crate::core::Workspace;
use crate::core::compiler::CompileTarget;
use crate::util::{CargoResult, FileLock};
use cargo_util::paths;
use std::path::{Path, PathBuf};

View File

@ -99,7 +99,7 @@ use crate::util::errors::{CargoResult, VerboseError};
use crate::util::interning::InternedString;
use crate::util::machine_message::{self, Message};
use crate::util::{add_path_args, internal};
use cargo_util::{paths, ProcessBuilder, ProcessError};
use cargo_util::{ProcessBuilder, ProcessError, paths};
use cargo_util_schemas::manifest::TomlDebugInfo;
use cargo_util_schemas::manifest::TomlTrimPaths;
use cargo_util_schemas::manifest::TomlTrimPathsValue;
@ -1398,7 +1398,7 @@ fn trim_paths_args_rustdoc(
match trim_paths {
// rustdoc supports diagnostics trimming only.
TomlTrimPaths::Values(values) if !values.contains(&TomlTrimPathsValue::Diagnostics) => {
return Ok(())
return Ok(());
}
_ => {}
}

View File

@ -6,8 +6,8 @@ use std::collections::{BTreeSet, HashSet};
use std::io::{BufWriter, Write};
use std::path::{Path, PathBuf};
use super::{fingerprint, BuildRunner, FileFlavor, Unit};
use crate::util::{internal, CargoResult};
use super::{BuildRunner, FileFlavor, Unit, fingerprint};
use crate::util::{CargoResult, internal};
use cargo_util::paths;
use tracing::debug;

View File

@ -8,10 +8,10 @@ use cargo_util_schemas::core::PackageIdSpec;
use itertools::Itertools;
use serde::Serialize;
use crate::core::TargetKind;
use crate::util::interning::InternedString;
use crate::util::Rustc;
use crate::CargoResult;
use crate::core::TargetKind;
use crate::util::Rustc;
use crate::util::interning::InternedString;
use super::{BuildRunner, CompileMode, Unit};

View File

@ -4,7 +4,7 @@ use crate::core::compiler::build_runner::BuildRunner;
use crate::core::compiler::unit::Unit;
use crate::core::compiler::{BuildContext, CompileKind};
use crate::sources::CRATES_IO_REGISTRY;
use crate::util::errors::{internal, CargoResult};
use crate::util::errors::{CargoResult, internal};
use cargo_util::ProcessBuilder;
use std::collections::HashMap;
use std::collections::HashSet;

View File

@ -1,11 +1,11 @@
//! Code for building the standard library.
use crate::core::compiler::unit_dependencies::IsArtifact;
use crate::core::compiler::UnitInterner;
use crate::core::compiler::unit_dependencies::IsArtifact;
use crate::core::compiler::{CompileKind, CompileMode, RustcTargetData, Unit};
use crate::core::profiles::{Profiles, UnitFor};
use crate::core::resolver::features::{CliFeatures, FeaturesFor, ResolvedFeatures};
use crate::core::resolver::HasDevUnits;
use crate::core::resolver::features::{CliFeatures, FeaturesFor, ResolvedFeatures};
use crate::core::{PackageId, PackageSet, Resolve, Workspace};
use crate::ops::{self, Packages};
use crate::util::errors::CargoResult;

View File

@ -3,9 +3,9 @@
//! This module implements some simple tracking information for timing of how
//! long it takes for different units to compile.
use super::{CompileMode, Unit};
use crate::core::PackageId;
use crate::core::compiler::job_queue::JobId;
use crate::core::compiler::{BuildContext, BuildRunner, TimingOutput};
use crate::core::PackageId;
use crate::util::cpu::State;
use crate::util::machine_message::{self, Message};
use crate::util::style;

View File

@ -1,13 +1,13 @@
//! Types and impls for [`Unit`].
use crate::core::Package;
use crate::core::compiler::unit_dependencies::IsArtifact;
use crate::core::compiler::{CompileKind, CompileMode, CompileTarget, CrateType};
use crate::core::manifest::{Target, TargetKind};
use crate::core::profiles::Profile;
use crate::core::Package;
use crate::util::GlobalContext;
use crate::util::hex::short_hash;
use crate::util::interning::InternedString;
use crate::util::GlobalContext;
use std::cell::RefCell;
use std::collections::{BTreeMap, HashSet};
use std::fmt;

View File

@ -19,21 +19,21 @@ use std::collections::{HashMap, HashSet};
use tracing::trace;
use crate::CargoResult;
use crate::core::compiler::UserIntent;
use crate::core::compiler::artifact::match_artifacts_kind_with_targets;
use crate::core::compiler::unit_graph::{UnitDep, UnitGraph};
use crate::core::compiler::UserIntent;
use crate::core::compiler::{
CompileKind, CompileMode, CrateType, RustcTargetData, Unit, UnitInterner,
};
use crate::core::dependency::{Artifact, ArtifactKind, ArtifactTarget, DepKind};
use crate::core::profiles::{Profile, Profiles, UnitFor};
use crate::core::resolver::features::{FeaturesFor, ResolvedFeatures};
use crate::core::resolver::Resolve;
use crate::core::resolver::features::{FeaturesFor, ResolvedFeatures};
use crate::core::{Dependency, Package, PackageId, PackageSet, Target, TargetKind, Workspace};
use crate::ops::resolve_all_features;
use crate::util::interning::InternedString;
use crate::util::GlobalContext;
use crate::CargoResult;
use crate::util::interning::InternedString;
const IS_NO_ARTIFACT_DEP: Option<&'static Artifact> = None;

View File

@ -4,13 +4,13 @@
use cargo_util_schemas::core::PackageIdSpec;
use crate::GlobalContext;
use crate::core::Target;
use crate::core::compiler::Unit;
use crate::core::compiler::{CompileKind, CompileMode};
use crate::core::profiles::{Profile, UnitFor};
use crate::core::Target;
use crate::util::interning::InternedString;
use crate::util::CargoResult;
use crate::GlobalContext;
use crate::util::interning::InternedString;
use std::collections::HashMap;
/// The dependency graph of Units.

View File

@ -1,7 +1,7 @@
use cargo_platform::Platform;
use semver::VersionReq;
use serde::ser;
use serde::Serialize;
use serde::ser;
use std::borrow::Cow;
use std::fmt;
use std::path::PathBuf;
@ -10,9 +10,9 @@ use tracing::trace;
use crate::core::compiler::{CompileKind, CompileTarget};
use crate::core::{CliUnstable, Feature, Features, PackageId, SourceId, Summary};
use crate::util::OptVersionReq;
use crate::util::errors::CargoResult;
use crate::util::interning::InternedString;
use crate::util::OptVersionReq;
/// Information about a dependency requested by a Cargo manifest.
/// Cheap to copy.
@ -126,7 +126,7 @@ impl Dependency {
return Err(anyhow::Error::new(err).context(format!(
"failed to parse the version requirement `{}` for dependency `{}`",
v, name,
)))
)));
}
},
None => (false, OptVersionReq::Any),
@ -633,7 +633,9 @@ impl ArtifactKind {
return kind
.strip_prefix("bin:")
.map(|bin_name| ArtifactKind::SelectedBinary(bin_name.into()))
.ok_or_else(|| anyhow::anyhow!("'{}' is not a valid artifact specifier", kind))
.ok_or_else(|| {
anyhow::anyhow!("'{}' is not a valid artifact specifier", kind)
});
}
})
}
@ -644,7 +646,9 @@ impl ArtifactKind {
.iter()
.any(|k| matches!(k, ArtifactKind::SelectedBinary(_)))
{
anyhow::bail!("Cannot specify both 'bin' and 'bin:<name>' binary artifacts, as 'bin' selects all available binaries.");
anyhow::bail!(
"Cannot specify both 'bin' and 'bin:<name>' binary artifacts, as 'bin' selects all available binaries."
);
}
let mut kinds_without_dupes = kinds.clone();
kinds_without_dupes.sort();

View File

@ -124,17 +124,16 @@ use std::fmt::{self, Write};
use std::path::PathBuf;
use std::str::FromStr;
use anyhow::{bail, Error};
use anyhow::{Error, bail};
use cargo_util::ProcessBuilder;
use serde::{Deserialize, Serialize};
use crate::GlobalContext;
use crate::core::resolver::ResolveBehavior;
use crate::util::errors::CargoResult;
use crate::util::indented_lines;
use crate::GlobalContext;
pub const SEE_CHANNELS: &str =
"See https://doc.rust-lang.org/book/appendix-07-nightly-rust.html for more information \
pub const SEE_CHANNELS: &str = "See https://doc.rust-lang.org/book/appendix-07-nightly-rust.html for more information \
about Rust release channels.";
/// Value of [`allow-features`](CliUnstable::allow_features)

View File

@ -23,7 +23,7 @@ use crate::core::global_cache_tracker::{self, GlobalCacheTracker};
use crate::ops::CleanContext;
use crate::util::cache_lock::{CacheLock, CacheLockMode};
use crate::{CargoResult, GlobalContext};
use anyhow::{format_err, Context as _};
use anyhow::{Context as _, format_err};
use serde::Deserialize;
use std::time::Duration;
@ -430,7 +430,7 @@ pub fn parse_human_size(input: &str) -> CargoResult<u64> {
None => {
return cap[1]
.parse()
.with_context(|| format!("expected an integer size, got `{}`", &cap[1]))
.with_context(|| format!("expected an integer size, got `{}`", &cap[1]));
}
};
let num = cap[1]

View File

@ -114,18 +114,18 @@
//!
//! There are checks for read-only filesystems, which is generally ignored.
use crate::core::gc::GcOpts;
use crate::core::Verbosity;
use crate::core::gc::GcOpts;
use crate::ops::CleanContext;
use crate::util::cache_lock::CacheLockMode;
use crate::util::interning::InternedString;
use crate::util::sqlite::{self, basic_migration, Migration};
use crate::util::sqlite::{self, Migration, basic_migration};
use crate::util::{Filesystem, Progress, ProgressStyle};
use crate::{CargoResult, GlobalContext};
use anyhow::{bail, Context as _};
use anyhow::{Context as _, bail};
use cargo_util::paths;
use rusqlite::{params, Connection, ErrorCode};
use std::collections::{hash_map, HashMap};
use rusqlite::{Connection, ErrorCode, params};
use std::collections::{HashMap, hash_map};
use std::path::{Path, PathBuf};
use std::time::{Duration, SystemTime};
use tracing::{debug, trace};
@ -1743,7 +1743,9 @@ impl DeferredGlobalLastUse {
&encoded_registry_name,
)?
else {
bail!("expected registry_index {encoded_registry_name} to exist, but wasn't found");
bail!(
"expected registry_index {encoded_registry_name} to exist, but wasn't found"
);
};
self.registry_keys.insert(encoded_registry_name, id);
Ok(id)

View File

@ -10,8 +10,8 @@ use anyhow::Context as _;
use cargo_util_schemas::manifest::RustVersion;
use cargo_util_schemas::manifest::{TomlManifest, TomlProfiles};
use semver::Version;
use serde::ser;
use serde::Serialize;
use serde::ser;
use url::Url;
use crate::core::compiler::rustdoc::RustdocScrapeExamples;
@ -21,7 +21,7 @@ use crate::core::{Dependency, PackageId, PackageIdSpec, SourceId, Summary};
use crate::core::{Edition, Feature, Features, WorkspaceConfig};
use crate::util::errors::*;
use crate::util::interning::InternedString;
use crate::util::{short_hash, Filesystem, GlobalContext};
use crate::util::{Filesystem, GlobalContext, short_hash};
pub const MANIFEST_PREAMBLE: &str = "\
# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO

View File

@ -11,8 +11,8 @@ pub use self::shell::{Shell, Verbosity};
pub use self::source_id::SourceId;
pub use self::summary::{FeatureMap, FeatureValue, Summary};
pub use self::workspace::{
find_workspace_root, resolve_relative_path, MaybePackage, Workspace, WorkspaceConfig,
WorkspaceRootConfig,
MaybePackage, Workspace, WorkspaceConfig, WorkspaceRootConfig, find_workspace_root,
resolve_relative_path,
};
pub use cargo_util_schemas::core::{GitReference, PackageIdSpec, SourceKind};

View File

@ -27,15 +27,15 @@ use crate::core::{
};
use crate::core::{Summary, Workspace};
use crate::sources::source::{MaybePackage, SourceMap};
use crate::util::HumanBytes;
use crate::util::cache_lock::{CacheLock, CacheLockMode};
use crate::util::errors::{CargoResult, HttpNotSuccessful};
use crate::util::interning::InternedString;
use crate::util::network::http::http_handle_and_timeout;
use crate::util::network::http::HttpTimeout;
use crate::util::network::http::http_handle_and_timeout;
use crate::util::network::retry::{Retry, RetryResult};
use crate::util::network::sleep::SleepTracker;
use crate::util::HumanBytes;
use crate::util::{self, internal, GlobalContext, Progress, ProgressStyle};
use crate::util::{self, GlobalContext, Progress, ProgressStyle, internal};
/// Information about a package that is available somewhere in the file system.
///
@ -881,7 +881,7 @@ impl<'a, 'gctx> Downloads<'a, 'gctx> {
match ret {
RetryResult::Success(data) => break (dl, data),
RetryResult::Err(e) => {
return Err(e.context(format!("failed to download from `{}`", dl.url)))
return Err(e.context(format!("failed to download from `{}`", dl.url)));
}
RetryResult::Retry(sleep) => {
debug!(target: "network", "download retry {} for {sleep}ms", dl.url);

View File

@ -12,8 +12,8 @@ use serde::ser;
use crate::core::PackageIdSpec;
use crate::core::SourceId;
use crate::util::interning::InternedString;
use crate::util::CargoResult;
use crate::util::interning::InternedString;
static PACKAGE_ID_CACHE: OnceLock<Mutex<HashSet<&'static PackageIdInner>>> = OnceLock::new();

View File

@ -1,6 +1,6 @@
use std::collections::HashMap;
use anyhow::{bail, Context as _};
use anyhow::{Context as _, bail};
use crate::core::PackageId;
use crate::core::PackageIdSpec;
@ -165,53 +165,77 @@ mod tests {
assert!(PackageIdSpec::parse("foo@1.2.3").unwrap().matches(foo));
assert!(!PackageIdSpec::parse("foo@1.2.2").unwrap().matches(foo));
assert!(PackageIdSpec::parse("foo@1.2").unwrap().matches(foo));
assert!(PackageIdSpec::parse("https://example.com#foo@1.2")
.unwrap()
.matches(foo));
assert!(!PackageIdSpec::parse("https://bob.com#foo@1.2")
.unwrap()
.matches(foo));
assert!(PackageIdSpec::parse("registry+https://example.com#foo@1.2")
.unwrap()
.matches(foo));
assert!(!PackageIdSpec::parse("git+https://example.com#foo@1.2")
.unwrap()
.matches(foo));
assert!(
PackageIdSpec::parse("https://example.com#foo@1.2")
.unwrap()
.matches(foo)
);
assert!(
!PackageIdSpec::parse("https://bob.com#foo@1.2")
.unwrap()
.matches(foo)
);
assert!(
PackageIdSpec::parse("registry+https://example.com#foo@1.2")
.unwrap()
.matches(foo)
);
assert!(
!PackageIdSpec::parse("git+https://example.com#foo@1.2")
.unwrap()
.matches(foo)
);
let meta = PackageId::try_new("meta", "1.2.3+hello", sid).unwrap();
assert!(PackageIdSpec::parse("meta").unwrap().matches(meta));
assert!(PackageIdSpec::parse("meta@1").unwrap().matches(meta));
assert!(PackageIdSpec::parse("meta@1.2").unwrap().matches(meta));
assert!(PackageIdSpec::parse("meta@1.2.3").unwrap().matches(meta));
assert!(!PackageIdSpec::parse("meta@1.2.3-alpha.0")
.unwrap()
.matches(meta));
assert!(PackageIdSpec::parse("meta@1.2.3+hello")
.unwrap()
.matches(meta));
assert!(!PackageIdSpec::parse("meta@1.2.3+bye")
.unwrap()
.matches(meta));
assert!(
!PackageIdSpec::parse("meta@1.2.3-alpha.0")
.unwrap()
.matches(meta)
);
assert!(
PackageIdSpec::parse("meta@1.2.3+hello")
.unwrap()
.matches(meta)
);
assert!(
!PackageIdSpec::parse("meta@1.2.3+bye")
.unwrap()
.matches(meta)
);
let pre = PackageId::try_new("pre", "1.2.3-alpha.0", sid).unwrap();
assert!(PackageIdSpec::parse("pre").unwrap().matches(pre));
assert!(!PackageIdSpec::parse("pre@1").unwrap().matches(pre));
assert!(!PackageIdSpec::parse("pre@1.2").unwrap().matches(pre));
assert!(!PackageIdSpec::parse("pre@1.2.3").unwrap().matches(pre));
assert!(PackageIdSpec::parse("pre@1.2.3-alpha.0")
.unwrap()
.matches(pre));
assert!(!PackageIdSpec::parse("pre@1.2.3-alpha.1")
.unwrap()
.matches(pre));
assert!(!PackageIdSpec::parse("pre@1.2.3-beta.0")
.unwrap()
.matches(pre));
assert!(!PackageIdSpec::parse("pre@1.2.3+hello")
.unwrap()
.matches(pre));
assert!(!PackageIdSpec::parse("pre@1.2.3-alpha.0+hello")
.unwrap()
.matches(pre));
assert!(
PackageIdSpec::parse("pre@1.2.3-alpha.0")
.unwrap()
.matches(pre)
);
assert!(
!PackageIdSpec::parse("pre@1.2.3-alpha.1")
.unwrap()
.matches(pre)
);
assert!(
!PackageIdSpec::parse("pre@1.2.3-beta.0")
.unwrap()
.matches(pre)
);
assert!(
!PackageIdSpec::parse("pre@1.2.3+hello")
.unwrap()
.matches(pre)
);
assert!(
!PackageIdSpec::parse("pre@1.2.3-alpha.0+hello")
.unwrap()
.matches(pre)
);
}
}

View File

@ -21,17 +21,17 @@
//! The precedence is explained in [`ProfileMaker`].
//! The algorithm happens within [`ProfileMaker::get_profile`].
use crate::core::Feature;
use crate::core::compiler::{CompileKind, CompileTarget, Unit};
use crate::core::dependency::Artifact;
use crate::core::resolver::features::FeaturesFor;
use crate::core::Feature;
use crate::core::{
PackageId, PackageIdSpec, PackageIdSpecQuery, Resolve, Shell, Target, Workspace,
};
use crate::util::interning::InternedString;
use crate::util::toml::validate_profile;
use crate::util::{closest_msg, context, CargoResult, GlobalContext};
use anyhow::{bail, Context as _};
use crate::util::{CargoResult, GlobalContext, closest_msg, context};
use anyhow::{Context as _, bail};
use cargo_util_schemas::manifest::TomlTrimPaths;
use cargo_util_schemas::manifest::TomlTrimPathsValue;
use cargo_util_schemas::manifest::{

View File

@ -10,19 +10,19 @@
//! while the latter involves operations on the registry Web API.
use std::collections::{HashMap, HashSet};
use std::task::{ready, Poll};
use std::task::{Poll, ready};
use crate::core::PackageSet;
use crate::core::{Dependency, PackageId, SourceId, Summary};
use crate::sources::IndexSummary;
use crate::sources::config::SourceConfigMap;
use crate::sources::source::QueryKind;
use crate::sources::source::Source;
use crate::sources::source::SourceMap;
use crate::sources::IndexSummary;
use crate::util::errors::CargoResult;
use crate::util::interning::InternedString;
use crate::util::{CanonicalUrl, GlobalContext};
use anyhow::{bail, Context as _};
use anyhow::{Context as _, bail};
use tracing::{debug, trace};
use url::Url;
@ -709,7 +709,7 @@ impl<'gctx> Registry for PackageRegistry<'gctx> {
let source = self.sources.get_mut(dep.source_id());
match (override_summary, source) {
(Some(_), None) => {
return Poll::Ready(Err(anyhow::anyhow!("override found but no real ones")))
return Poll::Ready(Err(anyhow::anyhow!("override found but no real ones")));
}
(None, None) => return Poll::Ready(Ok(())),

View File

@ -1,10 +1,10 @@
use super::RequestedFeatures;
use super::dep_cache::RegistryQueryer;
use super::errors::ActivateResult;
use super::types::{ActivationsKey, ConflictMap, ConflictReason, FeaturesSet, ResolveOpts};
use super::RequestedFeatures;
use crate::core::{Dependency, PackageId, Summary};
use crate::util::interning::{InternedString, INTERNED_DEFAULT};
use crate::util::Graph;
use crate::util::interning::{INTERNED_DEFAULT, InternedString};
use anyhow::format_err;
use std::collections::{BTreeSet, HashMap};
use tracing::debug;

View File

@ -22,7 +22,7 @@ use crate::core::{
use crate::sources::source::QueryKind;
use crate::util::closest_msg;
use crate::util::errors::CargoResult;
use crate::util::interning::{InternedString, INTERNED_DEFAULT};
use crate::util::interning::{INTERNED_DEFAULT, InternedString};
use anyhow::Context as _;
use std::collections::{BTreeSet, HashMap, HashSet};

View File

@ -115,8 +115,8 @@ use super::{Resolve, ResolveVersion};
use crate::core::{Dependency, GitReference, Package, PackageId, SourceId, Workspace};
use crate::util::errors::CargoResult;
use crate::util::interning::InternedString;
use crate::util::{internal, Graph};
use anyhow::{bail, Context as _};
use crate::util::{Graph, internal};
use anyhow::{Context as _, bail};
use serde::de;
use serde::ser;
use serde::{Deserialize, Serialize};

View File

@ -3,8 +3,8 @@ use std::fmt::Write as _;
use std::task::Poll;
use crate::core::{Dependency, PackageId, Registry, Summary};
use crate::sources::source::QueryKind;
use crate::sources::IndexSummary;
use crate::sources::source::QueryKind;
use crate::util::edit_distance::{closest, edit_distance};
use crate::util::errors::CargoResult;
use crate::util::{GlobalContext, OptVersionReq, VersionExt};
@ -327,7 +327,10 @@ pub(super) fn activation_error(
// If we have a pre-release candidate, then that may be what our user is looking for
if let Some(pre) = candidates.iter().find(|c| c.version().is_prerelease()) {
let _ = write!(&mut hints, "\nif you are looking for the prerelease package it needs to be specified explicitly");
let _ = write!(
&mut hints,
"\nif you are looking for the prerelease package it needs to be specified explicitly"
);
let _ = write!(
&mut hints,
"\n {} = {{ version = \"{}\" }}",

View File

@ -43,9 +43,9 @@ use crate::core::dependency::{ArtifactTarget, DepKind, Dependency};
use crate::core::resolver::types::FeaturesSet;
use crate::core::resolver::{Resolve, ResolveBehavior};
use crate::core::{FeatureValue, PackageId, PackageIdSpec, PackageSet, Workspace};
use crate::util::interning::{InternedString, INTERNED_DEFAULT};
use crate::util::CargoResult;
use anyhow::{bail, Context};
use crate::util::interning::{INTERNED_DEFAULT, InternedString};
use anyhow::{Context, bail};
use itertools::Itertools;
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet};
use std::rc::Rc;

View File

@ -4,9 +4,9 @@ use cargo_util_schemas::manifest::RustVersion;
use super::encode::Metadata;
use crate::core::dependency::DepKind;
use crate::core::{Dependency, PackageId, PackageIdSpec, PackageIdSpecQuery, Summary, Target};
use crate::util::Graph;
use crate::util::errors::CargoResult;
use crate::util::interning::InternedString;
use crate::util::Graph;
use std::borrow::Borrow;
use std::collections::{HashMap, HashSet};
use std::fmt;

View File

@ -1,8 +1,8 @@
use super::features::{CliFeatures, RequestedFeatures};
use crate::core::{Dependency, PackageId, SourceId, Summary};
use crate::util::GlobalContext;
use crate::util::errors::CargoResult;
use crate::util::interning::InternedString;
use crate::util::GlobalContext;
use std::cmp::Ordering;
use std::collections::{BTreeMap, BTreeSet};
use std::num::NonZeroU64;

View File

@ -1,6 +1,6 @@
use std::fmt;
use std::io::prelude::*;
use std::io::IsTerminal;
use std::io::prelude::*;
use annotate_snippets::{Message, Renderer};
use anstream::AutoStream;
@ -655,7 +655,6 @@ mod imp {
mod imp {
use std::{cmp, mem, ptr};
use windows_sys::core::PCSTR;
use windows_sys::Win32::Foundation::CloseHandle;
use windows_sys::Win32::Foundation::INVALID_HANDLE_VALUE;
use windows_sys::Win32::Foundation::{GENERIC_READ, GENERIC_WRITE};
@ -663,10 +662,11 @@ mod imp {
CreateFileA, FILE_SHARE_READ, FILE_SHARE_WRITE, OPEN_EXISTING,
};
use windows_sys::Win32::System::Console::{
GetConsoleScreenBufferInfo, GetStdHandle, CONSOLE_SCREEN_BUFFER_INFO, STD_ERROR_HANDLE,
CONSOLE_SCREEN_BUFFER_INFO, GetConsoleScreenBufferInfo, GetStdHandle, STD_ERROR_HANDLE,
};
use windows_sys::core::PCSTR;
pub(super) use super::{default_err_erase_line as err_erase_line, TtyWidth};
pub(super) use super::{TtyWidth, default_err_erase_line as err_erase_line};
pub fn stderr_width() -> TtyWidth {
unsafe {

View File

@ -3,10 +3,10 @@ use crate::core::PackageId;
use crate::core::SourceKind;
use crate::sources::registry::CRATES_IO_HTTP_INDEX;
use crate::sources::source::Source;
use crate::sources::{DirectorySource, CRATES_IO_DOMAIN, CRATES_IO_INDEX, CRATES_IO_REGISTRY};
use crate::sources::{CRATES_IO_DOMAIN, CRATES_IO_INDEX, CRATES_IO_REGISTRY, DirectorySource};
use crate::sources::{GitSource, PathSource, RegistrySource};
use crate::util::interning::InternedString;
use crate::util::{context, CanonicalUrl, CargoResult, GlobalContext, IntoUrl};
use crate::util::{CanonicalUrl, CargoResult, GlobalContext, IntoUrl, context};
use anyhow::Context as _;
use serde::de;
use serde::ser;
@ -809,12 +809,12 @@ mod tests {
use std::hash::Hasher;
use std::path::Path;
use snapbox::IntoData as _;
use snapbox::assert_data_eq;
use snapbox::str;
use snapbox::IntoData as _;
use crate::util::hex::short_hash;
use crate::util::StableHasher;
use crate::util::hex::short_hash;
#[cfg(not(windows))]
let ws_root = Path::new("/tmp/ws");

View File

@ -1,7 +1,7 @@
use crate::core::{Dependency, PackageId, SourceId};
use crate::util::CargoResult;
use crate::util::closest_msg;
use crate::util::interning::InternedString;
use crate::util::CargoResult;
use anyhow::bail;
use cargo_util_schemas::manifest::FeatureName;
use cargo_util_schemas::manifest::RustVersion;
@ -246,7 +246,7 @@ fn build_feature_map(
bail!(
"feature `{feature}` includes `{fv}` which is neither a dependency \
nor another feature{closest}"
);
);
}
if is_optional_dep {
if !map.contains_key(f) {
@ -257,15 +257,19 @@ fn build_feature_map(
);
}
} else {
bail!("feature `{feature}` includes `{fv}`, but `{f}` is not an optional dependency\n\
bail!(
"feature `{feature}` includes `{fv}`, but `{f}` is not an optional dependency\n\
A non-optional dependency of the same name is defined; \
consider adding `optional = true` to its definition.");
consider adding `optional = true` to its definition."
);
}
}
}
Dep { dep_name } => {
if !is_any_dep {
bail!("feature `{feature}` includes `{fv}`, but `{dep_name}` is not listed as a dependency");
bail!(
"feature `{feature}` includes `{fv}`, but `{dep_name}` is not listed as a dependency"
);
}
if !is_optional_dep {
bail!(
@ -282,7 +286,9 @@ fn build_feature_map(
} => {
// Early check for some unlikely syntax.
if dep_feature.contains('/') {
bail!("multiple slashes in feature `{fv}` (included by feature `{feature}`) are not allowed");
bail!(
"multiple slashes in feature `{fv}` (included by feature `{feature}`) are not allowed"
);
}
// dep: cannot be combined with /

View File

@ -4,7 +4,7 @@ use std::collections::{BTreeMap, BTreeSet, HashSet};
use std::path::{Path, PathBuf};
use std::rc::Rc;
use anyhow::{anyhow, bail, Context as _};
use anyhow::{Context as _, anyhow, bail};
use glob::glob;
use itertools::Itertools;
use tracing::debug;
@ -13,23 +13,23 @@ use url::Url;
use crate::core::compiler::Unit;
use crate::core::features::Features;
use crate::core::registry::PackageRegistry;
use crate::core::resolver::features::CliFeatures;
use crate::core::resolver::ResolveBehavior;
use crate::core::resolver::features::CliFeatures;
use crate::core::{
Dependency, Edition, FeatureValue, PackageId, PackageIdSpec, PackageIdSpecQuery,
};
use crate::core::{EitherManifest, Package, SourceId, VirtualManifest};
use crate::ops;
use crate::sources::{PathSource, SourceConfigMap, CRATES_IO_INDEX, CRATES_IO_REGISTRY};
use crate::sources::{CRATES_IO_INDEX, CRATES_IO_REGISTRY, PathSource, SourceConfigMap};
use crate::util::context::FeatureUnification;
use crate::util::edit_distance;
use crate::util::errors::{CargoResult, ManifestError};
use crate::util::interning::InternedString;
use crate::util::lints::{analyze_cargo_lints_table, check_im_a_teapot};
use crate::util::toml::{read_manifest, InheritableFields};
use crate::util::toml::{InheritableFields, read_manifest};
use crate::util::{
context::CargoResolverConfig, context::ConfigRelativePath, context::IncompatibleRustVersions,
Filesystem, GlobalContext, IntoUrl,
Filesystem, GlobalContext, IntoUrl, context::CargoResolverConfig, context::ConfigRelativePath,
context::IncompatibleRustVersions,
};
use cargo_util::paths;
use cargo_util::paths::normalize_path;
@ -1597,7 +1597,10 @@ impl<'gctx> Workspace<'gctx> {
)
} else {
let names = selected_members.iter().map(|m| m.name()).join(", ");
format!("none of the selected packages contains {these_features}: {}\nselected packages: {names}", unknown.join(", "))
format!(
"none of the selected packages contains {these_features}: {}\nselected packages: {names}",
unknown.join(", ")
)
};
use std::fmt::Write;

View File

@ -139,13 +139,13 @@
//! [The Cargo Book]: https://doc.rust-lang.org/cargo/
//! [Cargo Contributor Guide]: https://doc.crates.io/contrib/
use crate::core::shell::Verbosity::Verbose;
use crate::core::Shell;
use crate::core::shell::Verbosity::Verbose;
use anyhow::Error;
use tracing::debug;
pub use crate::util::errors::{AlreadyPrintedError, InternalError, VerboseError};
pub use crate::util::{indented_lines, CargoResult, CliError, CliResult, GlobalContext};
pub use crate::util::{CargoResult, CliError, CliResult, GlobalContext, indented_lines};
pub use crate::version::version;
pub const CARGO_ENV: &str = "CARGO";

View File

@ -3,8 +3,8 @@
use anyhow::Context as _;
use super::Dependency;
use crate::util::toml_mut::dependency::RegistrySource;
use crate::CargoResult;
use crate::util::toml_mut::dependency::RegistrySource;
use cargo_util_schemas::manifest::PackageName;
/// User-specified crate

Some files were not shown because too many files have changed in this diff Show More