Commit Graph

545 Commits

Author SHA1 Message Date
Tony Wu b967de6255 rustdoc: fix issues with redundant_explicit_links 2026-04-17 19:17:42 +08:00
Urgau ae6dbdd9f0 Add --remap-path-scope as unstable in rustdoc 2026-04-15 21:26:48 +02:00
Jacob Pratt 1700a21d10 Rollup merge of #155126 - folkertdev:target-object-format, r=Urgau
add `cfg(target_object_format = "...")`

tracking issue: https://github.com/rust-lang/rust/issues/152586

I'm implementing the predicate as `target_object_format`, because that's what is useful to me (for testing `#[link_section = "..."]` where `mach-o` has some extra restrictions) and maps cleanly to the `BinaryFormat` enum that is used internally. There is still room for a future `target_executable_format` when there is a use case.

cc @joshtriplett as the lang sponsor of this feature, @workingjubilee as the author of the proposal.

r? JonathanBrouwer a sidequest from the sidequest that is https://github.com/rust-lang/rust/pull/155065
2026-04-11 21:12:20 -04:00
Folkert de Vries 6bcd172f5a add cfg(target_object_format = "...") 2026-04-11 14:12:39 +02:00
Jacob Pratt ca34f771c0 Rollup merge of #154827 - scrabsha:push-zuosxmmnzkrq, r=jdonszelmann
distinguish "expected a single argument" and "expected an argument" on attribute parsing
2026-04-11 04:50:15 -04:00
Jonathan Brouwer 65745a1b95 Revert #152369 because of multiple regressions
The regressions are documented in the PR comments.
This reverts commit 2972b5e, reversing changes made to f908263.
2026-04-09 18:53:59 +02:00
Sasha Pourcelot 362e0f9160 special case expected_single_argument when no argument is provided 2026-04-09 16:39:58 +00:00
Scott Schafer 63ed113d84 chore: Update annotate-snippets to 0.12.15 2026-04-06 14:48:52 -06:00
bors 2972b5e59f Auto merge of #152369 - Bryntet:lint_attrs, r=JonathanBrouwer,jdonszelmann
Port lint attributes to attribute parser

