Commit Graph

100 Commits

Author SHA1 Message Date
Guillaume Gomez
116fdd183a Fix tidy error 2026-08-12 14:59:31 +02:00
Guillaume Gomez
e73699643d Split doc comment so lints are always emitted in the right order 2026-08-12 14:43:00 +02:00
Michael Howell
7253b43d6d Fix backslashes and line breaks in footnote lint 2026-08-12 11:39:31 +02:00
Guillaume Gomez
92dcc5b490 Add extra "broken_footnote" lint ui test 2026-08-12 11:39:31 +02:00
Guillaume Gomez
261a21353e Improve description of new rustdoc lints 2026-08-12 11:39:31 +02:00
Guillaume Gomez
9f30b845d0 Add ui test for new unused_footnote_definition rustdoc lint 2026-08-12 11:39:31 +02:00
Guillaume Gomez
37b8c5389e Add ui test for rustdoc broken_footnote lint 2026-08-12 11:39:31 +02:00
Jonathan Brouwer
085f52778e Rollup merge of #159633 - nnethercote:attr-suggestions, r=JonathanBrouwer
Improve workings of attribute suggestions

`AttrItem` span tracking improved in rust-lang/rust#159587, which lets us slightly simplify the workings of attribute suggestions.

r? @JonathanBrouwer
2026-07-26 15:47:14 +02:00
Nicholas Nethercote
00fb38532c Make attribute suggestions work at the level of attr items
Similar to the commit before the last.
2026-07-26 22:25:19 +10:00
Jacob Pratt
3fc9b07570 Rollup merge of #158709 - notriddle:html-lint-interleaving, r=camelid,GuillaumeGomez
rustdoc: warn on improperly interleaved HTML/MD

Enhances the `rustdoc::invalid_html_tags` lint to warn in cases where pulldown-cmark will produce invalid HTML because the Markdown and HTML are improperly nested.

As an extreme example, this code does not do what it looks like it does, and it doesn't produce a warning under current nightly, either:

```markdown
Figure 1: an X
<svg viewBox="0 0 10 10">
<path
    d="M0 10L10 0M10 10L0 0"
    stroke="black"
>
</svg>
```

This pull request makes it warn:

```text
error: unopened HTML tag `svg`
  --> $DIR/invalid-html-tags.rs:285:5
   |
LL | /// <svg viewBox="0 0 10 10">
   |     ---- does not match this unclosed tag
...
LL | /// >
   |     - because the Markdown paragraph is interrupted by this block quote
LL | /// </svg>
   |     ^^^^^^ this unopened tag
```

See also: https://talk.commonmark.org/t/thoughts-on-changing-supported-html-syntax-to-include-the-dangling-closing-angle-bracket/3827
2026-07-26 00:21:40 -04:00
Nicholas Nethercote
c4621ddc66 Improve consistency of "malformed foo attribute input" error messages
Similar to the previous three commits.
2026-07-24 13:01:21 +10:00
uselessgoddess
8a07fcc3f6 fix base_urls with periods 2026-07-18 12:09:58 +03:00
Michael Howell
fe11f5ecfd rustdoc: lint MD in HTML script/style
This is probably not what the user wants:

    error: nested Markdown emphasis in HTML `style` tag
      --> $DIR/invalid-html-tags-correct-script-style.rs:11:16
       |
    LL | /// One <style>*emph*</style>
       |                ^^^^^^ Markdown translates this into HTML, but the browser parses it as CSS
       |
    help: to turn off Markdown parsing, put the tag at the start of the line
       |
    LL ~ /// One
    LL ~ /// <style>*emph*</style>
       |
2026-07-16 13:30:38 -07:00
Jonathan Brouwer
ce7f185fd6 Rollup merge of #156618 - notriddle:rustdoc-lint-ignore-cli, r=lolbinarycat
rustdoc: test ignoring rustc lints in CLI

This works, but I couldn't find any tests for it.
2026-07-11 19:05:12 +02:00
Michael Howell
2200ed1c97 Add requested description comment 2026-07-10 21:13:04 -07:00
Jacob Pratt
9e7a9bad54 Rollup merge of #157561 - notriddle:do-not-destroy-function-name, r=lolbinarycat
rustdoc: do not include extra stuff in span

