87 Commits

Author SHA1 Message Date
bors
18c8c5fb99 Auto merge of #6065 - zachlute:change-project-to-package, r=dwijnand
Replace 'project' with 'package' in many strings and comments.

Partial fix for #6056.

Shouldn't be anything too interesting or surprising in here.

Still need to do documentation, but will do that as a different PR.
2018-09-21 23:34:08 +00:00
Eduard-Mihai Burtescu
afdde6081d Remove fix::local_paths_no_fix, as crate_in_paths is getting stabilized. 2018-09-21 18:44:38 +03:00
Zach Lute
3492a3905c Replace 'project' with 'package' in many strings and comments. 2018-09-20 23:47:09 -07:00
steveklabnik
d277c8447d No longer warn about #![feature(rust_2018_preview)]
This is no longer needed, and so the warning is outdated.

Fixes #6050
2018-09-18 15:15:02 -04:00
bors
56ee6204de Auto merge of #5984 - alexcrichton:stabilize-edition, r=ehuss
Stabilize `edition` key and add `cargo new --edition`

This commit stabilizes the `edition` key in `Cargo.toml`, both in the
`[package]` section and inside subtargets. Additionally the `cargo new` and
`cargo init` subcommands have been enhanced with a `--edition` flag to allow
explicitly specifying the edition to be generated.

This commit does not yet change the default edition that's generated.

Closes #5980
2018-09-06 22:17:24 +00:00
Alex Crichton
3d0290398a Stabilize edition key and add cargo new --edition
This commit stabilizes the `edition` key in `Cargo.toml`, both in the
`[package]` section and inside subtargets. Additionally the `cargo new` and
`cargo init` subcommands have been enhanced with a `--edition` flag to allow
explicitly specifying the edition to be generated.

This commit does not yet change the default edition that's generated.

Closes #5980
2018-09-06 11:28:10 -07:00
Alex Crichton
51be74244b fix: Fix unusual errors with RUSTC_WRAPPER
This commit fixes the interaction of `cargo fix` and `RUSTC_WRAPPER`, ensuring
that Cargo at least doesn't die internally. For now `RUSTC_WRAPPER` is
overridden for normal execution but we can eventually one day probably support
`RUSTC_WRAPPER`!

Closes #5981
2018-09-05 15:18:40 -07:00
bors
aecaef3e23 Auto merge of #5944 - dwijnand:fix-force-rebuild, r=alexcrichton
Force `cargo fix` to rebuild

Fixes #5736

This is a resubmit of @killercup's #5750, rebased on current master.

@alexcrichton From browsing the code I feel like `-p` would still restrict the packages to rebuild, despite the rebuild flag added. But I might be misreading or not-fully-reading the code. Could you give me some mentoring instructions for the test cases you're concerned with?
2018-08-31 22:43:25 +00:00
Dale Wijnand
7a42790a7c
Assert fix::doesnt_rebuild_dependencies stderr fully
Gives more confidence.
2018-08-30 07:28:20 +02:00
Dale Wijnand
b98ba8e289
Test that cargo fix doesn't aggressively rebuild 2018-08-29 21:24:16 +02:00
Pascal Hertleif
616e0ad3bf
Always rebuild targets when using cargo-fix 2018-08-29 01:57:52 +02:00
Dale Wijnand
8c2d0dffa4
Merge branch 'master' into fix-allow-staged
* master: (25 commits)
  Migrate from tests fom assert_that/execs to .run()
  Wrap ProcessBuilder in Execs & make .cargo return that
  Make old Execs methods take not consume self
  Extract Execs::match_process
  Add #[must_use] to Execs
  Inline Execs::_with_stderr
  Remove an unrun "cargo build" ProcessBuilder
  Add documentation for creating test dependencies.
  Only use non-absolute paths for `path` dependencies
  Fix test failure on nightly due to `codemap::Span` change.
  New metabuild strategy using custom src_path enum.
  Remove unnecessary change.
  Address review comments.
  Metabuild (RFC 2196)
  Handle Window's missing file error message
  Make "cargo uninstall" uninstall the cwd bins
  update comment based on further research
  List URL in HTTP download failures
  Fix compilation error
  Improve the `cargo install` deprecation messaging
  ...
2018-08-29 01:20:18 +02:00
Dale Wijnand
85984a8700
Migrate from tests fom assert_that/execs to .run() 2018-08-28 15:08:12 +02:00
Dale Wijnand
b5ee3635ef
Wrap ProcessBuilder in Execs & make .cargo return that 2018-08-28 09:24:37 +01:00
Jordan Justen
2bbbca3126
fix: Add test warns_about_staged_working_directory
Signed-off-by: Jordan Justen <jljusten@gmail.com>
2018-08-21 00:12:30 -07:00
Jordan Justen
6a616cb7c2
fix: Add --allow-staged switch to cargo fix
This change splits out staged changes from dirty changes, and lets the
user know if they should consider using the --allow-staged flag.

Signed-off-by: Jordan Justen <jljusten@gmail.com>
2018-08-21 00:12:30 -07:00
Jordan Justen
4539ff2191
fix: Prepare error message for --allow-staged
Signed-off-by: Jordan Justen <jljusten@gmail.com>
2018-08-21 00:12:30 -07:00
Dale Wijnand
16aeb0cd4f
Default test support's Execs to exit code 0 2018-08-03 07:44:42 +01:00
Alex Crichton
80f9d318d5 Add a --edition-idioms flag to cargo fix
This, like `--prepare-for`, will be part of the transition guide which
automatically applies the necessary lint group from the compiler to associated
code.

The `--edition-idioms` flag does not take an argument and will automatically
enable the right lint group based on the edition being compiled for.

cc #52679
2018-08-02 09:19:35 -07:00
bors
e3a90f2097 Auto merge of #5845 - alexcrichton:fix-edition, r=alexcrichton
Rename `--prepare-for` to `--edition`, drop arg

This commit tweaks the UI of `cargo fix` for the edition. Previously you'd
execute `cargo fix --prepare-for 2018`, but that's a lot of typing! Plus it's
some manual data that Cargo can already infer.

Instead, after this commit, you now type `cargo fix --edition`, and that's it!
The idea is that this'll tell Cargo to fix code for the *next* edition,
inferring whatever edition is in use and figuring out what to pass to rustc.

Functionality-wise this should be the exact same as `--prepare-for 2018` though

If others agree w/ this change I'll send a PR to the edition guide after this
merges!
2018-08-02 14:57:35 +00:00
Dale Wijnand
05400b8018
Drop the [/] test output macro 2018-08-02 10:18:48 +01:00
Alex Crichton
b2b120e9fd Rename --prepare-for to --edition, drop arg
This commit tweaks the UI of `cargo fix` for the edition. Previously you'd
execute `cargo fix --prepare-for 2018`, but that's a lot of typing! Plus it's
some manual data that Cargo can already infer.

Instead, after this commit, you now type `cargo fix --edition`, and that's it!
The idea is that this'll tell Cargo to fix code for the *next* edition,
inferring whatever edition is in use and figuring out what to pass to rustc.

Functionality-wise this should be the exact same as `--prepare-for 2018` though

If others agree w/ this change I'll send a PR to the edition guide after this
merges!
2018-08-01 15:03:15 -07:00
Alex Crichton
876a50366b fix: Iteratively apply suggestions from the compiler
This commit updates the `cargo fix` implementation to iteratively apply fixes
from the compiler instead of only once. Currently the compiler can sometimes
emit overlapping suggestions, such as in the case of transitioning

    ::foo::<::Bar>();

to ...

    crate::foo::<crate::Bar>();

and `rustfix` rightfully can't handle overlapping suggestions as there's no
clear way of how to disambiguate the fixes. To fix this problem Cargo will now
run `rustc` and `rustfix` multiple times, attempting to reach a steady state
where no fixes failed to apply.

Naturally this is a pretty tricky thing to do and we want to be sure that Cargo
doesn't loop forever, for example. A number of safeguards are in place to
prevent Cargo from going off into the weeds when fixing files, notably avoiding
to reattempt fixes if no successful fixes ended up being applied.

Closes #5813
Closes rust-lang/rust#52754
2018-07-31 14:20:58 -07:00
Alex Crichton
fa7a387740 Add more diagnostics to smooth edition transition
This commit adds two diagnostics in particular to ease the transition into the
2018 edition. The current transition process is pretty particular and must be
done carefully, so let's try to automate things to make it as painless as
possible! Notably the new diagnostics are:

* If you `cargo fix --prepare-for 2018` a crate which already has the 2018
  edition enabled, then an error is generated. This is because the compiler
  can't prepare for the 2018 edition if you're already in the 2018 edition, the
  lints won't have a chance to fire. You can only execute `--prepare-for 2018`
  over crates in the 2015 edition.

* If you `cargo fix --prepare-for 2018` and have forgotten the
  `rust_2018_preview` feature, a warning is issued. The lints don't fire unless
  the feature is enabled, so this is intended to warn in this situation to
  ensure that lints fire as much as they can.

After this commit if `cargo fix --prepare-for` exits successfully with zero
warnings then crates should be guaranteed to be compatible!

Closes #5778
2018-07-31 07:28:07 -07:00
Alex Crichton
7691deb325 fix: Only fix "primary" packages by default
The previous heuristic for fixing packages was to fix all packages in a
workspace, aka those with path dependencies. Instead this commit switches cargo
over to only fixing the "primary" package, or those requested on the command
line or implicitly via cwd.

This will later help us identify which packages are being targeted so we can
provide tailored warnings and errors for mixed up transition steps.
2018-07-30 16:27:31 -07:00
bors
af6e295d20 Auto merge of #5814 - alexcrichton:fix-all-targets, r=alexcrichton
cargo fix: Pass `--all-targets` to `cargo fix` by default

This'll help fix as much code as possible, including tests!

Closes #5739
2018-07-30 22:11:58 +00:00
Alex Crichton
ff8a95e296 fix: Pass --all-targets to cargo fix by default
This'll help fix as much code as possible, including tests!

Closes #5739
2018-07-27 08:54:40 -07:00
Eh2406
7fc0dffed2 remove all of the (now) unnecessary temp file usage in tests 2018-07-26 15:10:48 -04:00
Without Boats
064a1461d7
Respect .gitignore during cargo new
When running `cargo new`, we check to see if you are inside a git
repository. If you are, we do not initialize a new git repo for
your project unless you specifically asked for it using --vcs.
(See #1210 for more background).

This commit changes that behavior to *also* create a new repo if
the project would be an ignored path in the parent repository.
This way, if your home directory is a git repository, as long as
you have ignored the directory you are creating a new project in,
we will instantiate a git repository without you having to
specifically request it.
2018-07-26 15:39:42 +02:00
Dale Wijnand
ca7d9ee292
Declare one-line files on one line, in test projects 2018-07-25 09:58:50 +01:00
Dale Wijnand
ab19c48358
Dedup a bunch more manifest 2018-07-25 00:43:30 +01:00
Dale Wijnand
081e7930d2
Drop now unnecessary basic manifests 2018-07-24 16:33:55 +01:00
Dale Wijnand
252f6e8e9f
Opt-out all other failing tests
Looks like cargo traverses the filesystem & fails if it runs into a
Cargo.toml that doesn't declare a target.  I couldn't find a nice way to
re-engineer the test to avoid this issue.  So I'll leave that as someone
else's exercise.
2018-07-24 13:59:42 +01:00
Alex Crichton
6cdee674fc Don't warn about ignored files in cargo-fix
They're not being tracked, so no worries if we stomp over them!
2018-07-23 07:33:51 -07:00
Dale Wijnand
43b42d6f4c
Reorganise the testsuite crate module hierarchy
* Collapse the nested cargotest::support module into the cargotest
  module (merge the mod.rs's)
* Rename the cargotest module to support
* Nest the top-level hamcrest module into support
2018-07-22 08:46:44 +01:00
Dale Wijnand
7fe2fbc8a3
Remove the argument from the project test support function
By rewriting the tests, with rerast (https://github.com/google/rerast),
to use the newly introduced "at" method.

First I added the following temporary function to cargotest::support:

    pub fn project_foo() -> ProjectBuilder {
        project("foo")
    }

Then I defined the following rewrite.rs:

    use cargotest::support::{ project, project_foo };

    fn rule1(a: &'static str) {
        replace!(project("foo") => project_foo());
        replace!(project(a) => project_foo().at(a));
    }

Then I ran rerast:

    cargo +nightly rerast --rules_file=rewrite.rs --force --targets tests --file tests/testsuite/main.rs

Finally I searched and replaced the references to project_foo with
argument-less project (a little awkardly on macOS with a git clean).

    find tests -type f -exec sed -i -e 's/project_foo/project/g' {} +
    git clean -d tests
2018-07-20 13:31:50 +01:00
Alex Crichton
b02ba3771e Import cargo fix directly in to Cargo
This commit imports the `cargo fix` subcommand in rust-lang-nursery/rustfix
directly into Cargo as a subcommand. This should allow us to ease our
distribution story of `cargo fix` as we prepare for the upcoming 2018 edition
release.

It's been attempted here to make the code as idiomatic as possible for Cargo's
own codebase. Additionally all tests from cargo-fix were imported into Cargo's
test suite as well. After this lands and is published in nightly the `cargo-fix`
command in rust-lang-nursery/rustfix will likely be removed.

cc rust-lang/rust#52272
2018-07-16 21:58:58 -07:00