diff options
| author | bors <bors@rust-lang.org> | 2025-01-29 19:16:29 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2025-01-29 19:16:29 +0000 |
| commit | ae5de6c759cd337ecdb2de4e94f47eaafb5d4606 (patch) | |
| tree | c3ba73cdd365225357b6803009a52fa1ea341433 /src/librustdoc/html | |
| parent | 0cc4f4f7b81f88df6bdd54b41d4a0b1703fd014d (diff) | |
| parent | 559648a0a4c942993c321d999f708e64f169b245 (diff) | |
| download | rust-ae5de6c759cd337ecdb2de4e94f47eaafb5d4606.tar.gz rust-ae5de6c759cd337ecdb2de4e94f47eaafb5d4606.zip | |
Auto merge of #134248 - oli-obk:patkind-path-removal, r=BoxyUwU
Merge `PatKind::Path` into `PatKind::Expr` Follow-up to #134228 We always had a duplication where `Path`s could be represented as `PatKind::Path` or `PatKind::Lit(ExprKind::Path)`. We had to handle both everywhere, and still do after #134228, so I'm removing it now.
Diffstat (limited to 'src/librustdoc/html')
| -rw-r--r-- | src/librustdoc/html/render/span_map.rs | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/src/librustdoc/html/render/span_map.rs b/src/librustdoc/html/render/span_map.rs index 85f87f01afd..a15ac155123 100644 --- a/src/librustdoc/html/render/span_map.rs +++ b/src/librustdoc/html/render/span_map.rs @@ -4,7 +4,9 @@ use rustc_data_structures::fx::{FxHashMap, FxIndexMap}; use rustc_hir::def::{DefKind, Res}; use rustc_hir::def_id::{DefId, LOCAL_CRATE}; use rustc_hir::intravisit::{self, Visitor}; -use rustc_hir::{ExprKind, HirId, Item, ItemKind, Mod, Node, Pat, PatKind, QPath}; +use rustc_hir::{ + ExprKind, HirId, Item, ItemKind, Mod, Node, Pat, PatExpr, PatExprKind, PatKind, QPath, +}; use rustc_middle::hir::nested_filter; use rustc_middle::ty::TyCtxt; use rustc_span::hygiene::MacroKind; @@ -191,17 +193,21 @@ impl SpanMapVisitor<'_> { } fn handle_pat(&mut self, p: &Pat<'_>) { + let mut check_qpath = |qpath, hir_id| match qpath { + QPath::TypeRelative(_, path) if matches!(path.res, Res::Err) => { + self.infer_id(path.hir_id, Some(hir_id), qpath.span()); + } + QPath::Resolved(_, path) => self.handle_path(path), + _ => {} + }; match p.kind { PatKind::Binding(_, _, _, Some(p)) => self.handle_pat(p), - PatKind::Struct(qpath, _, _) - | PatKind::TupleStruct(qpath, _, _) - | PatKind::Path(qpath) => match qpath { - QPath::TypeRelative(_, path) if matches!(path.res, Res::Err) => { - self.infer_id(path.hir_id, Some(p.hir_id), qpath.span()); - } - QPath::Resolved(_, path) => self.handle_path(path), - _ => {} - }, + PatKind::Struct(qpath, _, _) | PatKind::TupleStruct(qpath, _, _) => { + check_qpath(qpath, p.hir_id) + } + PatKind::Expr(PatExpr { kind: PatExprKind::Path(qpath), hir_id, .. }) => { + check_qpath(*qpath, *hir_id) + } PatKind::Or(pats) => { for pat in pats { self.handle_pat(pat); |
