about summary refs log tree commit diff
path: root/src/librustdoc/passes
AgeCommit message (Collapse)AuthorLines
2025-09-29Move doc cfg propagation pass before items stripping passesGuillaume Gomez-2/+2
2025-09-27Improve code and fix typoGuillaume Gomez-2/+1
2025-09-27Apply first review round suggestionsGuillaume Gomez-13/+1
2025-09-27Add code documentation, improve code and improve error messageGuillaume Gomez-5/+9
2025-09-27Put back the `doc_cfg` code behind a nightly featureGuillaume Gomez-1/+5
2025-09-27Remove useless code in `propagate_doc_cfg.rs`Guillaume Gomez-18/+1
2025-09-27Implement RFC 3631Guillaume Gomez-40/+94
2025-09-26Add new `tyalias` intra-doc link disambiguatorGuillaume Gomez-0/+2
2025-09-24Rollup merge of #146897 - lolbinarycat:rustdoc-invalid_html_tags-ice-146890, ↵Matthias Krüger-1/+2
r=GuillaumeGomez fix ICE in rustdoc::invalid_html_tags fixes https://github.com/rust-lang/rust/issues/146890 r? ```@GuillaumeGomez```
2025-09-22fix ICE in rustdoc::invalid_html_tagsbinarycat-1/+2
2025-09-21Port #[macro_export] to the new attribute parsing infrastructureJonathan Brouwer-2/+3
Co-authored-by: Anne Stijns <anstijns@gmail.com>
2025-09-12Don't store defaultness for inherent impl itemsCameron Steffen-1/+1
2025-09-10Simplify code for `find_raw_urls`Guillaume Gomez-17/+11
2025-09-10Improve suggestion in case a bare URL is surrounded by bracketsGuillaume Gomez-13/+40
2025-08-28Add new `doc(attribute = "...")` attributeGuillaume Gomez-3/+7
2025-08-21rustdoc::invalid_html_tags(unclosed comment): fix off by one in spanbinarycat-1/+1
2025-08-21refactor rustdoc::invalid_html_tags tag parserbinarycat-169/+380
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-13Rollup merge of #145153 - joshtriplett:macro-kinds-plural, r=petrochenkovGuillaume Gomez-12/+16
Handle macros with multiple kinds, and improve errors (I recommend reviewing this commit-by-commit.) Switch to a bitflags `MacroKinds` to support macros with more than one kind Review everything that uses `MacroKind`, and switch anything that could refer to more than one kind to use `MacroKinds`. Add a new `SyntaxExtensionKind::MacroRules` for `macro_rules!` macros, using the concrete `MacroRulesMacroExpander` type, and have it track which kinds it can handle. Eliminate the separate optional `attr_ext`, now that a `SyntaxExtension` can handle multiple macro kinds. This also avoids the need to downcast when calling methods on `MacroRulesMacroExpander`, such as `get_unused_rule`. Integrate macro kind checking into name resolution's `sub_namespace_match`, so that we only find a macro if it's the right type, and eliminate the special-case hack for attributes. This allows detecting and report macro kind mismatches early, and more precisely, improving various error messages. In particular, this eliminates the case in `failed_to_match_macro` to check for a function-like invocation of a macro with no function-like rules. Instead, macro kind mismatches now result in an unresolved macro, and we detect this case in `unresolved_macro_suggestions`, which now carefully distinguishes between a kind mismatch and other errors. This also handles cases of forward-referenced attributes and cyclic attributes. ---- In this PR, I've minimally fixed up `rustdoc` so that it compiles and passes tests. This is just the minimal necessary fixes to handle the switch to `MacroKinds`, and it only works for macros that don't actually have multiple kinds. This will panic (with a `todo!`) if it encounters a macro with multiple kinds. rustdoc needs further fixes to handle macros with multiple kinds, and to handle attributes and derive macros that aren't proc macros. I'd appreciate some help from a rustdoc expert on that. ---- r? ````````@petrochenkov````````
2025-08-12rustdoc: Minimal fixes to compile with `MacroKinds`Josh Triplett-12/+16
This makes the minimal fixes necessary for rustdoc to compile and pass existing tests with the switch to `MacroKinds`. It only works for macros that don't actually have multiple kinds, and will panic (with a `todo!`) if it encounters a macro with multiple kinds. rustdoc needs further fixes to handle macros with multiple kinds, and to handle attributes and derive macros that aren't proc macros.
2025-08-12Rollup merge of #144921 - lolbinarycat:rustdoc-intra-doc-gfm-141866, ↵Stuart Cook-2/+14
r=fmease,GuillaumeGomez Don't emit `rustdoc::broken_intra_doc_links` for GitHub-flavored Markdown admonitions like `[!NOTE]` fixes rust-lang/rust#141866
2025-08-11don't emit rustdoc::broken_intra_doc_links for stuff like [!NOTE]binarycat-2/+14
2025-08-05rustdoc: fix caching of intra-doc links on reexportsbinarycat-1/+6
2025-08-02Rollup merge of #132748 - ↵Samuel Tardieu-3/+29
lolbinarycat:rustdoc-intra-doc-link-warn-more-54191, r=GuillaumeGomez get rid of some false negatives in rustdoc::broken_intra_doc_links rustdoc will not try to do intra-doc linking if the "path" of a link looks too much like a "real url". however, only inline links (`[text](url)`) can actually contain a url, other types of links (reference links, shortcut links) contain a *reference* which is later resolved to an actual url. the "path" in this case cannot be a url, and therefore it should not be skipped due to looking like a url. fixes https://github.com/rust-lang/rust/issues/54191 to minimize the number of false positives that will be introduced, the following heuristic is used: If there's no backticks, be lenient revert to old behavior. This is to prevent churn by linting on stuff that isn't meant to be a link. only shortcut links have simple enough syntax that they are likely to be written accidentlly, collapsed and reference links need 4 metachars, and reference links will not usually use backticks in the reference name. therefore, only shortcut syntax gets the lenient behavior. here's a truth table for how link kinds that cannot be urls are handled: | | is shortcut link | not shortcut link | |--------------|--------------------|-------------------| | has backtick | never ignore | never ignore | | no backtick | ignore if url-like | never ignore |
2025-07-31remove rustc_attr_data_structuresJana Dönszelmann-1/+1
2025-07-24rustdoc::broken_intra_doc_links: only be lenient with shortcut linksbinarycat-5/+22
collapsed links and reference links have a pretty particular syntax, it seems unlikely they would show up on accident. Co-authored-by: León Orell Valerian Liehr <me@fmease.dev>
2025-07-24rustdoc::broken_intra_doc_links: no backticks = use old behaviorbinarycat-1/+3
this is in an effort to reduce the amount of code churn caused by this lint triggering on text that was never meant to be a link. a more principled hierustic for ignoring lints is not possible without extensive changes, due to the lint emitting code being so far away from the link collecting code, and the fact that only the link collecting code has access to details about how the link appears in the unnormalized markdown.
2025-07-24get rid of some false negatives in rustdoc::broken_intra_doc_linksbinarycat-3/+10
rustdoc will not try to do intra-doc linking if the "path" of a link looks too much like a "real url". however, only inline links ([text](url)) can actually contain a url, other types of links (reference links, shortcut links) contain a *reference* which is later resolved to an actual url. the "path" in this case cannot be a url, and therefore it should not be skipped due to looking like a url. Co-authored-by: Michael Howell <michael@notriddle.com>
2025-07-19Fix clippy lints in librustdocGuillaume Gomez-27/+24
2025-07-03setup CI and tidy to use typos for spellchecking and fix few typosklensy-2/+2
2025-06-23Improve code and documentationGuillaume Gomez-12/+22
2025-06-23Do not emit `redundant_explicit_links` rustdoc lint if the doc comment comes ↵Guillaume Gomez-22/+50
from expansion
2025-06-20Auto merge of #142794 - tgross35:rollup-iae7okj, r=tgross35bors-18/+10
Rollup of 9 pull requests Successful merges: - rust-lang/rust#142331 (Add `trim_prefix` and `trim_suffix` methods for both `slice` and `str` types.) - rust-lang/rust#142491 (Rework #[cold] attribute parser) - rust-lang/rust#142494 (Fix missing docs in `rustc_attr_parsing`) - rust-lang/rust#142495 (Better template for `#[repr]` attributes) - rust-lang/rust#142497 (Fix random failure when JS code is executed when the whole file was not read yet) - rust-lang/rust#142575 (Ensure copy* intrinsics also perform the static self-init checks) - rust-lang/rust#142650 (Refactor Translator) - rust-lang/rust#142713 (mbe: Refactor transcription) - rust-lang/rust#142755 (rustdoc: Remove `FormatRenderer::cache`) r? `@ghost` `@rustbot` modify labels: rollup
2025-06-19Extract Translator structCameron Steffen-18/+10
2025-06-19De-dup common code from `ExternalCrate` methodsYotam Ofek-1/+1
2025-05-31Rollup merge of #141740 - nnethercote:hir-ItemKind-field-order, r=fee1-deadMatthias Krüger-1/+1
Hir item kind field order A follow-up to rust-lang/rust#141675. r? `@fee1-dead`
2025-05-29Rework `#[doc(cfg(..))]` checks as distinct pass in rustdocUrgau-0/+81
2025-05-30Reorder fields in `hir::ItemKind` variants.Nicholas Nethercote-1/+1
Specifically `TyAlias`, `Enum`, `Struct`, `Union`. So the fields match the textual order in the source code. The interesting part of the change is in `compiler/rustc_hir/src/hir.rs`. The rest is extremely mechanical refactoring.
2025-05-28Rollup merge of #141411 - lolbinarycat:rustdoc-link-proc-macro-91274, ↵Trevor Gross-8/+28
r=GuillaumeGomez rustdoc: linking to a local proc macro no longer warns fixes https://github.com/rust-lang/rust/issues/91274 tried to keep the fix general in case we ever have any other kind of item that occupies multiple namespaces simultaniously.
2025-05-27rustdoc: linking to a local proc macro no longer warnsbinarycat-8/+28
fixes https://github.com/rust-lang/rust/issues/91274 Co-authored-by: Guillaume Gomez <guillaume1.gomez@gmail.com>
2025-05-23Rollup merge of #136400 - lolbinarycat:rustdoc-link-lint-135851, ↵Matthias Krüger-4/+8
r=GuillaumeGomez Improve handling of rustdoc lints when used with raw doc fragments. 1. `rustdoc::bare_urls` no longer outputs incoherent suggestions if `source_span_for_markdown_range` returns None, instead outputting no suggestion 2. `source_span_for_markdown_range` has one more heuristic, so it will return `None` less often. 3. add ui test to make sure we don't emit nonsense suggestions. fixes https://github.com/rust-lang/rust/issues/135851
2025-05-22rustdoc: improve diagnostics on raw doc fragmentsbinarycat-4/+8
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-22Remove `is_empty` check in `filter_assoc_items_by_name_and_namespace`.Nicholas Nethercote-6/+1
It was added in #140052, but the subsequent changes in #140252 means it is no longer necessary. (Indeed, `Ident`s cannot be empty any more.)
2025-05-18Remove rustc_attr_data_structures re-export from rustc_attr_parsingmejrs-1/+1
2025-05-09Remove `Ident::empty`.Nicholas Nethercote-6/+15
All uses have been removed. And it's nonsensical: an identifier by definition has at least one char. The commits adds an is-non-empty assertion to `Ident::new` to enforce this, and converts some `Ident` constructions to use `Ident::new`. Adding the assertion requires making `Ident::new` and `Ident::with_dummy_span` non-const, which is no great loss. The commit amends a couple of places that do path splitting to ensure no empty identifiers are created.
2025-05-06rustdoc: remove unportable markdown lint and old parserMichael Howell-149/+0
Follow up https://github.com/rust-lang/rust/pull/127127
2025-04-25Rollup merge of #137096 - ehuss:stabilize-doctest-xcompile, r=fmeaseMatthias Krüger-2/+2
Stabilize flags for doctest cross compilation This makes the following changes in preparation for supporting doctest cross-compiling in cargo: - Renames `--runtool` and `--runtool-arg` to `--test-runtool` and `--test-runtool-arg` to maintain consistency with other `--test-*` arguments. - Stabilizes the `--test-runtool` and `--test-runtool-arg`. These are needed in order to support cargo's `target.runner` option which specifies a runner to execute a cross-compiled doctest (for example, qemu). - Stabilizes the `--enable-per-target-ignores` flag by removing it and making it unconditionally enabled. This makes it possible to disable a doctest on a per-target basis, which I think will be helpful for rolling out this feature. These changes were suggested in https://rust-lang.zulipchat.com/#narrow/channel/266220-t-rustdoc/topic/stabilizing.20doctest.20xcompile/near/409281127 The intent is to stabilize the doctest-xcompile feature in cargo. This will help ensure that for projects that do cross-compile testing that their doctests are also covered. Currently there is a somewhat surprising behavior that they are ignored. Closes https://github.com/rust-lang/rust/issues/64245 try-job: x86_64-msvc-1
2025-04-19Fix error when an intra doc link is trying to resolve an empty associated itemGuillaume Gomez-1/+6
2025-04-15Move two methods from `AssocKind` to `AssocItem`.Nicholas Nethercote-2/+2
Because all the other similar methods are on `AssocItem`.
2025-04-10Rollup merge of #138167 - ↵Matthias Krüger-10/+12
GuillaumeGomez:rustdoc-hidden-stripper-improvement, r=camelid Small code improvement in rustdoc hidden stripper This is a very minor code improvement following https://github.com/rust-lang/rust/pull/137534. It doesn't change anything about the performance issue. r? ```@notriddle```
2025-04-03Remove `LintExpectationId` from `Level` variantsOli Scherer-2/+2