Skip to content

Commit e144a13

Browse files
committed
Replace object_safety_violations().is_empty() calls with is_object_safe
1 parent d8da513 commit e144a13

File tree

3 files changed

+3
-5
lines changed

3 files changed

+3
-5
lines changed

compiler/rustc_hir_analysis/src/check/wfcheck.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -834,7 +834,7 @@ fn check_object_unsafe_self_trait_by_name(tcx: TyCtxt<'_>, item: &hir::TraitItem
834834
_ => {}
835835
}
836836
if !trait_should_be_self.is_empty() {
837-
if tcx.object_safety_violations(trait_def_id).is_empty() {
837+
if tcx.is_object_safe(trait_def_id) {
838838
return;
839839
}
840840
let sugg = trait_should_be_self.iter().map(|span| (*span, "Self".to_string())).collect();

compiler/rustc_hir_typeck/src/coercion.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1823,7 +1823,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
18231823
.trait_ref()
18241824
.and_then(|t| t.trait_def_id())
18251825
.map_or(false, |def_id| {
1826-
fcx.tcx.object_safety_violations(def_id).is_empty()
1826+
fcx.tcx.is_object_safe(def_id)
18271827
})
18281828
})
18291829
}

compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1749,9 +1749,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
17491749
let is_object_safe = match ty.kind() {
17501750
ty::Dynamic(predicates, _, ty::Dyn) => {
17511751
// If the `dyn Trait` is not object safe, do not suggest `Box<dyn Trait>`.
1752-
predicates
1753-
.principal_def_id()
1754-
.map_or(true, |def_id| self.tcx.object_safety_violations(def_id).is_empty())
1752+
predicates.principal_def_id().map_or(true, |def_id| self.tcx.is_object_safe(def_id))
17551753
}
17561754
// We only want to suggest `impl Trait` to `dyn Trait`s.
17571755
// For example, `fn foo() -> str` needs to be filtered out.

0 commit comments

Comments
 (0)