//@revisions: private all //@[private] rustc-env:CLIPPY_CONF_DIR=tests/ui/ref_option/private //@[all] rustc-env:CLIPPY_CONF_DIR=tests/ui/ref_option/all #![allow(unused, clippy::needless_lifetimes, clippy::borrowed_box)] #![warn(clippy::ref_option)] fn opt_u8(a: Option<&u8>) {} //~^ ref_option fn opt_gen(a: Option<&T>) {} //~^ ref_option fn opt_string(a: std::option::Option<&String>) {} //~^ ref_option fn ret_string<'a>(p: &'a str) -> Option<&'a u8> { //~^ ref_option panic!() } fn ret_string_static() -> Option<&'static u8> { //~^ ref_option panic!() } fn mult_string(a: Option<&String>, b: Option<&Vec>) {} //~^ ref_option fn ret_box<'a>() -> Option<&'a Box> { //~^ ref_option panic!() } pub fn pub_opt_string(a: &Option) {} //~[all]^ ref_option pub fn pub_mult_string(a: &Option, b: &Option>) {} //~[all]^ ref_option pub trait PubTrait { fn pub_trait_opt(&self, a: &Option>); //~[all]^ ref_option fn pub_trait_ret(&self) -> &Option>; //~[all]^ ref_option } trait PrivateTrait { fn trait_opt(&self, a: Option<&String>); //~^ ref_option fn trait_ret(&self) -> Option<&String>; //~^ ref_option } pub struct PubStruct; impl PubStruct { pub fn pub_opt_params(&self, a: &Option<()>) {} //~[all]^ ref_option pub fn pub_opt_ret(&self) -> &Option { //~[all]^ ref_option panic!() } fn private_opt_params(&self, a: Option<&()>) {} //~^ ref_option fn private_opt_ret(&self) -> Option<&String> { //~^ ref_option panic!() } } // valid, don't change fn mut_u8(a: &mut Option) {} pub fn pub_mut_u8(a: &mut Option) {} // might be good to catch in the future fn mut_u8_ref(a: &mut &Option) {} pub fn pub_mut_u8_ref(a: &mut &Option) {} fn lambdas() { // Not handled for now, not sure if we should let x = |a: &Option| {}; let x = |a: &Option| -> &Option { panic!() }; } fn main() {}