Skip to content

Commit e1e58fc

Browse files
authored
Rollup merge of rust-lang#108133 - kylematsuda:earlybinder-cleanups, r=compiler-errors
Small cleanups around `EarlyBinder` Cleaning up a few things that were brought up by `@lcnr` in reviewing rust-lang#106696: - [make `issue33140_self_ty` query return `Option<EarlyBinder<Ty>>`](rust-lang#106696 (comment)) - [small style improvement](rust-lang#106696 (comment))
2 parents 9b2ee41 + 382ade6 commit e1e58fc

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

compiler/rustc_metadata/src/rmeta/encoder.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1541,8 +1541,9 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
15411541
self.tables.impl_defaultness.set_some(def_id.index, *defaultness);
15421542
self.tables.constness.set_some(def_id.index, *constness);
15431543

1544-
let trait_ref = self.tcx.impl_trait_ref(def_id).map(ty::EarlyBinder::skip_binder);
1544+
let trait_ref = self.tcx.impl_trait_ref(def_id);
15451545
if let Some(trait_ref) = trait_ref {
1546+
let trait_ref = trait_ref.skip_binder();
15461547
let trait_def = self.tcx.trait_def(trait_ref.def_id);
15471548
if let Ok(mut an) = trait_def.ancestors(self.tcx, def_id) {
15481549
if let Some(specialization_graph::Node::Impl(parent)) = an.nth(1) {

compiler/rustc_middle/src/query/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,7 @@ rustc_queries! {
781781
separate_provide_extern
782782
}
783783

784-
query issue33140_self_ty(key: DefId) -> Option<ty::Ty<'tcx>> {
784+
query issue33140_self_ty(key: DefId) -> Option<ty::EarlyBinder<ty::Ty<'tcx>>> {
785785
desc { |tcx| "computing Self type wrt issue #33140 `{}`", tcx.def_path_str(key) }
786786
}
787787

compiler/rustc_ty_utils/src/ty.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
use rustc_data_structures::fx::FxIndexSet;
22
use rustc_hir as hir;
33
use rustc_index::bit_set::BitSet;
4-
use rustc_middle::ty::{self, Binder, Predicate, PredicateKind, ToPredicate, Ty, TyCtxt};
4+
use rustc_middle::ty::{
5+
self, Binder, EarlyBinder, Predicate, PredicateKind, ToPredicate, Ty, TyCtxt,
6+
};
57
use rustc_session::config::TraitSolver;
68
use rustc_span::def_id::{DefId, CRATE_DEF_ID};
79
use rustc_trait_selection::traits;
@@ -355,7 +357,7 @@ fn instance_def_size_estimate<'tcx>(
355357
/// If `def_id` is an issue 33140 hack impl, returns its self type; otherwise, returns `None`.
356358
///
357359
/// See [`ty::ImplOverlapKind::Issue33140`] for more details.
358-
fn issue33140_self_ty(tcx: TyCtxt<'_>, def_id: DefId) -> Option<Ty<'_>> {
360+
fn issue33140_self_ty(tcx: TyCtxt<'_>, def_id: DefId) -> Option<EarlyBinder<Ty<'_>>> {
359361
debug!("issue33140_self_ty({:?})", def_id);
360362

361363
let trait_ref = tcx
@@ -394,7 +396,7 @@ fn issue33140_self_ty(tcx: TyCtxt<'_>, def_id: DefId) -> Option<Ty<'_>> {
394396

395397
if self_ty_matches {
396398
debug!("issue33140_self_ty - MATCHES!");
397-
Some(self_ty)
399+
Some(EarlyBinder(self_ty))
398400
} else {
399401
debug!("issue33140_self_ty - non-matching self type");
400402
None

0 commit comments

Comments
 (0)