Skip to content

Commit

Permalink
Merge branch 'master' into trywithout
Browse files Browse the repository at this point in the history
  • Loading branch information
illicitonion committed May 14, 2020
2 parents 18ceb9f + 2fef2e5 commit 8064909
Show file tree
Hide file tree
Showing 84 changed files with 2,109 additions and 947 deletions.
2 changes: 1 addition & 1 deletion crates/cargo-test-support/src/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ impl Package {
} else {
registry_path.join(&file)
};
let prev = fs::read_to_string(&dst).unwrap_or(String::new());
let prev = fs::read_to_string(&dst).unwrap_or_default();
t!(fs::create_dir_all(dst.parent().unwrap()));
t!(fs::write(&dst, prev + &line[..] + "\n"));

Expand Down
21 changes: 12 additions & 9 deletions src/bin/cargo/cli.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use cargo::core::features;
use cargo::{self, CliResult, Config};
use cargo::{self, drop_print, drop_println, CliResult, Config};
use clap::{AppSettings, Arg, ArgMatches};

use super::commands;
Expand All @@ -25,7 +25,8 @@ pub fn main(config: &mut Config) -> CliResult {
};

if args.value_of("unstable-features") == Some("help") {
println!(
drop_println!(
config,
"
Available unstable (nightly-only) flags:
Expand All @@ -40,15 +41,17 @@ Available unstable (nightly-only) flags:
Run with 'cargo -Z [FLAG] [SUBCOMMAND]'"
);
if !features::nightly_features_allowed() {
println!(
drop_println!(
config,
"\nUnstable flags are only available on the nightly channel \
of Cargo, but this is the `{}` channel.\n\
{}",
features::channel(),
features::SEE_CHANNELS
);
}
println!(
drop_println!(
config,
"\nSee https://doc.rust-lang.org/nightly/cargo/reference/unstable.html \
for more information about these flags."
);
Expand All @@ -58,7 +61,7 @@ Run with 'cargo -Z [FLAG] [SUBCOMMAND]'"
let is_verbose = args.occurrences_of("verbose") > 0;
if args.is_present("version") {
let version = get_version_string(is_verbose);
print!("{}", version);
drop_print!(config, "{}", version);
return Ok(());
}

Expand All @@ -69,19 +72,19 @@ Run with 'cargo -Z [FLAG] [SUBCOMMAND]'"
}

if args.is_present("list") {
println!("Installed Commands:");
drop_println!(config, "Installed Commands:");
for command in list_commands(config) {
match command {
CommandInfo::BuiltIn { name, about } => {
let summary = about.unwrap_or_default();
let summary = summary.lines().next().unwrap_or(&summary); // display only the first line
println!(" {:<20} {}", name, summary)
drop_println!(config, " {:<20} {}", name, summary);
}
CommandInfo::External { name, path } => {
if is_verbose {
println!(" {:<20} {}", name, path.display())
drop_println!(config, " {:<20} {}", name, path.display());
} else {
println!(" {}", name)
drop_println!(config, " {}", name);
}
}
}
Expand Down
4 changes: 1 addition & 3 deletions src/bin/cargo/commands/locate_project.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
use crate::command_prelude::*;

use cargo::print_json;
use serde::Serialize;

pub fn cli() -> App {
Expand Down Expand Up @@ -30,6 +28,6 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {

let location = ProjectLocation { root };

print_json(&location);
config.shell().print_json(&location);
Ok(())
}
4 changes: 1 addition & 3 deletions src/bin/cargo/commands/metadata.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
use crate::command_prelude::*;

use cargo::ops::{self, OutputMetadataOptions};
use cargo::print_json;

pub fn cli() -> App {
subcommand("metadata")
Expand Down Expand Up @@ -54,6 +52,6 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
};

let result = ops::output_metadata(&ws, &options)?;
print_json(&result);
config.shell().print_json(&result);
Ok(())
}
2 changes: 1 addition & 1 deletion src/bin/cargo/commands/pkgid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
let ws = args.workspace(config)?;
let spec = args.value_of("spec").or_else(|| args.value_of("package"));
let spec = ops::pkgid(&ws, spec)?;
println!("{}", spec);
cargo::drop_println!(config, "{}", spec);
Ok(())
}
4 changes: 1 addition & 3 deletions src/bin/cargo/commands/read_manifest.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
use crate::command_prelude::*;

use cargo::print_json;

pub fn cli() -> App {
subcommand("read-manifest")
.about(
Expand All @@ -17,6 +15,6 @@ Deprecated, use `cargo metadata --no-deps` instead.\

pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
let ws = args.workspace(config)?;
print_json(&ws.current()?);
config.shell().print_json(&ws.current()?);
Ok(())
}
4 changes: 2 additions & 2 deletions src/bin/cargo/commands/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
if args.is_present("version") {
let verbose = args.occurrences_of("verbose") > 0;
let version = cli::get_version_string(verbose);
print!("{}", version);
cargo::drop_print!(config, "{}", version);
return Ok(());
}
let prefix = if args.is_present("no-indent") {
Expand Down Expand Up @@ -206,7 +206,7 @@ fn parse_edge_kinds(config: &Config, args: &ArgMatches<'_>) -> CargoResult<HashS
.warn("the --no-dev-dependencies flag has changed to -e=no-dev")?;
kinds.push("no-dev");
}
if kinds.len() == 0 {
if kinds.is_empty() {
kinds.extend(&["normal", "build", "dev"]);
}

Expand Down
14 changes: 4 additions & 10 deletions src/bin/cargo/commands/verify_project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ use crate::command_prelude::*;
use std::collections::HashMap;
use std::process;

use cargo::print_json;

pub fn cli() -> App {
subcommand("verify-project")
.about("Check correctness of crate manifest")
Expand All @@ -13,19 +11,15 @@ pub fn cli() -> App {
}

pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
fn fail(reason: &str, value: &str) -> ! {
if let Err(e) = args.workspace(config) {
let mut h = HashMap::new();
h.insert(reason.to_string(), value.to_string());
print_json(&h);
h.insert("invalid".to_string(), e.to_string());
config.shell().print_json(&h);
process::exit(1)
}

if let Err(e) = args.workspace(config) {
fail("invalid", &e.to_string())
}

let mut h = HashMap::new();
h.insert("success".to_string(), "true".to_string());
print_json(&h);
config.shell().print_json(&h);
Ok(())
}
7 changes: 3 additions & 4 deletions src/bin/cargo/commands/version.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
use crate::command_prelude::*;

use crate::cli;
use crate::command_prelude::*;

pub fn cli() -> App {
subcommand("version")
.about("Show version information")
.arg(opt("quiet", "No output printed to stdout").short("q"))
}

pub fn exec(_config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
let verbose = args.occurrences_of("verbose") > 0;
let version = cli::get_version_string(verbose);
print!("{}", version);
cargo::drop_print!(config, "{}", version);
Ok(())
}
2 changes: 1 addition & 1 deletion src/cargo/core/compiler/build_context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use std::collections::HashMap;
use std::path::PathBuf;

mod target_info;
pub use self::target_info::{FileFlavor, RustcTargetData, TargetInfo};
pub use self::target_info::{FileFlavor, FileType, RustcTargetData, TargetInfo};

/// The build context, containing all information about a build task.
///
Expand Down
Loading

0 comments on commit 8064909

Please sign in to comment.