1
Fork 0

Make use of Option/Result diagnostic items

This commit is contained in:
Philipp Hansch 2020-04-12 15:23:07 +02:00
parent 79982a2813
commit 83874d0ee7
No known key found for this signature in database
GPG key ID: 2B4399C4BF4DCBDE
14 changed files with 45 additions and 55 deletions

View file

@ -1,4 +1,4 @@
use crate::utils::{implements_trait, is_entrypoint_fn, match_type, paths, return_ty, span_lint};
use crate::utils::{implements_trait, is_entrypoint_fn, is_type_diagnostic_item, return_ty, span_lint};
use if_chain::if_chain;
use itertools::Itertools;
use rustc_ast::ast::{AttrKind, Attribute};
@ -217,7 +217,7 @@ fn lint_for_missing_headers<'a, 'tcx>(
);
}
if !headers.errors {
if match_type(cx, return_ty(cx, hir_id), &paths::RESULT) {
if is_type_diagnostic_item(cx, return_ty(cx, hir_id), sym!(result_type)) {
span_lint(
cx,
MISSING_ERRORS_DOC,
@ -235,7 +235,7 @@ fn lint_for_missing_headers<'a, 'tcx>(
if let ty::Opaque(_, subs) = ret_ty.kind;
if let Some(gen) = subs.types().next();
if let ty::Generator(_, subs, _) = gen.kind;
if match_type(cx, subs.as_generator().return_ty(), &paths::RESULT);
if is_type_diagnostic_item(cx, subs.as_generator().return_ty(), sym!(result_type));
then {
span_lint(
cx,