about summary refs log tree commit diff
diff options
context:
space:
mode:
authorWill Crichton <wcrichto@cs.stanford.edu>2022-01-25 12:11:44 -0800
committerWill Crichton <wcrichto@cs.stanford.edu>2022-03-27 18:10:50 -0700
commitf1e3e2c366b05f232c6b2225af7fc155925029df (patch)
tree7e80c8e663ed41899e198b2679abbe6b291925e6
parentd58c9dfdb910089afc1296142bae21634ce5eb4b (diff)
downloadrust-f1e3e2c366b05f232c6b2225af7fc155925029df.tar.gz
rust-f1e3e2c366b05f232c6b2225af7fc155925029df.zip
Use PathSegment::ident for scraping method calls
-rw-r--r--src/librustdoc/scrape_examples.rs17
1 files changed, 2 insertions, 15 deletions
diff --git a/src/librustdoc/scrape_examples.rs b/src/librustdoc/scrape_examples.rs
index 21af26a1c91..fee42de746d 100644
--- a/src/librustdoc/scrape_examples.rs
+++ b/src/librustdoc/scrape_examples.rs
@@ -160,27 +160,14 @@ where
                     return;
                 }
             }
-            hir::ExprKind::MethodCall(_, args, call_span) => {
+            hir::ExprKind::MethodCall(path, _, call_span) => {
                 let types = tcx.typeck(ex.hir_id.owner);
                 let Some(def_id) = types.type_dependent_def_id(ex.hir_id) else {
                     trace!("type_dependent_def_id({}) = None", ex.hir_id);
                     return;
                 };
 
-                // The MethodCall node doesn't directly contain a span for the
-                // method identifier, so we have to compute it by trimming the full
-                // span based on the arguments.
-                let ident_span = match args.get(1) {
-                    // If there is an argument, e.g. "f(x)", then
-                    // get the span "f(" and delete the lparen.
-                    Some(arg) => {
-                        let with_paren = call_span.until(arg.span);
-                        with_paren.with_hi(with_paren.hi() - BytePos(1))
-                    }
-                    // Otherwise, just delete both parens directly.
-                    None => call_span.with_hi(call_span.hi() - BytePos(2)),
-                };
-
+                let ident_span = path.ident.span;
                 (tcx.type_of(def_id), call_span, ident_span)
             }
             _ => {