]> git.lizzy.rs Git - rust.git/blobdiff - src/librustdoc/scrape_examples.rs
Fix remaining bugs
[rust.git] / src / librustdoc / scrape_examples.rs
index 1b5a750455248610ae2295adf7a0d33d7e23e343..10b6fdf87f41972c414708bfa452b91b8c9fe61e 100644 (file)
@@ -48,7 +48,7 @@ impl ScrapeExamplesOptions {
                 target_crates,
             })),
             (Some(_), false) | (None, true) => {
-                diag.err(&format!("must use --scrape-examples-output-path and --scrape-examples-target-crate together"));
+                diag.err("must use --scrape-examples-output-path and --scrape-examples-target-crate together");
                 Err(1)
             }
             (None, false) => Ok(None),
@@ -142,16 +142,21 @@ fn visit_expr(&mut self, ex: &'tcx hir::Expr<'tcx>) {
             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 {
+                    trace!("node_type_opt({}) = None", f.hir_id);
+                    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 {
+                    trace!("type_dependent_def_id({}) = None", ex.hir_id);
+                    return;
+                };
                 (tcx.type_of(def_id), span)
             }
             _ => {