about summary refs log tree commit diff
path: root/src/librustdoc/clean/mod.rs
AgeCommit message (Collapse)AuthorLines
2025-10-02Move doc_cfg-specific code into `cfg.rs`Guillaume Gomez-0/+1
2025-09-27Implement RFC 3631Guillaume Gomez-9/+1
2025-09-17Remove `DynKind`León Orell Valerian Liehr-1/+1
2025-09-12Don't store defaultness for inherent impl itemsCameron Steffen-1/+4
2025-09-12Split AssocContainer::{InherentImpl,TraitImpl}Cameron Steffen-9/+11
2025-09-12Rename AssocItemContainer -> AssocContainerCameron Steffen-10/+10
2025-09-01Remove dead code stemming from an old effects desugaringLeón Orell Valerian Liehr-4/+2
2025-08-13Rollup merge of #145153 - joshtriplett:macro-kinds-plural, r=petrochenkovGuillaume Gomez-3/+11
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-3/+11
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-11Propagate TraitImplHeader to hirCameron Steffen-3/+6
2025-08-08Reduce indirect assoc parent queriesCameron Steffen-1/+1
2025-07-31remove rustc_attr_data_structuresJana Dönszelmann-2/+2
2025-07-26Fix toolingJonathan Brouwer-31/+20
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-07-17parse `const trait Trait`Deadbeef-1/+1
2025-07-15Implement other logicstiif-1/+2
2025-07-13Retire hir::*ItemRef.Camille GILLOT-2/+2
2025-07-08Fix weird rustdoc output when single and glob reexport conflict on a nameGuillaume Gomez-21/+29
2025-07-06rustdoc: migrate BareFn -> FnPtrJubilee Young-2/+2
2025-07-04Same for typesMichael Goulet-2/+3
2025-07-04Remove Symbol for Named LateParam/Bound variantsMichael Goulet-41/+42
2025-07-03Rollup merge of #141831 - lolbinarycat:rustdoc-extern-reexport-135092, ↵Guillaume Gomez-8/+11
r=GuillaumeGomez rustdoc: fix attrs of locally reexported foreign items fixes rust-lang/rust#135092 also tweaks a few outdated/misleading comments. r? `@GuillaumeGomez`
2025-07-03Rollup merge of #143083 - JonathanBrouwer:rustdoc-fix, r=jdonszelmannJana Dönszelmann-1/+2
Fix rustdoc not correctly showing attributes on re-exports Fixes attributes not being shown correctly in rustdoc on re-exports Does this need to be backported to beta? r? ``@jdonszelmann``
2025-07-03setup CI and tidy to use typos for spellchecking and fix few typosklensy-1/+1
2025-06-27Fix rustdoc not correctly showing attributes with re-exportsJonathan Brouwer-1/+2
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-06-27rustdoc: fix attrs of locally reexported foreign itemsbinarycat-6/+9
2025-06-27rustdoc: add regression test for issue 135092binarycat-2/+2
2025-06-26Change const trait bound syntax from ~const to [const]Oli Scherer-3/+3
2025-06-16rustdoc: skip `MetaSized` boundsDavid Wood-1/+18
These should never be shown to users at the moment.
2025-06-10rustdoc: Refractor `clean_ty_generics`Alona Enraght-Moony-7/+7
2025-06-05Support middle::ty assoc const eq predicates againLeón Orell Valerian Liehr-79/+50
2025-06-05Rename `should_show_cast` to `should_fully_qualify`León Orell Valerian Liehr-11/+12
2025-06-03Overhaul `UsePath`.Nicholas Nethercote-2/+2
`UsePath` contains a `SmallVec<[Res; 3]>`. This holds up to three `Res` results, one per namespace (type, value, or macro). `lower_import_res` takes a `PerNS<Option<Res<NodeId>>>` result and lowers it into the `SmallVec`. This is pretty weird. The input `PerNS` makes it clear which `Res` belongs to which namespace, but the `SmallVec` throws that information away. And code that operates on the `SmallVec` tends to use iteration (or even just grabbing the first entry!) without knowing which namespace the `Res` belongs to. Even weirder! Also, `SmallVec` is an overly flexible type to use here, because it can contain any number of elements (even though it's optimized for 3 in this case). This commit changes `UsePath` so it also contains a `PerNS<Option<Res<HirId>>>`. This type preserves more information and is more self-documenting. The commit also changes a lot of the use sites to access the result for a particular namespace. E.g. if you're looking up a trait, it will be in the `Res` for the type namespace if it's present; it's silly to look in the `Res` for the value namespace or macro namespace. Overall I find the new code much easier to understand. However, some use sites still iterate. These now use `present_items` because that filters out the `None` results. Also, `redundant_pub_crate.rs` gets a bigger change. A `UseKind:ListStem` item gets no `Res` results, which means the old `all` call in `is_not_macro_export` would succeed (because `all` succeeds on an empty iterator) and the `ListStem` would be ignored. This is what we want, but was more by luck than design. The new code detects `ListStem` explicitly. The commit generalizes the name of that function accordingly. Finally, the commit also removes the `use_path` arena, because `PerNS<Option<Res>>` impls `Copy` (unlike `SmallVec`) and it can be allocated in the arena shared by all `Copy` types.
2025-05-31Rollup merge of #141740 - nnethercote:hir-ItemKind-field-order, r=fee1-deadMatthias Krüger-9/+9
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-1/+0
2025-05-30Reorder fields in `hir::ItemKind` variants.Nicholas Nethercote-9/+9
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-27Rollup merge of #140894 - Urgau:check-cfg-rustdoc, r=GuillaumeGomezTrevor Gross-0/+1
Make check-cfg diagnostics work in `#[doc(cfg(..))]` This PR makes it so that the check-cfg `unexpected_cfgs` lint, is correctly emitted in `rustdoc`'s `#[doc(cfg(..))]`. This is achieved by adding a custom trait to `cfg_matches` (the method that emits the lint) which permits `rustc` and `rustdoc` to each have their way to emitting lints (via buffered lints/AST for `rustc` and via `TyCtxt`/HIR for `rustdoc`). The reason this is required is because buffered lints operates on the AST but `rustdoc` uses the HIR and by the time `rustdoc` calls `cfg_matches` we are way passed the point where buffered lints have been drain and emitted. Best reviewed commit by commit. r? `@jieyouxu` (for the compiler part) r? `@GuillaumeGomez` (for the rustdoc part)
2025-05-27Rename unpack to kindMichael Goulet-1/+1
2025-05-26rustdoc: use custom `CfgMatchesLintEmitter` to make check-cfg workUrgau-0/+1
2025-05-17Make some `match`es slightly more ergonomic in `librustdoc`Yotam Ofek-11/+11
2025-04-24Remove `weak` alias terminologyBoxy-2/+2
2025-04-19Rollup merge of #140008 - GuillaumeGomez:cleanup-clean_maybe_renamed_item, ↵Chris Denton-14/+33
r=nnethercote Improve `clean_maybe_renamed_item` function code a bit Follow-up of #139846. This is what I tried to say in there: the `name` variable can be unwrapped in most cases so better do it directly once and for all if possible and move the cases where it's not possible above. r? `@nnethercote`
2025-04-18Improve `clean_maybe_renamed_item` function code a bitGuillaume Gomez-14/+33
2025-04-17rustdoc: Properly clean fn params in all contextsLeón Orell Valerian Liehr-30/+28
2025-04-17rustdoc/clean: Change terminology of items pertaining to (formal) fn params ↵León Orell Valerian Liehr-86/+64
from "argument" to "parameter"
2025-04-17Rollup merge of #139846 - nnethercote:kw-Empty-rustdoc, r=GuillaumeGomezMatthias Krüger-26/+32
Remove `kw::Empty` uses in rustdoc Helps with #137978. r? ``@GuillaumeGomez``
2025-04-15Remove another `kw::Empty` use in rustdoc.Nicholas Nethercote-16/+19
Again by using `Option<Symbol>` to represent "no name".
2025-04-15Remove some `kw::Empty` uses in rustdoc.Nicholas Nethercote-16/+19
Some `unwrap` uses here, but they are on paths involving item kinds that are known to have an identifier.
2025-04-15Move `name` field from `AssocItem` to `AssocKind` variants.Nicholas Nethercote-6/+6
To accurately reflect that RPITIT assoc items don't have a name. This avoids the use of `kw::Empty` to mean "no name", which is error prone. Helps with #137978.
2025-04-15Move `opt_rpitit_info` field to `hir::AssocKind::Type`.Nicholas Nethercote-1/+1
From `hir::AssocItem`.
2025-04-14Move `has_self` field to `hir::AssocKind::Fn`.Nicholas Nethercote-2/+2
`hir::AssocItem` currently has a boolean `fn_has_self_parameter` field, which is misplaced, because it's only relevant for associated fns, not for associated consts or types. This commit moves it (and renames it) to the `AssocKind::Fn` variant, where it belongs. This requires introducing a new C-style enum, `AssocTag`, which is like `AssocKind` but without the fields. This is because `AssocKind` values are passed to various functions like `find_by_ident_and_kind` to indicate what kind of associated item should be searched for, and having to specify `has_self` isn't relevant there. New methods: - Predicates `AssocItem::is_fn` and `AssocItem::is_method`. - `AssocItem::as_tag` which converts `AssocItem::kind` to `AssocTag`. Removed `find_by_name_and_kinds`, which is unused. `AssocItem::descr` can now distinguish between methods and associated functions, which slightly improves some error messages.