File tree Expand file tree Collapse file tree 2 files changed +29
-22
lines changed Expand file tree Collapse file tree 2 files changed +29
-22
lines changed Original file line number Diff line number Diff line change @@ -1745,8 +1745,13 @@ impl Config {
1745
1745
. env_config
1746
1746
. try_borrow_with ( || self . get :: < EnvConfig > ( "env" ) ) ?;
1747
1747
1748
- if env_config. get ( "CARGO_HOME" ) . is_some ( ) {
1749
- bail ! ( "setting the `CARGO_HOME` environment variable is not supported in the `[env]` configuration table" )
1748
+ for disallowed in & [ "CARGO_HOME" , "RUSTUP_HOME" ] {
1749
+ if env_config. contains_key ( * disallowed) {
1750
+ bail ! (
1751
+ "setting the `{disallowed}` environment variable is not supported \
1752
+ in the `[env]` configuration table"
1753
+ ) ;
1754
+ }
1750
1755
}
1751
1756
1752
1757
Ok ( env_config)
Original file line number Diff line number Diff line change @@ -59,29 +59,31 @@ fn env_invalid() {
59
59
}
60
60
61
61
#[ cargo_test]
62
- fn env_no_cargo_home ( ) {
62
+ fn env_no_disallowed ( ) {
63
+ // Checks for keys that are not allowed in the [env] table.
63
64
let p = project ( )
64
- . file ( "Cargo.toml" , & basic_bin_manifest ( "foo" ) )
65
- . file (
66
- "src/main.rs" ,
67
- r#"
68
- fn main() {
69
- }
70
- "# ,
71
- )
72
- . file (
73
- ".cargo/config" ,
74
- r#"
75
- [env]
76
- CARGO_HOME = "/"
77
- "# ,
78
- )
65
+ . file ( "Cargo.toml" , & basic_manifest ( "foo" , "1.0.0" ) )
66
+ . file ( "src/lib.rs" , "" )
79
67
. build ( ) ;
80
68
81
- p. cargo ( "check" )
82
- . with_status ( 101 )
83
- . with_stderr_contains ( "[..]setting the `CARGO_HOME` environment variable is not supported in the `[env]` configuration table" )
84
- . run ( ) ;
69
+ for disallowed in & [ "CARGO_HOME" , "RUSTUP_HOME" ] {
70
+ p. change_file (
71
+ ".cargo/config" ,
72
+ & format ! (
73
+ r#"
74
+ [env]
75
+ {disallowed} = "foo"
76
+ "#
77
+ ) ,
78
+ ) ;
79
+ p. cargo ( "check" )
80
+ . with_status ( 101 )
81
+ . with_stderr ( & format ! (
82
+ "[ERROR] setting the `{disallowed}` environment variable \
83
+ is not supported in the `[env]` configuration table"
84
+ ) )
85
+ . run ( ) ;
86
+ }
85
87
}
86
88
87
89
#[ cargo_test]
You can’t perform that action at this time.
0 commit comments