X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Ftools%2Fclippy%2Ftests%2Fui%2Fredundant_allocation.rs;h=1b4f2a66c705ec088d5396bc3dbed187e12579df;hb=12ed22ffe44d7b06e94c2fe0003ef96a20cf4b98;hp=677b3e56d4dcebe5ea58a9996b5cac7c5332cddc;hpb=a08a03ced7909d2a8d6e6df1005b6acda7f10bf4;p=rust.git diff --git a/src/tools/clippy/tests/ui/redundant_allocation.rs b/src/tools/clippy/tests/ui/redundant_allocation.rs index 677b3e56d4d..1b4f2a66c70 100644 --- a/src/tools/clippy/tests/ui/redundant_allocation.rs +++ b/src/tools/clippy/tests/ui/redundant_allocation.rs @@ -1,10 +1,7 @@ -// run-rustfix #![warn(clippy::all)] #![allow(clippy::boxed_local, clippy::needless_pass_by_value)] #![allow(clippy::blacklisted_name, unused_variables, dead_code)] - -use std::boxed::Box; -use std::rc::Rc; +#![allow(unused_imports)] pub struct MyStruct {} @@ -17,32 +14,67 @@ pub enum MyEnum { Two, } -// Rc<&T> +mod outer_box { + use crate::MyEnum; + use crate::MyStruct; + use crate::SubT; + use std::boxed::Box; + use std::rc::Rc; + use std::sync::Arc; -pub fn test1(foo: Rc<&T>) {} + pub fn box_test6(foo: Box>) {} -pub fn test2(foo: Rc<&MyStruct>) {} + pub fn box_test7(foo: Box>) {} -pub fn test3(foo: Rc<&MyEnum>) {} + pub fn box_test8() -> Box>> { + unimplemented!(); + } -pub fn test4_neg(foo: Rc>) {} + pub fn box_test9(foo: Box>) -> Box>> { + unimplemented!(); + } +} -// Rc> +mod outer_rc { + use crate::MyEnum; + use crate::MyStruct; + use crate::SubT; + use std::boxed::Box; + use std::rc::Rc; + use std::sync::Arc; -pub fn test5(a: Rc>) {} + pub fn rc_test5(a: Rc>) {} -// Rc> + pub fn rc_test7(a: Rc>) {} -pub fn test6(a: Rc>) {} + pub fn rc_test8() -> Rc>> { + unimplemented!(); + } -// Box<&T> + pub fn rc_test9(foo: Rc>) -> Rc>> { + unimplemented!(); + } +} -pub fn test7(foo: Box<&T>) {} +mod outer_arc { + use crate::MyEnum; + use crate::MyStruct; + use crate::SubT; + use std::boxed::Box; + use std::rc::Rc; + use std::sync::Arc; -pub fn test8(foo: Box<&MyStruct>) {} + pub fn arc_test5(a: Arc>) {} -pub fn test9(foo: Box<&MyEnum>) {} + pub fn arc_test6(a: Arc>) {} -pub fn test10_neg(foo: Box>) {} + pub fn arc_test8() -> Arc>> { + unimplemented!(); + } + + pub fn arc_test9(foo: Arc>) -> Arc>> { + unimplemented!(); + } +} fn main() {}