File tree 4 files changed +38
-4
lines changed
4 files changed +38
-4
lines changed Original file line number Diff line number Diff line change @@ -88,7 +88,7 @@ struct InferVisitor(bool);
88
88
89
89
impl < ' tcx > Visitor < ' tcx > for InferVisitor {
90
90
fn visit_ty ( & mut self , t : & rustc_hir:: Ty < ' _ > ) {
91
- self . 0 |= matches ! ( t. kind, TyKind :: Infer ) ;
91
+ self . 0 |= matches ! ( t. kind, TyKind :: Infer | TyKind :: OpaqueDef ( .. ) | TyKind :: TraitObject ( .. ) ) ;
92
92
if !self . 0 {
93
93
walk_ty ( self , t) ;
94
94
}
Original file line number Diff line number Diff line change @@ -40,4 +40,18 @@ fn ret_ty_fn() -> Box<bool> {
40
40
}
41
41
42
42
#[allow(clippy::boxed_local)]
43
- fn call_ty_fn(_b: Box<u8>) {}
43
+ fn call_ty_fn(_b: Box<u8>) {
44
+ issue_9621_dyn_trait();
45
+ }
46
+
47
+ use std::io::{Read, Result};
48
+
49
+ impl Read for ImplementsDefault {
50
+ fn read(&mut self, _: &mut [u8]) -> Result<usize> {
51
+ Ok(0)
52
+ }
53
+ }
54
+
55
+ fn issue_9621_dyn_trait() {
56
+ let _: Box<dyn Read> = Box::<ImplementsDefault>::default();
57
+ }
Original file line number Diff line number Diff line change @@ -40,4 +40,18 @@ fn ret_ty_fn() -> Box<bool> {
40
40
}
41
41
42
42
#[ allow( clippy:: boxed_local) ]
43
- fn call_ty_fn ( _b : Box < u8 > ) { }
43
+ fn call_ty_fn ( _b : Box < u8 > ) {
44
+ issue_9621_dyn_trait ( ) ;
45
+ }
46
+
47
+ use std:: io:: { Read , Result } ;
48
+
49
+ impl Read for ImplementsDefault {
50
+ fn read ( & mut self , _: & mut [ u8 ] ) -> Result < usize > {
51
+ Ok ( 0 )
52
+ }
53
+ }
54
+
55
+ fn issue_9621_dyn_trait ( ) {
56
+ let _: Box < dyn Read > = Box :: new ( ImplementsDefault :: default ( ) ) ;
57
+ }
Original file line number Diff line number Diff line change @@ -78,5 +78,11 @@ error: `Box::new(_)` of default value
78
78
LL | Box::new(bool::default())
79
79
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::<bool>::default()`
80
80
81
- error: aborting due to 13 previous errors
81
+ error: `Box::new(_)` of default value
82
+ --> $DIR/box_default.rs:56:28
83
+ |
84
+ LL | let _: Box<dyn Read> = Box::new(ImplementsDefault::default());
85
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::<ImplementsDefault>::default()`
86
+
87
+ error: aborting due to 14 previous errors
82
88
You can’t perform that action at this time.
0 commit comments