X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Flibrustdoc%2Fscrape_examples.rs;h=10b6fdf87f41972c414708bfa452b91b8c9fe61e;hb=1e55c31cbbc43a21c93ed5652dc39c267e6557af;hp=1b5a750455248610ae2295adf7a0d33d7e23e343;hpb=18cae2680fff914c95a633c468f09b614f385844;p=rust.git diff --git a/src/librustdoc/scrape_examples.rs b/src/librustdoc/scrape_examples.rs index 1b5a7504552..10b6fdf87f4 100644 --- a/src/librustdoc/scrape_examples.rs +++ b/src/librustdoc/scrape_examples.rs @@ -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) } _ => {