]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/clippy_lints/src/types/option_option.rs
Move `{core,std}::stream::Stream` to `{core,std}::async_iter::AsyncIterator`.
[rust.git] / src / tools / clippy / clippy_lints / src / types / option_option.rs
1 use clippy_utils::diagnostics::span_lint;
2 use clippy_utils::is_ty_param_diagnostic_item;
3 use rustc_hir::{self as hir, def_id::DefId, QPath};
4 use rustc_lint::LateContext;
5 use rustc_span::symbol::sym;
6
7 use super::OPTION_OPTION;
8
9 pub(super) fn check(cx: &LateContext<'_>, hir_ty: &hir::Ty<'_>, qpath: &QPath<'_>, def_id: DefId) -> bool {
10     if cx.tcx.is_diagnostic_item(sym::Option, def_id) && is_ty_param_diagnostic_item(cx, qpath, sym::Option).is_some() {
11         span_lint(
12             cx,
13             OPTION_OPTION,
14             hir_ty.span,
15             "consider using `Option<T>` instead of `Option<Option<T>>` or a custom \
16                                  enum if you need to distinguish all 3 cases",
17         );
18         true
19     } else {
20         false
21     }
22 }