summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/tests/ui/box_default.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/clippy/tests/ui/box_default.rs')
-rw-r--r--src/tools/clippy/tests/ui/box_default.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/tools/clippy/tests/ui/box_default.rs b/src/tools/clippy/tests/ui/box_default.rs
index 5c8d0b835..f7d832193 100644
--- a/src/tools/clippy/tests/ui/box_default.rs
+++ b/src/tools/clippy/tests/ui/box_default.rs
@@ -33,6 +33,7 @@ fn main() {
let _vec4: Box<_> = Box::new(Vec::from([false; 0]));
let _more = ret_ty_fn();
call_ty_fn(Box::new(u8::default()));
+ issue_10381();
}
fn ret_ty_fn() -> Box<bool> {
@@ -65,3 +66,20 @@ fn issue_10089() {
let _ = Box::new(WeirdPathed::default());
};
}
+
+fn issue_10381() {
+ #[derive(Default)]
+ pub struct Foo {}
+ pub trait Bar {}
+ impl Bar for Foo {}
+
+ fn maybe_get_bar(i: u32) -> Option<Box<dyn Bar>> {
+ if i % 2 == 0 {
+ Some(Box::new(Foo::default()))
+ } else {
+ None
+ }
+ }
+
+ assert!(maybe_get_bar(2).is_some());
+}