Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit f550dab

Browse files
authored
Unrolled build for rust-lang#117830
Rollup merge of rust-lang#117830 - Nilstrieb:object-lifetime-default-nits, r=cjgillot Small improvements in object lifetime default code I found those while trying to understand how the code works.
2 parents 4bd2fd5 + 8bcd221 commit f550dab

File tree

3 files changed

+4
-10
lines changed

3 files changed

+4
-10
lines changed

compiler/rustc_hir_analysis/src/astconv/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2847,6 +2847,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
28472847
/// provided, if they provided one, and otherwise search the supertypes of trait bounds
28482848
/// for region bounds. It may be that we can derive no bound at all, in which case
28492849
/// we return `None`.
2850+
#[instrument(level = "debug", skip(self, span), ret)]
28502851
fn compute_object_lifetime_bound(
28512852
&self,
28522853
span: Span,
@@ -2855,8 +2856,6 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
28552856
{
28562857
let tcx = self.tcx();
28572858

2858-
debug!("compute_opt_region_bound(existential_predicates={:?})", existential_predicates);
2859-
28602859
// No explicit region bound specified. Therefore, examine trait
28612860
// bounds and see if we can derive region bounds from those.
28622861
let derived_region_bounds = object_region_bounds(tcx, existential_predicates);

compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1848,8 +1848,8 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
18481848
}
18491849
}
18501850

1851+
#[instrument(level = "debug", skip(self))]
18511852
fn resolve_object_lifetime_default(&mut self, lifetime_ref: &'tcx hir::Lifetime) {
1852-
debug!("resolve_object_lifetime_default(lifetime_ref={:?})", lifetime_ref);
18531853
let mut late_depth = 0;
18541854
let mut scope = self.scope;
18551855
let lifetime = loop {

compiler/rustc_trait_selection/src/traits/wf.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -913,20 +913,15 @@ pub fn object_region_bounds<'tcx>(
913913
tcx: TyCtxt<'tcx>,
914914
existential_predicates: &'tcx ty::List<ty::PolyExistentialPredicate<'tcx>>,
915915
) -> Vec<ty::Region<'tcx>> {
916-
// Since we don't actually *know* the self type for an object,
917-
// this "open(err)" serves as a kind of dummy standin -- basically
918-
// a placeholder type.
919-
let open_ty = Ty::new_fresh(tcx, 0);
920-
921916
let predicates = existential_predicates.iter().filter_map(|predicate| {
922917
if let ty::ExistentialPredicate::Projection(_) = predicate.skip_binder() {
923918
None
924919
} else {
925-
Some(predicate.with_self_ty(tcx, open_ty))
920+
Some(predicate.with_self_ty(tcx, tcx.types.trait_object_dummy_self))
926921
}
927922
});
928923

929-
required_region_bounds(tcx, open_ty, predicates)
924+
required_region_bounds(tcx, tcx.types.trait_object_dummy_self, predicates)
930925
}
931926

932927
/// Given a set of predicates that apply to an object type, returns

0 commit comments

Comments
 (0)