[rustdoc] Simplify module rendering and HTML tags handling
Extracted code from rust-lang/rust#145458.
This PR simplifies the rendering of modules, in particular the HTML tags handling. Instead of having all items in a `vec`, we make a map with their types as key, allowing to then iterate over the types, which allows us to open and close the HTML tag at every turn without the need to check if a tag was opened or not, or to check it's still the same kind of type.
For a better review experience: enable "Hide whitespace", the diff will be much smaller.
r? `@notriddle`
Add TidyFlags and merge DiagCtx
Adds a struct `TidyFlags` and merges it with `DiagCtx` into `TidyCtx`. Removes the need to pass `bless` into individual check functions in tidy.
fix: Don't add diff symbol to unchanged lines
When rendering a "multi-line" suggestion with the [`Diff`](dc1feabef2/compiler/rustc_errors/src/emitter.rs (L3078)) format, `rustc` uses a [diff symbol](dc1feabef2/compiler/rustc_errors/src/emitter.rs (L3017-L3022)) for
[any line that has a highlight part](dc1feabef2/compiler/rustc_errors/src/emitter.rs (L2705-L2713)). This includes highlight parts that are highlighting nothing, i.e., a span of `0..0`. This leads `rustc` to add a diff symbol unnecessarily to lines that have no changes and are not highlighted. This PR makes it so that `rustc` will not add a diff symbol to lines that contain no changes/highlights.
Note: This PR is part of my ongoing effort to have `rustc` use `annotate-snippets` for rendering. This change will make it so that `rustc` and `annotate-snippets` will match in this case.
feat(rustdoc): `--emit=depinfo` output to stdout via `-`
rustdoc's `--emit=depinfo` flag now supports using `-` to write the output to stdout,
aligning with rustc's behavior.
This will fix <https://github.com/rust-lang/rust/issues/147649>.
### How to review
* The first commit demonstrates that `rustdoc --emit=depinfo=-` hasn't yet supported emitting to stdout.
* The second implements it and the diff shows how the behavior changes.
[rustdoc] Check `doc(cfg())` even of private/hidden items
Fixes regression found out by `@fmease` [here](https://github.com/rust-lang/rust/pull/138907#discussion_r2382597615).
In short: the pass which checks the `doc(cfg())` attributes needed to be moved before the private/hidden stripping items passes.
Fix invalid jump to def link generated on derive attributes
Fixes https://github.com/rust-lang/rust/issues/147820.
The issue was that we only handled bang macros whereas we should handle all of them.
r? `@notriddle`
docs(style): Specify the frontmatter style
Taken from [a style team discussion](https://github.com/rust-lang/style-team/issues/212#issuecomment-3185911143).
Assumptions on my part:
- I specify that frontmatter fences should not have trailing whitespace
- We aren't specifying when to include the infostring (one idea being if there is no shebang)
- Keep it simple and have a single example instead of showing allowed several variations
Tracking issue: rust-lang/rust#136889Closesrust-lang/style-team#212
refactor: Move to anstream + anstyle for styling
`rustc` uses [`termcolor`](https://crates.io/crates/termcolor) for styling and writing, while `annotate-snippets` uses [`anstyle`](https://crates.io/crates/anstyle) for styling and currently writes directly to a `String`. When rendering directly to a terminal, there isn't/shouldn't be any differences. Still, there are differences in the escape sequences, which leads to slightly different output in JSON and SVG tests. As part of my work to have `rustc` use `annotate-snippets`, and to reduce the test differences between the two, I switched `rustc` to use `anstlye` and [`anstream`](https://crates.io/crates/anstream) for styling and writing.
The first commit migrates to `anstyle` and `anstream` and notably does not change the output. This is because it includes extra formatting to ensure that `anstyle` + `anstream` match the current output exactly. Most of this code is unnecessary, as it adds redundant resets or uses 256-color (8-bit) when it could be using 4-bit color. The subsequent commits remove this extra formatting while maintaining the correct output when rendered.
[Zulip discussion](https://rust-lang.zulipchat.com/#narrow/channel/147480-t-compiler.2Fdiagnostics/topic/annotate-snippets.20hurdles)
Add NonNull pattern types
These are the final piece missing for
* https://github.com/rust-lang/rust/pull/136006
We cannot use the previous scheme of using an integer range for raw pointers, as we're not just changing the layout of raw pointers anymore, but also the type representation. And we can't represent "any provenance or NonZero<usize>" natively as patterns. So I created a new `!null` pattern. Since this is all unstable representation stuff for replacing rustc_layout_scalar_range_start with pattern types, the divergence from normal patterns is fine, especially since T-lang seems interested in exploring general negation patterns
r? `@BoxyUwU`
compiletest: More directive handling tweaks
- Follow-up to rust-lang/rust#147903.
---
These are some more preparatory changes that were extracted from a larger overhaul of directive handling that I'm still working on.
---
The revision check was introduced by rust-lang/rust#61778, and later modified by rust-lang/rust#113603. It doesn't appear to be doing anything particularly load-bearing (since a bogus mode seems to cause a panic later anyway), and getting rid of it avoids the need to pass the current test revision to directive-handling code.
- rust-lang/rust#61778
- rust-lang/rust#113603
r? jieyouxu
compiletest: Don't set `TARGET` for non run-make tests
There are a few tests that were using `TARGET` to quietly do nothing on `i586` targets, but it's cleaner to just add support for `//@ ignore-i586` instead.
This lets us get rid of an unsafe `env::set_var` in compiletest, which really should have been setting the environment variable on individual build/run subprocess commands anyway.
- The original code and tests were introduced way back in rust-lang/rust#39068
If something like this is needed again in the future, please set environment
variables for the build and run subprocesses, instead of setting them on the
compiletest process.