Fix ICE.
This commit is contained in:
parent
0ee393cf01
commit
d8716f5a3f
1 changed files with 22 additions and 21 deletions
|
@ -153,11 +153,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for DocMarkdown {
|
||||||
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::Item<'_>) {
|
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::Item<'_>) {
|
||||||
let headers = check_attrs(cx, &self.valid_idents, &item.attrs);
|
let headers = check_attrs(cx, &self.valid_idents, &item.attrs);
|
||||||
match item.kind {
|
match item.kind {
|
||||||
hir::ItemKind::Fn(ref sig, ..) => {
|
hir::ItemKind::Fn(ref sig, _, body_id) => {
|
||||||
if !(is_entrypoint_fn(cx, cx.tcx.hir().local_def_id(item.hir_id))
|
if !(is_entrypoint_fn(cx, cx.tcx.hir().local_def_id(item.hir_id))
|
||||||
|| in_external_macro(cx.tcx.sess, item.span))
|
|| in_external_macro(cx.tcx.sess, item.span))
|
||||||
{
|
{
|
||||||
lint_for_missing_headers(cx, item.hir_id, item.span, sig, headers);
|
lint_for_missing_headers(cx, item.hir_id, item.span, sig, headers, Some(body_id));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
hir::ItemKind::Impl {
|
hir::ItemKind::Impl {
|
||||||
|
@ -180,7 +180,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for DocMarkdown {
|
||||||
let headers = check_attrs(cx, &self.valid_idents, &item.attrs);
|
let headers = check_attrs(cx, &self.valid_idents, &item.attrs);
|
||||||
if let hir::TraitItemKind::Method(ref sig, ..) = item.kind {
|
if let hir::TraitItemKind::Method(ref sig, ..) = item.kind {
|
||||||
if !in_external_macro(cx.tcx.sess, item.span) {
|
if !in_external_macro(cx.tcx.sess, item.span) {
|
||||||
lint_for_missing_headers(cx, item.hir_id, item.span, sig, headers);
|
lint_for_missing_headers(cx, item.hir_id, item.span, sig, headers, None);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -190,8 +190,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for DocMarkdown {
|
||||||
if self.in_trait_impl || in_external_macro(cx.tcx.sess, item.span) {
|
if self.in_trait_impl || in_external_macro(cx.tcx.sess, item.span) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if let hir::ImplItemKind::Method(ref sig, ..) = item.kind {
|
if let hir::ImplItemKind::Method(ref sig, body_id) = item.kind {
|
||||||
lint_for_missing_headers(cx, item.hir_id, item.span, sig, headers);
|
lint_for_missing_headers(cx, item.hir_id, item.span, sig, headers, Some(body_id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -202,6 +202,7 @@ fn lint_for_missing_headers<'a, 'tcx>(
|
||||||
span: impl Into<MultiSpan> + Copy,
|
span: impl Into<MultiSpan> + Copy,
|
||||||
sig: &hir::FnSig<'_>,
|
sig: &hir::FnSig<'_>,
|
||||||
headers: DocHeaders,
|
headers: DocHeaders,
|
||||||
|
body_id: Option<hir::BodyId>,
|
||||||
) {
|
) {
|
||||||
if !cx.access_levels.is_exported(hir_id) {
|
if !cx.access_levels.is_exported(hir_id) {
|
||||||
return; // Private functions do not require doc comments
|
return; // Private functions do not require doc comments
|
||||||
|
@ -222,14 +223,15 @@ fn lint_for_missing_headers<'a, 'tcx>(
|
||||||
span,
|
span,
|
||||||
"docs for function returning `Result` missing `# Errors` section",
|
"docs for function returning `Result` missing `# Errors` section",
|
||||||
);
|
);
|
||||||
} else {
|
} else if let (Some(body_id), Some(future)) = (body_id, get_trait_def_id(cx, &paths::FUTURE)) {
|
||||||
let def_id = cx.tcx.hir().local_def_id(hir_id);
|
let def_id = cx.tcx.hir().body_owner_def_id(body_id);
|
||||||
let mir = cx.tcx.optimized_mir(def_id);
|
let mir = cx.tcx.optimized_mir(def_id);
|
||||||
if let Some(future) = get_trait_def_id(cx, &paths::FUTURE) {
|
let ret_ty = mir.return_ty();
|
||||||
if implements_trait(cx, mir.return_ty(), future, &[]) {
|
|
||||||
|
if implements_trait(cx, ret_ty, future, &[]) {
|
||||||
use TyKind::*;
|
use TyKind::*;
|
||||||
|
|
||||||
if let Opaque(_, subs) = mir.return_ty().kind {
|
if let Opaque(_, subs) = ret_ty.kind {
|
||||||
if let Some(ty) = subs.types().next() {
|
if let Some(ty) = subs.types().next() {
|
||||||
if let Generator(_, subs, _) = ty.kind {
|
if let Generator(_, subs, _) = ty.kind {
|
||||||
if match_type(cx, subs.as_generator().return_ty(def_id, cx.tcx), &paths::RESULT) {
|
if match_type(cx, subs.as_generator().return_ty(def_id, cx.tcx), &paths::RESULT) {
|
||||||
|
@ -247,7 +249,6 @@ fn lint_for_missing_headers<'a, 'tcx>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/// Cleanup documentation decoration (`///` and such).
|
/// Cleanup documentation decoration (`///` and such).
|
||||||
///
|
///
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue