Skip to content

Commit 8e2dab3

Browse files
committed
Use if_chain.
1 parent d8716f5 commit 8e2dab3

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

clippy_lints/src/doc.rs

+21-21
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use crate::utils::{get_trait_def_id, implements_trait, is_entrypoint_fn, match_type, paths, return_ty, span_lint};
2+
use if_chain::if_chain;
23
use itertools::Itertools;
34
use rustc::lint::in_external_macro;
45
use rustc::ty::TyKind;
@@ -223,27 +224,26 @@ fn lint_for_missing_headers<'a, 'tcx>(
223224
span,
224225
"docs for function returning `Result` missing `# Errors` section",
225226
);
226-
} else if let (Some(body_id), Some(future)) = (body_id, get_trait_def_id(cx, &paths::FUTURE)) {
227-
let def_id = cx.tcx.hir().body_owner_def_id(body_id);
228-
let mir = cx.tcx.optimized_mir(def_id);
229-
let ret_ty = mir.return_ty();
230-
231-
if implements_trait(cx, ret_ty, future, &[]) {
232-
use TyKind::*;
233-
234-
if let Opaque(_, subs) = ret_ty.kind {
235-
if let Some(ty) = subs.types().next() {
236-
if let Generator(_, subs, _) = ty.kind {
237-
if match_type(cx, subs.as_generator().return_ty(def_id, cx.tcx), &paths::RESULT) {
238-
span_lint(
239-
cx,
240-
MISSING_ERRORS_DOC,
241-
span,
242-
"docs for function returning `Result` missing `# Errors` section",
243-
);
244-
}
245-
}
246-
}
227+
} else {
228+
use TyKind::*;
229+
if_chain! {
230+
if let Some(body_id) = body_id;
231+
if let Some(future) = get_trait_def_id(cx, &paths::FUTURE);
232+
let def_id = cx.tcx.hir().body_owner_def_id(body_id);
233+
let mir = cx.tcx.optimized_mir(def_id);
234+
let ret_ty = mir.return_ty();
235+
if implements_trait(cx, ret_ty, future, &[]);
236+
if let Opaque(_, subs) = ret_ty.kind;
237+
if let Some(ty) = subs.types().next();
238+
if let Generator(_, subs, _) = ty.kind;
239+
if match_type(cx, subs.as_generator().return_ty(def_id, cx.tcx), &paths::RESULT);
240+
then {
241+
span_lint(
242+
cx,
243+
MISSING_ERRORS_DOC,
244+
span,
245+
"docs for function returning `Result` missing `# Errors` section",
246+
);
247247
}
248248
}
249249
}

0 commit comments

Comments
 (0)