Skip to content

Commit ea22fe5

Browse files
committed
Auto merge of #13506 - epage:context, r=weihanglo
refactor: Clarify more Config -> Context ### What does this PR try to resolve? This is a follow up to #13409 and #13486 ### How should we test and review this PR? ### Additional information
2 parents ecb8193 + a7ba26b commit ea22fe5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+75
-74
lines changed

crates/xtask-bump-check/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ fn main() {
66
let cli = xtask::cli();
77
let matches = cli.get_matches();
88

9-
let mut gctx = cargo::util::config::GlobalContext::default().unwrap_or_else(|e| {
9+
let mut gctx = cargo::util::context::GlobalContext::default().unwrap_or_else(|e| {
1010
let mut eval = cargo::core::shell::Shell::new();
1111
cargo::exit_with_error(e.into(), &mut eval)
1212
});

src/bin/cargo/cli.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use anyhow::{anyhow, Context as _};
22
use cargo::core::{features, CliUnstable};
3-
use cargo::util::config::TermConfig;
3+
use cargo::util::context::TermConfig;
44
use cargo::{drop_print, drop_println, CargoResult};
55
use clap::builder::UnknownArgumentValueParser;
66
use itertools::Itertools;
@@ -57,21 +57,21 @@ pub fn main(gctx: &mut GlobalContext) -> CliResult {
5757
== Some("help")
5858
{
5959
// Don't let config errors get in the way of parsing arguments
60-
let _ = config_configure(gctx, &expanded_args, None, global_args, None);
60+
let _ = configure_gctx(gctx, &expanded_args, None, global_args, None);
6161
print_zhelp(gctx);
6262
} else if expanded_args.flag("version") {
6363
// Don't let config errors get in the way of parsing arguments
64-
let _ = config_configure(gctx, &expanded_args, None, global_args, None);
64+
let _ = configure_gctx(gctx, &expanded_args, None, global_args, None);
6565
let version = get_version_string(is_verbose);
6666
drop_print!(gctx, "{}", version);
6767
} else if let Some(code) = expanded_args.get_one::<String>("explain") {
6868
// Don't let config errors get in the way of parsing arguments
69-
let _ = config_configure(gctx, &expanded_args, None, global_args, None);
69+
let _ = configure_gctx(gctx, &expanded_args, None, global_args, None);
7070
let mut procss = gctx.load_global_rustc(None)?.process();
7171
procss.arg("--explain").arg(code).exec()?;
7272
} else if expanded_args.flag("list") {
7373
// Don't let config errors get in the way of parsing arguments
74-
let _ = config_configure(gctx, &expanded_args, None, global_args, None);
74+
let _ = configure_gctx(gctx, &expanded_args, None, global_args, None);
7575
print_list(gctx, is_verbose);
7676
} else {
7777
let (cmd, subcommand_args) = match expanded_args.subcommand() {
@@ -83,7 +83,7 @@ pub fn main(gctx: &mut GlobalContext) -> CliResult {
8383
}
8484
};
8585
let exec = Exec::infer(cmd)?;
86-
config_configure(
86+
configure_gctx(
8787
gctx,
8888
&expanded_args,
8989
Some(subcommand_args),
@@ -377,7 +377,7 @@ For more information, see issue #12207 <https://github.com/rust-lang/cargo/issue
377377
Ok((args, GlobalArgs::default()))
378378
}
379379

380-
fn config_configure(
380+
fn configure_gctx(
381381
gctx: &mut GlobalContext,
382382
args: &ArgMatches,
383383
subcommand_args: Option<&ArgMatches>,

src/cargo/core/compiler/build_config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::core::compiler::CompileKind;
2-
use crate::util::config::JobsConfig;
2+
use crate::util::context::JobsConfig;
33
use crate::util::interning::InternedString;
44
use crate::util::{CargoResult, GlobalContext, RustfixDiagnosticServer};
55
use anyhow::{bail, Context as _};

src/cargo/core/compiler/build_context/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::core::compiler::{BuildConfig, CompileKind, Unit};
55
use crate::core::profiles::Profiles;
66
use crate::core::PackageSet;
77
use crate::core::Workspace;
8-
use crate::util::config::GlobalContext;
8+
use crate::util::context::GlobalContext;
99
use crate::util::errors::CargoResult;
1010
use crate::util::interning::InternedString;
1111
use crate::util::Rustc;

src/cargo/core/compiler/build_context/target_info.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use crate::core::compiler::{
1212
BuildOutput, BuildRunner, CompileKind, CompileMode, CompileTarget, CrateType,
1313
};
1414
use crate::core::{Dependency, Package, Target, TargetKind, Workspace};
15-
use crate::util::config::{GlobalContext, StringList, TargetConfig};
15+
use crate::util::context::{GlobalContext, StringList, TargetConfig};
1616
use crate::util::interning::InternedString;
1717
use crate::util::{CargoResult, Rustc};
1818
use anyhow::Context as _;

src/cargo/core/compiler/compilation.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use crate::core::compiler::apply_env_config;
1111
use crate::core::compiler::BuildContext;
1212
use crate::core::compiler::{CompileKind, Metadata, Unit};
1313
use crate::core::Package;
14-
use crate::util::{config, CargoResult, GlobalContext};
14+
use crate::util::{context, CargoResult, GlobalContext};
1515

1616
/// Represents the kind of process we are creating.
1717
#[derive(Debug)]
@@ -453,7 +453,7 @@ fn target_runner(
453453
// try target.{}.runner
454454
let key = format!("target.{}.runner", target);
455455

456-
if let Some(v) = bcx.gctx.get::<Option<config::PathAndArgs>>(&key)? {
456+
if let Some(v) = bcx.gctx.get::<Option<context::PathAndArgs>>(&key)? {
457457
let path = v.path.resolve_program(bcx.gctx);
458458
return Ok(Some((path, v.args)));
459459
}

src/cargo/core/features.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@
112112
//! and summarize it similar to the other entries. Update the rest of the
113113
//! documentation to add the new feature.
114114
//!
115-
//! [`GlobalContext::cli_unstable`]: crate::util::config::GlobalContext::cli_unstable
115+
//! [`GlobalContext::cli_unstable`]: crate::util::context::GlobalContext::cli_unstable
116116
//! [`fail_if_stable_opt`]: CliUnstable::fail_if_stable_opt
117117
//! [`features!`]: macro.features.html
118118
//! [`unstable_cli_options!`]: macro.unstable_cli_options.html

src/cargo/core/profiles.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use crate::core::{
3030
};
3131
use crate::util::interning::InternedString;
3232
use crate::util::toml::validate_profile;
33-
use crate::util::{closest_msg, config, CargoResult, GlobalContext};
33+
use crate::util::{closest_msg, context, CargoResult, GlobalContext};
3434
use anyhow::{bail, Context as _};
3535
use cargo_util_schemas::manifest::TomlTrimPaths;
3636
use cargo_util_schemas::manifest::TomlTrimPathsValue;
@@ -1298,7 +1298,7 @@ fn merge_config_profiles(
12981298

12991299
/// Helper for fetching a profile from config.
13001300
fn get_config_profile(ws: &Workspace<'_>, name: &str) -> CargoResult<Option<TomlProfile>> {
1301-
let profile: Option<config::Value<TomlProfile>> =
1301+
let profile: Option<context::Value<TomlProfile>> =
13021302
ws.gctx().get(&format!("profile.{}", name))?;
13031303
let Some(profile) = profile else {
13041304
return Ok(None);

src/cargo/core/resolver/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ use tracing::{debug, trace};
6767

6868
use crate::core::PackageIdSpec;
6969
use crate::core::{Dependency, PackageId, Registry, Summary};
70-
use crate::util::config::GlobalContext;
70+
use crate::util::context::GlobalContext;
7171
use crate::util::errors::CargoResult;
7272
use crate::util::network::PollExt;
7373
use crate::util::profile;

src/cargo/core/source_id.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::sources::source::Source;
66
use crate::sources::{DirectorySource, CRATES_IO_DOMAIN, CRATES_IO_INDEX, CRATES_IO_REGISTRY};
77
use crate::sources::{GitSource, PathSource, RegistrySource};
88
use crate::util::interning::InternedString;
9-
use crate::util::{config, CanonicalUrl, CargoResult, GlobalContext, IntoUrl};
9+
use crate::util::{context, CanonicalUrl, CargoResult, GlobalContext, IntoUrl};
1010
use anyhow::Context as _;
1111
use serde::de;
1212
use serde::ser;
@@ -268,7 +268,7 @@ impl SourceId {
268268

269269
/// Returns whether to access crates.io over the sparse protocol.
270270
pub fn crates_io_is_sparse(gctx: &GlobalContext) -> CargoResult<bool> {
271-
let proto: Option<config::Value<String>> = gctx.get("registries.crates-io.protocol")?;
271+
let proto: Option<context::Value<String>> = gctx.get("registries.crates-io.protocol")?;
272272
let is_sparse = match proto.as_ref().map(|v| v.val.as_str()) {
273273
Some("sparse") => true,
274274
Some("git") => false,

0 commit comments

Comments
 (0)