Skip to content

Commit 710fac1

Browse files
committed
Don't special-case ExprKind::Call
Don't unnecessarily try to obtain the type-dependent definition of callees. Just let `visit_qpath` handle callees. This means that for callees that are `Resolved` paths (the majority of callees) we don't try to `typeck` the enclosing body which should improve perf if the body doesn't contain any type-dependent definitions.
1 parent b6dde5a commit 710fac1

1 file changed

Lines changed: 6 additions & 13 deletions

File tree

src/librustdoc/html/render/span_map.rs

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -295,20 +295,13 @@ impl<'tcx> Visitor<'tcx> for SpanMapVisitor<'tcx> {
295295
}
296296

297297
fn visit_expr(&mut self, expr: &'tcx hir::Expr<'tcx>) {
298-
let mut handle_type_dependent_def = |hir_id: HirId, span: rustc_span::Span| {
299-
let typeck_results = self.typeck_results_for(hir_id.owner).unwrap();
300-
if let Some(def_id) = typeck_results.type_dependent_def_id(hir_id) {
301-
self.matches.insert(span.into(), self.link_for_def(def_id));
302-
}
303-
};
304-
305298
match expr.kind {
306-
ExprKind::MethodCall(seg, ..) => handle_type_dependent_def(expr.hir_id, seg.ident.span),
307-
// FIXME(fmease): We needlessly request `TypeckResults` even if the callee isn't
308-
// type-relative. In the majority of cases, it's just gonna be a
309-
// `Resolved` path meaning we can end up unnecessarily
310-
// `typeck`'ing the body which is super costly!
311-
ExprKind::Call(callee, ..) => handle_type_dependent_def(callee.hir_id, callee.span),
299+
ExprKind::MethodCall(segment, ..) => {
300+
let typeck_results = self.typeck_results_for(expr.hir_id.owner).unwrap();
301+
if let Some(def_id) = typeck_results.type_dependent_def_id(expr.hir_id) {
302+
self.matches.insert(segment.ident.span.into(), self.link_for_def(def_id));
303+
}
304+
}
312305
// We don't want to go deeper into the macro.
313306
_ if self.handle_macro(expr.span) => return,
314307
_ => {}

0 commit comments

Comments
 (0)