X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;ds=sidebyside;f=clippy_lints%2Fsrc%2Fref_option_ref.rs;h=909d6971a5497305a7937bd7b70984e7ffb729b6;hb=d647696c1f167802c9bb9ffe2c98459b152d563c;hp=0cf4e0ce7fe225bc0400d100b80b844e50f98a2e;hpb=f0ceb28ba16c9f7c138a4311cabcf44bacc923ce;p=rust.git diff --git a/clippy_lints/src/ref_option_ref.rs b/clippy_lints/src/ref_option_ref.rs index 0cf4e0ce7fe..909d6971a54 100644 --- a/clippy_lints/src/ref_option_ref.rs +++ b/clippy_lints/src/ref_option_ref.rs @@ -9,16 +9,18 @@ use rustc_span::symbol::sym; declare_clippy_lint! { - /// **What it does:** Checks for usage of `&Option<&T>`. + /// ### What it does + /// Checks for usage of `&Option<&T>`. /// - /// **Why is this bad?** Since `&` is Copy, it's useless to have a + /// ### Why is this bad? + /// Since `&` is Copy, it's useless to have a /// reference on `Option<&T>`. /// - /// **Known problems:** It may be irrelevant to use this lint on + /// ### Known problems + /// It may be irrelevant to use this lint on /// public API code as it will make a breaking change to apply it. /// - /// **Example:** - /// + /// ### Example /// ```rust,ignore /// let x: &Option<&u32> = &Some(&0u32); /// ``` @@ -26,6 +28,7 @@ /// ```rust,ignore /// let x: Option<&u32> = Some(&0u32); /// ``` + #[clippy::version = "1.49.0"] pub REF_OPTION_REF, pedantic, "use `Option<&T>` instead of `&Option<&T>`" @@ -43,7 +46,7 @@ fn check_ty(&mut self, cx: &LateContext<'tcx>, ty: &'tcx Ty<'tcx>) { if let Some(res) = last.res; if let Some(def_id) = res.opt_def_id(); - if cx.tcx.is_diagnostic_item(sym::option_type, def_id); + if cx.tcx.is_diagnostic_item(sym::Option, def_id); if let Some(params) = last_path_segment(qpath).args ; if !params.parenthesized; if let Some(inner_ty) = params.args.iter().find_map(|arg| match arg {