diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2021-11-26 22:41:39 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-11-26 22:41:39 +0100 |
| commit | 10743f0f6823b2a122cc4d552ed8aa0cabb9f088 (patch) | |
| tree | a7b2d4d401a4059c2702f368ac01381c2f8bcde9 /src | |
| parent | 6d246f0c8d3063fea86abbb65a824362709541ba (diff) | |
| parent | 9c14d828ba395be4c60f41ec93c30fdee1394d65 (diff) | |
| download | rust-10743f0f6823b2a122cc4d552ed8aa0cabb9f088.tar.gz rust-10743f0f6823b2a122cc4d552ed8aa0cabb9f088.zip | |
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`
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustdoc/scrape_examples.rs | 17 | ||||
| -rw-r--r-- | src/test/rustdoc-ui/scrape-examples-ice.rs | 4 |
2 files changed, 15 insertions, 6 deletions
diff --git a/src/librustdoc/scrape_examples.rs b/src/librustdoc/scrape_examples.rs index 3b39e3576e6..10b6fdf87f4 100644 --- a/src/librustdoc/scrape_examples.rs +++ b/src/librustdoc/scrape_examples.rs @@ -142,16 +142,21 @@ 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 { + 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) } _ => { diff --git a/src/test/rustdoc-ui/scrape-examples-ice.rs b/src/test/rustdoc-ui/scrape-examples-ice.rs new file mode 100644 index 00000000000..a6138add522 --- /dev/null +++ b/src/test/rustdoc-ui/scrape-examples-ice.rs @@ -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 _; |