*[View all comments](https://triagebot.infra.rust-lang.org/gh-comments/rust-lang/rust/pull/152369)*

Tracking issue: rust-lang/rust#131229

Ports `#[allow]`, `#[deny]`, `#[expect]`, `#[forbid]`, and `#[warn]` to being parsed attrs

I tried my best to make this PR as small as possible, it was difficult. I hope it isn't too difficult to review

r? @JonathanBrouwer 
r? @jdonszelmann
2026-04-03 13:51:50 +00:00
Edvin Bryntesson bd864efa70 bless tests and tidy
also removes E0452 and splits
`tests/rustdoc-ui/lints/renamed-lint-still-applies` into 2 tests

this is because of delayed warn lint being lost on compiler aborting on
error
2026-04-03 11:08:11 +02:00
Matthias Krüger 7a740135c2 Rollup merge of #154696 - lolbinarycat:rustdoc-missing_doc_code_examples-macro_rules, r=GuillaumeGomez
rustdoc_missing_doc_code_examples: lint on macro_rules macros

part of rust-lang/rust#154640

accidentally built this on top of rust-lang/rust#154644, but since that PR is already approved it should be fine if we just wait for it to be merged.

r? @GuillaumeGomez
2026-04-03 09:30:17 +02:00
Jacob Pratt 62a9658ca5 Rollup merge of #154590 - scrabsha:push-xzmtpsntoxwm, r=jdonszelmann
Make #[cfg] suggest any or all on #[cfg(a, b)]
2026-04-02 20:53:32 -04:00
Sasha Pourcelot 4e019ac160 make cfg parser suggest any or all on #[cfg(a, b)] 2026-04-02 14:13:11 +00:00
Jacob Adam 3888a633b7 Add a regression test for rustdoc ICEing on negative Deref/DerefMut impls 2026-04-01 23:05:41 +01:00
binarycat 6fd96ddc3d rustdoc_missing_doc_code_examples: lint on macro_rules macros 2026-04-01 15:17:23 -05:00
Guillaume Gomez 0ba684b705 Rollup merge of #154453 - chenyukang:yukang-fix-154383, r=notriddle
Fix ice in rustdoc of private reexport

Fixes rust-lang/rust#154383

The root cause is rustdoc could still try to resolve links for source docs that resolver did not cache in `ResolveDocLinks::Exported` mode. The test case will not crash with `--document-private-items` option, which will use `ResolveDocLinks::All`.

The fix makes rustdoc skip link resolution based on the source `DefId` of each doc fragment, so its behavior stays aligned with resolver's logic here: https://github.com/chenyukang/rust/blob/dc5cb1719eed6ac9275fe93d914d32141606b2ac/compiler/rustc_resolve/src/late.rs#L685
2026-03-29 00:06:52 +01:00
Ralf Jung d400f17222 Rollup merge of #154394 - aDotInTheVoid:in-one-word-he-told-me-secret-of-success-in-testing-normalize, r=fmease
Normalize rustc path prefix when testing `-Z track-diagnostics`

Fixes https://github.com/rust-lang/rust/issues/154392
2026-03-28 13:15:52 +01:00
Alona Enraght-Moony d10baae9ce Normalize rustc path prefix when testing -Z track-diagnostics
Fixes https://www.github.com/rust-lang/rust/issues/154392
2026-03-28 12:01:38 +00:00
yukang dc5cb1719e Fix ice in rustdoc of private reexport 2026-03-27 12:10:58 +08:00
yukang 7e95a22e1f rustdoc rejects html emits with json output 2026-03-27 08:59:51 +08:00
Stuart Cook 319df85a09 Rollup merge of #154048 - GuillaumeGomez:missing_doc_code_examples-improvement, r=lolbinarycat
Don't emit rustdoc `missing_doc_code_examples` lint on impl items

@lolbinarycat realized in [this comment](https://github.com/rust-lang/rust/pull/153964#discussion_r2953956702) that we weren't testing some cases for the `missing_doc_code_examples` lint. Turns out that it was not handling this case well. =D

So in short: `missing_doc_code_examples` lint should not be emitted on impl items and this PR fixes that.

r? @lolbinarycat
2026-03-20 15:33:05 +11:00
Guillaume Gomez 6d3b7809cf Add more tests for rustdoc missing_doc_code_examples lint 2026-03-18 17:28:55 +01:00
Matthias Krüger 81549a3cc1 Rollup merge of #153881 - estebank:const-e0308, r=Kivooeo
Provide more context on type errors in const context

- On `const` and `static` point at the type (like we do for let bindings)
- On fn calls, point at const parameter in fn definition
- On type, point at const parameter in type definition
- On array type lengths, explain that array length is always `usize`
- On enum variant discriminant, mention `repr`
- On default field value using type parameter, provide more context (Fix rust-lang/rust#147748)
2026-03-15 16:52:44 +01:00
Michael Howell 77eea39d45 rustdoc: error out on --test with --emit
These options don't behave reasonably when combined right now, and there
are no tests and no docs for how they should.

For the short term, make this a fatal error. If we decide to assign this
some semantics, then we can do that at any time.
2026-03-14 19:06:32 -07:00
Esteban Küber 724c1a02e1 Update rustdoc-ui test 2026-03-14 20:13:43 +00:00
Jynn Nelson 84442006ab Rustdoc lints on duplicate, unused, and stable features 2026-03-10 13:18:10 +01:00
Esteban Küber 37684bdfc5 Make all multipart suggestions verbose
The ShowAlways style of suggestions is usually easier to understand than the inline style.
2026-02-18 18:33:35 +00:00
Esteban Küber c73b3d20c6 Unify wording of resolve error
Remove "failed to resolve" and use the same format we use in other resolution errors "cannot find `name`".

```
error[E0433]: cannot find `nonexistent` in `existent`
  --> $DIR/custom_attr_multisegment_error.rs:5:13
   |
LL | #[existent::nonexistent]
   |             ^^^^^^^^^^^ could not find `nonexistent` in `existent`
```
2026-02-17 16:51:44 +00:00
Keith-Cancel 73a991fb9d Allow provisional mgca syntax of type const <IDENT> = <EXPR> to be reconized.
Revert, but without type const.

Update symbol for feature err, then update suggestion output, and lastly update tests that change because of those.

Update these new tests with the correct syntax, and few existing tests with the new outputs the merge with main added.

Fix for tidyfmt and some errors when manually resolving a merge conflicts.

Update these tests to use update error messages and type const syntax.

Update comments and error message to use new syntax instead of old type_const attribute.

Remove the type_const attribute

update some more tests to use the new syntax.

Update these test cases.

update feature gate test

Change gate logic for `mgca_type_const_syntax` to work also if `min_generic_const_args` is enabled.

Create a new feature gate that checks for the feature before expansion.

Make rustfmt handle the `type const` syntax correctly.

Add a convience method to check if a RhsKind is type const.

Rename `Const` discriminant to `Body` for `ConstItemRhsKind`

Give the `TraitItemKind` flag an enum instead of a simple bool to better describe what the flag is for.

Update formatting for these match statements.

Update clippy test to use type const syntax.

Update test to use type const syntax.

update rustfmt to match ast items.

Update clippy to match ast and hir items.

Few more test cases that used old attribute, instead of 'type const'

Update to match the output from the feature gate checks.

tidyfmt adjustments.

Update the is_type_const, so I can constrain record!(..) in encoder.rs

Update conditional compilation test.

Move the feature gate to after expansion to allow for cfg(...) to work.

Update some more tests to use the new syntax.

Update type const tests in associated-const-bindings to use new syntax.

Don't check based off the attribute, but the item here.

Update some tests outside of the const_generics folder that were using #[type_const]

update the tests in associated consts that use #[type_const] to use type const

Update these mgca tests with the type const syntax.

Add a flag to TraitItemKind for detecting type const for now. Maybe later change ItemConstRhs to have optional consts but that touches a lot more lines of code.

Don't need into for these now that it's a query.

Add is_type_const query to handle foreign def ids.

update this test to use type const syntax.

Fix logic here, we only want to lower if there is expression in this case.

Update built-in macros to use ConstItemRhsKind

Update more instance of the old ConstItemRhs.

Rename ConstItemKind to ConstItemRhsKind, I noticed there is a typed called ConstantItemKind, so add the Rhs to the name to avoid confusion.

Update lower to use ConstItemKind

Add an other helper method to check if the rhs kinda has an expr.

Update item parse to use ConstItemKind enum.

Felt the field name could a be little clear when editing a few other things.

Change the ConstItem struct see know if we have a type const or regular const.

Make sure this syntax is properly feature gated.
2026-02-09 07:59:24 -08:00
Jonathan Brouwer c1091da34c Fix existing messages in stderrs 2026-02-07 09:13:42 +01:00
Guillaume Gomez c910511cab Move remaining doc attribute parsing errors to warnings 2026-02-04 10:54:45 +01:00
Guillaume Gomez 6d713489d0 Make more doc attribute parsing error into future warnings 2026-02-04 10:54:45 +01:00
Guillaume Gomez 7dbbab63e2 Emit a future error warning for duplicate doc attribute 2026-02-04 10:54:44 +01:00
Jonathan Brouwer 775abf4f36 Rollup merge of #151449 - GuillaumeGomez:regression-test-for-151411, r=lolbinarycat
[rustdoc] Add regression test for #151411

Fixes rust-lang/rust#151411.

Seems like the ICE was already solved by https://github.com/rust-lang/rust/pull/151255. Well in any case, more regression tests won't hurt.

r? @lolbinarycat
2026-01-28 21:10:54 +01:00
Guillaume Gomez 35ccf18477 Add regression test for #151411 2026-01-28 00:23:30 +01:00
Esteban Küber 4a27be6972 Do not mention -Zmacro-backtrace for std macros that are a wrapper around a compiler intrinsic 2026-01-26 17:34:31 +00:00
Stuart Cook 0a5d1e8059 Rollup merge of #151255 - fix-rustdoc-ice-reexported-deprecated-note, r=lolbinarycat
rustdoc: Fix ICE when deprecated note is not resolved on the correct `DefId`

Supersedes https://github.com/rust-lang/rust/pull/151237.
Follow-up of rust-lang/rust#151120.

The `span` overlapping approach wasn't good enough so instead we now check if the reexport itself has the `deprecated` attribute, and if so, we resolve the path to the reexport `DefId`, otherwise we resolve it on the reexported item's `DefId`.

cc @Zalathar
r? @lolbinarycat
2026-01-20 18:00:10 +11:00
Guillaume Gomez 1faaa76961 Add regression test for ICE when deprecated note is not resolved on the correct DefId 2026-01-17 17:16:03 +01:00
León Orell Valerian Liehr ac8e8505b7 rustdoc: Stop unconditionally evaluating the initializer of associated consts 2026-01-17 12:12:36 +01:00
Jonathan Brouwer e33f5aa634 Rollup merge of #150934 - move-doc-attr-checks, r=JonathanBrouwer
Move some checks from `check_doc_attrs` directly into `rustc_attr_parsing`

Part of https://github.com/rust-lang/rust/issues/149865.

I also used this opportunity to remove the `id_is_crate_root` method.

Once this is merged, I think I'll try to see if we can remove `target_id` as well.

r? @JonathanBrouwer
2026-01-13 09:01:31 +01:00
Guillaume Gomez ef1e4e65b7 Move checks from check_doc_attrs directly into rustc_attr_parsing 2026-01-11 18:36:03 +01:00
Guillaume Gomez f9c71df88a Improve span for "unresolved intra doc link" on deprecated attribute 2026-01-09 20:36:52 +01:00
Folkert de Vries 3be74a7441 render intra-doc links in the #[deprectated] note 2026-01-08 11:35:33 +01:00
AprilNEA 4421270516 Merge associated_const_equality feature gate into MGCA
This removes `associated_const_equality` as a separate feature gate and makes it part of `min_generic_const_args` (mgca).

Key changes:
  - Remove `associated_const_equality` from unstable features, add to removed
  - Update all test files to use `min_generic_const_args` instead
  - Preserve the original "associated const equality is incomplete" error message by specially handling `sym::associated_const_equality` spans in `feature_gate.rs`
  - Rename FIXME(associated_const_equality) to FIXME(mgca)
2026-01-05 12:31:42 +08:00
Matthias Krüger 185f7dc044 Rollup merge of #149949 - JonathanBrouwer:error_cleanup, r=jdonszelmann
Cleanup of attribute parsing errors

Removes the specific `UnknownMetaItem` and `IllFormedAttributeInputLint` errors.
Note that `IllFormedAttributeInputLint` is not a lint, contrary to its name

r? ``````@jdonszelmann``````
2025-12-14 20:04:56 +01:00
Jonathan Brouwer ae39d3d9ab Improve spans of malformed attribute errors 2025-12-13 17:13:36 +01:00
bors 8188f6c808 Auto merge of #149709 - Urgau:overhaul-filenames, r=davidtwco
Overhaul filename handling for cross-compiler consistency

This PR overhauls the way we handle filenames in the compiler and `rmeta` in order to achieve achieve cross-compiler consistency (ie. having the same path no matter if the filename was created in the current compiler session or is coming from `rmeta`).

This is required as some parts of the compiler rely on consistent paths for the soundness of generated code (see rust-lang/rust#148328).

In order to achieved consistency multiple steps are being taken by this PR:
 - by making `RealFileName` immutable
 - by only having `SourceMap::to_real_filename` create `RealFileName`
   - currently `RealFileName` can be created from any `Path` and are remapped afterwards, which creates consistency issue
 - by also making `RealFileName` holds it's working directory, embeddable name and the remapped scopes
   - this removes the need for a `Session`, to know the current(!) scopes and cwd, which is invalid as they may not be equal to the scopes used when creating the filename

In order for `SourceMap::to_real_filename` to know which scopes to apply `FilePathMapping` now takes the current remapping scopes to apply, which makes `FileNameDisplayPreference` and company useless and are removed.

This PR is split-up in multiple commits (unfortunately not atomic), but should help review the changes.

Unblocks https://github.com/rust-lang/rust/pull/147611
Fixes https://github.com/rust-lang/rust/issues/148328
2025-12-13 14:32:09 +00:00
Guillaume Gomez d025cdef7d If there are too many suggestions for malformed attribute, do not suggest them 2025-12-12 14:55:17 +01:00
Urgau cefcd99c17 Fix normalization logic of the rustdoc extract doctests tests on Windows 2025-12-12 07:34:52 +01:00
bors c4dc70ee0a Auto merge of #149891 - matthiaskrgr:rollup-jh6xrhz, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - rust-lang/rust#142380 (Put negative implementors first and apply same ordering logic to foreign implementors)
 - rust-lang/rust#146584 (remove duplicated columns from `rustc_error_code::error_codes!`)
 - rust-lang/rust#148717 (Point at span within local macros even when error happens in nested external macro)
 - rust-lang/rust#149565 (rustdoc: Add unstable `--merge-doctests=yes/no/auto` flag)
 - rust-lang/rust#149770 (Rename some issue-* tests)
 - rust-lang/rust#149807 (Use ubuntu:24.04 for the `x86_64-gnu-miri` job)
 - rust-lang/rust#149850 (Remove "tidy" tool for `tests/rustdoc` testsuite)
 - rust-lang/rust#149863 (Do not suggest moving expression out of for loop when hitting `break` from desugaring)
 - rust-lang/rust#149867 (only resolve main in bin crates)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-12-12 06:30:06 +00:00