Skip to content

Commit 826b181

Browse files
authored
Rollup merge of #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 bf8cf45 + 8bcd221 commit 826b181

File tree

3 files changed

+4
-10
lines changed

3 files changed

+4
-10
lines changed

compiler/rustc_hir_analysis/src/astconv/mod.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -2845,6 +2845,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
28452845
/// provided, if they provided one, and otherwise search the supertypes of trait bounds
28462846
/// for region bounds. It may be that we can derive no bound at all, in which case
28472847
/// we return `None`.
2848+
#[instrument(level = "debug", skip(self, span), ret)]
28482849
fn compute_object_lifetime_bound(
28492850
&self,
28502851
span: Span,
@@ -2853,8 +2854,6 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
28532854
{
28542855
let tcx = self.tcx();
28552856

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

compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs

+1-1
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

+2-7
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)