This change prevents our lints from returning a span with stuff in it that isn't actually part of the doc comment. When that happens, it returns `None` instead.

Fixes https://github.com/rust-lang/rust-clippy/issues/16169, since the bug was reported against the `clippy::doc_paragraphs_missing_punctuation` lint but is actually a bug in `source_span_for_markdown_range_inner`.
2026-07-09 20:09:09 -04:00
Michael Howell
015e8af7ec rustdoc: test ignoring rustc lints in CLI 2026-07-09 16:01:47 -07:00
Michael Howell
c9be91c624 Clean up and test paragraph and table warn 2026-07-09 09:53:04 -07:00
Michael Howell
cb61eb4f92 rustdoc: add tests for MD/HTML interleaving 2026-07-03 00:08:01 -07:00
Michael Howell
3ffc0fbdd2 rustdoc: warn on improperly interleaved HTML/MD 2026-07-03 00:08:01 -07:00
Michael Howell
162a90c245 Handle block doc comments better 2026-06-26 09:50:53 -07:00
Michael Howell
9438aac0c2 Handle span failure in redundant_explicit_links 2026-06-26 09:50:53 -07:00
Michael Howell
84f289674c rustdoc: do not include extra stuff in span
This change prevents our lints from returning a span with stuff in it
that isn't actually part of the doc comment. When that happens, it
returns `None` instead.
2026-06-26 09:17:52 -07:00
Guillaume Gomez
f22107c1c7 Update rustdoc to use new doc_cfg syntax 2026-06-26 12:27:24 +02:00
Jonathan Brouwer
7a14504a86 Remove has_delayed_lints optimization 2026-06-21 10:01:09 +02:00
León Orell Valerian Liehr
e967d0cb28 rustdoc: Also run lint unused_doc_comments 2026-06-14 15:22:53 +02:00
bors
4d276d7fdb Auto merge of #155307 - Urgau:rustdoc-stabilize-remap-path-prefix, r=GuillaumeGomez
Stabilize `--remap-path-prefix` in rustdoc



# Stabilization report of  `--remap-path-prefix` in rustdoc

## Summary

`rustc` supports remapping source paths prefixes as a best effort in all compiler generated output, including compiler diagnostics, debugging information, macro expansions, documentation, doctests, etc.

This is useful for normalizing build products, for example, by removing the current directory out of the paths emitted into object files.

This stabilization stabilize the same flag used by `rustc` in `rustdoc`.

There are no tracking issue.

