Skip to content

Commit deb93ca

Browse files
authored
Rollup merge of #102834 - compiler-errors:unnecessary-lift, r=jyn514
Remove unnecessary `lift`/`lift_to_tcx` calls from rustdoc Not sure why they were here in the first place
2 parents 0a9b09f + 9a4d4d5 commit deb93ca

File tree

2 files changed

+9
-17
lines changed

2 files changed

+9
-17
lines changed

src/librustdoc/clean/mod.rs

+5-13
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use rustc_infer::infer::region_constraints::{Constraint, RegionConstraintData};
2222
use rustc_middle::middle::resolve_lifetime as rl;
2323
use rustc_middle::ty::fold::TypeFolder;
2424
use rustc_middle::ty::InternalSubsts;
25-
use rustc_middle::ty::{self, AdtKind, DefIdTree, EarlyBinder, Lift, Ty, TyCtxt};
25+
use rustc_middle::ty::{self, AdtKind, DefIdTree, EarlyBinder, Ty, TyCtxt};
2626
use rustc_middle::{bug, span_bug};
2727
use rustc_span::hygiene::{AstPass, MacroKind};
2828
use rustc_span::symbol::{kw, sym, Ident, Symbol};
@@ -176,8 +176,6 @@ fn clean_poly_trait_ref_with_bindings<'tcx>(
176176
poly_trait_ref: ty::PolyTraitRef<'tcx>,
177177
bindings: ThinVec<TypeBinding>,
178178
) -> GenericBound {
179-
let poly_trait_ref = poly_trait_ref.lift_to_tcx(cx.tcx).unwrap();
180-
181179
// collect any late bound regions
182180
let late_bound_regions: Vec<_> = cx
183181
.tcx
@@ -417,8 +415,7 @@ fn clean_projection<'tcx>(
417415
cx: &mut DocContext<'tcx>,
418416
def_id: Option<DefId>,
419417
) -> Type {
420-
let lifted = ty.lift_to_tcx(cx.tcx).unwrap();
421-
let trait_ = clean_trait_ref_with_bindings(cx, lifted.trait_ref(cx.tcx), ThinVec::new());
418+
let trait_ = clean_trait_ref_with_bindings(cx, ty.trait_ref(cx.tcx), ThinVec::new());
422419
let self_type = clean_middle_ty(ty.self_ty(), cx, None);
423420
let self_def_id = if let Some(def_id) = def_id {
424421
cx.tcx.opt_parent(def_id).or(Some(def_id))
@@ -1552,7 +1549,7 @@ pub(crate) fn clean_ty<'tcx>(ty: &hir::Ty<'tcx>, cx: &mut DocContext<'tcx>) -> T
15521549
}
15531550

15541551
/// Returns `None` if the type could not be normalized
1555-
fn normalize<'tcx>(cx: &mut DocContext<'tcx>, ty: Ty<'_>) -> Option<Ty<'tcx>> {
1552+
fn normalize<'tcx>(cx: &mut DocContext<'tcx>, ty: Ty<'tcx>) -> Option<Ty<'tcx>> {
15561553
// HACK: low-churn fix for #79459 while we wait for a trait normalization fix
15571554
if !cx.tcx.sess.opts.unstable_opts.normalize_docs {
15581555
return None;
@@ -1563,11 +1560,10 @@ fn normalize<'tcx>(cx: &mut DocContext<'tcx>, ty: Ty<'_>) -> Option<Ty<'tcx>> {
15631560
use rustc_middle::traits::ObligationCause;
15641561

15651562
// Try to normalize `<X as Y>::T` to a type
1566-
let lifted = ty.lift_to_tcx(cx.tcx).unwrap();
15671563
let infcx = cx.tcx.infer_ctxt().build();
15681564
let normalized = infcx
15691565
.at(&ObligationCause::dummy(), cx.param_env)
1570-
.normalize(lifted)
1566+
.normalize(ty)
15711567
.map(|resolved| infcx.resolve_vars_if_possible(resolved.value));
15721568
match normalized {
15731569
Ok(normalized_value) => {
@@ -1597,8 +1593,7 @@ pub(crate) fn clean_middle_ty<'tcx>(
15971593
ty::Float(float_ty) => Primitive(float_ty.into()),
15981594
ty::Str => Primitive(PrimitiveType::Str),
15991595
ty::Slice(ty) => Slice(Box::new(clean_middle_ty(ty, cx, None))),
1600-
ty::Array(ty, n) => {
1601-
let mut n = cx.tcx.lift(n).expect("array lift failed");
1596+
ty::Array(ty, mut n) => {
16021597
n = n.eval(cx.tcx, ty::ParamEnv::reveal_all());
16031598
let n = print_const(cx, n);
16041599
Array(Box::new(clean_middle_ty(ty, cx, None)), n)
@@ -1667,8 +1662,6 @@ pub(crate) fn clean_middle_ty<'tcx>(
16671662
.map(|pb| TypeBinding {
16681663
assoc: projection_to_path_segment(
16691664
pb.skip_binder()
1670-
.lift_to_tcx(cx.tcx)
1671-
.unwrap()
16721665
// HACK(compiler-errors): Doesn't actually matter what self
16731666
// type we put here, because we're only using the GAT's substs.
16741667
.with_self_ty(cx.tcx, cx.tcx.types.self_param)
@@ -1701,7 +1694,6 @@ pub(crate) fn clean_middle_ty<'tcx>(
17011694
ty::Opaque(def_id, substs) => {
17021695
// Grab the "TraitA + TraitB" from `impl TraitA + TraitB`,
17031696
// by looking up the bounds associated with the def_id.
1704-
let substs = cx.tcx.lift(substs).expect("Opaque lift failed");
17051697
let bounds = cx
17061698
.tcx
17071699
.explicit_item_bounds(def_id)

src/librustdoc/clean/utils.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -304,9 +304,9 @@ fn format_integer_with_underscore_sep(num: &str) -> String {
304304
.collect()
305305
}
306306

307-
fn print_const_with_custom_print_scalar(
308-
tcx: TyCtxt<'_>,
309-
ct: mir::ConstantKind<'_>,
307+
fn print_const_with_custom_print_scalar<'tcx>(
308+
tcx: TyCtxt<'tcx>,
309+
ct: mir::ConstantKind<'tcx>,
310310
underscores_and_type: bool,
311311
) -> String {
312312
// Use a slightly different format for integer types which always shows the actual value.
@@ -320,7 +320,7 @@ fn print_const_with_custom_print_scalar(
320320
}
321321
}
322322
(mir::ConstantKind::Val(ConstValue::Scalar(int), _), ty::Int(i)) => {
323-
let ty = tcx.lift(ct.ty()).unwrap();
323+
let ty = ct.ty();
324324
let size = tcx.layout_of(ty::ParamEnv::empty().and(ty)).unwrap().size;
325325
let data = int.assert_bits(size);
326326
let sign_extended_data = size.sign_extend(data) as i128;

0 commit comments

Comments
 (0)