//! 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 {
fn span(&self) -> Span;
}
-impl HirNode for hir::Expr {
+impl HirNode for hir::Expr<'_> {
fn hir_id(&self) -> hir::HirId {
self.hir_id
}
}
}
-impl HirNode for hir::Pat {
+impl HirNode for hir::Pat<'_> {
fn hir_id(&self) -> hir::HirId {
self.hir_id
}
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))
}
/// 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
}
/// 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);
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() {
crate fn cat_expr_adjusted(
&self,
- expr: &hir::Expr,
+ expr: &hir::Expr<'_>,
previous: Place<'tcx>,
adjustment: &adjustment::Adjustment<'tcx>,
) -> McResult<Place<'tcx>> {
fn cat_expr_adjusted_with<F>(
&self,
- expr: &hir::Expr,
+ expr: &hir::Expr<'_>,
previous: F,
adjustment: &adjustment::Adjustment<'tcx>,
) -> McResult<Place<'tcx>>
}
}
- 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 {
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
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.
}
}
- 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)?;
}
}
- PatKind::Or(ref pats) => {
+ PatKind::Or(pats) => {
for pat in pats {
self.cat_pattern_(place.clone(), &pat, op)?;
}
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 => {