rust-clippy/tests/ui/borrow_box.rs

82 lines
1.3 KiB
Rust
Raw Normal View History

2018-07-28 15:34:52 +00:00
#![deny(clippy::borrowed_box)]
#![allow(clippy::blacklisted_name)]
2017-06-11 03:50:57 +00:00
#![allow(unused_variables)]
#![allow(dead_code)]
pub fn test1(foo: &mut Box<bool>) {
println!("{:?}", foo)
}
pub fn test2() {
let foo: &Box<bool>;
}
struct Test3<'a> {
2018-12-09 22:26:16 +00:00
foo: &'a Box<bool>,
2017-06-11 03:50:57 +00:00
}
trait Test4 {
fn test4(a: &Box<bool>);
}
impl<'a> Test4 for Test3<'a> {
fn test4(a: &Box<bool>) {
unimplemented!();
}
}
2017-08-14 20:04:56 +00:00
use std::any::Any;
pub fn test5(foo: &mut Box<dyn Any>) {
2017-08-14 20:04:56 +00:00
println!("{:?}", foo)
}
pub fn test6() {
let foo: &Box<dyn Any>;
2017-08-14 20:04:56 +00:00
}
struct Test7<'a> {
foo: &'a Box<dyn Any>,
2017-08-14 20:04:56 +00:00
}
trait Test8 {
fn test8(a: &Box<dyn Any>);
2017-08-14 20:04:56 +00:00
}
impl<'a> Test8 for Test7<'a> {
fn test8(a: &Box<dyn Any>) {
2017-08-14 20:04:56 +00:00
unimplemented!();
}
}
pub fn test9(foo: &mut Box<dyn Any + Send + Sync>) {
2017-08-14 20:04:56 +00:00
let _ = foo;
}
pub fn test10() {
let foo: &Box<dyn Any + Send + 'static>;
2017-08-14 20:04:56 +00:00
}
struct Test11<'a> {
foo: &'a Box<dyn Any + Send>,
2017-08-14 20:04:56 +00:00
}
trait Test12 {
fn test4(a: &Box<dyn Any + 'static>);
2017-08-14 20:04:56 +00:00
}
impl<'a> Test12 for Test11<'a> {
fn test4(a: &Box<dyn Any + 'static>) {
2017-08-14 20:04:56 +00:00
unimplemented!();
}
}
2018-12-09 22:26:16 +00:00
fn main() {
2017-06-11 03:50:57 +00:00
test1(&mut Box::new(false));
test2();
test5(&mut (Box::new(false) as Box<dyn Any>));
2017-08-14 20:04:56 +00:00
test6();
test9(&mut (Box::new(false) as Box<dyn Any + Send + Sync>));
2017-08-14 20:04:56 +00:00
test10();
2017-06-11 03:50:57 +00:00
}