Run cargo fmt --all

Fix formatting errors
This commit is contained in:
Martin Donlon 2021-02-15 15:29:08 -08:00
parent 95de3e9fea
commit 3aa99422ca
3 changed files with 33 additions and 25 deletions

View File

@ -339,7 +339,6 @@ impl<'cfg> Compilation<'cfg> {
)
.env("CARGO_PKG_AUTHORS", &pkg.authors().join(":"))
.cwd(pkg.root());
// Apply any environment variables from the config
for (key, value) in self.config.env_config()?.iter() {

View File

@ -49,10 +49,12 @@
//! translate from `ConfigValue` and environment variables to the caller's
//! desired type.
use std::borrow::Cow;
use std::cell::{RefCell, RefMut};
use std::collections::hash_map::Entry::{Occupied, Vacant};
use std::collections::{HashMap, HashSet};
use std::env;
use std::ffi::OsStr;
use std::fmt;
use std::fs::{self, File};
use std::io::prelude::*;
@ -62,8 +64,6 @@ use std::path::{Path, PathBuf};
use std::str::FromStr;
use std::sync::Once;
use std::time::Instant;
use std::borrow::Cow;
use std::ffi::OsStr;
use anyhow::{anyhow, bail, format_err};
use curl::easy::Easy;
@ -1278,9 +1278,7 @@ impl Config {
}
pub fn env_config(&self) -> CargoResult<&EnvConfig> {
self.env_config.try_borrow_with(|| {
self.get_env_config()
})
self.env_config.try_borrow_with(|| self.get_env_config())
}
/// This is used to validate the `term` table has valid syntax.
@ -2006,7 +2004,7 @@ impl EnvConfigValue {
EnvConfigValue {
value,
force: false,
relative: false
relative: false,
}
}

View File

@ -6,16 +6,19 @@ use cargo_test_support::{basic_bin_manifest, project};
fn env_basic() {
let p = project()
.file("Cargo.toml", &basic_bin_manifest("foo"))
.file("src/main.rs", r#"
.file(
"src/main.rs",
r#"
use std::env;
fn main() {
println!( "compile-time:{}", env!("ENV_TEST_1233") );
println!( "run-time:{}", env::var("ENV_TEST_1233").unwrap());
}
"#)
"#,
)
.file(
".cargo/config",
r#"
".cargo/config",
r#"
[env]
ENV_TEST_1233 = "Hello"
"#,
@ -32,13 +35,16 @@ fn env_basic() {
fn env_invalid() {
let p = project()
.file("Cargo.toml", &basic_bin_manifest("foo"))
.file("src/main.rs", r#"
.file(
"src/main.rs",
r#"
fn main() {
}
"#)
"#,
)
.file(
".cargo/config",
r#"
".cargo/config",
r#"
[env]
ENV_TEST_BOOL = false
"#,
@ -55,16 +61,19 @@ fn env_invalid() {
fn env_force() {
let p = project()
.file("Cargo.toml", &basic_bin_manifest("foo"))
.file("src/main.rs", r#"
.file(
"src/main.rs",
r#"
use std::env;
fn main() {
println!( "ENV_TEST_FORCED:{}", env!("ENV_TEST_FORCED") );
println!( "ENV_TEST_UNFORCED:{}", env!("ENV_TEST_UNFORCED") );
}
"#)
"#,
)
.file(
".cargo/config",
r#"
".cargo/config",
r#"
[env]
ENV_TEST_UNFORCED = "from-config"
ENV_TEST_FORCED = { value = "from-config", force = true }
@ -84,7 +93,9 @@ fn env_force() {
fn env_relative() {
let p = project()
.file("Cargo.toml", &basic_bin_manifest("foo2"))
.file("src/main.rs", r#"
.file(
"src/main.rs",
r#"
use std::env;
use std::path::Path;
fn main() {
@ -94,10 +105,11 @@ fn env_relative() {
assert!( Path::new(env!("ENV_TEST_ABSOLUTE")).is_absolute() );
assert!( !Path::new(env!("ENV_TEST_RELATIVE")).is_absolute() );
}
"#)
"#,
)
.file(
".cargo/config",
r#"
".cargo/config",
r#"
[env]
ENV_TEST_RELATIVE = "Cargo.toml"
ENV_TEST_ABSOLUTE = { value = "Cargo.toml", relative = true }
@ -105,6 +117,5 @@ fn env_relative() {
)
.build();
p.cargo("run")
.run();
p.cargo("run").run();
}