Skip to content

Commit 9031c50

Browse files
committed
refactor(gctx): make paths overrides getter explicit
1 parent e70e63d commit 9031c50

File tree

3 files changed

+6
-11
lines changed

3 files changed

+6
-11
lines changed

src/cargo/ops/resolve.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ pub fn add_overrides<'a>(
527527
ws: &Workspace<'a>,
528528
) -> CargoResult<()> {
529529
let gctx = ws.gctx();
530-
let Some(paths) = gctx.get_list("paths")? else {
530+
let Some(paths) = gctx.paths_overrides()? else {
531531
return Ok(());
532532
};
533533

src/cargo/util/context/mod.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -986,15 +986,10 @@ impl GlobalContext {
986986
}
987987
}
988988

989-
/// Get a list of strings.
990-
///
991-
/// DO NOT USE outside of the config module. `pub` will be removed in the
992-
/// future.
993-
///
994-
/// NOTE: this does **not** support environment variables. Use `get` instead
995-
/// if you want that.
996-
pub fn get_list(&self, key: &str) -> CargoResult<OptValue<Vec<(String, Definition)>>> {
997-
let key = ConfigKey::from_str(key);
989+
/// Get the `paths` overrides config value.
990+
pub fn paths_overrides(&self) -> CargoResult<OptValue<Vec<(String, Definition)>>> {
991+
let key = ConfigKey::from_str("paths");
992+
// paths overrides cannot be set via env config, so use get_cv here.
998993
match self.get_cv(&key)? {
999994
Some(CV::List(val, definition)) => Ok(Some(Value { val, definition })),
1000995
Some(val) => self.expected("list", &key, &val),

tests/testsuite/config_cli.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ fn merge_array_mixed_def_paths() {
281281
// env is currently ignored for get_list()
282282
.env("CARGO_PATHS", "env")
283283
.build();
284-
let paths = gctx.get_list("paths").unwrap().unwrap();
284+
let paths = gctx.paths_overrides().unwrap().unwrap();
285285
// The definition for the root value is somewhat arbitrary, but currently starts with the file because that is what is loaded first.
286286
assert_eq!(paths.definition, Definition::Path(paths::root()));
287287
assert_eq!(paths.val.len(), 2);

0 commit comments

Comments
 (0)