about summary refs log tree commit diff
path: root/src/librustdoc/html/render/span_map.rs
AgeCommit message (Collapse)AuthorLines
2025-09-30Replace `rustc_span::Span` with a stripped down version for librustdoc's ↵Yotam Ofek-14/+54
highlighter
2025-09-25Rollup merge of #135771 - GuillaumeGomez:jump-to-def-perf, r=fmeaseMatthias Krüger-46/+78
[rustdoc] Add support for associated items in "jump to def" feature Fixes https://github.com/rust-lang/rust/issues/135485. r? ``@fmease``
2025-08-23Do macro expansion at AST level rather than HIRGuillaume Gomez-131/+4
2025-08-23Clean up computation of macro expansion span and correctly handle spans open ↵Guillaume Gomez-11/+32
inside expansion spans
2025-08-23Add new unstable `--generate-macro-expansion` rustdoc command line flagGuillaume Gomez-5/+5
2025-08-23Add support for macro expansion in rustdoc source code pagesGuillaume Gomez-4/+110
2025-08-10Ignore impl associated types in jump to def featureGuillaume Gomez-1/+7
2025-08-10Fix panic if an item does not have a bodyGuillaume Gomez-10/+22
2025-08-10Update to last rustc_hir Visitor changesGuillaume Gomez-6/+3
2025-08-10Better handling of paths in link to def featureGuillaume Gomez-27/+43
2025-08-10Add support for trait associated itemsGuillaume Gomez-30/+31
2025-04-02Move methods from `Map` to `TyCtxt`, part 5.Nicholas Nethercote-1/+1
This eliminates all methods on `Map`. Actually removing `Map` will occur in a follow-up PR.
2025-03-18Move `hir::Item::ident` into `hir::ItemKind`.Nicholas Nethercote-15/+14
`hir::Item` has an `ident` field. - It's always non-empty for these item kinds: `ExternCrate`, `Static`, `Const`, `Fn`, `Macro`, `Mod`, `TyAlias`, `Enum`, `Struct`, `Union`, Trait`, TraitAalis`. - It's always empty for these item kinds: `ForeignMod`, `GlobalAsm`, `Impl`. - For `Use`, it is non-empty for `UseKind::Single` and empty for `UseKind::{Glob,ListStem}`. All of this is quite non-obvious; the only documentation is a single comment saying "The name might be a dummy name in case of anonymous items". Some sites that handle items check for an empty ident, some don't. This is a very C-like way of doing things, but this is Rust, we have sum types, we can do this properly and never forget to check for the exceptional case and never YOLO possibly empty identifiers (or possibly dummy spans) around and hope that things will work out. The commit is large but it's mostly obvious plumbing work. Some notable things. - A similar transformation makes sense for `ast::Item`, but this is already a big change. That can be done later. - Lots of assertions are added to item lowering to ensure that identifiers are empty/non-empty as expected. These will be removable when `ast::Item` is done later. - `ItemKind::Use` doesn't get an `Ident`, but `UseKind::Single` does. - `lower_use_tree` is significantly simpler. No more confusing `&mut Ident` to deal with. - `ItemKind::ident` is a new method, it returns an `Option<Ident>`. It's used with `unwrap` in a few places; sometimes it's hard to tell exactly which item kinds might occur. None of these unwraps fail on the test suite. It's conceivable that some might fail on alternative input. We can deal with those if/when they happen. - In `trait_path` the `find_map`/`if let` is replaced with a loop, and things end up much clearer that way. - `named_span` no longer checks for an empty name; instead the call site now checks for a missing identifier if necessary. - `maybe_inline_local` doesn't need the `glob` argument, it can be computed in-function from the `renamed` argument. - `arbitrary_source_item_ordering::check_mod` had a big `if` statement that was just getting the ident from the item kinds that had one. It could be mostly replaced by a single call to the new `ItemKind::ident` method. - `ItemKind` grows from 56 to 64 bytes, but `Item` stays the same size, and that's what matters, because `ItemKind` only occurs within `Item`.
2025-03-11Implement `#[define_opaque]` attribute for functions.Oli Scherer-1/+1
2025-03-07Rollup merge of #138150 - nnethercote:streamline-intravisit-visit_id, r=oli-obkMatthias Krüger-1/+1
Streamline HIR intravisit `visit_id` calls for items A small clean up.
2025-03-07Move `visit_id` calls.Nicholas Nethercote-1/+1
In `walk_item`, we call `visit_id` on every item kind. For most of them we do it directly in `walk_item`. But for `ItemKind::Mod`, `ItemKind::Enum`, and `ItemKind::Use` we instead do it in the `walk_*` function called (via the `visit_*` function) from `walk_item`. I can see no reason for this inconsistency, so this commit makes those three cases like all the other cases, moving the `visit_id` calls into `walk_item`. This also avoids the need for a few `HirId` arguments.
2025-03-06`librustdoc`: flatten nested ifsYotam Ofek-12/+10
2025-02-22Make asm a named fieldMichael Goulet-1/+1
2025-02-18Move methods from `Map` to `TyCtxt`, part 2.Nicholas Nethercote-5/+5
Continuing the work started in #136466. Every method gains a `hir_` prefix, though for the ones that already have a `par_` or `try_par_` prefix I added the `hir_` after that.
2025-02-17Overhaul the `intravisit::Map` trait.Nicholas Nethercote-2/+2
First of all, note that `Map` has three different relevant meanings. - The `intravisit::Map` trait. - The `map::Map` struct. - The `NestedFilter::Map` associated type. The `intravisit::Map` trait is impl'd twice. - For `!`, where the methods are all unreachable. - For `map::Map`, which gets HIR stuff from the `TyCtxt`. As part of getting rid of `map::Map`, this commit changes `impl intravisit::Map for map::Map` to `impl intravisit::Map for TyCtxt`. It's fairly straightforward except various things are renamed, because the existing names would no longer have made sense. - `trait intravisit::Map` becomes `trait intravisit::HirTyCtxt`, so named because it gets some HIR stuff from a `TyCtxt`. - `NestedFilter::Map` assoc type becomes `NestedFilter::MaybeTyCtxt`, because it's always `!` or `TyCtxt`. - `Visitor::nested_visit_map` becomes `Visitor::maybe_tcx`. I deliberately made the new trait and associated type names different to avoid the old `type Map: Map` situation, which I found confusing. We now have `type MaybeTyCtxt: HirTyCtxt`.
2025-01-29Eliminate PatKind::PathOli Scherer-10/+16
2025-01-14Rollup merge of #134216 - GuillaumeGomez:jump-to-def-pats, r=fmeaseMatthias Krüger-4/+29
Enable "jump to def" feature on patterns Part of https://github.com/rust-lang/rust/issues/89095. Pattern (as in "patterns in pattern matching") were not handled by the feature, it's now added. It all started when I realized that prelude values like `Some` or `Err` were not getting a link generated either (added support for it in the first commit). r? ``@fmease``
2025-01-04turn hir::ItemKind::Fn into a named-field variantRalf Jung-1/+1
2024-12-12Rename `handle_call` into `infer_id`Guillaume Gomez-4/+4
2024-12-12Enable "jump to def" feature on patternsGuillaume Gomez-1/+26
2024-11-28Fix new clippy lintsGuillaume Gomez-1/+1
2024-11-18Fix items with generics not having their jump to def link generatedGuillaume Gomez-3/+18
2024-11-18Fix typoGuillaume Gomez-1/+1
2024-10-06Handle `librustdoc` cases of `rustc::potential_query_instability` lintismailarilik-2/+2
2024-10-04rm `ItemKind::OpaqueTy`Noah Lev-1/+0
This introduce an additional collection of opaques on HIR, as they can no longer be listed using the free item list.
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-1/+1
2024-07-29Reformat `use` declarations.Nicholas Nethercote-3/+3
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-05-29Make `body_owned_by` return the body directly.Oli Scherer-3/+1
Almost all callers want this anyway, and now we can use it to also return fed bodies
2024-02-07hir: Remove `fn opt_hir_id` and `fn opt_span`Vadim Petrochenkov-2/+2
2024-01-04Fix invalid handling for static method calls in jump to definition featureGuillaume Gomez-20/+32
2023-12-12Move some methods from `tcx.hir()` to `tcx`zetanumbers-2/+2
Renamings: - find -> opt_hir_node - get -> hir_node - find_by_def_id -> opt_hir_node_by_def_id - get_by_def_id -> hir_node_by_def_id Fix rebase changes using removed methods Use `tcx.hir_node_by_def_id()` whenever possible in compiler Fix clippy errors Fix compiler Apply suggestions from code review Co-authored-by: Vadim Petrochenkov <vadim.petrochenkov@gmail.com> Add FIXME for `tcx.hir()` returned type about its removal Simplify with with `tcx.hir_node_by_def_id`
2023-07-28Render generic const items in rustdocLeón Orell Valerian Liehr-1/+1
2023-07-12Add jump to docGuillaume Gomez-24/+73
2023-03-09Fix typo in span_map.rsIkko Eltociear Ashimine-3/+3
correspondance -> correspondence
2022-12-01rustc_hir: Change representation of import paths to support multiple resolutionsVadim Petrochenkov-8/+0
2022-12-01rustc_hir: Relax lifetime requirements on `Visitor::visit_path`Vadim Petrochenkov-1/+1
2022-09-05Make `hir::PathSegment::hir_id` non-optional.Nicholas Nethercote-18/+16
2022-06-20Improve code readability and documentationGuillaume Gomez-28/+40
2022-06-20Add support for macro in "jump to def" featureGuillaume Gomez-17/+54
2022-05-24fix simple clippy lintsklensy-1/+1
2022-05-21Remove `crate` visibility modifier in libs, testsJacob Pratt-4/+4
2022-05-06Remove unneeded SpanMapVisitor::visit_generics functionGuillaume Gomez-13/+1
2022-05-02Fix regression in link-to-definition introduced in #93803Guillaume Gomez-2/+12
2022-04-30Store all generic bounds as where predicates.Camille GILLOT-11/+2
2022-03-31remove find_use_placementFausto-2/+5
A more robust solution to finding where to place use suggestions was added. The algorithm uses the AST to find the span for the suggestion so we pass this span down to the HIR during lowering and use it. Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>