Commit graph

16554 commits

Author SHA1 Message Date
bors 903a509919 Auto merge of #13220 - ehuss:fix_in_dependency, r=weihanglo
Fix fix::fix_in_dependency to not rely on rustc

This changes the `fix::fix_in_dependency` test so that it does not rely on the behavior of rustc.

This test is checking the behavior when rustc includes a suggestion diagnostic that modifies a file in CARGO_HOME from a dependency. rustc should not be emitting suggestions that point outside of the current crate, but there are some known bugs where it does this. #9938 added a workaround for this to avoid writing to CARGO_HOME.

However, the current test was relying on one of those bugs in rustc to exhibit its behavior. https://github.com/rust-lang/rust/pull/119204 is fixing that particular behavior. Instead of relying on issues in rustc, this PR changes the test so that the test creates a fake `rustc` executable that will emit a hard-coded JSON message that tells `cargo fix` to modify a file in CARGO_HOME. This should be stable as it is no longer relying on rustc.

Testing or validating this change is a little tricky. You have to essentially comment out [these three lines](4f70d1781a/src/cargo/ops/fix.rs (L654-L656)) from the original #9938 change, and verify that the test fails (it says "Fixed" in the output). With those three lines in place, it should pass.
2024-01-01 21:27:29 +00:00
renovate[bot] 37f4a971ca
chore(deps): update gix 2024-01-01 03:52:17 +00:00
renovate[bot] 647dc34c27
chore(deps): update alpine docker tag to v3.19 2024-01-01 01:19:21 +00:00
Eric Huss 3d3e1b3668 Handle Windows newlines.
Suggestions that come from rustc that are multi-line only use LF line
endings. But if the file is checked out on windows with CRLF
line-endings, then you end up with a mix of line endings that don't
match the "fixed.rs" file.

Tracking this at https://github.com/rust-lang/rust/issues/119482.
2023-12-31 16:20:41 -08:00
Eric Huss a21997f0cc rustfix: Support inserting new lines.
If rustfix received a suggestion which inserts new lines without
replacing existing lines, it would ignore the suggestion. This is
because `parse_snippet` would immediately return if the `lines` to
replace was empty.

The solution here is to just drop the code which messes with the
original text line. `cargo fix` (and compiletest) currently do not use
this. This was originally added back in the days when rustfix supported
an interactive UI which showed color highlighting of what it looks like
with the replacement. My feeling is that when we add something like this
back in, I would prefer to instead use a real diff library and display
instead of trying to do various text manipulation for display. This
particular code has generally been buggy, and has been a problem several
times.

The included test fails without this fix because the changes do not
apply, and the code cannot compile.
2023-12-31 10:18:22 -08:00
Eric Huss 029fe2bafc Add a primitive way to add new tests to parse_and_replace.
This adds an environment variable to make it easier to add new tests.
2023-12-31 09:58:37 -08:00
Eric Huss c54fa88ea4 Cleanup rustfix parse_and_replace test.
This is just some minor code cleanup for the parse_and_replace test,
there should not be any functional differences.
2023-12-31 09:56:20 -08:00
bors ef94adb927 Auto merge of #13224 - ehuss:fix-error-format, r=epage
cleanup: Remove error-format special-case in `cargo fix`

`cargo fix` had some special handling to deal with ensuring that the `--error-format=json` flag was passed to rustc. However, cargo was changed in https://github.com/rust-lang/cargo/pull/7450 to always pass that flag. This special handling is no longer necessary, so this PR removes it.
2023-12-31 02:20:45 +00:00
Eric Huss 1a8034cc80 cleanup: Remove error-format special-case in cargo fix
`cargo fix` had some special handling to deal with ensuring that the
`--error-format=json` flag was passed to rustc. However, cargo was
changed in https://github.com/rust-lang/cargo/pull/7450 to always pass
that flag. This special handling is no longer necessary, so this PR
removes it.
2023-12-30 18:18:45 -08:00
bors bc7e5cefca Auto merge of #13225 - ehuss:fix-jobserver-always, r=epage
`cargo fix`: always inherit the jobserver

https://github.com/rust-lang/cargo/pull/12951 changed `cargo fix` to ensure that `rustc` has access to the jobserver. However, it only did that for the final "verification" step. It was not set for any of the previous calls to rustc (which is up to ~5 calls).

