70 Commits

Author SHA1 Message Date
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
Guillaume Gomez c06a076634 Put back the doc_cfg code behind a nightly feature 2025-09-27 11:29:49 +02:00
Guillaume Gomez 63aefe0737 Strenghten checks for doc(auto_cfg(show/hide)) attributes 2025-09-27 11:29:48 +02:00
Guillaume Gomez 6537278e11 Update rustdoc tests 2025-09-27 11:29:48 +02:00
binarycat 82c4018619 fix ICE in rustdoc::invalid_html_tags 2025-09-22 14:57:36 -05:00
Guillaume Gomez 3205e4db0f Add new ui tests for rustdoc::bare_urls 2025-09-10 18:44:20 +02:00
binarycat 15a8999aed refactor rustdoc::invalid_html_tags tag parser
previously, this lint did not distinguish between `<img` and `<img>`,
and since the latter should be accepted under html5,
the former was also accepted.

the parser now also handles multi-line tags and multi-line attributes.
2025-08-21 15:00:01 -05:00
binarycat e50fed79a8 add regression test for #145529 2025-08-21 15:00:00 -05:00
binarycat 87d7d80cec adjust more unit tests to reflect more aggressive intra-doc linting 2025-07-24 11:17:13 -05:00
Guillaume Gomez 3b5525bc42 Improve code and documentation 2025-06-23 16:12:49 +02:00
Guillaume Gomez a0d64177f0 Add ui test for redundant_explicit_links rustdoc lint for items coming from expansion 2025-06-23 16:02:33 +02:00
binarycat 3005a09fed rustdoc: improve diagnostics on raw doc fragments
1. rustdoc::bare_urls doesn't output
   invalid suggestions if source_span_for_markdown_range
   fails to find a span

2. source_span_for_markdown_range tries harder to
   return a span by applying an additional diagnostic

fixes https://github.com/rust-lang/rust/issues/135851
2025-05-22 12:31:28 -05:00
Vadim Petrochenkov 4d64990690 compiletest: Require //~ annotations even if error-pattern is specified 2025-04-03 11:08:55 +03:00
Vadim Petrochenkov 8d5109aa6e compiletest: Support matching on diagnostics without a span 2025-03-25 17:33:09 +03:00
Esteban Küber f0845adb0c Show diff suggestion format on verbose replacement
```
error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields
  --> $DIR/attempted-access-non-fatal.rs:7:15
   |
LL |     let _ = 2.l;
   |               ^
   |
help: if intended to be a floating point literal, consider adding a `0` after the period and a `f64` suffix
   |
LL -     let _ = 2.l;
LL +     let _ = 2.0f64;
   |
```
2025-02-10 20:21:39 +00:00
Zalathar 835fbcbcab Remove the -test suffix from normalize directives 2024-12-27 19:58:16 +11:00
Esteban Küber 19e44f4db4 Point at lint name instead of whole attr for gated lints
```
warning: unknown lint: `test_unstable_lint`
  --> $DIR/warn-unknown-unstable-lint-inline.rs:4:10
   |
LL | #![allow(test_unstable_lint, another_unstable_lint)]
   |          ^^^^^^^^^^^^^^^^^^
   |
   = note: the `test_unstable_lint` lint is unstable
   = help: add `#![feature(test_unstable_lint)]` to the crate attributes to enable
   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
note: the lint level is defined here
  --> $DIR/warn-unknown-unstable-lint-inline.rs:3:9
   |
LL | #![warn(unknown_lints)]
   |         ^^^^^^^^^^^^^

warning: unknown lint: `test_unstable_lint`
  --> $DIR/warn-unknown-unstable-lint-inline.rs:4:29
   |
LL | #![allow(test_unstable_lint, another_unstable_lint)]
   |                              ^^^^^^^^^^^^^^^^^^^^^
   |
   = note: the `test_unstable_lint` lint is unstable
   = help: add `#![feature(test_unstable_lint)]` to the crate attributes to enable
   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
note: the lint level is defined here
  --> $DIR/warn-unknown-unstable-lint-inline.rs:3:9
   |
LL | #![warn(unknown_lints)]
   |         ^^^^^^^^^^^^^
```

This is particularly relevant when there are multiple lints in the same `warn` attribute. Pointing at the smaller span makes it clearer which one the warning is complaining about.
2024-12-18 19:27:44 +00:00
Esteban Küber 9f1044ef76 Account for /// when rendering multiline spans
Don't consider `///` and `//!` docstrings to be empty for the purposes of multiline span rendering.
2024-12-13 18:48:33 +00:00
Esteban Küber 49a22a4245 Filter empty lines, comments and delimiters from previous to last multiline span rendering 2024-12-12 23:36:27 +00:00
Esteban Küber 65a54a7f27 Tweak multispan rendering
Consider comments and bare delimiters the same as an "empty line" for purposes of hiding rendered code output of long multispans. This results in more aggressive shortening of rendered output without losing too much context, specially in `*.stderr` tests that have "hidden" comments.
2024-12-12 23:36:27 +00:00
Guillaume Gomez 7cf3f8ba7a Do not emit missing_doc_code_examples rustdoc lint on module and a few other items 2024-11-28 21:22:06 +01:00
Guillaume Gomez 632fed891d Improve mistyped docblock attribute warning messages 2024-09-28 18:38:11 +02:00
Esteban Küber 140392b041 Adjust rustdoc automatic link suggestion
Use more accurate spans for multipart suggestion.
2024-07-04 00:40:04 +00:00
xFrednet d9e32a69a7 RFC 2373: Update tests for rustdoc for lint_reasons 2024-06-25 17:50:55 +02:00
xFrednet 8b14e23dce RFC 2383: Stabilize lint_reasons 🎉 2024-06-25 17:22:22 +02:00
Esteban Küber cc9631a371 When displaying multispans, ignore empty lines adjacent to ...
```
error[E0308]: `match` arms have incompatible types
   --> tests/ui/codemap_tests/huge_multispan_highlight.rs:98:18
    |
6   |       let _ = match true {
    |               ---------- `match` arms have incompatible types
7   |           true => (
    |  _________________-
8   | |             // last line shown in multispan header
...   |
96  | |
97  | |         ),
    | |_________- this is found to be of type `()`
98  |           false => "
    |  __________________^
...   |
119 | |
120 | |         ",
    | |_________^ expected `()`, found `&str`

error[E0308]: `match` arms have incompatible types
   --> tests/ui/codemap_tests/huge_multispan_highlight.rs:215:18
    |
122 |       let _ = match true {
    |               ---------- `match` arms have incompatible types
123 |           true => (
    |  _________________-
124 | |
125 | |         1 // last line shown in multispan header
...   |
213 | |
214 | |         ),
    | |_________- this is found to be of type `{integer}`
215 |           false => "
    |  __________________^
216 | |
217 | |
218 | |         1 last line shown in multispan
...   |
237 | |
238 | |         ",
    | |_________^ expected integer, found `&str`
```
2024-03-18 16:25:36 +00:00
Guillaume Gomez 8e817af3ae Update ui tests 2024-02-29 14:43:43 +01:00
sisungo da37c8f1f2 Fix tests that are affected by this change 2024-02-29 14:59:10 +08:00
许杰友 Jieyou Xu (Joe) 6e48b96692 [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
Ralf Jung 1254ee48c4 remove illegal_floating_point_literal_pattern lint 2024-01-26 17:25:02 +01:00
George-lewis d56cdd48cb Bless tests
Update tests
2024-01-13 12:46:58 -05:00