Stabilization was discussed at the last meeting, [#t-rustdoc/meetings > 2026-04-13 @ 💬](https://rust-lang.zulipchat.com/#narrow/channel/393423-t-rustdoc.2Fmeetings/topic/2026-04-13/near/585264347).

### What is stabilized

The rustdoc `--remap-path-prefix` flag is being stabilized by this PR. (It's equivalent to rustc flag)

It permits remapping (as a best effort) source path prefixes in all output, including diagnostics, debug information, macro expansions, generated documentation, etc.

It takes a value of the form `FROM=TO` where a path prefix equal to `FROM` is rewritten to the value `TO`.

#### Example

```sh
rustdoc src/lib.rs --remap-path-prefix="$PWD=/foo"
```

### What isn't stabilized

Neither `--remap-path-scope` (~~soon to be added as unstable in `rustdoc`~~ https://github.com/rust-lang/rust/issues/155451) or the already unstable in `rustc` `documentation` scope are being stabilized or added here.

## Design

### Implementation history

- rust-lang/rust#107099

### Unresolved questions

There are no unresolved questions.

### Post-implementation changes

The implementation has evolved with `rustc`, but no changes to the flag it-self have been made.

### Nightly extensions

The `documentation` scope, which currently can only be set from `rustc`, as we need to add an equivalent to the `--remap-path-scope` flag, ~~which is planned~~ (EDIT: https://github.com/rust-lang/rust/issues/155451), but not required, the current `--remap-path-prefix` defaults to the `all` scope, like `rustc`.

### Doors closed

We are committing to having to having a flag that permits remapping paths. The compiler team already made the same commitment.

## Feedback

### Call for testing

No call for testing has been done.

### Nightly use

Unable to determine. A [GitHub search](https://github.com/search?q=%20%2F--remap-path-prefix%2F&type=code) only seems to only reveals the `rustc` usage (over 6k though).

Rust-for-Linux is using the [flag](e80d033851/Makefile (L1151-L1153)).

## Implementation

### Major parts

- rust-lang/rust#107099
- rust-lang/rust#149709
- rust-lang/rust#150172
- rust-lang/rust#151589

### Coverage

- [`tests/rustdoc-ui/remap-path-prefix-failed-doctest-output.rs`](12f35ad39e/tests/rustdoc-ui/remap-path-prefix-failed-doctest-output.rs)
- [`tests/rustdoc-ui/remap-path-prefix-invalid-doctest.rs`](12f35ad39e/tests/rustdoc-ui/remap-path-prefix-invalid-doctest.rs)
- [`tests/rustdoc-ui/remap-path-prefix-macro.rs`](12f35ad39e/tests/rustdoc-ui/remap-path-prefix-macro.rs)
- [`tests/rustdoc-ui/remap-path-prefix-passed-doctest-output.rs`](12f35ad39e/tests/rustdoc-ui/remap-path-prefix-passed-doctest-output.rs)
- [`tests/rustdoc-ui/lints/remap-path-prefix-lint.rs`](12f35ad39e/tests/rustdoc-ui/lints/remap-path-prefix-lint.rs)
- [`tests/rustdoc-html/import-remapped-paths.rs`](12f35ad39e/tests/rustdoc-html/import-remapped-paths.rs)
- [`tests/rustdoc-html/macro/external-macro-src.rs`](12f35ad39e/tests/rustdoc-html/macro/external-macro-src.rs)

### Outstanding bugs

There are no outstanding bugs regarding `--remap-path-prefix` in `rustdoc`.

There are [caveats and limitation](https://doc.rust-lang.org/nightly/rustc/remap-source-paths.html#caveats-and-limitations) in `rustc`, but they mostly concern generated object files, which we don't really have. 

### Outstanding FIXMEs

There are no FIXME regarding `--remap-path-prefix`.

## Acknowledgments

- @edward-shen
- @Urgau
2026-05-21 22:46:41 +00:00
Michael Howell
0344a02261 rustdoc: add test case for --cap-lints=allow 2026-05-15 11:13:16 -07:00
Michael Howell
5f2e455a1c rustdoc: add test case for -Drustdoc:: CLI param
This works, but I couldn't find any test cases for it.
2026-05-15 10:46:35 -07:00
Urgau
d3bdea115d Stabilize --remap-path-prefix in rustdoc 2026-04-17 18:52:21 +02:00
Tony Wu
b967de6255 rustdoc: fix issues with redundant_explicit_links 2026-04-17 19:17:42 +08: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
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
binarycat
6fd96ddc3d rustdoc_missing_doc_code_examples: lint on macro_rules macros 2026-04-01 15:17:23 -05:00
Guillaume Gomez
6d3b7809cf Add more tests for rustdoc missing_doc_code_examples lint 2026-03-18 17:28:55 +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
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
Guillaume Gomez
ef1e4e65b7 Move checks from check_doc_attrs directly into rustc_attr_parsing 2026-01-11 18:36:03 +01: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
Guillaume Gomez
4936973d49 Fix ui tests 2025-12-10 12:28:05 +01:00
Guillaume Gomez
e4f57dd4b3 Finish fixing ui tests 2025-12-10 12:27:34 +01:00
Guillaume Gomez
9c8c67bfdd Fix warning messages 2025-12-10 12:27:34 +01:00
Aarav Desai
0715745c1c Move rustdoc tests to appropriate subdirectories
Reorganize rustdoc tests into their correct subdirectories for better
categorization:
- Move lint-related tests to rustdoc-ui/lints/
- Move intra-doc link tests to rustdoc-ui/intra-doc/
- Move deref-related tests to rustdoc-ui/deref/
- Move doc-cfg test to rustdoc/doc-cfg/

This improves test organization and makes it easier to find tests
related to specific rustdoc functionality.
2025-10-26 19:16:41 -07:00
James Barford-Evans
2c1e796ed0 Improve missing create level error message 2025-10-08 11:35:20 +01:00
Guillaume Gomez
553308b115 Improve code and better check doc(cfg(...)) attributes 2025-09-27 11:29:49 +02:00
Guillaume Gomez
1561efe41a Add code documentation, improve code and improve error message 2025-09-27 11:29:49 +02:00