I'm not sure if this was done intentionally, I did not see any discussion of this in #12951.

This isn't too important in the grand scheme of things, because `rustc` is not doing codegen, so the parallel behavior is currently not used. However, this removes an extraneous `warning: failed to connect to jobserver from environment variable` warning that is printed in cargo's log every time it runs rustc. It also might be relevant in the future if rustc enables the parallel frontend.
2023-12-31 01:17:27 +00:00
Eric Huss 448c437ef0 fix: cargo fix: always inherit the jobserver 2023-12-30 15:10:04 -08:00
Eric Huss 1ef1b7e313 Fix fix::fix_in_dependency to not rely on rustc 2023-12-29 12:56:23 -08:00
bors 2ed2dbd8ce Auto merge of #13221 - ehuss:bump-cargo-credential, r=epage
Bump cargo-credential to 0.4.3

This should fix the check-version-bump CI job. #13216 made some changes without bumping the version.
2023-12-29 20:48:16 +00:00
Eric Huss 1bab2005f3 Bump cargo-credential to 0.4.3 2023-12-29 12:44:31 -08:00
bors 4f70d1781a Auto merge of #13213 - stupendoussuperpowers:mulpack-features-git, r=epage
`cargo add` - fix for adding features from repository with multiple packages.

Fixes #13121

As discussed in the issue, when using `cargo add` to add a package with features from a git repository from one of it's members, the command might fail due to improper target for querying for said features.

This PR adds a test for this edge-case where we expect it to fail with current code. It also adds a fix for this, and updates the test to expect success.

While populating available features, the current code does a `Fuzzy` search which might lead to searching for features in a wrong member package. If we change it to an `Exact` query, we get back the proper member to search within.
2023-12-29 18:46:27 +00:00
bors 04b6aed4d5 Auto merge of #13216 - rustaceanclub:master, r=epage
Remove repetitive words
2023-12-29 13:01:22 +00:00
cui fliter 5c7fbd80f2 Remove repetitive words
Signed-off-by: cui fliter <imcusg@gmail.com>
2023-12-29 13:55:24 +08:00
sanchit e46d80e24e Fixes #13121: Use Exact query during populating features. Update test
fix target output
2023-12-29 10:03:54 +05:30
bors 312ad26ca3 Auto merge of #13212 - Brooooooklyn:master, r=epage
Add cargo:rustc-cdylib-link-arg into RESERVED_PREFIXES list

After https://github.com/rust-lang/cargo/pull/12201 was merged, the `cargo:rustc-cdylib-link-arg` in build script no longer works
```rs
println!("cargo:rustc-cdylib-link-arg=-Wl");
println!("cargo:rustc-cdylib-link-arg=-undefined");
println!("cargo:rustc-cdylib-link-arg=dynamic_lookup");
```
2023-12-29 02:04:16 +00:00
sanchit 61f6248a07 add test expecting failure: adding features from git repo w multiple packages 2023-12-29 04:54:50 +05:30
LongYinan 7aaf2752ad
Add cargo:rustc-cdylib-link-arg into RESERVED_PREFIXES list 2023-12-28 11:28:22 +08:00
bors 1f70597241 Auto merge of #13203 - linyihai:subcommand-doc, r=weihanglo
chore(doc): doc for custom subcommands look up.

### What does this PR try to resolve?

as the https://github.com/rust-lang/cargo/issues/13194 metions, the lookup rules for custom subcommands are only reflected in comments inside the code, and it is time to inform users of this behavior through documentation.

### How should we test and review this PR?

### Additional information
2023-12-27 12:07:18 +00:00
bors ac6bbb3329 Auto merge of #13209 - weihanglo:link, r=epage
docs: fix link to nightly doc of cargo-util-schemas

should be https://doc.rust-lang.org/nightly/nightly-rustc/cargo_util_schemas/
2023-12-26 23:22:08 +00:00
bors d711ac06c1 Auto merge of #13206 - shivdhar:patch-1, r=weihanglo
doc: improve word usage
2023-12-26 22:38:22 +00:00
Weihang Lo 6e9cf8513d
fix(trim-paths): remap common prefix only
New remap rules for git/registry dependencies:

