1
Fork 0

Replace object_safety_violations().is_empty() calls with is_object_safe

This commit is contained in:
Gary Guo 2022-12-29 09:52:46 +00:00
parent d8da513668
commit e144a13254
3 changed files with 3 additions and 5 deletions

View file

@ -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.