Skip to content

Commit 3aa9942

Browse files
committed
Run cargo fmt --all
Fix formatting errors
1 parent 95de3e9 commit 3aa9942

File tree

3 files changed

+33
-25
lines changed

3 files changed

+33
-25
lines changed

src/cargo/core/compiler/compilation.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,6 @@ impl<'cfg> Compilation<'cfg> {
339339
)
340340
.env("CARGO_PKG_AUTHORS", &pkg.authors().join(":"))
341341
.cwd(pkg.root());
342-
343342

344343
// Apply any environment variables from the config
345344
for (key, value) in self.config.env_config()?.iter() {

src/cargo/util/config/mod.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,12 @@
4949
//! translate from `ConfigValue` and environment variables to the caller's
5050
//! desired type.
5151
52+
use std::borrow::Cow;
5253
use std::cell::{RefCell, RefMut};
5354
use std::collections::hash_map::Entry::{Occupied, Vacant};
5455
use std::collections::{HashMap, HashSet};
5556
use std::env;
57+
use std::ffi::OsStr;
5658
use std::fmt;
5759
use std::fs::{self, File};
5860
use std::io::prelude::*;
@@ -62,8 +64,6 @@ use std::path::{Path, PathBuf};
6264
use std::str::FromStr;
6365
use std::sync::Once;
6466
use std::time::Instant;
65-
use std::borrow::Cow;
66-
use std::ffi::OsStr;
6767

6868
use anyhow::{anyhow, bail, format_err};
6969
use curl::easy::Easy;
@@ -1278,9 +1278,7 @@ impl Config {
12781278
}
12791279

12801280
pub fn env_config(&self) -> CargoResult<&EnvConfig> {
1281-
self.env_config.try_borrow_with(|| {
1282-
self.get_env_config()
1283-
})
1281+
self.env_config.try_borrow_with(|| self.get_env_config())
12841282
}
12851283

12861284
/// This is used to validate the `term` table has valid syntax.
@@ -2006,7 +2004,7 @@ impl EnvConfigValue {
20062004
EnvConfigValue {
20072005
value,
20082006
force: false,
2009-
relative: false
2007+
relative: false,
20102008
}
20112009
}
20122010

tests/testsuite/cargo_env_config.rs

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,19 @@ use cargo_test_support::{basic_bin_manifest, project};
66
fn env_basic() {
77
let p = project()
88
.file("Cargo.toml", &basic_bin_manifest("foo"))
9-
.file("src/main.rs", r#"
9+
.file(
10+
"src/main.rs",
11+
r#"
1012
use std::env;
1113
fn main() {
1214
println!( "compile-time:{}", env!("ENV_TEST_1233") );
1315
println!( "run-time:{}", env::var("ENV_TEST_1233").unwrap());
1416
}
15-
"#)
17+
"#,
18+
)
1619
.file(
17-
".cargo/config",
18-
r#"
20+
".cargo/config",
21+
r#"
1922
[env]
2023
ENV_TEST_1233 = "Hello"
2124
"#,
@@ -32,13 +35,16 @@ fn env_basic() {
3235
fn env_invalid() {
3336
let p = project()
3437
.file("Cargo.toml", &basic_bin_manifest("foo"))
35-
.file("src/main.rs", r#"
38+
.file(
39+
"src/main.rs",
40+
r#"
3641
fn main() {
3742
}
38-
"#)
43+
"#,
44+
)
3945
.file(
40-
".cargo/config",
41-
r#"
46+
".cargo/config",
47+
r#"
4248
[env]
4349
ENV_TEST_BOOL = false
4450
"#,
@@ -55,16 +61,19 @@ fn env_invalid() {
5561
fn env_force() {
5662
let p = project()
5763
.file("Cargo.toml", &basic_bin_manifest("foo"))
58-
.file("src/main.rs", r#"
64+
.file(
65+
"src/main.rs",
66+
r#"
5967
use std::env;
6068
fn main() {
6169
println!( "ENV_TEST_FORCED:{}", env!("ENV_TEST_FORCED") );
6270
println!( "ENV_TEST_UNFORCED:{}", env!("ENV_TEST_UNFORCED") );
6371
}
64-
"#)
72+
"#,
73+
)
6574
.file(
66-
".cargo/config",
67-
r#"
75+
".cargo/config",
76+
r#"
6877
[env]
6978
ENV_TEST_UNFORCED = "from-config"
7079
ENV_TEST_FORCED = { value = "from-config", force = true }
@@ -84,7 +93,9 @@ fn env_force() {
8493
fn env_relative() {
8594
let p = project()
8695
.file("Cargo.toml", &basic_bin_manifest("foo2"))
87-
.file("src/main.rs", r#"
96+
.file(
97+
"src/main.rs",
98+
r#"
8899
use std::env;
89100
use std::path::Path;
90101
fn main() {
@@ -94,17 +105,17 @@ fn env_relative() {
94105
assert!( Path::new(env!("ENV_TEST_ABSOLUTE")).is_absolute() );
95106
assert!( !Path::new(env!("ENV_TEST_RELATIVE")).is_absolute() );
96107
}
97-
"#)
108+
"#,
109+
)
98110
.file(
99-
".cargo/config",
100-
r#"
111+
".cargo/config",
112+
r#"
101113
[env]
102114
ENV_TEST_RELATIVE = "Cargo.toml"
103115
ENV_TEST_ABSOLUTE = { value = "Cargo.toml", relative = true }
104116
"#,
105117
)
106118
.build();
107119

108-
p.cargo("run")
109-
.run();
120+
p.cargo("run").run();
110121
}

0 commit comments

Comments
 (0)