136 Commits

Author SHA1 Message Date
Ed Page
6ec8da96f4 fix(schema): Mark package.name as optional 2025-02-10 14:29:15 -06:00
Ed Page
5f529f792d test(toml): Verify missing package.name 2025-02-06 14:54:30 -06:00
Ed Page
f6514977ef
feat: add cargo pkgid support for cargo-script (#14961)
### What does this PR try to resolve?

close https://github.com/rust-lang/cargo/issues/14831

In this PR, we added the `cargo pkgid` support for the cargo-script.

For the package itself:

```console
cargo pkgid --manifest-path foo.rs
path+file:///my-project/foo.rs/foo#0.86.0
```

For its dependence:

```console
cargo pkgid --manifest-path foo.rs -p sqlx
registry+https://github.com/rust-lang/crates.io-index#sqlx@0.7.4
```

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

I have updated the unit tests and also added more test cases for it.

### Additional information

None
2025-02-04 19:52:07 +00:00
Rustin170506
d4c1eeeaa0 refactor: use manifest path as the key
Signed-off-by: Rustin170506 <techregister@pm.me>

fix
2025-01-20 21:53:13 +08:00
许杰友 Jieyou Xu (Joe)
17aaafd92f tests: relax bad_crate_type to only match error message prefix
So that the cargo test isn't sensitive to suggestions for known crate
types that a rustc PR <https://github.com/rust-lang/rust/pull/134720> is
trying to add.
2024-12-30 04:22:28 +08:00
Ed Page
81411ec545 feat: Stabilize Edition 2024 2024-11-25 09:27:09 -06:00
Ed Page
d2ec764995 fix(resolve): Dont show locking workspace members
This is for `cargo generate-lockfile` and when syncing the lockfile with
the manifest.
We still show it for `cargo update` because of `cargo update
--workspace`.

We hacked around this previously by filtering out the `num_pkgs==1` case
for single packages but this didn't help with workspaces.
2024-08-22 16:57:06 -05:00
Joe Birr-Pixton
b9fe71853e Correct diagnostic for TomlDebugInfo
This is missing the friendly aliases introduced in 3dbb474c.
2024-08-16 16:48:03 +01:00
Scott Schafer
eff4b74da3
test: Resolve bad_config deprecations 2024-06-12 13:31:55 -06:00
Ed Page
dc5ac62cab fix(test): Deprecate non-snapbox assertions
While this is noisy and hides other deprecations, I figured deprecations would
make it easier for people to discover what tasks remain and allow us to
divide and conquer this work rather than doing a heroic PR.
In theory, this will be short lived and we'll go back to seeing
deprecations in our tests.
2024-06-10 10:20:52 -05:00
Ed Page
c00c5cd1cf fix(add): Avoid escaping double-quotes by using string literals
Fixes #14002
2024-06-03 11:22:00 -05:00
Ed Page
fe0819ee9e fix(toml): Validate crates_types/proc-macro for bin like others
Turns out, we allow these fields, just in limited ways, so we need to be
consistent.

I limited when this applies to reduce noise from the user solving there
problem because they are unlikely to keep the field and switch it to the
opposite value
2024-05-01 19:36:30 -05:00
Ed Page
2c31fe33e8 test(toml): Show underscore behavior for bin targets 2024-05-01 19:35:53 -05:00
Ed Page
d59e7a3443 test(toml): Scope proc_macro2 tests to libs 2024-05-01 19:32:13 -05:00
Ed Page
aecb40baac fix(toml): Remove underscore field support in 2024
This is part of the 2024 Edition and is part of rust-lang/rust#123754 and #13629
2024-04-25 11:56:32 -05:00
bors
955503e1de Auto merge of #13800 - epage:u3, r=weihanglo
fix(toml): Don't double-warn when underscore is used in workspace dep

### What does this PR try to resolve?

This is prep for removing them in the 2024 Edition and is part of rust-lang/rust#123754 and #13629

Particularly, I wanted to make sure I didn't make things worse and in doing so found there was room for improvement.

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

### Additional information
2024-04-24 20:25:10 +00:00
Ed Page
751fd47d34 fix(toml): Don't double-warn when underscore is used in workspace dep 2024-04-24 14:22:23 -05:00
Ed Page
4cc82833bd test(toml): Show default_features warning for workspace dependencies 2024-04-24 13:51:31 -05:00
Ed Page
034ef3c27b fix(toml): Be more forceful with underscore/dash redundancy
During #13783, I had considered making the 2024 edition behavior a
"unused key" warning.  However, I'm being too lazy in piping the data
through correctly (and a hard error might be better to help users
transition).
2024-04-22 12:47:43 -05:00
Ed Page
d1f02476c2 fix(toml): Deprecate underscore fields 2024-04-18 16:15:34 -05:00
Ed Page
868662c480 test(toml): Show underscore field behavior 2024-04-18 14:57:12 -05:00
Ed Page
208d10d06d fix(toml): Switch the duplicate table warning to an unused key warning 2024-04-18 14:49:50 -05:00
Ed Page
265f93e913 test(toml): Be consistent on expected output formatting 2024-04-18 14:45:27 -05:00
Ed Page
d210644a1b test(toml): Switch from build to check for these bad_config 2024-04-18 14:40:04 -05:00
Ed Page
8520ec63b6 test(toml): Centralize underscore field tests 2024-04-18 14:38:05 -05:00
Ed Page
cf23e4b538 fix(toml)!: Disallow source-less dependencies
This is part of #13629

This turns deps like
```toml
foo = { optional = true }
```
from `version="*"` deps with a warning into errors.
This breaking change was deemed acceptable because this behavior has
been considered a bug from the beginning.
We have gotten little to no feedback about people wanting this behavior.

This improves our forwards-compatibility story as we can add new
dependency sources and they won't be considered a wildcard registry
dependency on older cargo.
2024-04-18 12:55:27 -05:00
Ed Page
14646e6af6 test: Make edition explicit on packages 2024-02-22 11:37:03 -06:00
Ed Page
e7e8d8748a fix(compiler): Clarify we're showing a profile name 2024-02-08 14:01:39 -06:00
Ed Page
db54c040ae fix(new): Print a 'Creating', rather than 'Created' status
This has bothered me about `cargo new` and `cargo init` for a while that
the output is read backwards, for example:
```diff
--- i/tests/testsuite/cargo_init/path_contains_separator/stderr.log
+++ w/tests/testsuite/cargo_init/path_contains_separator/stderr.log
@@ -1,3 +1,3 @@
+    Creating binary (application) package
 warning: the path `[ROOT]/case/test:ing/.` contains invalid PATH characters (usually `:`, `;`, or `"`)
 It is recommended to use a different name to avoid problems.
-     Created binary (application) package
```
2024-01-29 15:29:10 -06:00
Ed Page
675224b3a0 test(config): Shift to config.toml 2024-01-26 13:40:46 -06:00
Scott Schafer
0d62ae2fc3
feat: Add rustc style errors for manifest parsing 2023-12-15 13:30:10 -07:00
renovate[bot]
b4efcdbf32 chore(deps): update rust crate gix to 0.55.2 2023-11-01 00:12:37 +00:00
Weihang Lo
08c5e35f60
test(trim-paths): parsing in mainfest and config 2023-10-30 16:38:55 -04:00
David Tolnay
3871aecf3e
Improve deserialization errors of untagged enums 2023-08-27 16:27:08 -07:00
David Tolnay
58d042516e
Fill in more configuration deserialization and manifest deserialization tests 2023-08-27 16:14:29 -07:00
Ed Page
53dcd2f454 fix(manifest): Provide more context on sematic errors 2023-08-24 16:27:53 -05:00
Ed Page
511c17c961 fix(lock): Render source for serde errors
Before, we'd render the source for TOML syntax errors but not semantic errors.
Now we render for both.

Originally I changed `parse_document` to returned `T: DeserializeOwned`
but that adds an extra "could not parse TOML" which is both redundant
and makes it sound like its a syntax issue.
2023-08-24 16:27:37 -05:00
Ed Page
5cac7aa8c6 fix(toml): Remove redundant error messages 2023-08-24 16:19:48 -05:00
bors
b5177c6d46 Auto merge of #12001 - hi-rustin:rustin-patch-dep-empty, r=weihanglo
Improve error message for empty dep
2023-04-24 09:20:41 +00:00
hi-rustin
af0cd9fc5a Improve error message for empty dep
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2023-04-20 09:32:24 +08:00
jyn
8a9db7a020 Address review comments
- Update the documentation and doc-comments
- Improve the error message for parsing Cargo.toml
2023-04-12 12:05:14 -05:00
Joshua Nelson
d861dcf792 Allow named debuginfo options in Cargo.toml
Rustc supports these since rust-lang/rust#109808. It's technically
possible to set a named debuginfo level through `RUSTFLAGS`, but in
practice cargo always passes its own opinion of what the debuginfo level
is, so allow it to be configured through cargo too.
2023-04-11 15:06:02 -05:00
Sebastian Thiel
cfffda9ae5
add -Zgitoxide=fetch feature toggle and implementation.
This allows to use `gitoxide` for all fetch operations, boosting performance
for fetching the `crates.io` index by a factor of 2.2x, while being consistent
on all platforms.

For trying it, nightly builds of `cargo` can specify `-Zgitoxide=fetch`.
It's also possible to set the `__CARGO_USE_GITOXIDE_INSTEAD_OF_GIT2=1` environment
variable (value matters), which is when `-Zgitoxide=none` can be used
to use `git2` instead.

Limitations
-----------
Note that what follows are current shortcomings that will be addressed in future PRs.

- it's likely that authentication around the `ssh` protocol will work differently in practice
  as it uses the `ssh` program.
- clones from `file://` based crates indices will need the `git` binary to serve the locatl repository.
- the progress bar shown when fetching doesn't work like the orgiinal, but should already feel 'faster'.
2023-03-02 12:35:50 +01:00
bors
0c331721d9 Auto merge of #11725 - Muscraft:reduce-build-in-tests, r=ehuss
Switch some tests from `build` to `check`

#11341 brought up issues with cargo's `testsute` size and speed. One of the suggested fixes was switching most tests to `check` instead of `build`. This PR did that.

Before size on `nightly`: 4.4GB

After size on `nightly`: 4.2GB

Regex to find `build` in `tests/testsuite`: `cargo\(".*build.*\)`
Before: 1607
After: 626

Note I did not remove all `build` I only did the easy ones that required minimal changes. I also tried not to touch systems I was unsure about. There could be other uses of `build` I missed as well.

I still need to play around with `opt-level`, `debug=0`, and a few other tweaks, but there should be more time/memory to drop.

Each test file changed is in a commit of its own, so you should look commit by commit.
2023-02-21 23:27:36 +00:00
Scott Schafer
9708e6f62d refactor: Make two tests stderr not match their test name 2023-02-20 11:09:05 -06:00
Scott Schafer
9174c22744 chore: update build_config test to use check 2023-02-15 15:28:48 -06:00
Ed Page
6007f05a85 chore: Update to toml v0.6, toml_edit v0.18
`toml` replaces `toml_edit::easy`, using `toml_edit` as its parser.
2023-01-19 15:26:28 -06:00
Eric Huss
fab135885c Fix panic on ignored target dependency. 2023-01-04 18:44:51 -08:00
Arlo Siemsen
dd5134c7a5 Implement RFC 3289: source replacement ambiguity 2022-10-07 22:30:59 -05:00
Scott Schafer
ab18bd40d5 refactor(testsuite): Replace [project] with [package] 2022-09-26 09:51:16 -06:00