7275 Commits

Author SHA1 Message Date
Ed Page
b674a60384 fix(frontmatter): Be more specific about trailing character span 2025-09-16 11:43:20 -05:00
Ed Page
5b4d0cfad8 fix(frontmatter): Add more visible context to errors 2025-09-16 11:38:03 -05:00
Ed Page
b6326d3255 fix(frontmatter): Have too few error match too many on close 2025-09-16 11:10:32 -05:00
Ed Page
0cbd02f093 fix(fontmatter): Specialize the extra frontmatter close for dashes
For comparison, rustc's message is:

> error: frontmatter close does not match the opening
>   --> $DIR/mismatch-1.rs:1:1
>    |
> LL |   ---cargo
>    |   ^--
>    |   |
>    |  _the opening here has 3 dashes...
>    | |
> LL | |
> LL | | ----
>    | |_---^
>    |   |
>    |   ...while the close has 4 dashes
2025-09-16 11:06:53 -05:00
Ed Page
1b25322d8e fix(frontmatter): Be more direct in trailing close character error
For comparison, the rustc error is:

> error: extra characters after frontmatter close are not allowed
>   --> $DIR/extra-after-end.rs:2:1
>    |
> LL | ---cargo
>    | ^^^^^^^^
2025-09-16 11:06:53 -05:00
Ed Page
60bcd83510 fix(frontmatter): Be more direct in unclosed error
For comparison, rustc's message is:

