2020-03-12 15:41:13 -05:00
|
|
|
#![warn(clippy::all)]
|
|
|
|
#![allow(clippy::boxed_local, clippy::needless_pass_by_value)]
|
|
|
|
#![allow(clippy::blacklisted_name, unused_variables, dead_code)]
|
2021-06-02 00:41:52 -05:00
|
|
|
#![allow(unused_imports)]
|
2020-03-12 15:41:13 -05:00
|
|
|
|
2022-03-27 07:41:09 -05:00
|
|
|
pub struct MyStruct;
|
2020-03-12 15:41:13 -05:00
|
|
|
|
|
|
|
pub struct SubT<T> {
|
|
|
|
foo: T,
|
|
|
|
}
|
|
|
|
|
|
|
|
pub enum MyEnum {
|
|
|
|
One,
|
|
|
|
Two,
|
|
|
|
}
|
|
|
|
|
2021-06-02 00:41:52 -05:00
|
|
|
mod outer_box {
|
|
|
|
use crate::MyEnum;
|
|
|
|
use crate::MyStruct;
|
|
|
|
use crate::SubT;
|
|
|
|
use std::boxed::Box;
|
|
|
|
use std::rc::Rc;
|
|
|
|
use std::sync::Arc;
|
2020-03-12 15:41:13 -05:00
|
|
|
|
2021-06-02 00:41:52 -05:00
|
|
|
pub fn box_test6<T>(foo: Box<Rc<T>>) {}
|
2020-03-12 15:41:13 -05:00
|
|
|
|
2021-06-02 00:41:52 -05:00
|
|
|
pub fn box_test7<T>(foo: Box<Arc<T>>) {}
|
2020-03-12 15:41:13 -05:00
|
|
|
|
2021-06-02 00:41:52 -05:00
|
|
|
pub fn box_test8() -> Box<Rc<SubT<usize>>> {
|
|
|
|
unimplemented!();
|
|
|
|
}
|
2020-03-12 15:41:13 -05:00
|
|
|
|
2021-06-02 00:41:52 -05:00
|
|
|
pub fn box_test9<T>(foo: Box<Arc<T>>) -> Box<Arc<SubT<T>>> {
|
|
|
|
unimplemented!();
|
|
|
|
}
|
|
|
|
}
|
2020-03-12 15:41:13 -05:00
|
|
|
|
2021-06-02 00:41:52 -05:00
|
|
|
mod outer_rc {
|
|
|
|
use crate::MyEnum;
|
|
|
|
use crate::MyStruct;
|
|
|
|
use crate::SubT;
|
|
|
|
use std::boxed::Box;
|
|
|
|
use std::rc::Rc;
|
|
|
|
use std::sync::Arc;
|
2020-03-12 15:41:13 -05:00
|
|
|
|
2021-06-02 00:41:52 -05:00
|
|
|
pub fn rc_test5(a: Rc<Box<bool>>) {}
|
2020-03-12 15:41:13 -05:00
|
|
|
|
2021-06-02 00:41:52 -05:00
|
|
|
pub fn rc_test7(a: Rc<Arc<bool>>) {}
|
2020-03-12 15:41:13 -05:00
|
|
|
|
2021-06-02 00:41:52 -05:00
|
|
|
pub fn rc_test8() -> Rc<Box<SubT<usize>>> {
|
|
|
|
unimplemented!();
|
|
|
|
}
|
2020-03-12 15:41:13 -05:00
|
|
|
|
2021-06-02 00:41:52 -05:00
|
|
|
pub fn rc_test9<T>(foo: Rc<Arc<T>>) -> Rc<Arc<SubT<T>>> {
|
|
|
|
unimplemented!();
|
|
|
|
}
|
|
|
|
}
|
2020-03-12 15:41:13 -05:00
|
|
|
|
2021-06-02 00:41:52 -05:00
|
|
|
mod outer_arc {
|
|
|
|
use crate::MyEnum;
|
|
|
|
use crate::MyStruct;
|
|
|
|
use crate::SubT;
|
|
|
|
use std::boxed::Box;
|
|
|
|
use std::rc::Rc;
|
|
|
|
use std::sync::Arc;
|
2020-03-12 15:41:13 -05:00
|
|
|
|
2021-06-02 00:41:52 -05:00
|
|
|
pub fn arc_test5(a: Arc<Box<bool>>) {}
|
2020-03-12 15:41:13 -05:00
|
|
|
|
2021-06-02 00:41:52 -05:00
|
|
|
pub fn arc_test6(a: Arc<Rc<bool>>) {}
|
2020-03-12 15:41:13 -05:00
|
|
|
|
2021-06-02 00:41:52 -05:00
|
|
|
pub fn arc_test8() -> Arc<Box<SubT<usize>>> {
|
|
|
|
unimplemented!();
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn arc_test9<T>(foo: Arc<Rc<T>>) -> Arc<Rc<SubT<T>>> {
|
|
|
|
unimplemented!();
|
|
|
|
}
|
|
|
|
}
|
2020-03-12 15:41:13 -05:00
|
|
|
|
2021-08-22 02:22:28 -05:00
|
|
|
// 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<Box<dyn T>>,
|
|
|
|
b: Rc<Box<dyn T>>,
|
|
|
|
c: Arc<Box<dyn T>>,
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn test_box(_: Box<Box<dyn T>>) {}
|
|
|
|
pub fn test_rc(_: Rc<Box<dyn T>>) {}
|
|
|
|
pub fn test_arc(_: Arc<Box<dyn T>>) {}
|
|
|
|
pub fn test_rc_box(_: Rc<Box<Box<dyn T>>>) {}
|
|
|
|
}
|
|
|
|
|
2022-05-10 13:21:51 -05:00
|
|
|
// https://github.com/rust-lang/rust-clippy/issues/8604
|
2022-05-12 18:06:23 -05:00
|
|
|
mod box_fat_ptr {
|
2022-05-10 13:21:51 -05:00
|
|
|
use std::boxed::Box;
|
2022-05-12 18:06:23 -05:00
|
|
|
use std::path::Path;
|
2022-05-10 13:21:51 -05:00
|
|
|
use std::rc::Rc;
|
|
|
|
use std::sync::Arc;
|
|
|
|
|
2022-05-12 18:06:23 -05:00
|
|
|
pub struct DynSized {
|
|
|
|
foo: [usize],
|
|
|
|
}
|
|
|
|
|
2022-05-10 13:21:51 -05:00
|
|
|
struct S {
|
|
|
|
a: Box<Box<str>>,
|
|
|
|
b: Rc<Box<str>>,
|
|
|
|
c: Arc<Box<str>>,
|
2022-05-12 18:06:23 -05:00
|
|
|
|
|
|
|
e: Box<Box<[usize]>>,
|
|
|
|
f: Box<Box<Path>>,
|
|
|
|
g: Box<Box<DynSized>>,
|
2022-05-10 13:21:51 -05:00
|
|
|
}
|
|
|
|
|
2022-05-12 18:06:23 -05:00
|
|
|
pub fn test_box_str(_: Box<Box<str>>) {}
|
|
|
|
pub fn test_rc_str(_: Rc<Box<str>>) {}
|
|
|
|
pub fn test_arc_str(_: Arc<Box<str>>) {}
|
|
|
|
|
|
|
|
pub fn test_box_slice(_: Box<Box<[usize]>>) {}
|
|
|
|
pub fn test_box_path(_: Box<Box<Path>>) {}
|
|
|
|
pub fn test_box_custom(_: Box<Box<DynSized>>) {}
|
|
|
|
|
|
|
|
pub fn test_rc_box_str(_: Rc<Box<Box<str>>>) {}
|
|
|
|
pub fn test_rc_box_slice(_: Rc<Box<Box<[usize]>>>) {}
|
|
|
|
pub fn test_rc_box_path(_: Rc<Box<Box<Path>>>) {}
|
|
|
|
pub fn test_rc_box_custom(_: Rc<Box<Box<DynSized>>>) {}
|
2022-05-10 13:21:51 -05:00
|
|
|
}
|
|
|
|
|
2020-03-12 15:41:13 -05:00
|
|
|
fn main() {}
|