]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_typeck/mem_categorization.rs
Rollup merge of #68994 - Keruspe:sanitizers-conflict, r=Mark-Simulacrum
[rust.git] / src / librustc_typeck / mem_categorization.rs
index 8bca422ca184789160e8132479f0a9013fc3d450..d3d0aa2e5807fc8b99d9896575488135c3d33e76 100644 (file)
 //! result of `*x'`, effectively, where `x'` is a `Categorization::Upvar` reference
 //! tied to `x`. The type of `x'` will be a borrowed pointer.
 
-use rustc::hir;
-use rustc::hir::def::{DefKind, Res};
-use rustc::hir::def_id::DefId;
-use rustc::hir::PatKind;
 use rustc::infer::InferCtxt;
 use rustc::ty::adjustment;
 use rustc::ty::fold::TypeFoldable;
 use rustc::ty::{self, Ty, TyCtxt};
-
-use syntax_pos::Span;
-
 use rustc_data_structures::fx::FxIndexMap;
+use rustc_hir as hir;
+use rustc_hir::def::{DefKind, Res};
+use rustc_hir::def_id::DefId;
+use rustc_hir::PatKind;
+use rustc_span::Span;
 
 #[derive(Clone, Debug)]
 pub enum PlaceBase {
@@ -117,7 +115,7 @@ impl<'tcx> Place<'tcx> {
     fn span(&self) -> Span;
 }
 
-impl HirNode for hir::Expr {
+impl HirNode for hir::Expr<'_> {
     fn hir_id(&self) -> hir::HirId {
         self.hir_id
     }
@@ -126,7 +124,7 @@ fn span(&self) -> Span {
     }
 }
 
-impl HirNode for hir::Pat {
+impl HirNode for hir::Pat<'_> {
     fn hir_id(&self) -> hir::HirId {
         self.hir_id
     }
@@ -213,11 +211,11 @@ fn resolve_type_vars_or_error(
         self.resolve_type_vars_or_error(hir_id, self.tables.node_type_opt(hir_id))
     }
 
-    fn expr_ty(&self, expr: &hir::Expr) -> McResult<Ty<'tcx>> {
+    fn expr_ty(&self, expr: &hir::Expr<'_>) -> McResult<Ty<'tcx>> {
         self.resolve_type_vars_or_error(expr.hir_id, self.tables.expr_ty_opt(expr))
     }
 
-    crate fn expr_ty_adjusted(&self, expr: &hir::Expr) -> McResult<Ty<'tcx>> {
+    crate fn expr_ty_adjusted(&self, expr: &hir::Expr<'_>) -> McResult<Ty<'tcx>> {
         self.resolve_type_vars_or_error(expr.hir_id, self.tables.expr_ty_adjusted_opt(expr))
     }
 
@@ -231,7 +229,7 @@ fn expr_ty(&self, expr: &hir::Expr) -> McResult<Ty<'tcx>> {
     ///   implicit deref patterns attached (e.g., it is really
     ///   `&Some(x)`). In that case, we return the "outermost" type
     ///   (e.g., `&Option<T>).
-    crate fn pat_ty_adjusted(&self, pat: &hir::Pat) -> McResult<Ty<'tcx>> {
+    crate fn pat_ty_adjusted(&self, pat: &hir::Pat<'_>) -> McResult<Ty<'tcx>> {
         // Check for implicit `&` types wrapping the pattern; note
         // that these are never attached to binding patterns, so
         // actually this is somewhat "disjoint" from the code below
@@ -247,7 +245,7 @@ fn expr_ty(&self, expr: &hir::Expr) -> McResult<Ty<'tcx>> {
     }
 
     /// Like `pat_ty`, but ignores implicit `&` patterns.
-    fn pat_ty_unadjusted(&self, pat: &hir::Pat) -> McResult<Ty<'tcx>> {
+    fn pat_ty_unadjusted(&self, pat: &hir::Pat<'_>) -> McResult<Ty<'tcx>> {
         let base_ty = self.node_ty(pat.hir_id)?;
         debug!("pat_ty(pat={:?}) base_ty={:?}", pat, base_ty);
 
@@ -280,12 +278,12 @@ fn pat_ty_unadjusted(&self, pat: &hir::Pat) -> McResult<Ty<'tcx>> {
         Ok(ret_ty)
     }
 
-    crate fn cat_expr(&self, expr: &hir::Expr) -> McResult<Place<'tcx>> {
+    crate fn cat_expr(&self, expr: &hir::Expr<'_>) -> McResult<Place<'tcx>> {
         // This recursion helper avoids going through *too many*
         // adjustments, since *only* non-overloaded deref recurses.
         fn helper<'a, 'tcx>(
             mc: &MemCategorizationContext<'a, 'tcx>,
-            expr: &hir::Expr,
+            expr: &hir::Expr<'_>,
             adjustments: &[adjustment::Adjustment<'tcx>],
         ) -> McResult<Place<'tcx>> {
             match adjustments.split_last() {
@@ -301,7 +299,7 @@ fn helper<'a, 'tcx>(
 
     crate fn cat_expr_adjusted(
         &self,
-        expr: &hir::Expr,
+        expr: &hir::Expr<'_>,
         previous: Place<'tcx>,
         adjustment: &adjustment::Adjustment<'tcx>,
     ) -> McResult<Place<'tcx>> {
@@ -310,7 +308,7 @@ fn helper<'a, 'tcx>(
 
     fn cat_expr_adjusted_with<F>(
         &self,
-        expr: &hir::Expr,
+        expr: &hir::Expr<'_>,
         previous: F,
         adjustment: &adjustment::Adjustment<'tcx>,
     ) -> McResult<Place<'tcx>>
@@ -342,12 +340,12 @@ fn cat_expr_adjusted_with<F>(
         }
     }
 
-    crate fn cat_expr_unadjusted(&self, expr: &hir::Expr) -> McResult<Place<'tcx>> {
+    crate fn cat_expr_unadjusted(&self, expr: &hir::Expr<'_>) -> McResult<Place<'tcx>> {
         debug!("cat_expr: id={} expr={:?}", expr.hir_id, expr);
 
         let expr_ty = self.expr_ty(expr)?;
         match expr.kind {
-            hir::ExprKind::Unary(hir::UnDeref, ref e_base) => {
+            hir::ExprKind::Unary(hir::UnOp::UnDeref, ref e_base) => {
                 if self.tables.is_method_call(expr) {
                     self.cat_overloaded_place(expr, e_base)
                 } else {
@@ -513,7 +511,11 @@ fn cat_upvar(
         ret
     }
 
-    fn cat_overloaded_place(&self, expr: &hir::Expr, base: &hir::Expr) -> McResult<Place<'tcx>> {
+    fn cat_overloaded_place(
+        &self,
+        expr: &hir::Expr<'_>,
+        base: &hir::Expr<'_>,
+    ) -> McResult<Place<'tcx>> {
         debug!("cat_overloaded_place(expr={:?}, base={:?})", expr, base);
 
         // Reconstruct the output assuming it's a reference with the
@@ -557,17 +559,27 @@ fn cat_deref(&self, node: &impl HirNode, base_place: Place<'tcx>) -> McResult<Pl
         Ok(ret)
     }
 
-    crate fn cat_pattern<F>(&self, place: Place<'tcx>, pat: &hir::Pat, mut op: F) -> McResult<()>
+    crate fn cat_pattern<F>(
+        &self,
+        place: Place<'tcx>,
+        pat: &hir::Pat<'_>,
+        mut op: F,
+    ) -> McResult<()>
     where
-        F: FnMut(&Place<'tcx>, &hir::Pat),
+        F: FnMut(&Place<'tcx>, &hir::Pat<'_>),
     {
         self.cat_pattern_(place, pat, &mut op)
     }
 
     // FIXME(#19596) This is a workaround, but there should be a better way to do this
-    fn cat_pattern_<F>(&self, mut place: Place<'tcx>, pat: &hir::Pat, op: &mut F) -> McResult<()>
+    fn cat_pattern_<F>(
+        &self,
+        mut place: Place<'tcx>,
+        pat: &hir::Pat<'_>,
+        op: &mut F,
+    ) -> McResult<()>
     where
-        F: FnMut(&Place<'tcx>, &hir::Pat),
+        F: FnMut(&Place<'tcx>, &hir::Pat<'_>),
     {
         // Here, `place` is the `Place` being matched and pat is the pattern it
         // is being matched against.
@@ -638,7 +650,7 @@ fn cat_pattern_<F>(&self, mut place: Place<'tcx>, pat: &hir::Pat, op: &mut F) ->
                 }
             }
 
-            PatKind::Struct(_, ref field_pats, _) => {
+            PatKind::Struct(_, field_pats, _) => {
                 // S { f1: p1, ..., fN: pN }
                 for fp in field_pats {
                     let field_ty = self.pat_ty_adjusted(&fp.pat)?;
@@ -647,7 +659,7 @@ fn cat_pattern_<F>(&self, mut place: Place<'tcx>, pat: &hir::Pat, op: &mut F) ->
                 }
             }
 
-            PatKind::Or(ref pats) => {
+            PatKind::Or(pats) => {
                 for pat in pats {
                     self.cat_pattern_(place.clone(), &pat, op)?;
                 }
@@ -665,7 +677,7 @@ fn cat_pattern_<F>(&self, mut place: Place<'tcx>, pat: &hir::Pat, op: &mut F) ->
                 self.cat_pattern_(subplace, &subpat, op)?;
             }
 
-            PatKind::Slice(ref before, ref slice, ref after) => {
+            PatKind::Slice(before, ref slice, after) => {
                 let element_ty = match place.ty.builtin_index() {
                     Some(ty) => ty,
                     None => {