File tree Expand file tree Collapse file tree 4 files changed +38
-4
lines changed Expand file tree Collapse file tree 4 files changed +38
-4
lines changed Original file line number Diff line number Diff line change @@ -88,7 +88,7 @@ struct InferVisitor(bool);
8888
8989impl < ' tcx > Visitor < ' tcx > for InferVisitor {
9090 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 ( .. ) ) ;
9292 if !self . 0 {
9393 walk_ty ( self , t) ;
9494 }
Original file line number Diff line number Diff line change @@ -40,4 +40,18 @@ fn ret_ty_fn() -> Box<bool> {
4040}
4141
4242#[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> {
4040}
4141
4242#[ 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
7878LL | Box::new(bool::default())
7979 | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::<bool>::default()`
8080
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
8288
You can’t perform that action at this time.
0 commit comments