7140 Commits

Author SHA1 Message Date
Dale Wijnand
5ddc8b1338
Test PackageId Debug & Display 2018-11-26 11:04:01 +00:00
bors
de1d0de31f Auto merge of #6347 - Eh2406:dell-copy, r=alexcrichton
remove clones made redundant by Intern SourceId

This is a follow up to #6342. I used clippy to find all the places we called `.clone()`  on a `SourceId` or where we passed `&SourceId`. This also involved fixing a large number of other things clippy was complaining about, and running `fmt` on a large number of files.
2018-11-26 03:46:26 +00:00
Eh2406
92485f8c14 Other clippy things and fmt 2018-11-25 21:45:43 -05:00
Eh2406
dad9fe6618 add clippy:: 2018-11-25 21:26:18 -05:00
Eh2406
7cd4a94db8 Other clippy things and fmt 2018-11-25 21:13:51 -05:00
Eh2406
e5a11190b3 SourceId is copy, clippy thinks we dont need &SourceId or SourceId.clone() 2018-11-25 21:08:05 -05:00
bors
1ff5975b96 Auto merge of #6342 - dwijnand:intern-SourceId, r=Eh2406
Intern SourceId

Refs #6207
sibling of #6332
2018-11-25 14:59:12 +00:00
Dale Wijnand
9b22eb1998
Make SourceId derive Copy 2018-11-25 13:44:06 +00:00
Dale Wijnand
ba175dcc4d
Add pointer equality to PartialEq for SourceId 2018-11-25 12:31:21 +00:00
Dale Wijnand
653ce4d4c3
Move the custom equality up to SourceId
That way we:

* preserve that SourceIds that have slightly different URLs are actually equal
* make SourceIdInner lawful in its Hash/Eq definition.
2018-11-25 12:31:21 +00:00
bors
99bea3b72e Auto merge of #6255 - evq:tweak-build-dir, r=alexcrichton
Tweak Layout to allow for non json file targets with internal "."

Per @alexcrichton 's comment in https://github.com/rust-lang/rust/pull/55041#issuecomment-431363683, currently cargo assumes that a target with an internal `.` is a custom json target spec, using the file stem for the build directory name.

This PR changes cargo to only use the file stem for files with a `json` extension.
2018-11-25 09:49:56 +00:00
David Laehnemann
b606256fec docs: correct profile usage of cargo test --release 2018-11-23 12:07:31 +01:00
bors
ad239245a1 Auto merge of #6343 - neersighted:patch-1, r=ehuss
Correct Target Directory command-line option

The option is `--target-dir`, not `--target`, which is discussed above.
2018-11-22 15:23:47 +00:00
Bjorn Neergaard
2dffd7c1d9
Correct Target Directory command-line option
The option is `--target-dir`, not `--target`, which is discussed above.
2018-11-22 03:25:45 -07:00
Dale Wijnand
3d91b79541
Intern SourceId 2018-11-21 20:29:29 +00:00
bors
c93e84716d Auto merge of #6336 - Eh2406:im-rs, r=alexcrichton
Persistent data structures by im-rs