> error: unclosed frontmatter
>   --> $DIR/frontmatter-whitespace-2.rs:1:1
>    |
> LL | / ---cargo
> ...  |
> LL | |
>    | |_^
>    |
> note: frontmatter opening here was not closed
>   --> $DIR/frontmatter-whitespace-2.rs:1:1
>    |
> LL | ---cargo
>    | ^^^
2025-09-16 11:06:53 -05:00
Ed Page
16d979fca9 fix(manifest): Be more direct in infostring errors 2025-09-15 21:04:21 -05:00
Weihang Lo
32497862ac
Clarify warning for using features or default-features in patch (#15953)
### What does this PR try to resolve?

When attempting to substitute a local version of a dependency, since the
`patch` section uses syntax similar to a dependency (and the
documentation even says "The syntax is similar to the `[dependencies]`
section", it's natural to assume that other things from `[dependencies]`
also work, such as `features` or `default-features`. Attempting to use
them produces this warning:

> patch for `crate-name-here` uses the features mechanism.
> default-features and features will not take effect because the patch
dependency does not support this mechanism

The phrasing "the patch dependency does not support this mechanism"
makes it seem at first glance like `patch` just doesn't support this at
all. But the actual problem is that the user needs to move the
`features`/`default-features` keys to an entry in `dependencies`
instead.

Closes #13522

### How to test and review this PR?

This applies the review feedback from #13522 that the author didn't have
a chance to get back to.
2025-09-13 20:11:08 +00:00
Josh Triplett
5030f231ba Clarify warning for using features or default-features in patch
When attempting to substitute a local version of a dependency, since the
`patch` section uses syntax similar to a dependency (and the
documentation even says "The syntax is similar to the `[dependencies]`
section", it's natural to assume that other things from `[dependencies]`
also work, such as `features` or `default-features`. Attempting to use
them produces this warning:

> patch for `crate-name-here` uses the features mechanism.
> default-features and features will not take effect because the patch dependency does not support this mechanism

The phrasing "the patch dependency does not support this mechanism"
makes it seem at first glance like `patch` just doesn't support this at
all. But the actual problem is that the user needs to move the
`features`/`default-features` keys to an entry in `dependencies`
instead.

Modify the message, to make this more obvious.

Modify the corresponding warning for `replace` as well.

Update tests accordingly.
2025-09-12 14:03:29 -05:00
Weihang Lo
6d221efc4d
fix(future): Report all content as a single Report (#15943)
### What does this PR try to resolve?

This changes the future-incompat message to be reported in a single
`Report`. The primary motivation is to cleanup the output compared to
taking the existing note's and aligning all content with the first line
which is what would happen otherwise in #15917.

In preparation for this, the message was cleaned up and made more like
what a rustc message might look like.

### How to test and review this PR?
2025-09-12 18:23:40 +00:00
Josh Triplett
840aff8377 Eliminate the last three "did you mean" warning phrasings
Inspired by https://github.com/rust-lang/cargo/pull/15138 , this
eliminates the last three instances.

Also rephrase a comment that implied the use of "did you mean"
suggestions.
2025-09-12 08:48:47 -05:00
Weihang Lo
b10679fc26
fix(info): Suggest a more universal cargo tree command (#15954)
### What does this PR try to resolve?

Passing a package to `--package` is for workspace members; we need to
pass it to `--invert`.

### How to test and review this PR?

This is part of #14993

While I think we should instead improve the `cargo tree` command to help
users with `--all-features`, we can at least take the other improvement
from #14991.
2025-09-12 13:00:22 +00:00
Craig Macomber
5ed8d67df9 fix(info): Suggest a more universal cargo tree command
Passing a package to `--package` is for workspace members; we need to
pass it to `--invert`.

This is part of #14993
2025-09-11 20:10:02 -05:00
Ed Page
2c5b4dfca9 fix(future): Report all content as a single Report 2025-09-11 17:15:42 -05:00
Ed Page
8e1cdcfb55 fix(future): Remove gap between item and its children 2025-09-11 17:15:42 -05:00
Ed Page
54ce51c343 fix(future): Lead with non-capital letter
Per rustc dev guide
2025-09-11 17:15:42 -05:00
Ed Page
155255fe41 fix(future): Lead with the suggested action 2025-09-11 17:15:42 -05:00
Ed Page
95aa52c177 fix(future): Indent potential candidates
This better matches other sub-lists
2025-09-11 17:15:42 -05:00
Ed Page
1b9265ca73 fix(future): Remove leading newline to match note conventions 2025-09-11 17:15:42 -05:00
Ed Page
8682394e7b fix(future): Be consistent in suggestion spacing 2025-09-11 17:15:42 -05:00
Ed Page
322b82a2e0 test(future): Serialize output to avoid unordered
Parallel isn't part of this test and it makes snapshot updating
annoying.
2025-09-11 17:15:42 -05:00
Ed Page
5736aad97a fix(publish): Switch the 'ctrl-c on wait' line to a help message
Unsure if this should be two groups or one group with a message.

If its one group, then we'll have a decorative line and then the `help:`
will be further indented.

I went with what is closer to how we do things today.  We can always
re-evaluate at a later point.
2025-09-11 17:02:25 -05:00
Ed Page
1865ef6834 fix(frontmatter): Try alternative len code fences
Of the non-ideal error cases mentioned in #15939, this is likely the one
people will hit the most and so important for us to improve.
2025-09-11 15:59:11 -05:00
Ed Page
90b68c87f4 fix(manifest): Show error source to users
Several parts of this are not ideal yet
- Frontmatter close should show the open and show the EOF, instead of
  pointing at the open
- Trailing content on close will usually have a newline
- Multiple frontmatters should show the original frontmatter
- Some content, like supported infostrings, should go in a help
- Ideally we try to recover on no closing and instead point out a
  mismatched open/close

But this is still an improvement over nothing!
2025-09-08 16:06:29 -05:00
Ed Page
da2eafe024 test(help): Ensure consistent behavior regardless of rustup use 2025-09-10 15:25:35 -05:00
Ed Page
2e231072f4 test(manifest): Fix test output order
As this is an unordered test, sometimes snapshot updating can mess up
the line order.
2025-09-08 21:04:05 -05:00
Ed Page
4909d78973 fix(frontmatter): Report script manifest errors for the right line number 2025-09-04 16:15:04 -05:00
Ed Page
578ab7cc45 test(script): Show line numbers are off 2025-09-04 14:56:33 -05:00
Weihang Lo
3ceb2cb250
fix(cli): Adjust messages to match rustc (#15928)
### What does this PR try to resolve?

Fixes #12740

This is also prep for #15917, #15922

Changes:
- `note` changes from Cyan to Bright Green
- `cargo info` had to be changed because the header and context colors
became the same
- Switch to Bright colors which is usually redundant with Bold but that
is theme dependent
- `warning` only changes to Bright on Windows which is to work around a
shell issue on some Windows versions
  - except for `PLACEHOLDER` to tell it apart from `LITERAL`
- the `:` in `note:` is no longer bolded to match rustc

### How to test and review this PR?

### Notes

While annotate-snippets does not have a style for every one of our
styles, I updated our manual styles to be similar to annotate snippets.

For annotate snippets color definitions, see
d38b08b81d/src/renderer/mod.rs (L41-L78)
2025-09-08 04:10:39 +00:00
Ed Page
19f1d1561c fix: Switch from --nocapture to --no-capture
`--no-capture` was added in 1.88, with `--nocapture` being
soft-deprecated.
2025-09-05 10:33:00 -05:00
Ed Page
eac1ad1cd3 fix(shell): Don't bold the colon after error/warn/note 2025-09-05 09:40:24 -05:00
Ed Page
883cbb22e5 test(credential): Switch more expected results to snapshots
Had to deal with manually updating these when changing notes
2025-09-05 09:24:38 -05:00
Ed Page
7d6d673e23 fix(cli): Adjust terminal styles to match rustc
Fixes #12740
2025-09-04 16:35:40 -05:00
Ed Page
c8a15f324f fix(publish): Don't generate final artifacts 2025-09-02 15:29:04 -05:00
Ed Page
3f857e9dd4 test(publish): Show the build-dir behavior 2025-09-02 13:21:35 -05:00
Scott Schafer
022dc5b381
chore: Address most typos 2025-09-02 18:15:50 -06:00
Scott Schafer
d36c326926
chore(deps): update rust crate annotate-snippets to 0.12.1 2025-09-02 15:43:38 -06:00
Scott Schafer
2ef151bdc9
fix: Emit inline help after first snippet 2025-09-02 15:43:37 -06:00
Ed Page
57c97cc190 test(script): Switch frontmatter tests to end-to-end
This will make it easier to validate error improvements I'm working on
as well as make it easier to update from rust-lang/rust
2025-08-29 16:11:59 -05:00
Ed Page
79b6548c13 test(script): Pull out test mod 2025-08-29 16:11:59 -05:00
Ed Page
db6891f244 fix(cli): Show the bad manifest path
In most cases, this will just be what you passed on the command line.
Even when its not, that likely represents a programmer error.

I mostly did this to help see what was the cause of a test failure.
2025-08-29 15:42:44 -05:00
Weihang Lo
a6c58d4305
test: avoid hardcoded target spec json (#15880)
Read a real target spec JSON so we no longer need to hardcode
a target spec JSON here.
Cargo itself should not care about the spec schema.

Let's stop bothering compiler contributors.

* https://github.com/rust-lang/rust/pull/144443
* https://github.com/rust-lang/rust/pull/145764#issuecomment-3216104449
* [#t-compiler > Is it possible to add a commit to a submodule? @
💬](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Is.20it.20possible.20to.20add.20a.20commit.20to.20a.20submodule.3F/near/535865215)
2025-08-26 23:05:12 +00:00
Ed Page
b54b92cc5f test(add): Ensure an empty frontmatter is handled properly
There are corner cases with empty frontmatters, so I wanted to ensure
this case works now and going forward
2025-08-26 15:12:19 -05:00
Ed Page
865dfe26d1 test(add): Ensure escaping is preserved
I cannot think of a programmatic way to require escaping when going from no frontmatter to a frontmatter
or to require more escaping than is already present.
2025-08-26 15:09:44 -05:00
Ojus Chugh
d2a6dcb43e fix(publish): Show remaining packages to be published 2025-08-25 14:45:02 -05:00
Ojus Chugh
f36cb83e98 fix(publish): Report which package failed to publish 2025-08-25 14:44:29 -05:00
Ojus Chugh
688ec9e9ef test(publish): Add test demonstrating error messages during workspace publish rate limiting 2025-08-25 14:38:07 -05:00
Weihang Lo
56f44bb212
test: avoid hardcoded target spec json
Read a real target spec JSON so we no longer need to hardcode
a target spec JSON here.
Cargo itself should not care about the spec schema.

Let's stop bothering compiler contributors.
2025-08-23 22:26:08 -04:00
Weihang Lo
4434ed8a2a
suggest workspace hints for boolean dependencies (#15507)
### What does this PR try to resolve?
via issue #15505, Cargo currently errors on
```toml
[dependencies]
crc32fast = true
```
with a message about `expected a version string or a detailed
dependency` It doesn’t hint that you can depend on a workspace member.
This PR updates `cargo` so that when you write dep = true, the error
also suggests:
```toml
dep = { workspace = true }
dep.workspace = true
```

### How should we test and review this PR?
In a workspace crate’s Cargo.toml, add
```toml
[dependencies]
crc32fast = true
```
Run `cargo build` and you should see the enhanced error with the two
workspace hints.

### Additional information

Regarding support for int/float, we only need a special case for boolean
because they’re the only values that get the `workspace hint`.
Everything else just uses the normal detailed dependency error
2025-08-21 14:31:55 +00:00
Scott Schafer
069723ebff
fix(unknown_lints): Make emitted_source come before other groups 2025-08-19 16:19:40 -06:00