Skip to content

Commit 94e59cb

Browse files
committed
Rename is_object_safe to check_is_object_safe to hint side effects
1 parent d6de40b commit 94e59cb

File tree

12 files changed

+17
-14
lines changed

12 files changed

+17
-14
lines changed

compiler/rustc_hir_analysis/src/check/wfcheck.rs

+1-1
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.is_object_safe(trait_def_id) {
837+
if tcx.check_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_analysis/src/coherence/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ fn check_object_overlap<'tcx>(
169169
});
170170

171171
for component_def_id in component_def_ids {
172-
if !tcx.is_object_safe(component_def_id) {
172+
if !tcx.check_is_object_safe(component_def_id) {
173173
// Without the 'object_safe_for_dispatch' feature this is an error
174174
// which will be reported by wfcheck. Ignore it here.
175175
// This is tested by `coherence-impl-trait-for-trait-object-safe.rs`.

compiler/rustc_hir_typeck/src/coercion.rs

+1-1
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.is_object_safe(def_id)
1826+
fcx.tcx.check_is_object_safe(def_id)
18271827
})
18281828
})
18291829
}

compiler/rustc_middle/src/query/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1274,8 +1274,8 @@ rustc_queries! {
12741274
query object_safety_violations(trait_id: DefId) -> &'tcx [traits::ObjectSafetyViolation] {
12751275
desc { |tcx| "determining object safety of trait `{}`", tcx.def_path_str(trait_id) }
12761276
}
1277-
query is_object_safe(trait_id: DefId) -> bool {
1278-
desc { |tcx| "determining object safety of trait `{}`", tcx.def_path_str(trait_id) }
1277+
query check_is_object_safe(trait_id: DefId) -> bool {
1278+
desc { |tcx| "checking if trait `{}` is object safe", tcx.def_path_str(trait_id) }
12791279
}
12801280

12811281
/// Gets the ParameterEnvironment for a given item; this environment

compiler/rustc_trait_selection/src/solve/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
363363
}
364364

365365
fn compute_object_safe_goal(&mut self, trait_def_id: DefId) -> QueryResult<'tcx> {
366-
if self.tcx().is_object_safe(trait_def_id) {
366+
if self.tcx().check_is_object_safe(trait_def_id) {
367367
self.make_canonical_response(Certainty::Yes)
368368
} else {
369369
Err(NoSolution)

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -1749,7 +1749,9 @@ 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.principal_def_id().map_or(true, |def_id| self.tcx.is_object_safe(def_id))
1752+
predicates
1753+
.principal_def_id()
1754+
.map_or(true, |def_id| self.tcx.check_is_object_safe(def_id))
17531755
}
17541756
// We only want to suggest `impl Trait` to `dyn Trait`s.
17551757
// For example, `fn foo() -> str` needs to be filtered out.

compiler/rustc_trait_selection/src/traits/fulfill.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
369369
}
370370

371371
ty::PredicateKind::ObjectSafe(trait_def_id) => {
372-
if !self.selcx.tcx().is_object_safe(trait_def_id) {
372+
if !self.selcx.tcx().check_is_object_safe(trait_def_id) {
373373
ProcessResult::Error(CodeSelectionError(Unimplemented))
374374
} else {
375375
ProcessResult::Changed(vec![])

compiler/rustc_trait_selection/src/traits/object_safety.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ fn object_safety_violations(tcx: TyCtxt<'_>, trait_def_id: DefId) -> &'_ [Object
6262
)
6363
}
6464

65-
fn is_object_safe(tcx: TyCtxt<'_>, trait_def_id: DefId) -> bool {
65+
fn check_is_object_safe(tcx: TyCtxt<'_>, trait_def_id: DefId) -> bool {
6666
let violations = tcx.object_safety_violations(trait_def_id);
6767

6868
if violations.is_empty() {
@@ -884,5 +884,6 @@ pub fn contains_illegal_impl_trait_in_trait<'tcx>(
884884
}
885885

886886
pub fn provide(providers: &mut ty::query::Providers) {
887-
*providers = ty::query::Providers { object_safety_violations, is_object_safe, ..*providers };
887+
*providers =
888+
ty::query::Providers { object_safety_violations, check_is_object_safe, ..*providers };
888889
}

compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
466466
if let Some(principal) = data.principal() {
467467
if !self.infcx.tcx.features().object_safe_for_dispatch {
468468
principal.with_self_ty(self.tcx(), self_ty)
469-
} else if self.tcx().is_object_safe(principal.def_id()) {
469+
} else if self.tcx().check_is_object_safe(principal.def_id()) {
470470
principal.with_self_ty(self.tcx(), self_ty)
471471
} else {
472472
return;

compiler/rustc_trait_selection/src/traits/select/confirmation.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1009,7 +1009,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
10091009
// `T` -> `Trait`
10101010
(_, &ty::Dynamic(ref data, r, ty::Dyn)) => {
10111011
let mut object_dids = data.auto_traits().chain(data.principal_def_id());
1012-
if let Some(did) = object_dids.find(|did| !tcx.is_object_safe(*did)) {
1012+
if let Some(did) = object_dids.find(|did| !tcx.check_is_object_safe(*did)) {
10131013
return Err(TraitNotObjectSafe(did));
10141014
}
10151015

compiler/rustc_trait_selection/src/traits/select/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
797797
}
798798

799799
ty::PredicateKind::ObjectSafe(trait_def_id) => {
800-
if self.tcx().is_object_safe(trait_def_id) {
800+
if self.tcx().check_is_object_safe(trait_def_id) {
801801
Ok(EvaluatedToOk)
802802
} else {
803803
Ok(EvaluatedToErr)

compiler/rustc_traits/src/chalk/db.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
580580
}
581581

582582
fn is_object_safe(&self, trait_id: chalk_ir::TraitId<RustInterner<'tcx>>) -> bool {
583-
self.interner.tcx.is_object_safe(trait_id.0)
583+
self.interner.tcx.check_is_object_safe(trait_id.0)
584584
}
585585

586586
fn hidden_opaque_type(

0 commit comments

Comments
 (0)