Commit Graph

60 Commits

Author SHA1 Message Date
Oli Scherer cb4751d4b8 Implement #[define_opaque] attribute for functions. 2025-03-11 12:05:02 +00:00
Matthias Krüger b772fa6165 Rollup merge of #138150 - nnethercote:streamline-intravisit-visit_id, r=oli-obk
Streamline HIR intravisit `visit_id` calls for items

A small clean up.
2025-03-07 19:15:36 +01:00
Nicholas Nethercote 872ac73f59 Move visit_id calls.
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-07 19:35:41 +11:00
Yotam Ofek fde37335aa librustdoc: flatten nested ifs 2025-03-06 08:16:28 +00:00
Michael Goulet 2a6daaf89a Make asm a named field 2025-02-22 00:05:09 +00:00
Nicholas Nethercote fd7b4bf4e1 Move methods from Map to TyCtxt, part 2.
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-18 10:17:44 +11:00
Nicholas Nethercote 661f99ba03 Overhaul the intravisit::Map trait.
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-02-17 13:21:35 +11:00
Oli Scherer f47ad71059 Eliminate PatKind::Path 2025-01-29 15:45:13 +00:00
Matthias Krüger aeadee0642 Rollup merge of #134216 - GuillaumeGomez:jump-to-def-pats, r=fmease
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-14 19:25:04 +01:00
Ralf Jung be65012aa3 turn hir::ItemKind::Fn into a named-field variant 2025-01-04 11:35:31 +01:00
Guillaume Gomez 12a12c9a83 Rename handle_call into infer_id 2024-12-12 17:09:38 +01:00
Guillaume Gomez f6525a621a Enable "jump to def" feature on patterns 2024-12-12 16:55:53 +01:00
Guillaume Gomez f0c301ffe4 Fix new clippy lints 2024-11-28 03:05:43 +01:00
Guillaume Gomez 786b7477f6 Fix items with generics not having their jump to def link generated 2024-11-18 17:58:57 +01:00
Guillaume Gomez 8ea02578cd Fix typo 2024-11-18 17:00:44 +01:00
ismailarilik e0a20b484d Handle librustdoc cases of rustc::potential_query_instability lint 2024-10-06 10:39:03 +03:00
Noah Lev d6f247f3d5 rm ItemKind::OpaqueTy
This introduce an additional collection of opaques on HIR, as they can no
longer be listed using the free item list.
2024-10-04 23:28:22 +00:00
Michael Goulet c682aa162b Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
Nicholas Nethercote 84ac80f192 Reformat use declarations.
The previous commit updated `rustfmt.toml` appropriately. This commit is
the outcome of running `x fmt --all` with the new formatting options.
2024-07-29 08:26:52 +10:00
Oli Scherer a34c26e7ec Make body_owned_by return the body directly.
Almost all callers want this anyway, and now we can use it to also return fed bodies
2024-05-29 10:04:08 +00:00
Vadim Petrochenkov a61019b290 hir: Remove fn opt_hir_id and fn opt_span 2024-02-07 09:38:24 +03:00
Guillaume Gomez 35ad2ae71c Fix invalid handling for static method calls in jump to definition feature 2024-01-04 20:24:16 +01:00
zetanumbers 24f009c5e5 Move some methods from tcx.hir() to tcx
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-12-12 06:40:29 -08:00
León Orell Valerian Liehr a011dd9dac Render generic const items in rustdoc 2023-07-28 22:21:42 +02:00
Guillaume Gomez 3fd36bc083 Add jump to doc 2023-07-12 16:45:36 +02:00
Ikko Eltociear Ashimine 18667722e2 Fix typo in span_map.rs
correspondance -> correspondence
2023-03-09 14:47:42 +09:00
Vadim Petrochenkov 1f259ae679 rustc_hir: Change representation of import paths to support multiple resolutions 2022-12-01 18:51:05 +03:00
Vadim Petrochenkov 6cd4dd3091 rustc_hir: Relax lifetime requirements on Visitor::visit_path 2022-12-01 17:04:02 +03:00
Nicholas Nethercote bb0ae3c446 Make hir::PathSegment::hir_id non-optional. 2022-09-05 14:20:25 +10:00
Guillaume Gomez 810254b31e Improve code readability and documentation 2022-06-20 21:09:55 +02:00
Guillaume Gomez 3f12fa7fda Add support for macro in "jump to def" feature 2022-06-20 17:00:48 +02:00
klensy 678059f7d0 fix simple clippy lints 2022-05-24 12:24:41 -04:00
Jacob Pratt 6970246886 Remove crate visibility modifier in libs, tests 2022-05-21 00:32:47 -04:00
Guillaume Gomez 5c7ce84d74 Remove unneeded SpanMapVisitor::visit_generics function 2022-05-06 22:01:30 +02:00
Guillaume Gomez a26cb6154d Fix regression in link-to-definition introduced in #93803 2022-05-02 15:06:45 +02:00
Camille GILLOT 94449e6101 Store all generic bounds as where predicates. 2022-04-30 13:55:13 +02:00
Fausto 8c2353b6c1 remove find_use_placement
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>
2022-03-31 17:20:03 -04:00
mark cf382de0cc Remove DiagnosticBuilder.quiet 2022-01-23 00:11:13 -06:00
Cameron Steffen b11733534d Remove a span from hir::ExprKind::MethodCall 2022-01-21 07:48:10 -06:00
Cameron Steffen 45db716902 Replace NestedVisitorMap with NestedFilter 2022-01-16 16:02:36 -06:00
Michael Goulet bc7968f961 remove in_band_lifetimes from librustdoc 2021-12-28 18:18:00 -08:00
Noah Lev 6215f7c85f Clean up now that visitors only need &clean::Crate 2021-10-31 20:59:22 -07:00
Guillaume Gomez 4614ca4541 Fix clippy lints in librustdoc 2021-10-25 11:30:09 +02:00
Guillaume Gomez 8f3fd3d08c Add support for primitives in "jump to definition" feature 2021-09-13 17:41:43 +02:00
Camille GILLOT d119a13137 Rename walk_crate. 2021-09-02 19:23:11 +02:00
Camille GILLOT 7ec973d9ce Stop using walk_crate. 2021-09-02 19:08:58 +02:00
Guillaume Gomez dfe4fec783 Remove LightSpan and use Span directly 2021-08-05 23:08:29 +02:00
Guillaume Gomez 5cf300d695 Remove warnings/errors from compiler when using typeck_body in rustdoc span map builder 2021-08-05 23:08:29 +02:00
Guillaume Gomez 0799528db7 * Rename LightSpan::empty into LightSpan::dummy
* Add Classifier::new_light_span to wrap LightSpan::new_in_file constructor
2021-08-05 23:08:29 +02:00
Guillaume Gomez fd69fa8670 Add missing root_path when generating links using href 2021-08-05 23:08:29 +02:00