Use if_chain
.
This commit is contained in:
parent
d8716f5a3f
commit
8e2dab3b3c
1 changed files with 21 additions and 21 deletions
|
@ -1,4 +1,5 @@
|
||||||
use crate::utils::{get_trait_def_id, implements_trait, is_entrypoint_fn, match_type, paths, return_ty, span_lint};
|
use crate::utils::{get_trait_def_id, implements_trait, is_entrypoint_fn, match_type, paths, return_ty, span_lint};
|
||||||
|
use if_chain::if_chain;
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use rustc::lint::in_external_macro;
|
use rustc::lint::in_external_macro;
|
||||||
use rustc::ty::TyKind;
|
use rustc::ty::TyKind;
|
||||||
|
@ -223,18 +224,20 @@ 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 if let (Some(body_id), Some(future)) = (body_id, get_trait_def_id(cx, &paths::FUTURE)) {
|
} else {
|
||||||
|
use TyKind::*;
|
||||||
|
if_chain! {
|
||||||
|
if let Some(body_id) = body_id;
|
||||||
|
if let Some(future) = get_trait_def_id(cx, &paths::FUTURE);
|
||||||
let def_id = cx.tcx.hir().body_owner_def_id(body_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);
|
||||||
let ret_ty = mir.return_ty();
|
let ret_ty = mir.return_ty();
|
||||||
|
if implements_trait(cx, ret_ty, future, &[]);
|
||||||
if implements_trait(cx, ret_ty, future, &[]) {
|
if let Opaque(_, subs) = ret_ty.kind;
|
||||||
use TyKind::*;
|
if let Some(ty) = subs.types().next();
|
||||||
|
if let Generator(_, subs, _) = ty.kind;
|
||||||
if let Opaque(_, subs) = ret_ty.kind {
|
if match_type(cx, subs.as_generator().return_ty(def_id, cx.tcx), &paths::RESULT);
|
||||||
if let Some(ty) = subs.types().next() {
|
then {
|
||||||
if let Generator(_, subs, _) = ty.kind {
|
|
||||||
if match_type(cx, subs.as_generator().return_ty(def_id, cx.tcx), &paths::RESULT) {
|
|
||||||
span_lint(
|
span_lint(
|
||||||
cx,
|
cx,
|
||||||
MISSING_ERRORS_DOC,
|
MISSING_ERRORS_DOC,
|
||||||
|
@ -246,9 +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