There has been a long standing "TODO: We should switch to persistent hash maps if we can" in the resolver. This PR introduces a dependency on [im-rs](https://github.com/bodil/im-rs/issues/26) to provide persistent hash maps. It then uses `im_rc::OrdSet` to store the priority list of dependencies, instead of `std::BinaryHeap`, as cloning the `Heap` was one of the most expensive things we did. In Big O terms these changes are very big wins, in practice the improvement is small. This is do to a number of factors like, `std::collections` are very fast, N is usually only in the hundreds, we only clone when the borrow checker insists on it, and we use `RC` and other tricks to avoid cloning.

I would advocate that we accept this PR, as:
- Things are only going to get more complicated in the future. It would be nice to have Big O on our side.
- When developing a new feature finding each place to add `RC` should be an afterthought not absolutely required before merge. (cc #6129 witch is stuck on this kind of per tick performance problem as well as other things).
- As the code gets more complex, making sure we never break any of the tricks becomes harder. It would be easier to work on this if such mistakes are marginal instead of show stoppers. (cc #5130 a bug report of one of these bing removed and affecting `./x.py build` enough to trigger an investigation).
- The resolver is already very complicated with a lot of moving parts to keep in your head at the same time, this will only get worse as we add  features. There are a long list of tricks that are *critical* before and `~5%`  after, it would be nice to consider if each one is worth the code complexity. (I can list some of the ones I have tried to remove but are still small wins, if that would help the discussion).

Overall, I think it is worth doing now, but can see that if is not a slam dunk.
2018-11-21 18:21:27 +00:00
Eh2406
1699a5b1ce Clarify the need for a counter 2018-11-20 15:52:52 -05:00
bors
e192fdf424 Auto merge of #6335 - Metaswitch:cli-in-library, r=dwijnand
Move command prelude into main library

When writing cargo sub-commands, it would be really useful to have access to these pre-built command line argument creates/parsers.

In a perfect world, I'd also move the contents of `src/bin/cargo/{cli.rs, main.rs, command/mod.rs}` that aren't specific to the built-in commands, but that's more complicated than this simple move of a module.
2018-11-20 17:32:52 +00:00
Andy Caldwell
077a31adb3
Move command prelude into main library 2018-11-19 21:41:09 +00:00
Eh2406
fd06af4e0b better error for benchmarking 2018-11-19 16:21:00 -05:00
Eh2406
e3b44cc325 use im-rs for RemainingDeps 2018-11-19 16:20:16 -05:00
Eh2406
a703851abe try im-rs 2018-11-19 16:20:15 -05:00
bors
9caf0bac4c Auto merge of #6331 - dwijnand:distinguish-custom-build-invocations, r=alexcrichton
Distinguish custom build invocations

Distinguish building a build script from running it,
in build plan invocations.

Fixes #5719
2018-11-19 18:35:19 +00:00
bors
85060d8452 Auto merge of #6330 - dwijnand:run_bin_example, r=alexcrichton
Allow crate_type=bin examples to run

Fixes #6159
2018-11-19 18:01:37 +00:00
bors
bf6aa590b1 Auto merge of #6326 - dwijnand:verify_project_honours_unstable_features, r=alexcrichton
Make verify-project honour unstable features

Fixes #6209
2018-11-19 17:18:24 +00:00
bors
cd43d3a11f Auto merge of #6329 - dwijnand:disable-autobins, r=alexcrichton
Make autodiscovery disable inferred targets

Fixes #6205
2018-11-19 16:37:01 +00:00
bors
2ad447f704 Auto merge of #6218 - ordovicia:alias-check, r=dwijnand
Add `c` alias for `check`

This PR adds `cargo c` alias for `cargo check`.

I believe that one of the most frequently used subcommands is `check`.
Adding this alias would save much time.

Currently, there are three aliases: `b` for `build`, `r` for `run`, `t` for `test`.
I think that adding out-of-the-box `c` alias is *natural* for many developers, and these aliases would cover most of the use cases.
We can add aliases via a configuration file, but I guess people would expect built-in `c` alias along with `b` and others.

One problem I have come up with is that the `clean` subcommand also starts with the letter `c`.
But I believe that running `check` subcommand by mistake would not hurt developers so much.

Fixes #6215
2018-11-19 07:30:13 +00:00
Hidehito Yabuuchi
2a667323ef Add c alias for check 2018-11-19 09:59:28 +09:00
bors
61c83bac9c Auto merge of #6259 - ordovicia:user-alias-override, r=ehuss
Allow user aliases to override built-in aliases

This PR allows user-defined aliases take precedence over built-in ones, with a warning that tells there exists a built-in alias.
This PR does not allow user aliases override built-in subcommands.

```console
$ cat .cargo/config
[alias]
b = "fetch"
build = "fetch"

$ ./target/debug/cargo b
warning: user-defined alias `b` overrides a built-in alias for `build`

$ ./target/debug/cargo build
warning: user-defined alias `build` is ignored, because it is shadowed by a built-in command
   Compiling proc-macro2 v0.4.19
   Compiling unicode-xid v0.1.0
   Compiling cc v1.0.25
(snip)
```

In the current version of Cargo, user aliases cannot override built-in aliases.
This behavior is keeping us from safely adding new built-in aliases without interfering existing user config.
Merging this PR will allow that.

Fixes #6221
Relating to #6218
2018-11-18 22:24:07 +00:00
Dale Wijnand
e8c1811f83
Fix metabuild::metabuild_build_plan 2018-11-18 18:39:08 +00:00
Dale Wijnand
27424e2dba
Use kebab-case for CompileMode, & discard some info 2018-11-18 18:32:54 +00:00
Dale Wijnand
7b081569ed
Distinguish custom build invocations
Distinguish building a build script from running it,
in build plan invocations.
2018-11-18 17:59:05 +00:00
Dale Wijnand
e95036467e
Allow crate_type=bin examples to run 2018-11-18 17:32:42 +00:00
Dale Wijnand
8d996a2df0
Make autodiscovery disable inferred targets 2018-11-18 15:57:54 +00:00
Dale Wijnand
dc6b5be30d
Simplify tool_paths::absolute_tools test
... by reusing the new [ROOT] macro.
2018-11-18 14:45:28 +00:00
Dale Wijnand
092f7baea3
Fix cargo_command::cargo_subcommand_args test 2018-11-18 14:44:16 +00:00
Dale Wijnand
49f73b9c4e
Simplify cargo_command::cargo_subcommand_args test 2018-11-18 13:38:33 +00:00
Dale Wijnand
6afca122e5
Handle backslash-escaped backslashes in actual output too 2018-11-18 12:08:46 +00:00
Dale Wijnand
b088539de8
Handle backslash-escaped backslashes 2018-11-18 09:10:20 +00:00
Hidehito Yabuuchi
ea1f525c02 Allow user aliases to override built-in aliases 2018-11-18 18:08:28 +09:00
bors
53e436d665 Auto merge of #6328 - ehuss:rename-cross-build-output, r=alexcrichton
Fix renaming directory project using build scripts with cross-compiling.

The rename-protection introduced in #4818 checks for paths with a prefix of `/…/target/debug`, but this does not work for paths used during cross-compiling.

This change checks for paths with the full `OUT_DIR` prefix, and the `build/PKG/root-output` file now includes that full `OUT_DIR` instead of `/…/target/debug`.

This also includes a few other changes:
- Support fixing KIND=PATH style paths.
- Support fixing paths in metadata (like `cargo:root=…` or `cargo:include=…` which are common).
- Adds a "version" value to the metadata hash to ensure that cargo doesn't get confused with the new `root-output` file format.

Fixes #6177
2018-11-18 08:12:27 +00:00
bors
3468918428 Auto merge of #6327 - ehuss:add_plugin_deps-tests, r=alexcrichton
Fix add_plugin_deps-related tests.

These tests were modified in #3974 in such a way that they stopped testing the `add_plugin_deps` code path. The tests can't be directly reverted because #3651 changed it so that dylib paths must be within the root output directory. I compromised by just copying the dylib into `$OUT_DIR`.

Closes #6318.
2018-11-18 07:49:10 +00:00
Eric Huss
d1045c9cc2 Fix renaming directory project using build scripts with cross-compiling. 2018-11-17 19:10:29 -08:00
Eric Huss
83ff57a4ad Fix add_plugin_deps-related tests. 2018-11-17 16:33:24 -08:00
Dale Wijnand
104ab6c2bc
Make verify-project honour unstable features 2018-11-17 22:57:06 +00:00
bors
ebd0ef1be9 Auto merge of #6321 - ehuss:glossary, r=dwijnand
Add a glossary.

Closes #4392, closes #3380.
2018-11-17 22:51:43 +00:00
Eric Huss
091fa8c214 Crate/target clarification. 2018-11-17 14:33:33 -08:00
Eric Huss
6de96b4937 Fix unstable sentence. 2018-11-16 10:22:34 -08:00
Eric Huss
f11f6c23e6 Add a glossary. 2018-11-16 09:22:43 -08:00
bors
b3d0b2e545 Auto merge of #6311 - alexcrichton:stabilize-renames, r=the-whole-team
Stabilize the `rename-dependency` feature

This commit stabilizes Cargo's `rename-dependency` feature which allows
renaming packages in `Cargo.toml`, enabling importing multiple versions
of a single crate or simply avoiding a `use foo as bar` in `src/lib.rs`.

Closes #5653
2018-11-15 19:13:04 +00:00