Skip to content

Commit f1e3e2c

Browse files
committed
Use PathSegment::ident for scraping method calls
1 parent d58c9df commit f1e3e2c

File tree

1 file changed

+2
-15
lines changed

1 file changed

+2
-15
lines changed

src/librustdoc/scrape_examples.rs

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -160,27 +160,14 @@ where
160160
return;
161161
}
162162
}
163-
hir::ExprKind::MethodCall(_, args, call_span) => {
163+
hir::ExprKind::MethodCall(path, _, call_span) => {
164164
let types = tcx.typeck(ex.hir_id.owner);
165165
let Some(def_id) = types.type_dependent_def_id(ex.hir_id) else {
166166
trace!("type_dependent_def_id({}) = None", ex.hir_id);
167167
return;
168168
};
169169

170-
// The MethodCall node doesn't directly contain a span for the
171-
// method identifier, so we have to compute it by trimming the full
172-
// span based on the arguments.
173-
let ident_span = match args.get(1) {
174-
// If there is an argument, e.g. "f(x)", then
175-
// get the span "f(" and delete the lparen.
176-
Some(arg) => {
177-
let with_paren = call_span.until(arg.span);
178-
with_paren.with_hi(with_paren.hi() - BytePos(1))
179-
}
180-
// Otherwise, just delete both parens directly.
181-
None => call_span.with_hi(call_span.hi() - BytePos(2)),
182-
};
183-
170+
let ident_span = path.ident.span;
184171
(tcx.type_of(def_id), call_span, ident_span)
185172
}
186173
_ => {

0 commit comments

Comments
 (0)