Rollup merge of #90611 - fee1-dead:rustdoc-ice-fix, r=jyn514,willcrichton

Fix another ICE in rustdoc scrape_examples

This has occurred to me when documenting a crate with the arguments. Not sure what could have caused it.

r? `@willcrichton`
This commit is contained in:
Matthias Krüger 2021-11-26 22:41:39 +01:00 committed by GitHub
commit 10743f0f68
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 6 deletions

View file

@ -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)
}
_ => {

View file

@ -0,0 +1,4 @@
// compile-flags: -Z unstable-options --scrape-examples-output-path t.calls --scrape-examples-target-crate foobar
// check-pass
#![no_std]
use core as _;