Skip to content

Commit 5dea1d1

Browse files
committedDec 13, 2022
EarlyBinder nits
1 parent b96d9e0 commit 5dea1d1

File tree

4 files changed

+20
-17
lines changed

4 files changed

+20
-17
lines changed
 

‎compiler/rustc_hir_analysis/src/astconv/mod.rs

+5-9
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,9 @@ use rustc_hir::intravisit::{walk_generics, Visitor as _};
2626
use rustc_hir::{GenericArg, GenericArgs, OpaqueTyOrigin};
2727
use rustc_middle::middle::stability::AllowUnstable;
2828
use rustc_middle::ty::subst::{self, GenericArgKind, InternalSubsts, SubstsRef};
29-
use rustc_middle::ty::DynKind;
3029
use rustc_middle::ty::GenericParamDefKind;
31-
use rustc_middle::ty::{
32-
self, Const, DefIdTree, EarlyBinder, IsSuggestable, Ty, TyCtxt, TypeVisitable,
33-
};
30+
use rustc_middle::ty::{self, Const, DefIdTree, IsSuggestable, Ty, TyCtxt, TypeVisitable};
31+
use rustc_middle::ty::{DynKind, EarlyBinder};
3432
use rustc_session::lint::builtin::{AMBIGUOUS_ASSOCIATED_ITEMS, BARE_TRAIT_OBJECTS};
3533
use rustc_span::edition::Edition;
3634
use rustc_span::lev_distance::find_best_match_for_name;
@@ -490,7 +488,8 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
490488
self.astconv
491489
.normalize_ty(
492490
self.span,
493-
EarlyBinder(tcx.at(self.span).type_of(param.def_id))
491+
tcx.at(self.span)
492+
.bound_type_of(param.def_id)
494493
.subst(tcx, substs),
495494
)
496495
.into()
@@ -1258,10 +1257,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
12581257
item_segment: &hir::PathSegment<'_>,
12591258
) -> Ty<'tcx> {
12601259
let substs = self.ast_path_substs_for_ty(span, did, item_segment);
1261-
self.normalize_ty(
1262-
span,
1263-
EarlyBinder(self.tcx().at(span).type_of(did)).subst(self.tcx(), substs),
1264-
)
1260+
self.normalize_ty(span, self.tcx().at(span).bound_type_of(did).subst(self.tcx(), substs))
12651261
}
12661262

12671263
fn conv_object_ty_poly_trait_ref(

‎compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs

+1
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
336336
/// Basically whenever we are converting from a type scheme into
337337
/// the fn body space, we always want to normalize associated
338338
/// types as well. This function combines the two.
339+
// FIXME(compiler-errors): Remove this.
339340
fn instantiate_type_scheme<T>(&self, span: Span, substs: SubstsRef<'tcx>, value: T) -> T
340341
where
341342
T: TypeFoldable<'tcx>,

‎compiler/rustc_infer/src/infer/outlives/verify.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::infer::{GenericKind, VerifyBound};
55
use rustc_data_structures::sso::SsoHashSet;
66
use rustc_hir::def_id::DefId;
77
use rustc_middle::ty::GenericArg;
8-
use rustc_middle::ty::{self, EarlyBinder, OutlivesPredicate, SubstsRef, Ty, TyCtxt};
8+
use rustc_middle::ty::{self, OutlivesPredicate, SubstsRef, Ty, TyCtxt};
99

1010
use smallvec::smallvec;
1111

@@ -304,14 +304,13 @@ impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> {
304304
substs: SubstsRef<'tcx>,
305305
) -> impl Iterator<Item = ty::Region<'tcx>> {
306306
let tcx = self.tcx;
307-
let bounds = tcx.item_bounds(def_id);
308-
trace!("{:#?}", bounds);
307+
let bounds = tcx.bound_item_bounds(def_id);
308+
trace!("{:#?}", bounds.0);
309309
bounds
310-
.into_iter()
310+
.subst_iter(tcx, substs)
311311
.filter_map(|p| p.to_opt_type_outlives())
312312
.filter_map(|p| p.no_bound_vars())
313-
.map(|b| b.1)
314-
.map(move |r| EarlyBinder(r).subst(tcx, substs))
313+
.map(|OutlivesPredicate(_, r)| r)
315314
}
316315

317316
/// Searches through a predicate list for a predicate `T: 'a`.

‎compiler/rustc_middle/src/ty/util.rs

+9-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ use crate::middle::codegen_fn_attrs::CodegenFnAttrFlags;
44
use crate::mir;
55
use crate::ty::layout::IntegerExt;
66
use crate::ty::{
7-
self, DefIdTree, FallibleTypeFolder, Ty, TyCtxt, TypeFoldable, TypeFolder, TypeSuperFoldable,
8-
TypeVisitable,
7+
self, DefIdTree, FallibleTypeFolder, Ty, TyCtxt, TypeFoldable, TypeFolder,
8+
TypeSuperFoldable, TypeVisitable,
99
};
10+
use crate::ty::query::TyCtxtAt;
1011
use crate::ty::{GenericArgKind, SubstsRef};
1112
use rustc_apfloat::Float as _;
1213
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
@@ -770,6 +771,12 @@ impl<'tcx> TyCtxt<'tcx> {
770771
}
771772
}
772773

774+
impl<'tcx> TyCtxtAt<'tcx> {
775+
pub fn bound_type_of(self, def_id: DefId) -> ty::EarlyBinder<Ty<'tcx>> {
776+
ty::EarlyBinder(self.type_of(def_id))
777+
}
778+
}
779+
773780
struct OpaqueTypeExpander<'tcx> {
774781
// Contains the DefIds of the opaque types that are currently being
775782
// expanded. When we expand an opaque type we insert the DefId of

0 commit comments

Comments
 (0)
Please sign in to comment.