Skip to content

Commit 54d8303

Browse files
committed
Merge remote-tracking branch 'origin/master' into job-fix
2 parents 5a4af4e + ae97799 commit 54d8303

File tree

136 files changed

+4791
-3510
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

136 files changed

+4791
-3510
lines changed

ARCHITECTURE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,13 @@ call to `execs()`:
9393
// Before
9494
assert_that(
9595
p.cargo("run"),
96-
execs().with_status(0)
96+
execs()
9797
);
9898

9999
// After
100100
assert_that(
101101
p.cargo("run"),
102-
execs().stream().with_status(0)
102+
execs().stream()
103103
);
104104
```
105105

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ ignore the cross-compile test failures or disable them by
9696
using `CFG_DISABLE_CROSS_TESTS=1 cargo test`. Note that some tests are enabled
9797
only on `nightly` toolchain. If you can, test both toolchains.
9898
* All code changes are expected to comply with the formatting suggested by `rustfmt`.
99-
You can use `rustup +stable component add rustfmt-preview` to install `rustfmt` and use
100-
`rustfmt +stable --skip-children $FILE` on the changed files to automatically format your code.
99+
You can use `rustup component add --toolchain nightly rustfmt-preview` to install `rustfmt` and use
100+
`rustfmt +nightly --unstable-features --skip-children` on the changed files to automatically format your code.
101101
* Push your commits to GitHub and create a pull request against Cargo's
102102
`master` branch.
103103

Cargo.toml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ crossbeam-utils = "0.5"
2323
crypto-hash = "0.3.1"
2424
curl = "0.4.13"
2525
env_logger = "0.5.4"
26-
failure = "0.1.1"
26+
failure = "0.1.2"
2727
filetime = "0.2"
2828
flate2 = "1.0"
2929
fs2 = "0.4"
30-
git2 = "0.7.3"
30+
git2 = "0.7.5"
3131
git2-curl = "0.8.1"
3232
glob = "0.2.11"
3333
hex = "0.3"
@@ -40,7 +40,7 @@ libc = "0.2"
4040
log = "0.4"
4141
libgit2-sys = "0.7.5"
4242
num_cpus = "1.0"
43-
rustfix = "0.4"
43+
rustfix = "0.4.2"
4444
same-file = "1"
4545
semver = { version = "0.9.0", features = ["serde"] }
4646
serde = "1.0"
@@ -55,16 +55,19 @@ toml = "0.4.2"
5555
url = "1.1"
5656
clap = "2.31.2"
5757
unicode-width = "0.1.5"
58+
openssl = { version = '0.10.11', optional = true }
5859

59-
# Not actually needed right now but required to make sure that rls/cargo build
60-
# with the same set of features in rust-lang/rust
61-
num-traits = "0.2" # enable the default feature
60+
# A noop dependency that changes in the Rust repository, it's a bit of a hack.
61+
# See the `src/tools/rustc-workspace-hack/README.md` file in `rust-lang/rust`
62+
# for more information.
63+
rustc-workspace-hack = "1.0.0"
6264

6365
[target.'cfg(target_os = "macos")'.dependencies]
6466
core-foundation = { version = "0.6.0", features = ["mac_os_10_7_support"] }
6567

6668
[target.'cfg(windows)'.dependencies]
6769
miow = "0.3.1"
70+
fwdansi = "1"
6871

6972
[target.'cfg(windows)'.dependencies.winapi]
7073
version = "0.3"
@@ -94,3 +97,6 @@ bufstream = "0.1"
9497
name = "cargo"
9598
test = false
9699
doc = false
100+
101+
[features]
102+
vendored-openssl = ['openssl/vendored']

src/bin/cargo/command_prelude.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ pub trait AppExt: Sized {
127127
opt("message-format", "Error format")
128128
.value_name("FMT")
129129
.case_insensitive(true)
130-
.possible_values(&["human", "json"])
130+
.possible_values(&["human", "json", "short"])
131131
.default_value("human"),
132132
)
133133
}
@@ -270,6 +270,8 @@ pub trait ArgMatchesExt {
270270
MessageFormat::Json
271271
} else if f.eq_ignore_ascii_case("human") {
272272
MessageFormat::Human
273+
} else if f.eq_ignore_ascii_case("short") {
274+
MessageFormat::Short
273275
} else {
274276
panic!("Impossible message format: {:?}", f)
275277
}

src/bin/cargo/commands/fix.rs

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use command_prelude::*;
22

3-
use cargo::ops;
3+
use cargo::ops::{self, CompileFilter, FilterRule};
44

55
pub fn cli() -> App {
66
subcommand("fix")
@@ -37,10 +37,24 @@ pub fn cli() -> App {
3737
)
3838
.arg(
3939
Arg::with_name("edition")
40+
.long("edition")
41+
.help("Fix in preparation for the next edition"),
42+
)
43+
.arg(
44+
// This is a deprecated argument, we'll want to phase it out
45+
// eventually.
46+
Arg::with_name("prepare-for")
4047
.long("prepare-for")
4148
.help("Fix warnings in preparation of an edition upgrade")
4249
.takes_value(true)
43-
.possible_values(&["2018"]),
50+
.possible_values(&["2018"])
51+
.conflicts_with("edition")
52+
.hidden(true),
53+
)
54+
.arg(
55+
Arg::with_name("idioms")
56+
.long("edition-idioms")
57+
.help("Fix warnings to migrate to the idioms of an edition")
4458
)
4559
.arg(
4660
Arg::with_name("allow-no-vcs")
@@ -67,22 +81,16 @@ remaining warnings will be displayed when the check process is finished. For
6781
example if you'd like to prepare for the 2018 edition, you can do so by
6882
executing:
6983
70-
cargo fix --prepare-for 2018
71-
72-
Note that this is not guaranteed to fix all your code as it only fixes code that
73-
`cargo check` would otherwise compile. For example unit tests are left out
74-
from this command, but they can be checked with:
75-
76-
cargo fix --prepare-for 2018 --all-targets
84+
cargo fix --edition
7785
7886
which behaves the same as `cargo check --all-targets`. Similarly if you'd like
7987
to fix code for different platforms you can do:
8088
81-
cargo fix --prepare-for 2018 --target x86_64-pc-windows-gnu
89+
cargo fix --edition --target x86_64-pc-windows-gnu
8290
8391
or if your crate has optional features:
8492
85-
cargo fix --prepare-for 2018 --no-default-features --features foo
93+
cargo fix --edition --no-default-features --features foo
8694
8795
If you encounter any problems with `cargo fix` or otherwise have any questions
8896
or feature requests please don't hesitate to file an issue at
@@ -106,9 +114,25 @@ pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
106114
}
107115
};
108116
let mode = CompileMode::Check { test };
117+
118+
// Unlike other commands default `cargo fix` to all targets to fix as much
119+
// code as we can.
120+
let mut opts = args.compile_options(config, mode)?;
121+
if let CompileFilter::Default { .. } = opts.filter {
122+
opts.filter = CompileFilter::Only {
123+
all_targets: true,
124+
lib: true,
125+
bins: FilterRule::All,
126+
examples: FilterRule::All,
127+
benches: FilterRule::All,
128+
tests: FilterRule::All,
129+
}
130+
}
109131
ops::fix(&ws, &mut ops::FixOptions {
110-
edition: args.value_of("edition"),
111-
compile_opts: args.compile_options(config, mode)?,
132+
edition: args.is_present("edition"),
133+
prepare_for: args.value_of("prepare-for"),
134+
idioms: args.is_present("idioms"),
135+
compile_opts: opts,
112136
allow_dirty: args.is_present("allow-dirty"),
113137
allow_no_vcs: args.is_present("allow-no-vcs"),
114138
broken_code: args.is_present("broken-code"),

src/bin/cargo/commands/locate_project.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ pub fn cli() -> App {
99
}
1010

1111
#[derive(Serialize)]
12-
pub struct ProjectLocation {
13-
root: String,
12+
pub struct ProjectLocation<'a> {
13+
root: &'a str,
1414
}
1515

1616
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
@@ -23,8 +23,7 @@ pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
2323
not representable in Unicode"
2424
)
2525
})
26-
.map_err(|e| CliError::new(e, 1))?
27-
.to_string();
26+
.map_err(|e| CliError::new(e, 1))?;
2827

2928
let location = ProjectLocation { root };
3029

src/bin/cargo/commands/run.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,18 @@ run. If you're passing arguments to both Cargo and the binary, the ones after
3838
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
3939
let ws = args.workspace(config)?;
4040

41-
let mut compile_opts = args.compile_options_for_single_package(config, CompileMode::Build)?;
41+
let mut compile_opts = args.compile_options(config, CompileMode::Build)?;
4242
if !args.is_present("example") && !args.is_present("bin") {
43-
if let Some(default_run) = compile_opts.get_package(&ws)?
44-
.and_then(|pkg| pkg.manifest().default_run())
45-
{
43+
let default_runs: Vec<_> = compile_opts
44+
.spec
45+
.get_packages(&ws)?
46+
.iter()
47+
.filter_map(|pkg| pkg.manifest().default_run())
48+
.collect();
49+
if default_runs.len() == 1 {
4650
compile_opts.filter = CompileFilter::new(
4751
false,
48-
vec![default_run.to_owned()],
52+
vec![default_runs[0].to_owned()],
4953
false,
5054
vec![],
5155
false,
@@ -56,7 +60,11 @@ pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
5660
false,
5761
);
5862
} else {
63+
// ops::run will take care of errors if len pkgs != 1.
5964
compile_opts.filter = CompileFilter::Default {
65+
// Force this to false because the code in ops::run is not
66+
// able to pre-check features before compilation starts to
67+
// enforce that only 1 binary is built.
6068
required_features_filterable: false,
6169
};
6270
}

src/bin/cargo/commands/test.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ pub fn cli() -> App {
2121
"Test only this package's library",
2222
"Test only the specified binary",
2323
"Test all binaries",
24-
"Check that the specified examples compile",
25-
"Check that all examples compile",
24+
"Test only the specified example",
25+
"Test all examples",
2626
"Test only the specified test target",
2727
"Test all tests",
2828
"Test only the specified bench target",

src/bin/cargo/commands/uninstall.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ pub fn cli() -> App {
66
subcommand("uninstall")
77
.about("Remove a Rust binary")
88
.arg(Arg::with_name("spec").multiple(true))
9+
.arg_package_spec_simple("Package to uninstall")
910
.arg(multi_opt("bin", "NAME", "Only uninstall the binary NAME"))
1011
.arg(opt("root", "Directory to uninstall packages from").value_name("DIR"))
1112
.after_help(
@@ -20,7 +21,10 @@ only uninstall particular binaries.
2021

2122
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
2223
let root = args.value_of("root");
23-
let specs = args.values_of("spec").unwrap_or_default().collect();
24+
let specs = args
25+
.values_of("spec")
26+
.unwrap_or_else(|| args.values_of("package").unwrap_or_default())
27+
.collect();
2428
ops::uninstall(root, specs, &values(args, "bin"), config)?;
2529
Ok(())
2630
}

src/bin/cargo/main.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// we have lots of arguments, cleaning this up would be a large project
2-
#![cfg_attr(feature = "cargo-clippy", allow(too_many_arguments))]
1+
#![cfg_attr(feature = "cargo-clippy", allow(too_many_arguments))] // large project
2+
#![cfg_attr(feature = "cargo-clippy", allow(redundant_closure))] // there's a false positive
33

44
extern crate cargo;
55
extern crate clap;
@@ -135,7 +135,6 @@ fn find_closest(config: &Config, cmd: &str) -> Option<String> {
135135

136136
fn execute_external_subcommand(config: &Config, cmd: &str, args: &[&str]) -> CliResult {
137137
let command_exe = format!("cargo-{}{}", cmd, env::consts::EXE_SUFFIX);
138-
#[cfg_attr(feature = "cargo-clippy", allow(redundant_closure))] // false positive
139138
let path = search_directories(config)
140139
.iter()
141140
.map(|dir| dir.join(&command_exe))

0 commit comments

Comments
 (0)