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
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
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>
|
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`.
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.
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
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
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
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.