diff --git a/crates/xtask-bump-check/src/main.rs b/crates/xtask-bump-check/src/main.rs index 55e8b746a08..57bceff53af 100644 --- a/crates/xtask-bump-check/src/main.rs +++ b/crates/xtask-bump-check/src/main.rs @@ -6,7 +6,7 @@ fn main() { let cli = xtask::cli(); let matches = cli.get_matches(); - let mut gctx = cargo::util::config::GlobalContext::default().unwrap_or_else(|e| { + let mut gctx = cargo::util::context::GlobalContext::default().unwrap_or_else(|e| { let mut eval = cargo::core::shell::Shell::new(); cargo::exit_with_error(e.into(), &mut eval) }); diff --git a/src/bin/cargo/cli.rs b/src/bin/cargo/cli.rs index da9d56217a8..74d3ddf76ac 100644 --- a/src/bin/cargo/cli.rs +++ b/src/bin/cargo/cli.rs @@ -1,6 +1,6 @@ use anyhow::{anyhow, Context as _}; use cargo::core::{features, CliUnstable}; -use cargo::util::config::TermConfig; +use cargo::util::context::TermConfig; use cargo::{drop_print, drop_println, CargoResult}; use clap::builder::UnknownArgumentValueParser; use itertools::Itertools; @@ -57,21 +57,21 @@ pub fn main(gctx: &mut GlobalContext) -> CliResult { == Some("help") { // Don't let config errors get in the way of parsing arguments - let _ = config_configure(gctx, &expanded_args, None, global_args, None); + let _ = configure_gctx(gctx, &expanded_args, None, global_args, None); print_zhelp(gctx); } else if expanded_args.flag("version") { // Don't let config errors get in the way of parsing arguments - let _ = config_configure(gctx, &expanded_args, None, global_args, None); + let _ = configure_gctx(gctx, &expanded_args, None, global_args, None); let version = get_version_string(is_verbose); drop_print!(gctx, "{}", version); } else if let Some(code) = expanded_args.get_one::("explain") { // Don't let config errors get in the way of parsing arguments - let _ = config_configure(gctx, &expanded_args, None, global_args, None); + let _ = configure_gctx(gctx, &expanded_args, None, global_args, None); let mut procss = gctx.load_global_rustc(None)?.process(); procss.arg("--explain").arg(code).exec()?; } else if expanded_args.flag("list") { // Don't let config errors get in the way of parsing arguments - let _ = config_configure(gctx, &expanded_args, None, global_args, None); + let _ = configure_gctx(gctx, &expanded_args, None, global_args, None); print_list(gctx, is_verbose); } else { let (cmd, subcommand_args) = match expanded_args.subcommand() { @@ -83,7 +83,7 @@ pub fn main(gctx: &mut GlobalContext) -> CliResult { } }; let exec = Exec::infer(cmd)?; - config_configure( + configure_gctx( gctx, &expanded_args, Some(subcommand_args), @@ -377,7 +377,7 @@ For more information, see issue #12207 , diff --git a/src/cargo/core/compiler/build_config.rs b/src/cargo/core/compiler/build_config.rs index 3e5f32cf9ea..9536e58be56 100644 --- a/src/cargo/core/compiler/build_config.rs +++ b/src/cargo/core/compiler/build_config.rs @@ -1,5 +1,5 @@ use crate::core::compiler::CompileKind; -use crate::util::config::JobsConfig; +use crate::util::context::JobsConfig; use crate::util::interning::InternedString; use crate::util::{CargoResult, GlobalContext, RustfixDiagnosticServer}; use anyhow::{bail, Context as _}; diff --git a/src/cargo/core/compiler/build_context/mod.rs b/src/cargo/core/compiler/build_context/mod.rs index 26b134acfdb..78c1e90ae5a 100644 --- a/src/cargo/core/compiler/build_context/mod.rs +++ b/src/cargo/core/compiler/build_context/mod.rs @@ -5,7 +5,7 @@ use crate::core::compiler::{BuildConfig, CompileKind, Unit}; use crate::core::profiles::Profiles; use crate::core::PackageSet; use crate::core::Workspace; -use crate::util::config::GlobalContext; +use crate::util::context::GlobalContext; use crate::util::errors::CargoResult; use crate::util::interning::InternedString; use crate::util::Rustc; diff --git a/src/cargo/core/compiler/build_context/target_info.rs b/src/cargo/core/compiler/build_context/target_info.rs index 02e2043a0c2..f80f45c8f58 100644 --- a/src/cargo/core/compiler/build_context/target_info.rs +++ b/src/cargo/core/compiler/build_context/target_info.rs @@ -12,7 +12,7 @@ use crate::core::compiler::{ BuildOutput, BuildRunner, CompileKind, CompileMode, CompileTarget, CrateType, }; use crate::core::{Dependency, Package, Target, TargetKind, Workspace}; -use crate::util::config::{GlobalContext, StringList, TargetConfig}; +use crate::util::context::{GlobalContext, StringList, TargetConfig}; use crate::util::interning::InternedString; use crate::util::{CargoResult, Rustc}; use anyhow::Context as _; diff --git a/src/cargo/core/compiler/compilation.rs b/src/cargo/core/compiler/compilation.rs index 017c41b8afd..5e4b2d02518 100644 --- a/src/cargo/core/compiler/compilation.rs +++ b/src/cargo/core/compiler/compilation.rs @@ -11,7 +11,7 @@ use crate::core::compiler::apply_env_config; use crate::core::compiler::BuildContext; use crate::core::compiler::{CompileKind, Metadata, Unit}; use crate::core::Package; -use crate::util::{config, CargoResult, GlobalContext}; +use crate::util::{context, CargoResult, GlobalContext}; /// Represents the kind of process we are creating. #[derive(Debug)] @@ -453,7 +453,7 @@ fn target_runner( // try target.{}.runner let key = format!("target.{}.runner", target); - if let Some(v) = bcx.gctx.get::>(&key)? { + if let Some(v) = bcx.gctx.get::>(&key)? { let path = v.path.resolve_program(bcx.gctx); return Ok(Some((path, v.args))); } diff --git a/src/cargo/core/features.rs b/src/cargo/core/features.rs index ff3efe719f4..f0cd9c48d61 100644 --- a/src/cargo/core/features.rs +++ b/src/cargo/core/features.rs @@ -112,7 +112,7 @@ //! and summarize it similar to the other entries. Update the rest of the //! documentation to add the new feature. //! -//! [`GlobalContext::cli_unstable`]: crate::util::config::GlobalContext::cli_unstable +//! [`GlobalContext::cli_unstable`]: crate::util::context::GlobalContext::cli_unstable //! [`fail_if_stable_opt`]: CliUnstable::fail_if_stable_opt //! [`features!`]: macro.features.html //! [`unstable_cli_options!`]: macro.unstable_cli_options.html diff --git a/src/cargo/core/profiles.rs b/src/cargo/core/profiles.rs index 701f191d57c..ce2c9e414f6 100644 --- a/src/cargo/core/profiles.rs +++ b/src/cargo/core/profiles.rs @@ -30,7 +30,7 @@ use crate::core::{ }; use crate::util::interning::InternedString; use crate::util::toml::validate_profile; -use crate::util::{closest_msg, config, CargoResult, GlobalContext}; +use crate::util::{closest_msg, context, CargoResult, GlobalContext}; use anyhow::{bail, Context as _}; use cargo_util_schemas::manifest::TomlTrimPaths; use cargo_util_schemas::manifest::TomlTrimPathsValue; @@ -1298,7 +1298,7 @@ fn merge_config_profiles( /// Helper for fetching a profile from config. fn get_config_profile(ws: &Workspace<'_>, name: &str) -> CargoResult> { - let profile: Option> = + let profile: Option> = ws.gctx().get(&format!("profile.{}", name))?; let Some(profile) = profile else { return Ok(None); diff --git a/src/cargo/core/resolver/mod.rs b/src/cargo/core/resolver/mod.rs index 335a75c6aaa..c351ed0fe8a 100644 --- a/src/cargo/core/resolver/mod.rs +++ b/src/cargo/core/resolver/mod.rs @@ -67,7 +67,7 @@ use tracing::{debug, trace}; use crate::core::PackageIdSpec; use crate::core::{Dependency, PackageId, Registry, Summary}; -use crate::util::config::GlobalContext; +use crate::util::context::GlobalContext; use crate::util::errors::CargoResult; use crate::util::network::PollExt; use crate::util::profile; diff --git a/src/cargo/core/source_id.rs b/src/cargo/core/source_id.rs index 4eb2ad127b3..d03a0a5769c 100644 --- a/src/cargo/core/source_id.rs +++ b/src/cargo/core/source_id.rs @@ -6,7 +6,7 @@ use crate::sources::source::Source; use crate::sources::{DirectorySource, CRATES_IO_DOMAIN, CRATES_IO_INDEX, CRATES_IO_REGISTRY}; use crate::sources::{GitSource, PathSource, RegistrySource}; use crate::util::interning::InternedString; -use crate::util::{config, CanonicalUrl, CargoResult, GlobalContext, IntoUrl}; +use crate::util::{context, CanonicalUrl, CargoResult, GlobalContext, IntoUrl}; use anyhow::Context as _; use serde::de; use serde::ser; @@ -268,7 +268,7 @@ impl SourceId { /// Returns whether to access crates.io over the sparse protocol. pub fn crates_io_is_sparse(gctx: &GlobalContext) -> CargoResult { - let proto: Option> = gctx.get("registries.crates-io.protocol")?; + let proto: Option> = gctx.get("registries.crates-io.protocol")?; let is_sparse = match proto.as_ref().map(|v| v.val.as_str()) { Some("sparse") => true, Some("git") => false, diff --git a/src/cargo/core/workspace.rs b/src/cargo/core/workspace.rs index c8e98667e18..d4be9a43a11 100644 --- a/src/cargo/core/workspace.rs +++ b/src/cargo/core/workspace.rs @@ -25,7 +25,7 @@ use crate::util::edit_distance; use crate::util::errors::{CargoResult, ManifestError}; use crate::util::interning::InternedString; use crate::util::toml::{read_manifest, InheritableFields}; -use crate::util::{config::ConfigRelativePath, Filesystem, GlobalContext, IntoUrl}; +use crate::util::{context::ConfigRelativePath, Filesystem, GlobalContext, IntoUrl}; use cargo_util::paths; use cargo_util::paths::normalize_path; use cargo_util_schemas::manifest::RustVersion; diff --git a/src/cargo/lib.rs b/src/cargo/lib.rs index 61fac71540a..467f96baaff 100644 --- a/src/cargo/lib.rs +++ b/src/cargo/lib.rs @@ -44,10 +44,11 @@ //! directory. //! - [`util`]: //! This directory contains generally-useful utility modules. -//! - [`util::config`]: -//! This directory contains the config parser. It makes heavy use of -//! [serde](https://serde.rs/) to merge and translate config values. The -//! [`util::GlobalContext`] is usually accessed from the +//! - [`util::context`]: +//! This directory contains the global applicaton context. +//! This includes the config parser which makes heavy use of +//! [serde](https://serde.rs/) to merge and translate config values. +//! The [`util::GlobalContext`] is usually accessed from the //! [`core::Workspace`] //! though references to it are scattered around for more convenient access. //! - [`util::toml`]: @@ -117,7 +118,7 @@ //! - `src/*/*`: Extracted from `*.crate` by [`sources::registry::RegistrySource`] //! - `git/`: Git source cache. See [`sources::git`]. //! - `**/.cargo/config.toml`: Environment dependent (env variables, files) configuration. See -//! [`util::config`] +//! [`util::context`] //! //! ## Contribute to Cargo documentations //! diff --git a/src/cargo/ops/cargo_compile/mod.rs b/src/cargo/ops/cargo_compile/mod.rs index 204354ccc77..b2a26ee0a8a 100644 --- a/src/cargo/ops/cargo_compile/mod.rs +++ b/src/cargo/ops/cargo_compile/mod.rs @@ -52,7 +52,7 @@ use crate::core::{PackageId, PackageSet, SourceId, TargetKind, Workspace}; use crate::drop_println; use crate::ops; use crate::ops::resolve::WorkspaceResolve; -use crate::util::config::GlobalContext; +use crate::util::context::GlobalContext; use crate::util::interning::InternedString; use crate::util::{profile, CargoResult, StableHasher}; diff --git a/src/cargo/ops/cargo_config.rs b/src/cargo/ops/cargo_config.rs index fee575b5b50..8cddf49dba9 100644 --- a/src/cargo/ops/cargo_config.rs +++ b/src/cargo/ops/cargo_config.rs @@ -1,6 +1,6 @@ //! Implementation of `cargo config` subcommand. -use crate::util::config::{ConfigKey, ConfigValue as CV, Definition, GlobalContext}; +use crate::util::context::{ConfigKey, ConfigValue as CV, Definition, GlobalContext}; use crate::util::errors::CargoResult; use crate::{drop_eprintln, drop_println}; use anyhow::{bail, format_err, Error}; diff --git a/src/cargo/ops/cargo_doc.rs b/src/cargo/ops/cargo_doc.rs index 542f4926959..d5e41561bec 100644 --- a/src/cargo/ops/cargo_doc.rs +++ b/src/cargo/ops/cargo_doc.rs @@ -1,7 +1,7 @@ use crate::core::compiler::{Compilation, CompileKind}; use crate::core::{Shell, Workspace}; use crate::ops; -use crate::util::config::{GlobalContext, PathAndArgs}; +use crate::util::context::{GlobalContext, PathAndArgs}; use crate::util::CargoResult; use anyhow::{bail, Error}; use std::path::Path; diff --git a/src/cargo/ops/cargo_fetch.rs b/src/cargo/ops/cargo_fetch.rs index 56ae6db670e..761f171f1f6 100644 --- a/src/cargo/ops/cargo_fetch.rs +++ b/src/cargo/ops/cargo_fetch.rs @@ -2,7 +2,7 @@ use crate::core::compiler::standard_lib; use crate::core::compiler::{BuildConfig, CompileMode, RustcTargetData}; use crate::core::{PackageSet, Resolve, Workspace}; use crate::ops; -use crate::util::config::JobsConfig; +use crate::util::context::JobsConfig; use crate::util::CargoResult; use crate::util::GlobalContext; use std::collections::HashSet; diff --git a/src/cargo/ops/cargo_generate_lockfile.rs b/src/cargo/ops/cargo_generate_lockfile.rs index c27754dbc81..574a9adcd78 100644 --- a/src/cargo/ops/cargo_generate_lockfile.rs +++ b/src/cargo/ops/cargo_generate_lockfile.rs @@ -7,7 +7,7 @@ use crate::core::{Resolve, SourceId, Workspace}; use crate::ops; use crate::sources::source::QueryKind; use crate::util::cache_lock::CacheLockMode; -use crate::util::config::GlobalContext; +use crate::util::context::GlobalContext; use crate::util::style; use crate::util::CargoResult; use anstyle::Style; diff --git a/src/cargo/ops/cargo_package.rs b/src/cargo/ops/cargo_package.rs index 3fe8239e48b..4e6c0585dd3 100644 --- a/src/cargo/ops/cargo_package.rs +++ b/src/cargo/ops/cargo_package.rs @@ -14,7 +14,7 @@ use crate::core::{Feature, Shell, Verbosity, Workspace}; use crate::core::{Package, PackageId, PackageSet, Resolve, SourceId}; use crate::sources::PathSource; use crate::util::cache_lock::CacheLockMode; -use crate::util::config::JobsConfig; +use crate::util::context::JobsConfig; use crate::util::errors::CargoResult; use crate::util::toml::{prepare_for_publish, to_real_manifest}; use crate::util::{self, human_readable_bytes, restricted_names, FileLock, GlobalContext}; diff --git a/src/cargo/ops/registry/mod.rs b/src/cargo/ops/registry/mod.rs index 48a2bab34c5..eb49dccb4d9 100644 --- a/src/cargo/ops/registry/mod.rs +++ b/src/cargo/ops/registry/mod.rs @@ -23,7 +23,7 @@ use crate::sources::source::Source; use crate::sources::{RegistrySource, SourceConfigMap}; use crate::util::auth; use crate::util::cache_lock::CacheLockMode; -use crate::util::config::{GlobalContext, PathAndArgs}; +use crate::util::context::{GlobalContext, PathAndArgs}; use crate::util::errors::CargoResult; use crate::util::network::http::http_handle; diff --git a/src/cargo/ops/registry/publish.rs b/src/cargo/ops/registry/publish.rs index b50cf6aa9d7..5ec2da64ee1 100644 --- a/src/cargo/ops/registry/publish.rs +++ b/src/cargo/ops/registry/publish.rs @@ -32,7 +32,7 @@ use crate::sources::SourceConfigMap; use crate::sources::CRATES_IO_REGISTRY; use crate::util::auth; use crate::util::cache_lock::CacheLockMode; -use crate::util::config::JobsConfig; +use crate::util::context::JobsConfig; use crate::util::Progress; use crate::util::ProgressStyle; use crate::CargoResult; diff --git a/src/cargo/ops/registry/yank.rs b/src/cargo/ops/registry/yank.rs index c05e8e18703..032939a75b3 100644 --- a/src/cargo/ops/registry/yank.rs +++ b/src/cargo/ops/registry/yank.rs @@ -9,7 +9,7 @@ use cargo_credential::Operation; use cargo_credential::Secret; use crate::core::Workspace; -use crate::util::config::GlobalContext; +use crate::util::context::GlobalContext; use crate::util::errors::CargoResult; use crate::util::important_paths::find_root_manifest_for_wd; diff --git a/src/cargo/sources/config.rs b/src/cargo/sources/config.rs index 7f9e9696327..a2e8051c326 100644 --- a/src/cargo/sources/config.rs +++ b/src/cargo/sources/config.rs @@ -7,7 +7,7 @@ use crate::core::{GitReference, PackageId, SourceId}; use crate::sources::source::Source; use crate::sources::{ReplacedSource, CRATES_IO_REGISTRY}; -use crate::util::config::{self, ConfigRelativePath, OptValue}; +use crate::util::context::{self, ConfigRelativePath, OptValue}; use crate::util::errors::CargoResult; use crate::util::{GlobalContext, IntoUrl}; use anyhow::{bail, Context as _}; @@ -311,7 +311,7 @@ restore the source replacement configuration to continue the build return Ok(()); - fn url(val: &config::Value, key: &str) -> CargoResult { + fn url(val: &context::Value, key: &str) -> CargoResult { let url = val.val.into_url().with_context(|| { format!( "configuration key `{}` specified an invalid \ diff --git a/src/cargo/sources/git/known_hosts.rs b/src/cargo/sources/git/known_hosts.rs index 31d93fe7df9..8ce081194b0 100644 --- a/src/cargo/sources/git/known_hosts.rs +++ b/src/cargo/sources/git/known_hosts.rs @@ -22,7 +22,7 @@ //! added (it just adds a little complexity). For example, hostname patterns, //! and revoked markers. See "FIXME" comments littered in this file. -use crate::util::config::{Definition, GlobalContext, Value}; +use crate::util::context::{Definition, GlobalContext, Value}; use base64::engine::general_purpose::STANDARD; use base64::engine::general_purpose::STANDARD_NO_PAD; use base64::Engine as _; diff --git a/src/cargo/sources/git/oxide.rs b/src/cargo/sources/git/oxide.rs index 9288cd0b7dc..46182fd9d44 100644 --- a/src/cargo/sources/git/oxide.rs +++ b/src/cargo/sources/git/oxide.rs @@ -301,7 +301,7 @@ pub fn cargo_config_to_gitoxide_overrides(gctx: &GlobalContext) -> CargoResult { values.push(Http::SSL_VERSION.validated_assignment_fmt(&version)?); diff --git a/src/cargo/util/auth/mod.rs b/src/cargo/util/auth/mod.rs index 8526973df23..cf4cccb9753 100644 --- a/src/cargo/util/auth/mod.rs +++ b/src/cargo/util/auth/mod.rs @@ -2,7 +2,7 @@ use crate::{ core::features::cargo_docs_link, - util::{config::ConfigKey, CanonicalUrl, CargoResult, GlobalContext, IntoUrl}, + util::{context::ConfigKey, CanonicalUrl, CargoResult, GlobalContext, IntoUrl}, }; use anyhow::{bail, Context as _}; use cargo_credential::{ @@ -17,12 +17,12 @@ use time::{Duration, OffsetDateTime}; use url::Url; use crate::core::SourceId; -use crate::util::config::Value; +use crate::util::context::Value; use crate::util::credential::adaptor::BasicProcessCredential; use crate::util::credential::paseto::PasetoCredential; use super::{ - config::{CredentialCacheValue, OptValue, PathAndArgs}, + context::{CredentialCacheValue, OptValue, PathAndArgs}, credential::process::CredentialProcessCredential, credential::token::TokenCredential, }; diff --git a/src/cargo/util/command_prelude.rs b/src/cargo/util/command_prelude.rs index 8cda32ae9c6..9fb542ee0ea 100644 --- a/src/cargo/util/command_prelude.rs +++ b/src/cargo/util/command_prelude.rs @@ -28,7 +28,7 @@ pub use clap::{value_parser, Arg, ArgAction, ArgMatches}; pub use clap::Command; -use super::config::JobsConfig; +use super::context::JobsConfig; use super::IntoUrl; pub mod heading { diff --git a/src/cargo/util/config/de.rs b/src/cargo/util/context/de.rs similarity index 99% rename from src/cargo/util/config/de.rs rename to src/cargo/util/context/de.rs index bfefad91ca2..18a84823bed 100644 --- a/src/cargo/util/config/de.rs +++ b/src/cargo/util/context/de.rs @@ -1,8 +1,8 @@ //! Support for deserializing configuration via `serde` -use crate::util::config::value; -use crate::util::config::{ConfigError, ConfigKey, GlobalContext}; -use crate::util::config::{ConfigValue as CV, Definition, Value}; +use crate::util::context::value; +use crate::util::context::{ConfigError, ConfigKey, GlobalContext}; +use crate::util::context::{ConfigValue as CV, Definition, Value}; use serde::{de, de::IntoDeserializer}; use std::collections::HashSet; use std::vec; diff --git a/src/cargo/util/config/environment.rs b/src/cargo/util/context/environment.rs similarity index 100% rename from src/cargo/util/config/environment.rs rename to src/cargo/util/context/environment.rs diff --git a/src/cargo/util/config/key.rs b/src/cargo/util/context/key.rs similarity index 100% rename from src/cargo/util/config/key.rs rename to src/cargo/util/context/key.rs diff --git a/src/cargo/util/config/mod.rs b/src/cargo/util/context/mod.rs similarity index 100% rename from src/cargo/util/config/mod.rs rename to src/cargo/util/context/mod.rs diff --git a/src/cargo/util/config/path.rs b/src/cargo/util/context/path.rs similarity index 100% rename from src/cargo/util/config/path.rs rename to src/cargo/util/context/path.rs diff --git a/src/cargo/util/config/target.rs b/src/cargo/util/context/target.rs similarity index 100% rename from src/cargo/util/config/target.rs rename to src/cargo/util/context/target.rs diff --git a/src/cargo/util/config/value.rs b/src/cargo/util/context/value.rs similarity index 99% rename from src/cargo/util/config/value.rs rename to src/cargo/util/context/value.rs index d1c181b1890..dd56276e2d0 100644 --- a/src/cargo/util/config/value.rs +++ b/src/cargo/util/context/value.rs @@ -8,7 +8,7 @@ //! from configuration, but also record where it was deserialized from when it //! was read. -use crate::util::config::GlobalContext; +use crate::util::context::GlobalContext; use serde::de; use std::cmp::Ordering; use std::fmt; diff --git a/src/cargo/util/credential/paseto.rs b/src/cargo/util/credential/paseto.rs index 38788e3b8d3..0d552608c2a 100644 --- a/src/cargo/util/credential/paseto.rs +++ b/src/cargo/util/credential/paseto.rs @@ -15,7 +15,7 @@ use url::Url; use crate::{ core::SourceId, ops::RegistryCredentialConfig, - util::{auth::registry_credential_config_raw, command_prelude::opt, config}, + util::{auth::registry_credential_config_raw, command_prelude::opt, context}, GlobalContext, }; @@ -196,12 +196,12 @@ impl<'a> Credential for PasetoCredential<'a> { None => old_key_subject, }, )); - config::save_credentials(self.gctx, Some(new_token), &sid)?; + context::save_credentials(self.gctx, Some(new_token), &sid)?; Ok(CredentialResponse::Login) } Action::Logout => { if reg_cfg.and_then(|c| c.secret_key).is_some() { - config::save_credentials(self.gctx, None, &sid)?; + context::save_credentials(self.gctx, None, &sid)?; let reg_name = sid.display_registry_name(); let _ = self.gctx.shell().status( "Logout", diff --git a/src/cargo/util/credential/token.rs b/src/cargo/util/credential/token.rs index dfb1d87dd7f..c58c874177f 100644 --- a/src/cargo/util/credential/token.rs +++ b/src/cargo/util/credential/token.rs @@ -7,7 +7,7 @@ use url::Url; use crate::{ core::SourceId, ops::RegistryCredentialConfig, - util::{auth::registry_credential_config_raw, config}, + util::{auth::registry_credential_config_raw, context}, GlobalContext, }; @@ -52,7 +52,7 @@ impl<'a> Credential for TokenCredential<'a> { .map(|line| line.replace("cargo login", "").trim().to_string()); crates_io::check_token(new_token.as_ref().expose()).map_err(Box::new)?; - config::save_credentials( + context::save_credentials( self.gctx, Some(RegistryCredentialConfig::Token(new_token)), &sid, @@ -68,7 +68,7 @@ impl<'a> Credential for TokenCredential<'a> { return Err(Error::NotFound); } let reg_name = sid.display_registry_name(); - config::save_credentials(self.gctx, None, &sid)?; + context::save_credentials(self.gctx, None, &sid)?; let _ = self.gctx.shell().status( "Logout", format!("token for `{reg_name}` has been removed from local storage"), diff --git a/src/cargo/util/mod.rs b/src/cargo/util/mod.rs index 84a7c639d4b..09e38190708 100644 --- a/src/cargo/util/mod.rs +++ b/src/cargo/util/mod.rs @@ -2,7 +2,7 @@ use std::path::{Path, PathBuf}; use std::time::Duration; pub use self::canonical_url::CanonicalUrl; -pub use self::config::{homedir, ConfigValue, GlobalContext}; +pub use self::context::{homedir, ConfigValue, GlobalContext}; pub(crate) use self::counter::MetricsCounter; pub use self::dependency_queue::DependencyQueue; pub use self::diagnostic_server::RustfixDiagnosticServer; @@ -32,7 +32,7 @@ pub mod auth; pub mod cache_lock; mod canonical_url; pub mod command_prelude; -pub mod config; +pub mod context; mod counter; pub mod cpu; pub mod credential; diff --git a/src/cargo/util/network/http.rs b/src/cargo/util/network/http.rs index c6e280ee7e5..137c67c7822 100644 --- a/src/cargo/util/network/http.rs +++ b/src/cargo/util/network/http.rs @@ -11,8 +11,8 @@ use curl::easy::SslVersion; use tracing::debug; use tracing::trace; -use crate::util::config::SslVersionConfig; -use crate::util::config::SslVersionConfigRange; +use crate::util::context::SslVersionConfig; +use crate::util::context::SslVersionConfigRange; use crate::version; use crate::CargoResult; use crate::GlobalContext; diff --git a/src/cargo/util/network/proxy.rs b/src/cargo/util/network/proxy.rs index 736b5fe48fa..87400b5659f 100644 --- a/src/cargo/util/network/proxy.rs +++ b/src/cargo/util/network/proxy.rs @@ -1,7 +1,7 @@ //! Utilities for network proxies. -use crate::util::config::CargoHttpConfig; -use crate::util::config::GlobalContext; +use crate::util::context::CargoHttpConfig; +use crate::util::context::GlobalContext; /// Proxy environment variables that are picked up by libcurl. const LIBCURL_HTTP_PROXY_ENVS: [&str; 4] = diff --git a/src/cargo/util/progress.rs b/src/cargo/util/progress.rs index 11f66b858a8..655fabcd4d9 100644 --- a/src/cargo/util/progress.rs +++ b/src/cargo/util/progress.rs @@ -4,7 +4,7 @@ use std::cmp; use std::time::{Duration, Instant}; use crate::core::shell::Verbosity; -use crate::util::config::ProgressWhen; +use crate::util::context::ProgressWhen; use crate::util::{CargoResult, GlobalContext}; use cargo_util::is_ci; use unicode_width::UnicodeWidthChar; diff --git a/src/cargo/util/toml/mod.rs b/src/cargo/util/toml/mod.rs index 059127de9f3..8049f538c1d 100644 --- a/src/cargo/util/toml/mod.rs +++ b/src/cargo/util/toml/mod.rs @@ -28,7 +28,7 @@ use crate::core::{GitReference, PackageIdSpec, SourceId, WorkspaceConfig, Worksp use crate::sources::{CRATES_IO_INDEX, CRATES_IO_REGISTRY}; use crate::util::errors::{CargoResult, ManifestError}; use crate::util::interning::InternedString; -use crate::util::{self, config::ConfigRelativePath, GlobalContext, IntoUrl, OptVersionReq}; +use crate::util::{self, context::ConfigRelativePath, GlobalContext, IntoUrl, OptVersionReq}; mod embedded; mod targets; diff --git a/tests/testsuite/config.rs b/tests/testsuite/config.rs index 802d7e4423d..39fcee2cd73 100644 --- a/tests/testsuite/config.rs +++ b/tests/testsuite/config.rs @@ -1,7 +1,7 @@ //! Tests for config settings. use cargo::core::{PackageIdSpec, Shell}; -use cargo::util::config::{ +use cargo::util::context::{ self, Definition, GlobalContext, JobsConfig, SslVersionConfig, StringList, }; use cargo::CargoResult; @@ -928,31 +928,31 @@ abs = '{}' .build(); assert_eq!( - gctx.get::("p1") + gctx.get::("p1") .unwrap() .resolve_path(&gctx), paths::root().join("foo/bar") ); assert_eq!( - gctx.get::("p2") + gctx.get::("p2") .unwrap() .resolve_path(&gctx), paths::root().join("../abc") ); assert_eq!( - gctx.get::("p3") + gctx.get::("p3") .unwrap() .resolve_path(&gctx), paths::root().join("d/e") ); assert_eq!( - gctx.get::("abs") + gctx.get::("abs") .unwrap() .resolve_path(&gctx), paths::home() ); assert_eq!( - gctx.get::("epath") + gctx.get::("epath") .unwrap() .resolve_path(&gctx), paths::root().join("a/b") diff --git a/tests/testsuite/config_cli.rs b/tests/testsuite/config_cli.rs index fa1a45f6837..1b90d58b918 100644 --- a/tests/testsuite/config_cli.rs +++ b/tests/testsuite/config_cli.rs @@ -4,7 +4,7 @@ use super::config::{ assert_error, assert_match, read_output, write_config_at, write_config_toml, GlobalContextBuilder, }; -use cargo::util::config::Definition; +use cargo::util::context::Definition; use cargo_test_support::paths; use std::{collections::HashMap, fs}; @@ -184,7 +184,7 @@ fn string_list_array() { .config_arg("build.rustflags = ['--cli']") .build(); assert_eq!( - gctx.get::("build.rustflags") + gctx.get::("build.rustflags") .unwrap() .as_slice(), ["--file", "--cli"] @@ -196,7 +196,7 @@ fn string_list_array() { .config_arg("build.rustflags = ['--cli']") .build(); assert_eq!( - gctx.get::("build.rustflags") + gctx.get::("build.rustflags") .unwrap() .as_slice(), ["--file", "--env1", "--env2", "--cli"] @@ -209,7 +209,7 @@ fn string_list_array() { .config_arg("build.rustflags = ['--cli']") .build(); assert_eq!( - gctx.get::("build.rustflags") + gctx.get::("build.rustflags") .unwrap() .as_slice(), ["--file", "--env", "--cli"] diff --git a/tests/testsuite/member_discovery.rs b/tests/testsuite/member_discovery.rs index a28480d535a..c44d5e48f47 100644 --- a/tests/testsuite/member_discovery.rs +++ b/tests/testsuite/member_discovery.rs @@ -1,7 +1,7 @@ //! Tests for workspace member discovery. use cargo::core::{Shell, Workspace}; -use cargo::util::config::GlobalContext; +use cargo::util::context::GlobalContext; use cargo_test_support::install::cargo_home; use cargo_test_support::project; diff --git a/tests/testsuite/member_errors.rs b/tests/testsuite/member_errors.rs index 8a5fe5e8cea..99c4cb313f2 100644 --- a/tests/testsuite/member_errors.rs +++ b/tests/testsuite/member_errors.rs @@ -3,7 +3,7 @@ use cargo::core::resolver::ResolveError; use cargo::core::{compiler::CompileMode, Shell, Workspace}; use cargo::ops::{self, CompileOptions}; -use cargo::util::{config::GlobalContext, errors::ManifestError}; +use cargo::util::{context::GlobalContext, errors::ManifestError}; use cargo_test_support::install::cargo_home; use cargo_test_support::project; diff --git a/triagebot.toml b/triagebot.toml index 881f8c73b1d..ab134f19721 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -80,7 +80,7 @@ trigger_files = ["crates/mdman/", "src/etc/man/"] trigger_files = ["src/etc/_cargo", "src/etc/cargo.bashcomp.sh"] [autolabel."A-configuration"] -trigger_files = ["src/cargo/util/config/mod.rs"] +trigger_files = ["src/cargo/util/context/mod.rs"] [autolabel."A-console-output"] trigger_files = [ @@ -117,7 +117,7 @@ trigger_files = ["src/doc/"] [autolabel."A-environment-variables"] trigger_files = [ "crates/home/", - "src/cargo/util/config/environment.rs", + "src/cargo/util/context/environment.rs", ] [autolabel."A-features2"]