rust/tests/ui/borrow_box.rs

82 lines
1.2 KiB
Rust
Raw Normal View History

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