diff options
| author | bors <bors@rust-lang.org> | 2022-09-05 13:36:54 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-09-05 13:36:54 +0000 |
| commit | 2dc703fd6e3aaaf343828cc7dd1aec192d24c628 (patch) | |
| tree | cfdce4f7717d0af4d6feae94ea2abbe95a2dd092 /src/librustdoc/html/render | |
| parent | 6e4a9ab650b135ae0ff761e4a37d96c8bcaf7b3d (diff) | |
| parent | 08a00eb0da303f82057174ab79d5b079d762bb61 (diff) | |
| download | rust-2dc703fd6e3aaaf343828cc7dd1aec192d24c628.tar.gz rust-2dc703fd6e3aaaf343828cc7dd1aec192d24c628.zip | |
Auto merge of #101228 - nnethercote:simplify-hir-PathSegment, r=petrochenkov
Simplify `hir::PathSegment` r? `@petrochenkov`
Diffstat (limited to 'src/librustdoc/html/render')
| -rw-r--r-- | src/librustdoc/html/render/span_map.rs | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/src/librustdoc/html/render/span_map.rs b/src/librustdoc/html/render/span_map.rs index 34d590fb244..151ec2b28ad 100644 --- a/src/librustdoc/html/render/span_map.rs +++ b/src/librustdoc/html/render/span_map.rs @@ -166,25 +166,23 @@ impl<'tcx> Visitor<'tcx> for SpanMapVisitor<'tcx> { fn visit_expr(&mut self, expr: &'tcx rustc_hir::Expr<'tcx>) { if let ExprKind::MethodCall(segment, ..) = expr.kind { - if let Some(hir_id) = segment.hir_id { - let hir = self.tcx.hir(); - let body_id = hir.enclosing_body_owner(hir_id); - // FIXME: this is showing error messages for parts of the code that are not - // compiled (because of cfg)! - // - // See discussion in https://github.com/rust-lang/rust/issues/69426#issuecomment-1019412352 - let typeck_results = self.tcx.typeck_body( - hir.maybe_body_owned_by(body_id).expect("a body which isn't a body"), + let hir = self.tcx.hir(); + let body_id = hir.enclosing_body_owner(segment.hir_id); + // FIXME: this is showing error messages for parts of the code that are not + // compiled (because of cfg)! + // + // See discussion in https://github.com/rust-lang/rust/issues/69426#issuecomment-1019412352 + let typeck_results = self + .tcx + .typeck_body(hir.maybe_body_owned_by(body_id).expect("a body which isn't a body")); + if let Some(def_id) = typeck_results.type_dependent_def_id(expr.hir_id) { + self.matches.insert( + segment.ident.span, + match hir.span_if_local(def_id) { + Some(span) => LinkFromSrc::Local(clean::Span::new(span)), + None => LinkFromSrc::External(def_id), + }, ); - if let Some(def_id) = typeck_results.type_dependent_def_id(expr.hir_id) { - self.matches.insert( - segment.ident.span, - match hir.span_if_local(def_id) { - Some(span) => LinkFromSrc::Local(clean::Span::new(span)), - None => LinkFromSrc::External(def_id), - }, - ); - } } } else if self.handle_macro(expr.span) { // We don't want to go deeper into the macro. |
