Skip to content

Commit d386717

Browse files
Simplify object_region_bounds
1 parent 7db7489 commit d386717

File tree

2 files changed

+7
-30
lines changed

2 files changed

+7
-30
lines changed

compiler/rustc_hir_analysis/src/hir_ty_lowering/dyn_compatibility.rs

-1
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,6 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
194194
for def_ids in associated_types.values_mut() {
195195
for (projection_bound, span) in &projection_bounds {
196196
let def_id = projection_bound.projection_def_id();
197-
// FIXME(#120456) - is `swap_remove` correct?
198197
def_ids.swap_remove(&def_id);
199198
if tcx.generics_require_sized_self(def_id) {
200199
tcx.emit_node_span_lint(

compiler/rustc_trait_selection/src/traits/wf.rs

+7-29
Original file line numberDiff line numberDiff line change
@@ -963,30 +963,7 @@ impl<'a, 'tcx> TypeVisitor<TyCtxt<'tcx>> for WfPredicates<'a, 'tcx> {
963963
/// bounds that must hold on the elided self type. These are derived
964964
/// from the declarations of `SomeTrait`, `Send`, and friends -- if
965965
/// they declare `trait SomeTrait : 'static`, for example, then
966-
/// `'static` would appear in the list. The hard work is done by
967-
/// `infer::required_region_bounds`, see that for more information.
968-
pub fn object_region_bounds<'tcx>(
969-
tcx: TyCtxt<'tcx>,
970-
existential_predicates: &'tcx ty::List<ty::PolyExistentialPredicate<'tcx>>,
971-
) -> Vec<ty::Region<'tcx>> {
972-
let predicates = existential_predicates.iter().filter_map(|predicate| {
973-
if let ty::ExistentialPredicate::Projection(_) = predicate.skip_binder() {
974-
None
975-
} else {
976-
Some(predicate.with_self_ty(tcx, tcx.types.trait_object_dummy_self))
977-
}
978-
});
979-
980-
required_region_bounds(tcx, tcx.types.trait_object_dummy_self, predicates)
981-
}
982-
983-
/// Given a set of predicates that apply to an object type, returns
984-
/// the region bounds that the (erased) `Self` type must
985-
/// outlive. Precisely *because* the `Self` type is erased, the
986-
/// parameter `erased_self_ty` must be supplied to indicate what type
987-
/// has been used to represent `Self` in the predicates
988-
/// themselves. This should really be a unique type; `FreshTy(0)` is a
989-
/// popular choice.
966+
/// `'static` would appear in the list.
990967
///
991968
/// N.B., in some cases, particularly around higher-ranked bounds,
992969
/// this function returns a kind of conservative approximation.
@@ -996,13 +973,14 @@ pub fn object_region_bounds<'tcx>(
996973
///
997974
/// Requires that trait definitions have been processed so that we can
998975
/// elaborate predicates and walk supertraits.
999-
#[instrument(skip(tcx, predicates), level = "debug", ret)]
1000-
pub(crate) fn required_region_bounds<'tcx>(
976+
pub fn object_region_bounds<'tcx>(
1001977
tcx: TyCtxt<'tcx>,
1002-
erased_self_ty: Ty<'tcx>,
1003-
predicates: impl Iterator<Item = ty::Clause<'tcx>>,
978+
existential_predicates: &'tcx ty::List<ty::PolyExistentialPredicate<'tcx>>,
1004979
) -> Vec<ty::Region<'tcx>> {
1005-
assert!(!erased_self_ty.has_escaping_bound_vars());
980+
let erased_self_ty = tcx.types.trait_object_dummy_self;
981+
982+
let predicates =
983+
existential_predicates.iter().map(|predicate| predicate.with_self_ty(tcx, erased_self_ty));
1006984

1007985
traits::elaborate(tcx, predicates)
1008986
.filter_map(|pred| {

0 commit comments

Comments
 (0)