Replace object_safety_violations().is_empty()
calls with is_object_safe
This commit is contained in:
parent
d8da513668
commit
e144a13254
3 changed files with 3 additions and 5 deletions
|
@ -1749,9 +1749,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
let is_object_safe = match ty.kind() {
|
||||
ty::Dynamic(predicates, _, ty::Dyn) => {
|
||||
// If the `dyn Trait` is not object safe, do not suggest `Box<dyn Trait>`.
|
||||
predicates
|
||||
.principal_def_id()
|
||||
.map_or(true, |def_id| self.tcx.object_safety_violations(def_id).is_empty())
|
||||
predicates.principal_def_id().map_or(true, |def_id| self.tcx.is_object_safe(def_id))
|
||||
}
|
||||
// We only want to suggest `impl Trait` to `dyn Trait`s.
|
||||
// For example, `fn foo() -> str` needs to be filtered out.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue