about summary refs log tree commit diff
path: root/src/librustdoc/scrape_examples.rs
diff options
context:
space:
mode:
authorDeadbeef <ent3rm4n@gmail.com>2021-11-05 22:37:33 +0800
committerDeadbeef <ent3rm4n@gmail.com>2021-11-27 00:26:18 +0800
commit2d3d6bc5a2c3b46a4920cf550824054568e87fee (patch)
treee3e9cfe1fb47bd9c42e37f1b50660c24d83bc62b /src/librustdoc/scrape_examples.rs
parentd2c24aabcddd1eb11af633ab6b7391ae0cd00ea2 (diff)
downloadrust-2d3d6bc5a2c3b46a4920cf550824054568e87fee.tar.gz
rust-2d3d6bc5a2c3b46a4920cf550824054568e87fee.zip
Fix another ICE in rustdoc scrape_examples
Diffstat (limited to 'src/librustdoc/scrape_examples.rs')
-rw-r--r--src/librustdoc/scrape_examples.rs15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/librustdoc/scrape_examples.rs b/src/librustdoc/scrape_examples.rs
index 3b39e3576e6..a2357a62617 100644
--- a/src/librustdoc/scrape_examples.rs
+++ b/src/librustdoc/scrape_examples.rs
@@ -142,16 +142,19 @@ where
             hir::ExprKind::Call(f, _) => {
                 let types = tcx.typeck(ex.hir_id.owner);
 
-                match types.node_type_opt(f.hir_id) {
-                    Some(ty) => (ty, ex.span),
-                    None => {
-                        return;
-                    }
+                if let Some(ty) = types.node_type_opt(f.hir_id) {
+                    (ty, ex.span)
+                } else {
+                    return;
                 }
             }
             hir::ExprKind::MethodCall(_, _, _, span) => {
                 let types = tcx.typeck(ex.hir_id.owner);
-                let def_id = types.type_dependent_def_id(ex.hir_id).unwrap();
+                let def_id = if let Some(def_id) = types.type_dependent_def_id(ex.hir_id) {
+                    def_id
+                } else {
+                    return;
+                };
                 (tcx.type_of(def_id), span)
             }
             _ => {