fix box-default
ignoring trait objects' types
This commit is contained in:
parent
272bbfb857
commit
bd61fdbd5f
@ -88,7 +88,7 @@ fn is_vec_expn(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
|
||||
|
||||
impl<'tcx> Visitor<'tcx> for InferVisitor {
|
||||
fn visit_ty(&mut self, t: &rustc_hir::Ty<'_>) {
|
||||
self.0 |= matches!(t.kind, TyKind::Infer);
|
||||
self.0 |= matches!(t.kind, TyKind::Infer | TyKind::OpaqueDef(..) | TyKind::TraitObject(..));
|
||||
if !self.0 {
|
||||
walk_ty(self, t);
|
||||
}
|
||||
|
@ -40,4 +40,18 @@ fn ret_ty_fn() -> Box<bool> {
|
||||
}
|
||||
|
||||
#[allow(clippy::boxed_local)]
|
||||
fn call_ty_fn(_b: Box<u8>) {}
|
||||
fn call_ty_fn(_b: Box<u8>) {
|
||||
issue_9621_dyn_trait();
|
||||
}
|
||||
|
||||
use std::io::{Read, Result};
|
||||
|
||||
impl Read for ImplementsDefault {
|
||||
fn read(&mut self, _: &mut [u8]) -> Result<usize> {
|
||||
Ok(0)
|
||||
}
|
||||
}
|
||||
|
||||
fn issue_9621_dyn_trait() {
|
||||
let _: Box<dyn Read> = Box::<ImplementsDefault>::default();
|
||||
}
|
||||
|
@ -40,4 +40,18 @@ fn ret_ty_fn() -> Box<bool> {
|
||||
}
|
||||
|
||||
#[allow(clippy::boxed_local)]
|
||||
fn call_ty_fn(_b: Box<u8>) {}
|
||||
fn call_ty_fn(_b: Box<u8>) {
|
||||
issue_9621_dyn_trait();
|
||||
}
|
||||
|
||||
use std::io::{Read, Result};
|
||||
|
||||
impl Read for ImplementsDefault {
|
||||
fn read(&mut self, _: &mut [u8]) -> Result<usize> {
|
||||
Ok(0)
|
||||
}
|
||||
}
|
||||
|
||||
fn issue_9621_dyn_trait() {
|
||||
let _: Box<dyn Read> = Box::new(ImplementsDefault::default());
|
||||
}
|
||||
|
@ -78,5 +78,11 @@ error: `Box::new(_)` of default value
|
||||
LL | Box::new(bool::default())
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::<bool>::default()`
|
||||
|
||||
error: aborting due to 13 previous errors
|
||||
error: `Box::new(_)` of default value
|
||||
--> $DIR/box_default.rs:56:28
|
||||
|
|
||||
LL | let _: Box<dyn Read> = Box::new(ImplementsDefault::default());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::<ImplementsDefault>::default()`
|
||||
|
||||
error: aborting due to 14 previous errors
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user