* Git dependencies: remove ~/.cargo/git/checkouts prefix.
* Registry dependencies: remove ~/.cargo/registry/src prefix.

This make the remap rules fixed to a finite number,
minimizing the burden for users to configure debuggers.
2023-12-26 13:24:59 -05:00
Weihang Lo 79f09db818
docs: fix link to nightly doc of cargo-util-schemas
https://doc.rust-lang.org/nightly/nightly-rustc/cargo_util_schemas/
2023-12-26 11:41:24 -05:00
bors 308ceee7fa Auto merge of #13205 - weihanglo:install, r=hi-rustin
fix: clarify `--path` is the installation source not destination

### What does this PR try to resolve?

There is a misunderstanding of “default location” mentioned in `cargo install --help`.
I don't think one-line explanation helps much there, So remove that imprecise description.

This PR also add more "from" for places mentioning installation sources.

### How should we test and review this PR?

Read the new help text.
2023-12-26 16:17:54 +00:00
Weihang Lo eb8870f098
docs(cargo-install): clarify default location is about "sources" 2023-12-26 10:42:57 -05:00
Weihang Lo 48cffc6729
fix(cargo-install): clarify --path is installation source 2023-12-26 10:42:57 -05:00
Weihang Lo 14ef091bd0
fix(cargo-install): remove imprecise install root descriptions 2023-12-26 10:42:57 -05:00
Lin Yihai d71b2bc5df chore(doc): doc for custom subcommands 2023-12-26 14:19:48 +08:00
Shiv Dhar d148d690e9
doc: improve word usage 2023-12-26 02:40:08 +05:30
bors 4e792c2858 Auto merge of #13202 - hi-rustin:rustin-patch-spec-example, r=weihanglo
refactor: give some better examples for package ID spec
2023-12-25 14:51:31 +00:00
hi-rustin ad18dd017b refactor: give some better examples for package ID spec
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2023-12-25 10:08:27 +08:00
bors c2408a712e Auto merge of #13201 - hi-rustin:rustin-patch-build-script-typo, r=weihanglo
chore: fix a typo
2023-12-25 02:03:27 +00:00
hi-rustin 1687fb8513 chore: fix a typo
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2023-12-25 09:39:44 +08:00
bors d45969a781 Auto merge of #12201 - hi-rustin:rustin-patch-build-script, r=epage
Extend the build directive syntax with `cargo::`
2023-12-24 03:06:43 +00:00
hi-rustin dec9e8cc1b Add tests for msrv check
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2023-12-23 13:24:53 +08:00
hi-rustin 0e42a8ae6d Add msrv check for new syntax
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2023-12-23 13:24:46 +08:00
hi-rustin a76564b9ba Update the dirty reason message
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2023-12-23 13:17:55 +08:00
hi-rustin eac79ec152 Update other docs to use cargo:: syntax
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2023-12-23 13:17:55 +08:00
hi-rustin ed9dc44f47 Update other tests to use cargo:: syntax
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2023-12-23 13:17:55 +08:00
hi-rustin 9eeffbf0d7 Add some syntax tests
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2023-12-23 13:17:55 +08:00
hi-rustin bd230e810c Update build script docs
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2023-12-23 13:17:55 +08:00
hi-rustin dfb2795ffe Update build script tests to use cargo::
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2023-12-23 13:17:55 +08:00
hi-rustin 25365d904c Use syntax_prefix to improve error message
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2023-12-23 13:17:55 +08:00
hi-rustin 56fdb1d0b6 Add parse_metadata to prase metadata
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2023-12-23 13:17:55 +08:00
hi-rustin 9ebe3b332a Extend the build directive syntax with cargo::
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2023-12-23 13:17:55 +08:00
bors 74ef21bb3f Auto merge of #13195 - Urgau:check-cfg-rework-comment, r=weihanglo
Rework `--check-cfg` generation comment

While working on something related to `--check-cfg`, I looked back at this comment and realized it could be improved, so here is my PR improving it.
2023-12-22 23:38:58 +00:00
Urgau 2dafb340dc Rework --check-cfg generation comment 2023-12-22 18:15:54 +01:00