#![warn(clippy::all)] #![allow(clippy::boxed_local, clippy::disallowed_names)] pub struct MyStruct; pub struct SubT { foo: T, } mod outer_box { use crate::{MyStruct, SubT}; use std::boxed::Box; use std::rc::Rc; use std::sync::Arc; pub fn box_test6(foo: Box>) {} //~^ ERROR: usage of `Box>` //~| NOTE: `Rc` is already on the heap, `Box>` makes an extra allocation pub fn box_test7(foo: Box>) {} //~^ ERROR: usage of `Box>` //~| NOTE: `Arc` is already on the heap, `Box>` makes an extra allocation pub fn box_test8() -> Box>> { //~^ ERROR: usage of `Box>>` //~| NOTE: `Rc>` is already on the heap, `Box>>` makes an e unimplemented!(); } pub fn box_test9(foo: Box>) -> Box>> { //~^ ERROR: usage of `Box>` //~| NOTE: `Arc` is already on the heap, `Box>` makes an extra allocation //~| ERROR: usage of `Box>>` //~| NOTE: `Arc>` is already on the heap, `Box>>` makes an extra a unimplemented!(); } } mod outer_rc { use crate::{MyStruct, SubT}; use std::boxed::Box; use std::rc::Rc; use std::sync::Arc; pub fn rc_test5(a: Rc>) {} //~^ ERROR: usage of `Rc>` //~| NOTE: `Box` is already on the heap, `Rc>` makes an extra allocati pub fn rc_test7(a: Rc>) {} //~^ ERROR: usage of `Rc>` //~| NOTE: `Arc` is already on the heap, `Rc>` makes an extra allocati pub fn rc_test8() -> Rc>> { //~^ ERROR: usage of `Rc>>` //~| NOTE: `Box>` is already on the heap, `Rc>>` makes an unimplemented!(); } pub fn rc_test9(foo: Rc>) -> Rc>> { //~^ ERROR: usage of `Rc>` //~| NOTE: `Arc` is already on the heap, `Rc>` makes an extra allocation //~| ERROR: usage of `Rc>>` //~| NOTE: `Arc>` is already on the heap, `Rc>>` makes an extra al unimplemented!(); } } mod outer_arc { use crate::{MyStruct, SubT}; use std::boxed::Box; use std::rc::Rc; use std::sync::Arc; pub fn arc_test5(a: Arc>) {} //~^ ERROR: usage of `Arc>` //~| NOTE: `Box` is already on the heap, `Arc>` makes an extra allocat pub fn arc_test6(a: Arc>) {} //~^ ERROR: usage of `Arc>` //~| NOTE: `Rc` is already on the heap, `Arc>` makes an extra allocatio pub fn arc_test8() -> Arc>> { //~^ ERROR: usage of `Arc>>` //~| NOTE: `Box>` is already on the heap, `Arc>>` makes an unimplemented!(); } pub fn arc_test9(foo: Arc>) -> Arc>> { //~^ ERROR: usage of `Arc>` //~| NOTE: `Rc` is already on the heap, `Arc>` makes an extra allocation //~| ERROR: usage of `Arc>>` //~| NOTE: `Rc>` is already on the heap, `Arc>>` makes an extra all unimplemented!(); } } // https://github.com/rust-lang/rust-clippy/issues/7487 mod box_dyn { use std::boxed::Box; use std::rc::Rc; use std::sync::Arc; pub trait T {} struct S { a: Box>, b: Rc>, c: Arc>, } pub fn test_box(_: Box>) {} pub fn test_rc(_: Rc>) {} pub fn test_arc(_: Arc>) {} pub fn test_rc_box(_: Rc>>) {} //~^ ERROR: usage of `Rc>>` //~| NOTE: `Box>` is already on the heap, `Rc>>` makes an ex } // https://github.com/rust-lang/rust-clippy/issues/8604 mod box_fat_ptr { use std::boxed::Box; use std::path::Path; use std::rc::Rc; use std::sync::Arc; pub struct DynSized { foo: [usize], } struct S { a: Box>, b: Rc>, c: Arc>, e: Box>, f: Box>, g: Box>, } pub fn test_box_str(_: Box>) {} pub fn test_rc_str(_: Rc>) {} pub fn test_arc_str(_: Arc>) {} pub fn test_box_slice(_: Box>) {} pub fn test_box_path(_: Box>) {} pub fn test_box_custom(_: Box>) {} pub fn test_rc_box_str(_: Rc>>) {} //~^ ERROR: usage of `Rc>>` //~| NOTE: `Box>` is already on the heap, `Rc>>` makes an extra pub fn test_rc_box_slice(_: Rc>>) {} //~^ ERROR: usage of `Rc>>` //~| NOTE: `Box>` is already on the heap, `Rc>>` makes a pub fn test_rc_box_path(_: Rc>>) {} //~^ ERROR: usage of `Rc>>` //~| NOTE: `Box>` is already on the heap, `Rc>>` makes an extr pub fn test_rc_box_custom(_: Rc>>) {} //~^ ERROR: usage of `Rc>>` //~| NOTE: `Box>` is already on the heap, `Rc>>` makes } // https://github.com/rust-lang/rust-clippy/issues/11417 fn type_in_closure() { let _ = |_: &mut Box>| {}; } fn main() {}