about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorYuki Okushi <jtitor@2k36.org>2022-10-10 00:09:43 +0900
committerGitHub <noreply@github.com>2022-10-10 00:09:43 +0900
commitdeb93ca060220e411e69788810a1da07da4bd72e (patch)
tree1bd05e5a3c24369bf55cf8b35e5ced3794960a3f /src
parent0a9b09f9fd6435d1e4a90941a1d7ffcd910dddd7 (diff)
parent9a4d4d5e6b0d68fbacc41e42fc8cb4bde3c2aea7 (diff)
downloadrust-deb93ca060220e411e69788810a1da07da4bd72e.tar.gz
rust-deb93ca060220e411e69788810a1da07da4bd72e.zip
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
Diffstat (limited to 'src')
-rw-r--r--src/librustdoc/clean/mod.rs18
-rw-r--r--src/librustdoc/clean/utils.rs8
2 files changed, 9 insertions, 17 deletions
diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs
index 602b72eb50b..8d556a962d9 100644
--- a/src/librustdoc/clean/mod.rs
+++ b/src/librustdoc/clean/mod.rs
@@ -22,7 +22,7 @@ use rustc_infer::infer::region_constraints::{Constraint, RegionConstraintData};
 use rustc_middle::middle::resolve_lifetime as rl;
 use rustc_middle::ty::fold::TypeFolder;
 use rustc_middle::ty::InternalSubsts;
-use rustc_middle::ty::{self, AdtKind, DefIdTree, EarlyBinder, Lift, Ty, TyCtxt};
+use rustc_middle::ty::{self, AdtKind, DefIdTree, EarlyBinder, Ty, TyCtxt};
 use rustc_middle::{bug, span_bug};
 use rustc_span::hygiene::{AstPass, MacroKind};
 use rustc_span::symbol::{kw, sym, Ident, Symbol};
@@ -176,8 +176,6 @@ fn clean_poly_trait_ref_with_bindings<'tcx>(
     poly_trait_ref: ty::PolyTraitRef<'tcx>,
     bindings: ThinVec<TypeBinding>,
 ) -> GenericBound {
-    let poly_trait_ref = poly_trait_ref.lift_to_tcx(cx.tcx).unwrap();
-
     // collect any late bound regions
     let late_bound_regions: Vec<_> = cx
         .tcx
@@ -417,8 +415,7 @@ fn clean_projection<'tcx>(
     cx: &mut DocContext<'tcx>,
     def_id: Option<DefId>,
 ) -> Type {
-    let lifted = ty.lift_to_tcx(cx.tcx).unwrap();
-    let trait_ = clean_trait_ref_with_bindings(cx, lifted.trait_ref(cx.tcx), ThinVec::new());
+    let trait_ = clean_trait_ref_with_bindings(cx, ty.trait_ref(cx.tcx), ThinVec::new());
     let self_type = clean_middle_ty(ty.self_ty(), cx, None);
     let self_def_id = if let Some(def_id) = def_id {
         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
 }
 
 /// Returns `None` if the type could not be normalized
-fn normalize<'tcx>(cx: &mut DocContext<'tcx>, ty: Ty<'_>) -> Option<Ty<'tcx>> {
+fn normalize<'tcx>(cx: &mut DocContext<'tcx>, ty: Ty<'tcx>) -> Option<Ty<'tcx>> {
     // HACK: low-churn fix for #79459 while we wait for a trait normalization fix
     if !cx.tcx.sess.opts.unstable_opts.normalize_docs {
         return None;
@@ -1563,11 +1560,10 @@ fn normalize<'tcx>(cx: &mut DocContext<'tcx>, ty: Ty<'_>) -> Option<Ty<'tcx>> {
     use rustc_middle::traits::ObligationCause;
 
     // Try to normalize `<X as Y>::T` to a type
-    let lifted = ty.lift_to_tcx(cx.tcx).unwrap();
     let infcx = cx.tcx.infer_ctxt().build();
     let normalized = infcx
         .at(&ObligationCause::dummy(), cx.param_env)
-        .normalize(lifted)
+        .normalize(ty)
         .map(|resolved| infcx.resolve_vars_if_possible(resolved.value));
     match normalized {
         Ok(normalized_value) => {
@@ -1597,8 +1593,7 @@ pub(crate) fn clean_middle_ty<'tcx>(
         ty::Float(float_ty) => Primitive(float_ty.into()),
         ty::Str => Primitive(PrimitiveType::Str),
         ty::Slice(ty) => Slice(Box::new(clean_middle_ty(ty, cx, None))),
-        ty::Array(ty, n) => {
-            let mut n = cx.tcx.lift(n).expect("array lift failed");
+        ty::Array(ty, mut n) => {
             n = n.eval(cx.tcx, ty::ParamEnv::reveal_all());
             let n = print_const(cx, n);
             Array(Box::new(clean_middle_ty(ty, cx, None)), n)
@@ -1667,8 +1662,6 @@ pub(crate) fn clean_middle_ty<'tcx>(
                 .map(|pb| TypeBinding {
                     assoc: projection_to_path_segment(
                         pb.skip_binder()
-                            .lift_to_tcx(cx.tcx)
-                            .unwrap()
                             // HACK(compiler-errors): Doesn't actually matter what self
                             // type we put here, because we're only using the GAT's substs.
                             .with_self_ty(cx.tcx, cx.tcx.types.self_param)
@@ -1701,7 +1694,6 @@ pub(crate) fn clean_middle_ty<'tcx>(
         ty::Opaque(def_id, substs) => {
             // Grab the "TraitA + TraitB" from `impl TraitA + TraitB`,
             // by looking up the bounds associated with the def_id.
-            let substs = cx.tcx.lift(substs).expect("Opaque lift failed");
             let bounds = cx
                 .tcx
                 .explicit_item_bounds(def_id)
diff --git a/src/librustdoc/clean/utils.rs b/src/librustdoc/clean/utils.rs
index 6b844710514..4572a712258 100644
--- a/src/librustdoc/clean/utils.rs
+++ b/src/librustdoc/clean/utils.rs
@@ -304,9 +304,9 @@ fn format_integer_with_underscore_sep(num: &str) -> String {
         .collect()
 }
 
-fn print_const_with_custom_print_scalar(
-    tcx: TyCtxt<'_>,
-    ct: mir::ConstantKind<'_>,
+fn print_const_with_custom_print_scalar<'tcx>(
+    tcx: TyCtxt<'tcx>,
+    ct: mir::ConstantKind<'tcx>,
     underscores_and_type: bool,
 ) -> String {
     // 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(
             }
         }
         (mir::ConstantKind::Val(ConstValue::Scalar(int), _), ty::Int(i)) => {
-            let ty = tcx.lift(ct.ty()).unwrap();
+            let ty = ct.ty();
             let size = tcx.layout_of(ty::ParamEnv::empty().and(ty)).unwrap().size;
             let data = int.assert_bits(size);
             let sign_extended_data = size.sign_extend(data) as i128;