From: Camille GILLOT Date: Sat, 30 Nov 2019 14:08:22 +0000 (+0100) Subject: Fallout in other crates. X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=82840353726668c624e46627ac11a1fec18d6d09;p=rust.git Fallout in other crates. --- diff --git a/src/librustc_lint/array_into_iter.rs b/src/librustc_lint/array_into_iter.rs index b6075d165dd..481ca43aa79 100644 --- a/src/librustc_lint/array_into_iter.rs +++ b/src/librustc_lint/array_into_iter.rs @@ -25,7 +25,7 @@ ); impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ArrayIntoIter { - fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx hir::Expr) { + fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx hir::Expr<'tcx>) { // We only care about method call expressions. if let hir::ExprKind::MethodCall(call, span, args) = &expr.kind { if call.ident.name != sym::into_iter { diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index 332176e1b0c..2d9e960716f 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -142,7 +142,7 @@ fn check_item(&mut self, cx: &LateContext<'_, '_>, it: &hir::Item<'_>) { } } - fn check_expr(&mut self, cx: &LateContext<'_, '_>, e: &hir::Expr) { + fn check_expr(&mut self, cx: &LateContext<'_, '_>, e: &hir::Expr<'_>) { let ty = cx.tables.node_type(e.hir_id); self.check_heap_type(cx, e.span, ty); } @@ -157,8 +157,8 @@ fn check_expr(&mut self, cx: &LateContext<'_, '_>, e: &hir::Expr) { declare_lint_pass!(NonShorthandFieldPatterns => [NON_SHORTHAND_FIELD_PATTERNS]); impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonShorthandFieldPatterns { - fn check_pat(&mut self, cx: &LateContext<'_, '_>, pat: &hir::Pat) { - if let PatKind::Struct(ref qpath, ref field_pats, _) = pat.kind { + fn check_pat(&mut self, cx: &LateContext<'_, '_>, pat: &hir::Pat<'_>) { + if let PatKind::Struct(ref qpath, field_pats, _) = pat.kind { let variant = cx .tables .pat_ty(pat) @@ -901,7 +901,7 @@ fn check_item(&mut self, cx: &LateContext<'_, '_>, it: &hir::Item<'_>) { declare_lint_pass!(MutableTransmutes => [MUTABLE_TRANSMUTES]); impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MutableTransmutes { - fn check_expr(&mut self, cx: &LateContext<'_, '_>, expr: &hir::Expr) { + fn check_expr(&mut self, cx: &LateContext<'_, '_>, expr: &hir::Expr<'_>) { use rustc_target::spec::abi::Abi::RustIntrinsic; let msg = "mutating transmuted &mut T from &T may cause undefined behavior, \ @@ -917,7 +917,7 @@ fn check_expr(&mut self, cx: &LateContext<'_, '_>, expr: &hir::Expr) { fn get_transmute_from_to<'a, 'tcx>( cx: &LateContext<'a, 'tcx>, - expr: &hir::Expr, + expr: &hir::Expr<'_>, ) -> Option<(Ty<'tcx>, Ty<'tcx>)> { let def = if let hir::ExprKind::Path(ref qpath) = expr.kind { cx.tables.qpath_res(qpath, expr.hir_id) @@ -1840,7 +1840,7 @@ fn check_crate(&mut self, cx: &EarlyContext<'_>, _: &ast::Crate) { declare_lint_pass!(InvalidValue => [INVALID_VALUE]); impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InvalidValue { - fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &hir::Expr) { + fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &hir::Expr<'_>) { #[derive(Debug, Copy, Clone, PartialEq)] enum InitKind { Zeroed, @@ -1852,7 +1852,7 @@ enum InitKind { type InitError = (String, Option); /// Test if this constant is all-0. - fn is_zero(expr: &hir::Expr) -> bool { + fn is_zero(expr: &hir::Expr<'_>) -> bool { use hir::ExprKind::*; use syntax::ast::LitKind::*; match &expr.kind { @@ -1869,7 +1869,7 @@ fn is_zero(expr: &hir::Expr) -> bool { } /// Determine if this expression is a "dangerous initialization". - fn is_dangerous_init(cx: &LateContext<'_, '_>, expr: &hir::Expr) -> Option { + fn is_dangerous_init(cx: &LateContext<'_, '_>, expr: &hir::Expr<'_>) -> Option { // `transmute` is inside an anonymous module (the `extern` block?); // `Invalid` represents the empty string and matches that. // FIXME(#66075): use diagnostic items. Somehow, that does not seem to work diff --git a/src/librustc_lint/nonstandard_style.rs b/src/librustc_lint/nonstandard_style.rs index b8b4c2b39e5..2752be9a6de 100644 --- a/src/librustc_lint/nonstandard_style.rs +++ b/src/librustc_lint/nonstandard_style.rs @@ -344,7 +344,7 @@ fn check_trait_item(&mut self, cx: &LateContext<'_, '_>, item: &hir::TraitItem<' } } - fn check_pat(&mut self, cx: &LateContext<'_, '_>, p: &hir::Pat) { + fn check_pat(&mut self, cx: &LateContext<'_, '_>, p: &hir::Pat<'_>) { if let &PatKind::Binding(_, _, ident, _) = &p.kind { self.check_snake_case(cx, "variable", &ident); } @@ -410,7 +410,7 @@ fn check_impl_item(&mut self, cx: &LateContext<'_, '_>, ii: &hir::ImplItem<'_>) } } - fn check_pat(&mut self, cx: &LateContext<'_, '_>, p: &hir::Pat) { + fn check_pat(&mut self, cx: &LateContext<'_, '_>, p: &hir::Pat<'_>) { // Lint for constants that look like binding identifiers (#7526) if let PatKind::Path(hir::QPath::Resolved(None, ref path)) = p.kind { if let Res::Def(DefKind::Const, _) = path.res { diff --git a/src/librustc_lint/types.rs b/src/librustc_lint/types.rs index 45b8666c42b..ba2087d2f26 100644 --- a/src/librustc_lint/types.rs +++ b/src/librustc_lint/types.rs @@ -65,8 +65,8 @@ fn lint_overflowing_range_endpoint<'a, 'tcx>( lit: &hir::Lit, lit_val: u128, max: u128, - expr: &'tcx hir::Expr, - parent_expr: &'tcx hir::Expr, + expr: &'tcx hir::Expr<'tcx>, + parent_expr: &'tcx hir::Expr<'tcx>, ty: &str, ) -> bool { // We only want to handle exclusive (`..`) ranges, @@ -150,7 +150,7 @@ fn get_bin_hex_repr(cx: &LateContext<'_, '_>, lit: &hir::Lit) -> Option fn report_bin_hex_error( cx: &LateContext<'_, '_>, - expr: &hir::Expr, + expr: &hir::Expr<'_>, ty: attr::IntType, repr_str: String, val: u128, @@ -244,7 +244,7 @@ macro_rules! find_fit { fn lint_int_literal<'a, 'tcx>( cx: &LateContext<'a, 'tcx>, type_limits: &TypeLimits, - e: &'tcx hir::Expr, + e: &'tcx hir::Expr<'tcx>, lit: &hir::Lit, t: ast::IntTy, v: u128, @@ -284,7 +284,7 @@ fn lint_int_literal<'a, 'tcx>( fn lint_uint_literal<'a, 'tcx>( cx: &LateContext<'a, 'tcx>, - e: &'tcx hir::Expr, + e: &'tcx hir::Expr<'tcx>, lit: &hir::Lit, t: ast::UintTy, ) { @@ -342,7 +342,7 @@ fn lint_uint_literal<'a, 'tcx>( fn lint_literal<'a, 'tcx>( cx: &LateContext<'a, 'tcx>, type_limits: &TypeLimits, - e: &'tcx hir::Expr, + e: &'tcx hir::Expr<'tcx>, lit: &hir::Lit, ) { match cx.tables.node_type(e.hir_id).kind { @@ -377,7 +377,7 @@ fn lint_literal<'a, 'tcx>( } impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits { - fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx hir::Expr) { + fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx hir::Expr<'tcx>) { match e.kind { hir::ExprKind::Unary(hir::UnNeg, ref expr) => { // propagate negation, if the negation itself isn't negated @@ -425,8 +425,8 @@ fn rev_binop(binop: hir::BinOp) -> hir::BinOp { fn check_limits( cx: &LateContext<'_, '_>, binop: hir::BinOp, - l: &hir::Expr, - r: &hir::Expr, + l: &hir::Expr<'_>, + r: &hir::Expr<'_>, ) -> bool { let (lit, expr, swap) = match (&l.kind, &r.kind) { (&hir::ExprKind::Lit(_), _) => (l, r, true), diff --git a/src/librustc_lint/unused.rs b/src/librustc_lint/unused.rs index 5f57aabe8d4..5edb81c1e51 100644 --- a/src/librustc_lint/unused.rs +++ b/src/librustc_lint/unused.rs @@ -37,7 +37,7 @@ declare_lint_pass!(UnusedResults => [UNUSED_MUST_USE, UNUSED_RESULTS]); impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults { - fn check_stmt(&mut self, cx: &LateContext<'_, '_>, s: &hir::Stmt) { + fn check_stmt(&mut self, cx: &LateContext<'_, '_>, s: &hir::Stmt<'_>) { let expr = match s.kind { hir::StmtKind::Semi(ref expr) => &**expr, _ => return, @@ -123,7 +123,7 @@ fn check_stmt(&mut self, cx: &LateContext<'_, '_>, s: &hir::Stmt) { fn check_must_use_ty<'tcx>( cx: &LateContext<'_, 'tcx>, ty: Ty<'tcx>, - expr: &hir::Expr, + expr: &hir::Expr<'_>, span: Span, descr_pre: &str, descr_post: &str, @@ -245,7 +245,7 @@ fn check_must_use_def( declare_lint_pass!(PathStatements => [PATH_STATEMENTS]); impl<'a, 'tcx> LateLintPass<'a, 'tcx> for PathStatements { - fn check_stmt(&mut self, cx: &LateContext<'_, '_>, s: &hir::Stmt) { + fn check_stmt(&mut self, cx: &LateContext<'_, '_>, s: &hir::Stmt<'_>) { if let hir::StmtKind::Semi(ref expr) = s.kind { if let hir::ExprKind::Path(_) = expr.kind { cx.span_lint(PATH_STATEMENTS, s.span, "path statement with no effect"); @@ -637,7 +637,7 @@ fn check_item(&mut self, cx: &EarlyContext<'_>, item: &ast::Item) { declare_lint_pass!(UnusedAllocation => [UNUSED_ALLOCATION]); impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedAllocation { - fn check_expr(&mut self, cx: &LateContext<'_, '_>, e: &hir::Expr) { + fn check_expr(&mut self, cx: &LateContext<'_, '_>, e: &hir::Expr<'_>) { match e.kind { hir::ExprKind::Box(_) => {} _ => return, diff --git a/src/librustc_metadata/rmeta/encoder.rs b/src/librustc_metadata/rmeta/encoder.rs index 1e93d144f15..84d5d529adf 100644 --- a/src/librustc_metadata/rmeta/encoder.rs +++ b/src/librustc_metadata/rmeta/encoder.rs @@ -1524,7 +1524,7 @@ impl Visitor<'tcx> for EncodeContext<'tcx> { fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { NestedVisitorMap::OnlyBodies(&self.tcx.hir()) } - fn visit_expr(&mut self, ex: &'tcx hir::Expr) { + fn visit_expr(&mut self, ex: &'tcx hir::Expr<'tcx>) { intravisit::walk_expr(self, ex); self.encode_info_for_expr(ex); } @@ -1587,7 +1587,7 @@ fn encode_info_for_generics(&mut self, generics: &hir::Generics) { } } - fn encode_info_for_expr(&mut self, expr: &hir::Expr) { + fn encode_info_for_expr(&mut self, expr: &hir::Expr<'_>) { match expr.kind { hir::ExprKind::Closure(..) => { let def_id = self.tcx.hir().local_def_id(expr.hir_id); diff --git a/src/librustc_mir/build/block.rs b/src/librustc_mir/build/block.rs index 077854c8ed5..da8bb6adf84 100644 --- a/src/librustc_mir/build/block.rs +++ b/src/librustc_mir/build/block.rs @@ -11,7 +11,7 @@ pub fn ast_block( &mut self, destination: &Place<'tcx>, block: BasicBlock, - ast_block: &'tcx hir::Block, + ast_block: &'tcx hir::Block<'tcx>, source_info: SourceInfo, ) -> BlockAnd<()> { let Block { diff --git a/src/librustc_mir/build/mod.rs b/src/librustc_mir/build/mod.rs index 5ecf393179c..f459ca8dbba 100644 --- a/src/librustc_mir/build/mod.rs +++ b/src/librustc_mir/build/mod.rs @@ -29,8 +29,10 @@ pub fn mir_build(tcx: TyCtxt<'_>, def_id: DefId) -> BodyAndCache<'_> { // Figure out what primary body this item has. let (body_id, return_ty_span) = match tcx.hir().get(id) { - Node::Expr(hir::Expr { kind: hir::ExprKind::Closure(_, decl, body_id, _, _), .. }) - | Node::Item(hir::Item { + Node::Expr(hir::Expr { kind: hir::ExprKind::Closure(_, decl, body_id, _, _), .. }) => { + (*body_id, decl.output.span()) + } + Node::Item(hir::Item { kind: hir::ItemKind::Fn(hir::FnSig { decl, .. }, _, body_id), .. }) @@ -529,7 +531,12 @@ fn should_abort_on_panic(tcx: TyCtxt<'_>, fn_def_id: DefId, _abi: Abi) -> bool { /////////////////////////////////////////////////////////////////////////// /// the main entry point for building MIR for a function -struct ArgInfo<'tcx>(Ty<'tcx>, Option, Option<&'tcx hir::Param>, Option); +struct ArgInfo<'tcx>( + Ty<'tcx>, + Option, + Option<&'tcx hir::Param<'tcx>>, + Option, +); fn construct_fn<'a, 'tcx, A>( hir: Cx<'a, 'tcx>, @@ -738,7 +745,7 @@ fn args_and_body( fn_def_id: DefId, arguments: &[ArgInfo<'tcx>], argument_scope: region::Scope, - ast_body: &'tcx hir::Expr, + ast_body: &'tcx hir::Expr<'tcx>, ) -> BlockAnd<()> { // Allocate locals for the function arguments for &ArgInfo(ty, _, arg_opt, _) in arguments.iter() { diff --git a/src/librustc_mir/hair/cx/block.rs b/src/librustc_mir/hair/cx/block.rs index 85adb6a0056..14f6c394530 100644 --- a/src/librustc_mir/hair/cx/block.rs +++ b/src/librustc_mir/hair/cx/block.rs @@ -8,7 +8,7 @@ use rustc_index::vec::Idx; -impl<'tcx> Mirror<'tcx> for &'tcx hir::Block { +impl<'tcx> Mirror<'tcx> for &'tcx hir::Block<'tcx> { type Output = Block<'tcx>; fn make_mirror(self, cx: &mut Cx<'_, 'tcx>) -> Block<'tcx> { @@ -37,7 +37,7 @@ fn make_mirror(self, cx: &mut Cx<'_, 'tcx>) -> Block<'tcx> { fn mirror_stmts<'a, 'tcx>( cx: &mut Cx<'a, 'tcx>, block_id: hir::ItemLocalId, - stmts: &'tcx [hir::Stmt], + stmts: &'tcx [hir::Stmt<'tcx>], ) -> Vec> { let mut result = vec![]; for (index, stmt) in stmts.iter().enumerate() { @@ -101,7 +101,10 @@ fn mirror_stmts<'a, 'tcx>( return result; } -pub fn to_expr_ref<'a, 'tcx>(cx: &mut Cx<'a, 'tcx>, block: &'tcx hir::Block) -> ExprRef<'tcx> { +pub fn to_expr_ref<'a, 'tcx>( + cx: &mut Cx<'a, 'tcx>, + block: &'tcx hir::Block<'tcx>, +) -> ExprRef<'tcx> { let block_ty = cx.tables().node_type(block.hir_id); let temp_lifetime = cx.region_scope_tree.temporary_scope(block.hir_id.local_id); let expr = Expr { diff --git a/src/librustc_mir/hair/cx/expr.rs b/src/librustc_mir/hair/cx/expr.rs index b5cd24bebc3..124b788fe8d 100644 --- a/src/librustc_mir/hair/cx/expr.rs +++ b/src/librustc_mir/hair/cx/expr.rs @@ -14,7 +14,7 @@ use rustc_index::vec::Idx; use syntax_pos::Span; -impl<'tcx> Mirror<'tcx> for &'tcx hir::Expr { +impl<'tcx> Mirror<'tcx> for &'tcx hir::Expr<'tcx> { type Output = Expr<'tcx>; fn make_mirror(self, cx: &mut Cx<'_, 'tcx>) -> Expr<'tcx> { @@ -65,7 +65,7 @@ fn make_mirror(self, cx: &mut Cx<'_, 'tcx>) -> Expr<'tcx> { fn apply_adjustment<'a, 'tcx>( cx: &mut Cx<'a, 'tcx>, - hir_expr: &'tcx hir::Expr, + hir_expr: &'tcx hir::Expr<'tcx>, mut expr: Expr<'tcx>, adjustment: &Adjustment<'tcx>, ) -> Expr<'tcx> { @@ -129,7 +129,10 @@ fn apply_adjustment<'a, 'tcx>( Expr { temp_lifetime, ty: adjustment.target, span, kind } } -fn make_mirror_unadjusted<'a, 'tcx>(cx: &mut Cx<'a, 'tcx>, expr: &'tcx hir::Expr) -> Expr<'tcx> { +fn make_mirror_unadjusted<'a, 'tcx>( + cx: &mut Cx<'a, 'tcx>, + expr: &'tcx hir::Expr<'tcx>, +) -> Expr<'tcx> { let expr_ty = cx.tables().expr_ty(expr); let temp_lifetime = cx.region_scope_tree.temporary_scope(expr.hir_id.local_id); @@ -608,7 +611,7 @@ fn user_substs_applied_to_res( fn method_callee<'a, 'tcx>( cx: &mut Cx<'a, 'tcx>, - expr: &hir::Expr, + expr: &hir::Expr<'_>, span: Span, overloaded_callee: Option<(DefId, SubstsRef<'tcx>)>, ) -> Expr<'tcx> { @@ -662,7 +665,7 @@ fn to_borrow_kind(&self) -> BorrowKind { } } -fn convert_arm<'tcx>(cx: &mut Cx<'_, 'tcx>, arm: &'tcx hir::Arm) -> Arm<'tcx> { +fn convert_arm<'tcx>(cx: &mut Cx<'_, 'tcx>, arm: &'tcx hir::Arm<'tcx>) -> Arm<'tcx> { Arm { pattern: cx.pattern_from_hir(&arm.pat), guard: match arm.guard { @@ -678,7 +681,7 @@ fn convert_arm<'tcx>(cx: &mut Cx<'_, 'tcx>, arm: &'tcx hir::Arm) -> Arm<'tcx> { fn convert_path_expr<'a, 'tcx>( cx: &mut Cx<'a, 'tcx>, - expr: &'tcx hir::Expr, + expr: &'tcx hir::Expr<'tcx>, res: Res, ) -> ExprKind<'tcx> { let substs = cx.tables().node_substs(expr.hir_id); @@ -771,7 +774,7 @@ fn convert_path_expr<'a, 'tcx>( fn convert_var( cx: &mut Cx<'_, 'tcx>, - expr: &'tcx hir::Expr, + expr: &'tcx hir::Expr<'tcx>, var_hir_id: hir::HirId, ) -> ExprKind<'tcx> { let upvar_index = cx @@ -914,7 +917,7 @@ fn bin_op(op: hir::BinOpKind) -> BinOp { fn overloaded_operator<'a, 'tcx>( cx: &mut Cx<'a, 'tcx>, - expr: &'tcx hir::Expr, + expr: &'tcx hir::Expr<'tcx>, args: Vec>, ) -> ExprKind<'tcx> { let fun = method_callee(cx, expr, expr.span, None); @@ -923,7 +926,7 @@ fn overloaded_operator<'a, 'tcx>( fn overloaded_place<'a, 'tcx>( cx: &mut Cx<'a, 'tcx>, - expr: &'tcx hir::Expr, + expr: &'tcx hir::Expr<'tcx>, place_ty: Ty<'tcx>, overloaded_callee: Option<(DefId, SubstsRef<'tcx>)>, args: Vec>, @@ -963,7 +966,7 @@ fn overloaded_place<'a, 'tcx>( fn capture_upvar<'tcx>( cx: &mut Cx<'_, 'tcx>, - closure_expr: &'tcx hir::Expr, + closure_expr: &'tcx hir::Expr<'tcx>, var_hir_id: hir::HirId, upvar_ty: Ty<'tcx>, ) -> ExprRef<'tcx> { @@ -1002,7 +1005,7 @@ fn capture_upvar<'tcx>( /// Converts a list of named fields (i.e., for struct-like struct/enum ADTs) into FieldExprRef. fn field_refs<'a, 'tcx>( cx: &mut Cx<'a, 'tcx>, - fields: &'tcx [hir::Field], + fields: &'tcx [hir::Field<'tcx>], ) -> Vec> { fields .iter() diff --git a/src/librustc_mir/hair/cx/mod.rs b/src/librustc_mir/hair/cx/mod.rs index dbabfb1b161..5c3baaa6ddc 100644 --- a/src/librustc_mir/hair/cx/mod.rs +++ b/src/librustc_mir/hair/cx/mod.rs @@ -151,7 +151,7 @@ pub fn const_eval_literal( } } - pub fn pattern_from_hir(&mut self, p: &hir::Pat) -> Pat<'tcx> { + pub fn pattern_from_hir(&mut self, p: &hir::Pat<'_>) -> Pat<'tcx> { let p = match self.tcx.hir().get(p.hir_id) { Node::Pat(p) | Node::Binding(p) => p, node => bug!("pattern became {:?}", node), diff --git a/src/librustc_mir/hair/cx/to_ref.rs b/src/librustc_mir/hair/cx/to_ref.rs index c365cc2ad85..e40e21e76c3 100644 --- a/src/librustc_mir/hair/cx/to_ref.rs +++ b/src/librustc_mir/hair/cx/to_ref.rs @@ -1,14 +1,13 @@ use crate::hair::*; use rustc::hir; -use rustc::hir::ptr::P; pub trait ToRef { type Output; fn to_ref(self) -> Self::Output; } -impl<'tcx> ToRef for &'tcx hir::Expr { +impl<'tcx> ToRef for &'tcx hir::Expr<'tcx> { type Output = ExprRef<'tcx>; fn to_ref(self) -> ExprRef<'tcx> { @@ -16,7 +15,7 @@ fn to_ref(self) -> ExprRef<'tcx> { } } -impl<'tcx> ToRef for &'tcx P { +impl<'tcx> ToRef for &'tcx &'tcx hir::Expr<'tcx> { type Output = ExprRef<'tcx>; fn to_ref(self) -> ExprRef<'tcx> { @@ -54,7 +53,7 @@ fn to_ref(self) -> Vec { } } -impl<'tcx, T, U> ToRef for &'tcx P<[T]> +impl<'tcx, T, U> ToRef for &'tcx [T] where &'tcx T: ToRef, { diff --git a/src/librustc_mir/hair/mod.rs b/src/librustc_mir/hair/mod.rs index 188c73e105a..8973c19d58f 100644 --- a/src/librustc_mir/hair/mod.rs +++ b/src/librustc_mir/hair/mod.rs @@ -184,7 +184,7 @@ pub enum ExprKind<'tcx> { arms: Vec>, }, Block { - body: &'tcx hir::Block, + body: &'tcx hir::Block<'tcx>, }, Assign { lhs: ExprRef<'tcx>, @@ -289,7 +289,7 @@ pub enum ExprKind<'tcx> { #[derive(Clone, Debug)] pub enum ExprRef<'tcx> { - Hair(&'tcx hir::Expr), + Hair(&'tcx hir::Expr<'tcx>), Mirror(Box>), } diff --git a/src/librustc_mir/hair/pattern/check_match.rs b/src/librustc_mir/hair/pattern/check_match.rs index 67c89c7293c..47f2b480850 100644 --- a/src/librustc_mir/hair/pattern/check_match.rs +++ b/src/librustc_mir/hair/pattern/check_match.rs @@ -53,7 +53,7 @@ fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { NestedVisitorMap::None } - fn visit_expr(&mut self, ex: &'tcx hir::Expr) { + fn visit_expr(&mut self, ex: &'tcx hir::Expr<'tcx>) { intravisit::walk_expr(self, ex); if let hir::ExprKind::Match(ref scrut, ref arms, source) = ex.kind { @@ -61,7 +61,7 @@ fn visit_expr(&mut self, ex: &'tcx hir::Expr) { } } - fn visit_local(&mut self, loc: &'tcx hir::Local) { + fn visit_local(&mut self, loc: &'tcx hir::Local<'tcx>) { intravisit::walk_local(self, loc); let (msg, sp) = match loc.source { @@ -121,7 +121,7 @@ fn span_e0158(&self, span: Span, text: &str) { } impl<'tcx> MatchVisitor<'_, 'tcx> { - fn check_patterns(&mut self, has_guard: bool, pat: &Pat) { + fn check_patterns(&mut self, has_guard: bool, pat: &Pat<'_>) { check_legality_of_move_bindings(self, has_guard, pat); check_borrow_conflicts_in_at_patterns(self, pat); if !self.tcx.features().bindings_after_at { @@ -129,7 +129,12 @@ fn check_patterns(&mut self, has_guard: bool, pat: &Pat) { } } - fn check_match(&mut self, scrut: &hir::Expr, arms: &'tcx [hir::Arm], source: hir::MatchSource) { + fn check_match( + &mut self, + scrut: &hir::Expr<'_>, + arms: &'tcx [hir::Arm<'tcx>], + source: hir::MatchSource, + ) { for arm in arms { // First, check legality of move bindings. self.check_patterns(arm.guard.is_some(), &arm.pat); @@ -178,7 +183,7 @@ fn check_match(&mut self, scrut: &hir::Expr, arms: &'tcx [hir::Arm], source: hir }) } - fn check_irrefutable(&self, pat: &'tcx Pat, origin: &str, sp: Option) { + fn check_irrefutable(&self, pat: &'tcx Pat<'tcx>, origin: &str, sp: Option) { let module = self.tcx.hir().get_module_parent(pat.hir_id); MatchCheckCtxt::create_and_enter(self.tcx, self.param_env, module, |ref mut cx| { let mut patcx = @@ -246,7 +251,12 @@ fn check_irrefutable(&self, pat: &'tcx Pat, origin: &str, sp: Option) { /// A path pattern was interpreted as a constant, not a new variable. /// This caused an irrefutable match failure in e.g. `let`. -fn const_not_var(err: &mut DiagnosticBuilder<'_>, tcx: TyCtxt<'_>, pat: &Pat, path: &hir::Path) { +fn const_not_var( + err: &mut DiagnosticBuilder<'_>, + tcx: TyCtxt<'_>, + pat: &Pat<'_>, + path: &hir::Path, +) { let descr = path.res.descr(); err.span_label( pat.span, @@ -268,7 +278,7 @@ fn const_not_var(err: &mut DiagnosticBuilder<'_>, tcx: TyCtxt<'_>, pat: &Pat, pa } } -fn check_for_bindings_named_same_as_variants(cx: &MatchVisitor<'_, '_>, pat: &Pat) { +fn check_for_bindings_named_same_as_variants(cx: &MatchVisitor<'_, '_>, pat: &Pat<'_>) { pat.walk_always(|p| { if let hir::PatKind::Binding(_, _, ident, None) = p.kind { if let Some(ty::BindByValue(hir::Mutability::Not)) = @@ -307,7 +317,7 @@ fn check_for_bindings_named_same_as_variants(cx: &MatchVisitor<'_, '_>, pat: &Pa } /// Checks for common cases of "catchall" patterns that may not be intended as such. -fn pat_is_catchall(pat: &Pat) -> bool { +fn pat_is_catchall(pat: &Pat<'_>) -> bool { match pat.kind { hir::PatKind::Binding(.., None) => true, hir::PatKind::Binding(.., Some(ref s)) => pat_is_catchall(s), @@ -320,7 +330,7 @@ fn pat_is_catchall(pat: &Pat) -> bool { /// Check for unreachable patterns. fn check_arms<'p, 'tcx>( cx: &mut MatchCheckCtxt<'p, 'tcx>, - arms: &[(&'p super::Pat<'tcx>, &hir::Pat, bool)], + arms: &[(&'p super::Pat<'tcx>, &hir::Pat<'_>, bool)], source: hir::MatchSource, ) -> Matrix<'p, 'tcx> { let mut seen = Matrix::empty(); @@ -575,7 +585,7 @@ fn maybe_point_at_variant(ty: Ty<'_>, patterns: &[super::Pat<'_>]) -> Vec } /// Check the legality of legality of by-move bindings. -fn check_legality_of_move_bindings(cx: &mut MatchVisitor<'_, '_>, has_guard: bool, pat: &Pat) { +fn check_legality_of_move_bindings(cx: &mut MatchVisitor<'_, '_>, has_guard: bool, pat: &Pat<'_>) { let sess = cx.tcx.sess; let tables = cx.tables; @@ -589,7 +599,7 @@ fn check_legality_of_move_bindings(cx: &mut MatchVisitor<'_, '_>, has_guard: boo // Find bad by-move spans: let by_move_spans = &mut Vec::new(); - let mut check_move = |p: &Pat, sub: Option<&Pat>| { + let mut check_move = |p: &Pat<'_>, sub: Option<&Pat<'_>>| { // Check legality of moving out of the enum. // // `x @ Foo(..)` is legal, but `x @ Foo(y)` isn't. @@ -638,7 +648,7 @@ fn check_legality_of_move_bindings(cx: &mut MatchVisitor<'_, '_>, has_guard: boo /// - `ref mut x @ Some(ref mut y)`. /// /// This analysis is *not* subsumed by NLL. -fn check_borrow_conflicts_in_at_patterns(cx: &MatchVisitor<'_, '_>, pat: &Pat) { +fn check_borrow_conflicts_in_at_patterns(cx: &MatchVisitor<'_, '_>, pat: &Pat<'_>) { let tab = cx.tables; let sess = cx.tcx.sess; // Get the mutability of `p` if it's by-ref. @@ -709,7 +719,7 @@ fn check_borrow_conflicts_in_at_patterns(cx: &MatchVisitor<'_, '_>, pat: &Pat) { /// Forbids bindings in `@` patterns. This used to be is necessary for memory safety, /// because of the way rvalues were handled in the borrow check. (See issue #14587.) -fn check_legality_of_bindings_in_at_patterns(cx: &MatchVisitor<'_, '_>, pat: &Pat) { +fn check_legality_of_bindings_in_at_patterns(cx: &MatchVisitor<'_, '_>, pat: &Pat<'_>) { AtBindingPatternVisitor { cx, bindings_allowed: true }.visit_pat(pat); struct AtBindingPatternVisitor<'a, 'b, 'tcx> { @@ -722,7 +732,7 @@ fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'v> { NestedVisitorMap::None } - fn visit_pat(&mut self, pat: &Pat) { + fn visit_pat(&mut self, pat: &Pat<'_>) { match pat.kind { hir::PatKind::Binding(.., ref subpat) => { if !self.bindings_allowed { diff --git a/src/librustc_mir/hair/pattern/mod.rs b/src/librustc_mir/hair/pattern/mod.rs index 869aeeba418..bf0de7e9ef0 100644 --- a/src/librustc_mir/hair/pattern/mod.rs +++ b/src/librustc_mir/hair/pattern/mod.rs @@ -11,7 +11,6 @@ use rustc::hir::def::{CtorKind, CtorOf, DefKind, Res}; use rustc::hir::pat_util::EnumerateAndAdjustIterator; -use rustc::hir::ptr::P; use rustc::hir::{self, RangeEnd}; use rustc::mir::interpret::{get_slice_bytes, sign_extend, ConstValue, ErrorHandled}; use rustc::mir::UserTypeProjection; @@ -356,7 +355,7 @@ pub fn from_hir( tcx: TyCtxt<'tcx>, param_env_and_substs: ty::ParamEnvAnd<'tcx, SubstsRef<'tcx>>, tables: &'a ty::TypeckTables<'tcx>, - pat: &'tcx hir::Pat, + pat: &'tcx hir::Pat<'tcx>, ) -> Self { let mut pcx = PatCtxt::new(tcx, param_env_and_substs, tables); let result = pcx.lower_pattern(pat); @@ -390,7 +389,7 @@ pub fn include_lint_checks(&mut self) -> &mut Self { self } - pub fn lower_pattern(&mut self, pat: &'tcx hir::Pat) -> Pat<'tcx> { + pub fn lower_pattern(&mut self, pat: &'tcx hir::Pat<'tcx>) -> Pat<'tcx> { // When implicit dereferences have been inserted in this pattern, the unadjusted lowered // pattern has the type that results *after* dereferencing. For example, in this code: // @@ -426,7 +425,7 @@ pub fn lower_pattern(&mut self, pat: &'tcx hir::Pat) -> Pat<'tcx> { fn lower_range_expr( &mut self, - expr: &'tcx hir::Expr, + expr: &'tcx hir::Expr<'tcx>, ) -> (PatKind<'tcx>, Option>) { match self.lower_lit(expr) { PatKind::AscribeUserType { @@ -437,7 +436,7 @@ fn lower_range_expr( } } - fn lower_pattern_unadjusted(&mut self, pat: &'tcx hir::Pat) -> Pat<'tcx> { + fn lower_pattern_unadjusted(&mut self, pat: &'tcx hir::Pat<'tcx>) -> Pat<'tcx> { let mut ty = self.tables.node_type(pat.hir_id); if let ty::Error = ty.kind { @@ -616,7 +615,7 @@ fn lower_pattern_unadjusted(&mut self, pat: &'tcx hir::Pat) -> Pat<'tcx> { fn lower_tuple_subpats( &mut self, - pats: &'tcx [P], + pats: &'tcx [&'tcx hir::Pat<'tcx>], expected_len: usize, gap_pos: Option, ) -> Vec> { @@ -629,11 +628,11 @@ fn lower_tuple_subpats( .collect() } - fn lower_patterns(&mut self, pats: &'tcx [P]) -> Vec> { + fn lower_patterns(&mut self, pats: &'tcx [&'tcx hir::Pat<'tcx>]) -> Vec> { pats.iter().map(|p| self.lower_pattern(p)).collect() } - fn lower_opt_pattern(&mut self, pat: &'tcx Option>) -> Option> { + fn lower_opt_pattern(&mut self, pat: &'tcx Option<&'tcx hir::Pat<'tcx>>) -> Option> { pat.as_ref().map(|p| self.lower_pattern(p)) } @@ -641,9 +640,9 @@ fn slice_or_array_pattern( &mut self, span: Span, ty: Ty<'tcx>, - prefix: &'tcx [P], - slice: &'tcx Option>, - suffix: &'tcx [P], + prefix: &'tcx [&'tcx hir::Pat<'tcx>], + slice: &'tcx Option<&'tcx hir::Pat<'tcx>>, + suffix: &'tcx [&'tcx hir::Pat<'tcx>], ) -> PatKind<'tcx> { let prefix = self.lower_patterns(prefix); let slice = self.lower_opt_pattern(slice); @@ -795,7 +794,7 @@ fn lower_path(&mut self, qpath: &hir::QPath, id: hir::HirId, span: Span) -> Pat< /// The special case for negation exists to allow things like `-128_i8` /// which would overflow if we tried to evaluate `128_i8` and then negate /// afterwards. - fn lower_lit(&mut self, expr: &'tcx hir::Expr) -> PatKind<'tcx> { + fn lower_lit(&mut self, expr: &'tcx hir::Expr<'tcx>) -> PatKind<'tcx> { match expr.kind { hir::ExprKind::Lit(ref lit) => { let ty = self.tables.expr_ty(expr); diff --git a/src/librustc_mir/transform/check_unsafety.rs b/src/librustc_mir/transform/check_unsafety.rs index 715ae1ce01e..8b8f1b6f670 100644 --- a/src/librustc_mir/transform/check_unsafety.rs +++ b/src/librustc_mir/transform/check_unsafety.rs @@ -479,7 +479,7 @@ fn nested_visit_map<'this>(&'this mut self) -> hir::intravisit::NestedVisitorMap hir::intravisit::NestedVisitorMap::None } - fn visit_block(&mut self, block: &'tcx hir::Block) { + fn visit_block(&mut self, block: &'tcx hir::Block<'tcx>) { hir::intravisit::walk_block(self, block); if let hir::UnsafeBlock(hir::UserProvided) = block.rules { diff --git a/src/librustc_passes/check_const.rs b/src/librustc_passes/check_const.rs index a0aead98911..fbfe2135012 100644 --- a/src/librustc_passes/check_const.rs +++ b/src/librustc_passes/check_const.rs @@ -214,7 +214,7 @@ fn visit_body(&mut self, body: &'tcx hir::Body<'tcx>) { self.recurse_into(kind, |this| hir::intravisit::walk_body(this, body)); } - fn visit_pat(&mut self, p: &'tcx hir::Pat) { + fn visit_pat(&mut self, p: &'tcx hir::Pat<'tcx>) { if self.const_kind.is_some() { if let hir::PatKind::Or { .. } = p.kind { self.const_check_violated(NonConstExpr::OrPattern, p.span); @@ -223,7 +223,7 @@ fn visit_pat(&mut self, p: &'tcx hir::Pat) { hir::intravisit::walk_pat(self, p) } - fn visit_expr(&mut self, e: &'tcx hir::Expr) { + fn visit_expr(&mut self, e: &'tcx hir::Expr<'tcx>) { match &e.kind { // Skip the following checks if we are not currently in a const context. _ if self.const_kind.is_none() => {} diff --git a/src/librustc_passes/dead.rs b/src/librustc_passes/dead.rs index ce1b68c967c..a13c9aff70a 100644 --- a/src/librustc_passes/dead.rs +++ b/src/librustc_passes/dead.rs @@ -115,7 +115,7 @@ fn lookup_and_handle_method(&mut self, id: hir::HirId) { } } - fn handle_field_access(&mut self, lhs: &hir::Expr, hir_id: hir::HirId) { + fn handle_field_access(&mut self, lhs: &hir::Expr<'_>, hir_id: hir::HirId) { match self.tables.expr_ty_adjusted(lhs).kind { ty::Adt(def, _) => { let index = self.tcx.field_index(hir_id, self.tables); @@ -126,7 +126,12 @@ fn handle_field_access(&mut self, lhs: &hir::Expr, hir_id: hir::HirId) { } } - fn handle_field_pattern_match(&mut self, lhs: &hir::Pat, res: Res, pats: &[hir::FieldPat]) { + fn handle_field_pattern_match( + &mut self, + lhs: &hir::Pat<'_>, + res: Res, + pats: &[hir::FieldPat<'_>], + ) { let variant = match self.tables.node_type(lhs.hir_id).kind { ty::Adt(adt, _) => adt.variant_of_res(res), _ => span_bug!(lhs.span, "non-ADT in struct pattern"), @@ -197,7 +202,7 @@ fn visit_node(&mut self, node: Node<'tcx>) { self.inherited_pub_visibility = had_inherited_pub_visibility; } - fn mark_as_used_if_union(&mut self, adt: &ty::AdtDef, fields: &hir::HirVec) { + fn mark_as_used_if_union(&mut self, adt: &ty::AdtDef, fields: &[hir::Field<'_>]) { if adt.is_union() && adt.non_enum_variant().fields.len() > 1 && adt.did.is_local() { for field in fields { let index = self.tcx.field_index(field.hir_id, self.tables); @@ -239,7 +244,7 @@ fn visit_variant_data( intravisit::walk_struct_def(self, def); } - fn visit_expr(&mut self, expr: &'tcx hir::Expr) { + fn visit_expr(&mut self, expr: &'tcx hir::Expr<'tcx>) { match expr.kind { hir::ExprKind::Path(ref qpath @ hir::QPath::TypeRelative(..)) => { let res = self.tables.qpath_res(qpath, expr.hir_id); @@ -262,7 +267,7 @@ fn visit_expr(&mut self, expr: &'tcx hir::Expr) { intravisit::walk_expr(self, expr); } - fn visit_arm(&mut self, arm: &'tcx hir::Arm) { + fn visit_arm(&mut self, arm: &'tcx hir::Arm<'tcx>) { // Inside the body, ignore constructions of variants // necessary for the pattern to match. Those construction sites // can't be reached unless the variant is constructed elsewhere. @@ -272,7 +277,7 @@ fn visit_arm(&mut self, arm: &'tcx hir::Arm) { self.ignore_variant_stack.truncate(len); } - fn visit_pat(&mut self, pat: &'tcx hir::Pat) { + fn visit_pat(&mut self, pat: &'tcx hir::Pat<'tcx>) { match pat.kind { PatKind::Struct(ref path, ref fields, _) => { let res = self.tables.qpath_res(path, pat.hir_id); diff --git a/src/librustc_passes/hir_stats.rs b/src/librustc_passes/hir_stats.rs index fc06538e94a..5ec1d458a96 100644 --- a/src/librustc_passes/hir_stats.rs +++ b/src/librustc_passes/hir_stats.rs @@ -86,7 +86,7 @@ fn print(&self, title: &str) { } impl<'v> hir_visit::Visitor<'v> for StatCollector<'v> { - fn visit_param(&mut self, param: &'v hir::Param) { + fn visit_param(&mut self, param: &'v hir::Param<'v>) { self.record("Param", Id::Node(param.hir_id), param); hir_visit::walk_param(self, param) } @@ -130,32 +130,32 @@ fn visit_foreign_item(&mut self, i: &'v hir::ForeignItem<'v>) { hir_visit::walk_foreign_item(self, i) } - fn visit_local(&mut self, l: &'v hir::Local) { + fn visit_local(&mut self, l: &'v hir::Local<'v>) { self.record("Local", Id::Node(l.hir_id), l); hir_visit::walk_local(self, l) } - fn visit_block(&mut self, b: &'v hir::Block) { + fn visit_block(&mut self, b: &'v hir::Block<'v>) { self.record("Block", Id::Node(b.hir_id), b); hir_visit::walk_block(self, b) } - fn visit_stmt(&mut self, s: &'v hir::Stmt) { + fn visit_stmt(&mut self, s: &'v hir::Stmt<'v>) { self.record("Stmt", Id::Node(s.hir_id), s); hir_visit::walk_stmt(self, s) } - fn visit_arm(&mut self, a: &'v hir::Arm) { + fn visit_arm(&mut self, a: &'v hir::Arm<'v>) { self.record("Arm", Id::Node(a.hir_id), a); hir_visit::walk_arm(self, a) } - fn visit_pat(&mut self, p: &'v hir::Pat) { + fn visit_pat(&mut self, p: &'v hir::Pat<'v>) { self.record("Pat", Id::Node(p.hir_id), p); hir_visit::walk_pat(self, p) } - fn visit_expr(&mut self, ex: &'v hir::Expr) { + fn visit_expr(&mut self, ex: &'v hir::Expr<'v>) { self.record("Expr", Id::Node(ex.hir_id), ex); hir_visit::walk_expr(self, ex) } diff --git a/src/librustc_passes/intrinsicck.rs b/src/librustc_passes/intrinsicck.rs index de74877b7dd..92903e95a0d 100644 --- a/src/librustc_passes/intrinsicck.rs +++ b/src/librustc_passes/intrinsicck.rs @@ -142,7 +142,7 @@ fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { NestedVisitorMap::None } - fn visit_expr(&mut self, expr: &'tcx hir::Expr) { + fn visit_expr(&mut self, expr: &'tcx hir::Expr<'tcx>) { let res = if let hir::ExprKind::Path(ref qpath) = expr.kind { self.tables.qpath_res(qpath, expr.hir_id) } else { diff --git a/src/librustc_passes/liveness.rs b/src/librustc_passes/liveness.rs index 1a8abeb7abc..ea4479ef5ce 100644 --- a/src/librustc_passes/liveness.rs +++ b/src/librustc_passes/liveness.rs @@ -100,7 +100,6 @@ use rustc::hir::def::*; use rustc::hir::def_id::DefId; use rustc::hir::intravisit::{self, FnKind, NestedVisitorMap, Visitor}; -use rustc::hir::ptr::P; use rustc::hir::Node; use rustc::hir::{Expr, HirId}; use rustc::lint; @@ -171,13 +170,13 @@ fn visit_fn( visit_fn(self, fk, fd, b, s, id); } - fn visit_local(&mut self, l: &'tcx hir::Local) { + fn visit_local(&mut self, l: &'tcx hir::Local<'tcx>) { visit_local(self, l); } - fn visit_expr(&mut self, ex: &'tcx Expr) { + fn visit_expr(&mut self, ex: &'tcx Expr<'tcx>) { visit_expr(self, ex); } - fn visit_arm(&mut self, a: &'tcx hir::Arm) { + fn visit_arm(&mut self, a: &'tcx hir::Arm<'tcx>) { visit_arm(self, a); } } @@ -406,7 +405,7 @@ fn visit_fn<'tcx>( lsets.warn_about_unused_args(body, entry_ln); } -fn add_from_pat(ir: &mut IrMaps<'_>, pat: &P) { +fn add_from_pat(ir: &mut IrMaps<'_>, pat: &hir::Pat<'_>) { // For struct patterns, take note of which fields used shorthand // (`x` rather than `x: x`). let mut shorthand_field_ids = HirIdSet::default(); @@ -447,17 +446,17 @@ fn add_from_pat(ir: &mut IrMaps<'_>, pat: &P) { }); } -fn visit_local<'tcx>(ir: &mut IrMaps<'tcx>, local: &'tcx hir::Local) { +fn visit_local<'tcx>(ir: &mut IrMaps<'tcx>, local: &'tcx hir::Local<'tcx>) { add_from_pat(ir, &local.pat); intravisit::walk_local(ir, local); } -fn visit_arm<'tcx>(ir: &mut IrMaps<'tcx>, arm: &'tcx hir::Arm) { +fn visit_arm<'tcx>(ir: &mut IrMaps<'tcx>, arm: &'tcx hir::Arm<'tcx>) { add_from_pat(ir, &arm.pat); intravisit::walk_arm(ir, arm); } -fn visit_expr<'tcx>(ir: &mut IrMaps<'tcx>, expr: &'tcx Expr) { +fn visit_expr<'tcx>(ir: &mut IrMaps<'tcx>, expr: &'tcx Expr<'tcx>) { match expr.kind { // live nodes required for uses or definitions of variables: hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) => { @@ -714,7 +713,7 @@ fn variable(&self, hir_id: HirId, span: Span) -> Variable { self.ir.variable(hir_id, span) } - fn define_bindings_in_pat(&mut self, pat: &hir::Pat, mut succ: LiveNode) -> LiveNode { + fn define_bindings_in_pat(&mut self, pat: &hir::Pat<'_>, mut succ: LiveNode) -> LiveNode { // In an or-pattern, only consider the first pattern; any later patterns // must have the same bindings, and we also consider the first pattern // to be the "authoritative" set of ids. @@ -891,7 +890,7 @@ fn acc(&mut self, ln: LiveNode, var: Variable, acc: u32) { self.rwu_table.assign_unpacked(idx, rwu); } - fn compute(&mut self, body: &hir::Expr) -> LiveNode { + fn compute(&mut self, body: &hir::Expr<'_>) -> LiveNode { debug!( "compute: using id for body, {}", self.ir.tcx.hir().hir_to_pretty_string(body.hir_id) @@ -920,7 +919,7 @@ fn compute(&mut self, body: &hir::Expr) -> LiveNode { entry_ln } - fn propagate_through_block(&mut self, blk: &hir::Block, succ: LiveNode) -> LiveNode { + fn propagate_through_block(&mut self, blk: &hir::Block<'_>, succ: LiveNode) -> LiveNode { if blk.targeted_by_break { self.break_ln.insert(blk.hir_id, succ); } @@ -928,7 +927,7 @@ fn propagate_through_block(&mut self, blk: &hir::Block, succ: LiveNode) -> LiveN blk.stmts.iter().rev().fold(succ, |succ, stmt| self.propagate_through_stmt(stmt, succ)) } - fn propagate_through_stmt(&mut self, stmt: &hir::Stmt, succ: LiveNode) -> LiveNode { + fn propagate_through_stmt(&mut self, stmt: &hir::Stmt<'_>, succ: LiveNode) -> LiveNode { match stmt.kind { hir::StmtKind::Local(ref local) => { // Note: we mark the variable as defined regardless of whether @@ -955,15 +954,19 @@ fn propagate_through_stmt(&mut self, stmt: &hir::Stmt, succ: LiveNode) -> LiveNo } } - fn propagate_through_exprs(&mut self, exprs: &[Expr], succ: LiveNode) -> LiveNode { + fn propagate_through_exprs(&mut self, exprs: &[Expr<'_>], succ: LiveNode) -> LiveNode { exprs.iter().rev().fold(succ, |succ, expr| self.propagate_through_expr(&expr, succ)) } - fn propagate_through_opt_expr(&mut self, opt_expr: Option<&Expr>, succ: LiveNode) -> LiveNode { + fn propagate_through_opt_expr( + &mut self, + opt_expr: Option<&Expr<'_>>, + succ: LiveNode, + ) -> LiveNode { opt_expr.map_or(succ, |expr| self.propagate_through_expr(expr, succ)) } - fn propagate_through_expr(&mut self, expr: &Expr, succ: LiveNode) -> LiveNode { + fn propagate_through_expr(&mut self, expr: &Expr<'_>, succ: LiveNode) -> LiveNode { debug!("propagate_through_expr: {}", self.ir.tcx.hir().hir_to_pretty_string(expr.hir_id)); match expr.kind { @@ -1001,7 +1004,7 @@ fn propagate_through_expr(&mut self, expr: &Expr, succ: LiveNode) -> LiveNode { // at the label ident hir::ExprKind::Loop(ref blk, _, _) => self.propagate_through_loop(expr, &blk, succ), - hir::ExprKind::Match(ref e, ref arms, _) => { + hir::ExprKind::Match(ref e, arms, _) => { // // (e) // | @@ -1023,7 +1026,7 @@ fn propagate_through_expr(&mut self, expr: &Expr, succ: LiveNode) -> LiveNode { let body_succ = self.propagate_through_expr(&arm.body, succ); let guard_succ = self.propagate_through_opt_expr( - arm.guard.as_ref().map(|hir::Guard::If(e)| &**e), + arm.guard.as_ref().map(|hir::Guard::If(e)| *e), body_succ, ); let arm_succ = self.define_bindings_in_pat(&arm.pat, guard_succ); @@ -1162,8 +1165,8 @@ fn propagate_through_expr(&mut self, expr: &Expr, succ: LiveNode) -> LiveNode { hir::ExprKind::InlineAsm(ref asm) => { let ia = &asm.inner; - let outputs = &asm.outputs_exprs; - let inputs = &asm.inputs_exprs; + let outputs = asm.outputs_exprs; + let inputs = asm.inputs_exprs; let succ = ia.outputs.iter().zip(outputs).rev().fold(succ, |succ, (o, output)| { // see comment on places // in propagate_through_place_components() @@ -1190,7 +1193,7 @@ fn propagate_through_expr(&mut self, expr: &Expr, succ: LiveNode) -> LiveNode { } } - fn propagate_through_place_components(&mut self, expr: &Expr, succ: LiveNode) -> LiveNode { + fn propagate_through_place_components(&mut self, expr: &Expr<'_>, succ: LiveNode) -> LiveNode { // # Places // // In general, the full flow graph structure for an @@ -1248,7 +1251,7 @@ fn propagate_through_place_components(&mut self, expr: &Expr, succ: LiveNode) -> } // see comment on propagate_through_place() - fn write_place(&mut self, expr: &Expr, succ: LiveNode, acc: u32) -> LiveNode { + fn write_place(&mut self, expr: &Expr<'_>, succ: LiveNode, acc: u32) -> LiveNode { match expr.kind { hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) => { self.access_path(expr.hir_id, path, succ, acc) @@ -1301,8 +1304,8 @@ fn access_path( fn propagate_through_loop( &mut self, - expr: &Expr, - body: &hir::Block, + expr: &Expr<'_>, + body: &hir::Block<'_>, succ: LiveNode, ) -> LiveNode { /* @@ -1351,7 +1354,7 @@ fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { NestedVisitorMap::None } - fn visit_local(&mut self, local: &'tcx hir::Local) { + fn visit_local(&mut self, local: &'tcx hir::Local<'tcx>) { self.check_unused_vars_in_pat(&local.pat, None, |spans, hir_id, ln, var| { if local.init.is_some() { self.warn_about_dead_assign(spans, hir_id, ln, var); @@ -1361,17 +1364,17 @@ fn visit_local(&mut self, local: &'tcx hir::Local) { intravisit::walk_local(self, local); } - fn visit_expr(&mut self, ex: &'tcx Expr) { + fn visit_expr(&mut self, ex: &'tcx Expr<'tcx>) { check_expr(self, ex); } - fn visit_arm(&mut self, arm: &'tcx hir::Arm) { + fn visit_arm(&mut self, arm: &'tcx hir::Arm<'tcx>) { self.check_unused_vars_in_pat(&arm.pat, None, |_, _, _, _| {}); intravisit::walk_arm(self, arm); } } -fn check_expr<'tcx>(this: &mut Liveness<'_, 'tcx>, expr: &'tcx Expr) { +fn check_expr<'tcx>(this: &mut Liveness<'_, 'tcx>, expr: &'tcx Expr<'tcx>) { match expr.kind { hir::ExprKind::Assign(ref l, ..) => { this.check_place(&l); @@ -1384,12 +1387,12 @@ fn check_expr<'tcx>(this: &mut Liveness<'_, 'tcx>, expr: &'tcx Expr) { } hir::ExprKind::InlineAsm(ref asm) => { - for input in &asm.inputs_exprs { + for input in asm.inputs_exprs { this.visit_expr(input); } // Output operands must be places - for (o, output) in asm.inner.outputs.iter().zip(&asm.outputs_exprs) { + for (o, output) in asm.inner.outputs.iter().zip(asm.outputs_exprs) { if !o.is_indirect { this.check_place(output); } @@ -1430,7 +1433,7 @@ fn check_expr<'tcx>(this: &mut Liveness<'_, 'tcx>, expr: &'tcx Expr) { } impl<'tcx> Liveness<'_, 'tcx> { - fn check_place(&mut self, expr: &'tcx Expr) { + fn check_place(&mut self, expr: &'tcx Expr<'tcx>) { match expr.kind { hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) => { if let Res::Local(var_hid) = path.res { @@ -1471,7 +1474,7 @@ fn warn_about_unused_args(&self, body: &hir::Body<'_>, entry_ln: LiveNode) { fn check_unused_vars_in_pat( &self, - pat: &hir::Pat, + pat: &hir::Pat<'_>, entry_ln: Option, on_used_on_entry: impl Fn(Vec, HirId, LiveNode, Variable), ) { diff --git a/src/librustc_passes/loops.rs b/src/librustc_passes/loops.rs index e422501e81b..463e6899c4f 100644 --- a/src/librustc_passes/loops.rs +++ b/src/librustc_passes/loops.rs @@ -52,7 +52,7 @@ fn visit_anon_const(&mut self, c: &'hir hir::AnonConst) { self.with_context(AnonConst, |v| intravisit::walk_anon_const(v, c)); } - fn visit_expr(&mut self, e: &'hir hir::Expr) { + fn visit_expr(&mut self, e: &'hir hir::Expr<'hir>) { match e.kind { hir::ExprKind::Loop(ref b, _, source) => { self.with_context(Loop(source), |v| v.visit_block(&b)); diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs index cdfcb8090e6..a72b3b74cbb 100644 --- a/src/librustc_privacy/lib.rs +++ b/src/librustc_privacy/lib.rs @@ -883,7 +883,7 @@ fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) { self.prev_level = orig_level; } - fn visit_block(&mut self, b: &'tcx hir::Block) { + fn visit_block(&mut self, b: &'tcx hir::Block<'tcx>) { // Blocks can have public items, for example impls, but they always // start as completely private regardless of publicity of a function, // constant, type, field, etc., in which this block resides. @@ -1080,9 +1080,9 @@ fn visit_impl_item(&mut self, ii: &'tcx hir::ImplItem<'tcx>) { self.tables = orig_tables; } - fn visit_expr(&mut self, expr: &'tcx hir::Expr) { + fn visit_expr(&mut self, expr: &'tcx hir::Expr<'tcx>) { match expr.kind { - hir::ExprKind::Struct(ref qpath, ref fields, ref base) => { + hir::ExprKind::Struct(ref qpath, fields, ref base) => { let res = self.tables.qpath_res(qpath, expr.hir_id); let adt = self.tables.expr_ty(expr).ty_adt_def().unwrap(); let variant = adt.variant_of_res(res); @@ -1114,9 +1114,9 @@ fn visit_expr(&mut self, expr: &'tcx hir::Expr) { intravisit::walk_expr(self, expr); } - fn visit_pat(&mut self, pat: &'tcx hir::Pat) { + fn visit_pat(&mut self, pat: &'tcx hir::Pat<'tcx>) { match pat.kind { - PatKind::Struct(ref qpath, ref fields, _) => { + PatKind::Struct(ref qpath, fields, _) => { let res = self.tables.qpath_res(qpath, pat.hir_id); let adt = self.tables.pat_ty(pat).ty_adt_def().unwrap(); let variant = adt.variant_of_res(res); @@ -1245,7 +1245,7 @@ fn visit_trait_ref(&mut self, trait_ref: &'tcx hir::TraitRef) { } // Check types of expressions - fn visit_expr(&mut self, expr: &'tcx hir::Expr) { + fn visit_expr(&mut self, expr: &'tcx hir::Expr<'tcx>) { if self.check_expr_pat_type(expr.hir_id, expr.span) { // Do not check nested expressions if the error already happened. return; @@ -1313,7 +1313,7 @@ fn visit_qpath(&mut self, qpath: &'tcx hir::QPath, id: hir::HirId, span: Span) { } // Check types of patterns. - fn visit_pat(&mut self, pattern: &'tcx hir::Pat) { + fn visit_pat(&mut self, pattern: &'tcx hir::Pat<'tcx>) { if self.check_expr_pat_type(pattern.hir_id, pattern.span) { // Do not check nested patterns if the error already happened. return; @@ -1322,7 +1322,7 @@ fn visit_pat(&mut self, pattern: &'tcx hir::Pat) { intravisit::walk_pat(self, pattern); } - fn visit_local(&mut self, local: &'tcx hir::Local) { + fn visit_local(&mut self, local: &'tcx hir::Local<'tcx>) { if let Some(ref init) = local.init { if self.check_expr_pat_type(init.hir_id, init.span) { // Do not report duplicate errors for `let x = y`. @@ -1459,7 +1459,7 @@ fn visit_ty(&mut self, ty: &hir::Ty) { } // Don't want to recurse into `[, .. expr]`. - fn visit_expr(&mut self, _: &hir::Expr) {} + fn visit_expr(&mut self, _: &hir::Expr<'_>) {} } impl<'a, 'tcx> Visitor<'tcx> for ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> { @@ -1708,8 +1708,8 @@ fn visit_struct_field(&mut self, s: &'tcx hir::StructField<'tcx>) { // expression/block context can't possibly contain exported things. // (Making them no-ops stops us from traversing the whole AST without // having to be super careful about our `walk_...` calls above.) - fn visit_block(&mut self, _: &'tcx hir::Block) {} - fn visit_expr(&mut self, _: &'tcx hir::Expr) {} + fn visit_block(&mut self, _: &'tcx hir::Block<'tcx>) {} + fn visit_expr(&mut self, _: &'tcx hir::Expr<'tcx>) {} } /////////////////////////////////////////////////////////////////////////////// diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index d28af783c0b..8e0f5d17b9f 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -2648,7 +2648,7 @@ pub fn ast_ty_to_ty(&self, ast_ty: &hir::Ty) -> Ty<'tcx> { } /// Returns the `DefId` of the constant parameter that the provided expression is a path to. - pub fn const_param_def_id(&self, expr: &hir::Expr) -> Option { + pub fn const_param_def_id(&self, expr: &hir::Expr<'_>) -> Option { // Unwrap a block, so that e.g. `{ P }` is recognised as a parameter. Const arguments // currently have to be wrapped in curly brackets, so it's necessary to special-case. let expr = match &expr.kind { diff --git a/src/librustc_typeck/check/_match.rs b/src/librustc_typeck/check/_match.rs index 8a74143de01..0d7ddd0fc48 100644 --- a/src/librustc_typeck/check/_match.rs +++ b/src/librustc_typeck/check/_match.rs @@ -10,9 +10,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { pub fn check_match( &self, - expr: &'tcx hir::Expr, - discrim: &'tcx hir::Expr, - arms: &'tcx [hir::Arm], + expr: &'tcx hir::Expr<'tcx>, + discrim: &'tcx hir::Expr<'tcx>, + arms: &'tcx [hir::Arm<'tcx>], expected: Expectation<'tcx>, match_src: hir::MatchSource, ) -> Ty<'tcx> { @@ -194,7 +194,11 @@ pub fn check_match( /// When the previously checked expression (the scrutinee) diverges, /// warn the user about the match arms being unreachable. - fn warn_arms_when_scrutinee_diverges(&self, arms: &'tcx [hir::Arm], source: hir::MatchSource) { + fn warn_arms_when_scrutinee_diverges( + &self, + arms: &'tcx [hir::Arm<'tcx>], + source: hir::MatchSource, + ) { if self.diverges.get().is_always() { use hir::MatchSource::*; let msg = match source { @@ -214,8 +218,8 @@ fn warn_arms_when_scrutinee_diverges(&self, arms: &'tcx [hir::Arm], source: hir: fn if_fallback_coercion( &self, span: Span, - then_expr: &'tcx hir::Expr, - coercion: &mut CoerceMany<'tcx, '_, rustc::hir::Arm>, + then_expr: &'tcx hir::Expr<'tcx>, + coercion: &mut CoerceMany<'tcx, '_, rustc::hir::Arm<'tcx>>, ) -> bool { // If this `if` expr is the parent's function return expr, // the cause of the type coercion is the return type, point at it. (#25228) @@ -277,8 +281,8 @@ fn maybe_get_coercion_reason(&self, hir_id: hir::HirId, span: Span) -> Option<(S fn if_cause( &self, span: Span, - then_expr: &'tcx hir::Expr, - else_expr: &'tcx hir::Expr, + then_expr: &'tcx hir::Expr<'tcx>, + else_expr: &'tcx hir::Expr<'tcx>, then_ty: Ty<'tcx>, else_ty: Ty<'tcx>, ) -> ObligationCause<'tcx> { @@ -386,8 +390,8 @@ fn if_cause( fn demand_discriminant_type( &self, - arms: &'tcx [hir::Arm], - discrim: &'tcx hir::Expr, + arms: &'tcx [hir::Arm<'tcx>], + discrim: &'tcx hir::Expr<'tcx>, ) -> Ty<'tcx> { // Not entirely obvious: if matches may create ref bindings, we want to // use the *precise* type of the discriminant, *not* some supertype, as diff --git a/src/librustc_typeck/check/callee.rs b/src/librustc_typeck/check/callee.rs index 922e751db50..116f5ffc251 100644 --- a/src/librustc_typeck/check/callee.rs +++ b/src/librustc_typeck/check/callee.rs @@ -39,9 +39,9 @@ enum CallStep<'tcx> { impl<'a, 'tcx> FnCtxt<'a, 'tcx> { pub fn check_call( &self, - call_expr: &'tcx hir::Expr, - callee_expr: &'tcx hir::Expr, - arg_exprs: &'tcx [hir::Expr], + call_expr: &'tcx hir::Expr<'tcx>, + callee_expr: &'tcx hir::Expr<'tcx>, + arg_exprs: &'tcx [hir::Expr<'tcx>], expected: Expectation<'tcx>, ) -> Ty<'tcx> { let original_callee_ty = self.check_expr(callee_expr); @@ -81,9 +81,9 @@ pub fn check_call( fn try_overloaded_call_step( &self, - call_expr: &'tcx hir::Expr, - callee_expr: &'tcx hir::Expr, - arg_exprs: &'tcx [hir::Expr], + call_expr: &'tcx hir::Expr<'tcx>, + callee_expr: &'tcx hir::Expr<'tcx>, + arg_exprs: &'tcx [hir::Expr<'tcx>], autoderef: &Autoderef<'a, 'tcx>, ) -> Option> { let adjusted_ty = autoderef.unambiguous_final_ty(self); @@ -166,9 +166,9 @@ fn try_overloaded_call_step( fn try_overloaded_call_traits( &self, - call_expr: &hir::Expr, + call_expr: &hir::Expr<'_>, adjusted_ty: Ty<'tcx>, - opt_arg_exprs: Option<&'tcx [hir::Expr]>, + opt_arg_exprs: Option<&'tcx [hir::Expr<'tcx>]>, ) -> Option<(Option>, MethodCallee<'tcx>)> { // Try the options that are least restrictive on the caller first. for &(opt_trait_def_id, method_name, borrow) in &[ @@ -230,7 +230,7 @@ fn identify_bad_closure_def_and_call( &self, err: &mut DiagnosticBuilder<'a>, hir_id: hir::HirId, - callee_node: &hir::ExprKind, + callee_node: &hir::ExprKind<'_>, callee_span: Span, ) { let hir_id = self.tcx.hir().get_parent_node(hir_id); @@ -253,9 +253,9 @@ fn identify_bad_closure_def_and_call( fn confirm_builtin_call( &self, - call_expr: &'tcx hir::Expr, + call_expr: &'tcx hir::Expr<'tcx>, callee_ty: Ty<'tcx>, - arg_exprs: &'tcx [hir::Expr], + arg_exprs: &'tcx [hir::Expr<'tcx>], expected: Expectation<'tcx>, ) -> Ty<'tcx> { let (fn_sig, def_span) = match callee_ty.kind { @@ -403,8 +403,8 @@ fn confirm_builtin_call( fn confirm_deferred_closure_call( &self, - call_expr: &'tcx hir::Expr, - arg_exprs: &'tcx [hir::Expr], + call_expr: &'tcx hir::Expr<'tcx>, + arg_exprs: &'tcx [hir::Expr<'tcx>], expected: Expectation<'tcx>, fn_sig: ty::FnSig<'tcx>, ) -> Ty<'tcx> { @@ -436,8 +436,8 @@ fn confirm_deferred_closure_call( fn confirm_overloaded_call( &self, - call_expr: &'tcx hir::Expr, - arg_exprs: &'tcx [hir::Expr], + call_expr: &'tcx hir::Expr<'tcx>, + arg_exprs: &'tcx [hir::Expr<'tcx>], expected: Expectation<'tcx>, method_callee: MethodCallee<'tcx>, ) -> Ty<'tcx> { @@ -457,8 +457,8 @@ fn confirm_overloaded_call( #[derive(Debug)] pub struct DeferredCallResolution<'tcx> { - call_expr: &'tcx hir::Expr, - callee_expr: &'tcx hir::Expr, + call_expr: &'tcx hir::Expr<'tcx>, + callee_expr: &'tcx hir::Expr<'tcx>, adjusted_ty: Ty<'tcx>, adjustments: Vec>, fn_sig: ty::FnSig<'tcx>, diff --git a/src/librustc_typeck/check/cast.rs b/src/librustc_typeck/check/cast.rs index 23349a4e88d..f82bb1a751f 100644 --- a/src/librustc_typeck/check/cast.rs +++ b/src/librustc_typeck/check/cast.rs @@ -51,7 +51,7 @@ /// Reifies a cast check to be checked once we have full type information for /// a function context. pub struct CastCheck<'tcx> { - expr: &'tcx hir::Expr, + expr: &'tcx hir::Expr<'tcx>, expr_ty: Ty<'tcx>, cast_ty: Ty<'tcx>, cast_span: Span, @@ -193,7 +193,7 @@ fn make_invalid_casting_error<'a, 'tcx>( impl<'a, 'tcx> CastCheck<'tcx> { pub fn new( fcx: &FnCtxt<'a, 'tcx>, - expr: &'tcx hir::Expr, + expr: &'tcx hir::Expr<'tcx>, expr_ty: Ty<'tcx>, cast_ty: Ty<'tcx>, cast_span: Span, diff --git a/src/librustc_typeck/check/closure.rs b/src/librustc_typeck/check/closure.rs index 55bfa23a815..feb904ee71c 100644 --- a/src/librustc_typeck/check/closure.rs +++ b/src/librustc_typeck/check/closure.rs @@ -35,7 +35,7 @@ struct ClosureSignatures<'tcx> { impl<'a, 'tcx> FnCtxt<'a, 'tcx> { pub fn check_expr_closure( &self, - expr: &hir::Expr, + expr: &hir::Expr<'_>, _capture: hir::CaptureBy, decl: &'tcx hir::FnDecl, body_id: hir::BodyId, @@ -57,7 +57,7 @@ pub fn check_expr_closure( fn check_closure( &self, - expr: &hir::Expr, + expr: &hir::Expr<'_>, opt_kind: Option, decl: &'tcx hir::FnDecl, body: &'tcx hir::Body<'tcx>, diff --git a/src/librustc_typeck/check/coercion.rs b/src/librustc_typeck/check/coercion.rs index 7daa489374f..1df6a495343 100644 --- a/src/librustc_typeck/check/coercion.rs +++ b/src/librustc_typeck/check/coercion.rs @@ -805,7 +805,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// The expressions *must not* have any pre-existing adjustments. pub fn try_coerce( &self, - expr: &hir::Expr, + expr: &hir::Expr<'_>, expr_ty: Ty<'tcx>, target: Ty<'tcx>, allow_two_phase: AllowTwoPhase, @@ -844,7 +844,7 @@ fn try_find_coercion_lub( cause: &ObligationCause<'tcx>, exprs: &[E], prev_ty: Ty<'tcx>, - new: &hir::Expr, + new: &hir::Expr<'_>, new_ty: Ty<'tcx>, ) -> RelateResult<'tcx, Ty<'tcx>> where @@ -1020,10 +1020,10 @@ pub struct CoerceMany<'tcx, 'exprs, E: AsCoercionSite> { /// The type of a `CoerceMany` that is storing up the expressions into /// a buffer. We use this in `check/mod.rs` for things like `break`. -pub type DynamicCoerceMany<'tcx> = CoerceMany<'tcx, 'tcx, P>; +pub type DynamicCoerceMany<'tcx> = CoerceMany<'tcx, 'tcx, &'tcx hir::Expr<'tcx>>; enum Expressions<'tcx, 'exprs, E: AsCoercionSite> { - Dynamic(Vec<&'tcx hir::Expr>), + Dynamic(Vec<&'tcx hir::Expr<'tcx>>), UpFront(&'exprs [E]), } @@ -1077,7 +1077,7 @@ pub fn coerce<'a>( &mut self, fcx: &FnCtxt<'a, 'tcx>, cause: &ObligationCause<'tcx>, - expression: &'tcx hir::Expr, + expression: &'tcx hir::Expr<'tcx>, expression_ty: Ty<'tcx>, ) { self.coerce_inner(fcx, cause, Some(expression), expression_ty, None, false) @@ -1119,7 +1119,7 @@ fn coerce_inner<'a>( &mut self, fcx: &FnCtxt<'a, 'tcx>, cause: &ObligationCause<'tcx>, - expression: Option<&'tcx hir::Expr>, + expression: Option<&'tcx hir::Expr<'tcx>>, mut expression_ty: Ty<'tcx>, augment_error: Option<&mut dyn FnMut(&mut DiagnosticBuilder<'_>)>, label_expression_as_expected: bool, @@ -1298,7 +1298,7 @@ fn report_return_mismatched_types<'a>( ty_err: TypeError<'tcx>, fcx: &FnCtxt<'a, 'tcx>, id: hir::HirId, - expression: Option<(&'tcx hir::Expr, hir::HirId)>, + expression: Option<(&'tcx hir::Expr<'tcx>, hir::HirId)>, ) -> DiagnosticBuilder<'a> { let mut err = fcx.report_mismatched_types(cause, expected, found, ty_err); @@ -1368,17 +1368,17 @@ pub fn complete<'a>(self, fcx: &FnCtxt<'a, 'tcx>) -> Ty<'tcx> { /// Something that can be converted into an expression to which we can /// apply a coercion. pub trait AsCoercionSite { - fn as_coercion_site(&self) -> &hir::Expr; + fn as_coercion_site(&self) -> &hir::Expr<'_>; } -impl AsCoercionSite for hir::Expr { - fn as_coercion_site(&self) -> &hir::Expr { +impl AsCoercionSite for hir::Expr<'_> { + fn as_coercion_site(&self) -> &hir::Expr<'_> { self } } -impl AsCoercionSite for P { - fn as_coercion_site(&self) -> &hir::Expr { +impl AsCoercionSite for P> { + fn as_coercion_site(&self) -> &hir::Expr<'_> { self } } @@ -1387,19 +1387,19 @@ impl<'a, T> AsCoercionSite for &'a T where T: AsCoercionSite, { - fn as_coercion_site(&self) -> &hir::Expr { + fn as_coercion_site(&self) -> &hir::Expr<'_> { (**self).as_coercion_site() } } impl AsCoercionSite for ! { - fn as_coercion_site(&self) -> &hir::Expr { + fn as_coercion_site(&self) -> &hir::Expr<'_> { unreachable!() } } -impl AsCoercionSite for hir::Arm { - fn as_coercion_site(&self) -> &hir::Expr { +impl AsCoercionSite for hir::Arm<'_> { + fn as_coercion_site(&self) -> &hir::Expr<'_> { &self.body } } diff --git a/src/librustc_typeck/check/demand.rs b/src/librustc_typeck/check/demand.rs index 9a14b75ca2f..68f2943e9e1 100644 --- a/src/librustc_typeck/check/demand.rs +++ b/src/librustc_typeck/check/demand.rs @@ -16,7 +16,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { pub fn emit_coerce_suggestions( &self, err: &mut DiagnosticBuilder<'_>, - expr: &hir::Expr, + expr: &hir::Expr<'_>, expr_ty: Ty<'tcx>, expected: Ty<'tcx>, ) { @@ -110,7 +110,7 @@ pub fn demand_eqtype_pat( pub fn demand_coerce( &self, - expr: &hir::Expr, + expr: &hir::Expr<'_>, checked_ty: Ty<'tcx>, expected: Ty<'tcx>, allow_two_phase: AllowTwoPhase, @@ -129,7 +129,7 @@ pub fn demand_coerce( // diverges flag is currently "always". pub fn demand_coerce_diag( &self, - expr: &hir::Expr, + expr: &hir::Expr<'_>, checked_ty: Ty<'tcx>, expected: Ty<'tcx>, allow_two_phase: AllowTwoPhase, @@ -157,7 +157,11 @@ pub fn demand_coerce_diag( (expected, Some(err)) } - fn annotate_expected_due_to_let_ty(&self, err: &mut DiagnosticBuilder<'_>, expr: &hir::Expr) { + fn annotate_expected_due_to_let_ty( + &self, + err: &mut DiagnosticBuilder<'_>, + expr: &hir::Expr<'_>, + ) { let parent = self.tcx.hir().get_parent_node(expr.hir_id); if let Some(hir::Node::Local(hir::Local { ty: Some(ty), init: Some(init), .. })) = self.tcx.hir().find(parent) @@ -170,7 +174,7 @@ fn annotate_expected_due_to_let_ty(&self, err: &mut DiagnosticBuilder<'_>, expr: } /// Returns whether the expected type is `bool` and the expression is `x = y`. - pub fn is_assign_to_bool(&self, expr: &hir::Expr, expected: Ty<'tcx>) -> bool { + pub fn is_assign_to_bool(&self, expr: &hir::Expr<'_>, expected: Ty<'tcx>) -> bool { if let hir::ExprKind::Assign(..) = expr.kind { return expected == self.tcx.types.bool; } @@ -182,7 +186,7 @@ pub fn is_assign_to_bool(&self, expr: &hir::Expr, expected: Ty<'tcx>) -> bool { fn suggest_compatible_variants( &self, err: &mut DiagnosticBuilder<'_>, - expr: &hir::Expr, + expr: &hir::Expr<'_>, expected: Ty<'tcx>, expr_ty: Ty<'tcx>, ) { @@ -282,7 +286,7 @@ fn has_no_input_arg(&self, method: &AssocItem) -> bool { /// ``` /// opt.map(|param| { takes_ref(param) }); /// ``` - fn can_use_as_ref(&self, expr: &hir::Expr) -> Option<(Span, &'static str, String)> { + fn can_use_as_ref(&self, expr: &hir::Expr<'_>) -> Option<(Span, &'static str, String)> { let path = match expr.kind { hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) => path, _ => return None, @@ -352,7 +356,7 @@ fn can_use_as_ref(&self, expr: &hir::Expr) -> Option<(Span, &'static str, String if let Node::Expr(hir::Expr { kind: hir::ExprKind::Struct(_, fields, ..), .. }) = parent { if let Ok(src) = cm.span_to_snippet(sp) { - for field in fields { + for field in *fields { if field.ident.as_str() == src && field.is_shorthand { return true; } @@ -381,7 +385,7 @@ fn can_use_as_ref(&self, expr: &hir::Expr) -> Option<(Span, &'static str, String /// `&mut`!". pub fn check_ref( &self, - expr: &hir::Expr, + expr: &hir::Expr<'_>, checked_ty: Ty<'tcx>, expected: Ty<'tcx>, ) -> Option<(Span, &'static str, String)> { @@ -605,7 +609,7 @@ pub fn check_ref( pub fn check_for_cast( &self, err: &mut DiagnosticBuilder<'_>, - expr: &hir::Expr, + expr: &hir::Expr<'_>, checked_ty: Ty<'tcx>, expected_ty: Ty<'tcx>, ) -> bool { @@ -635,7 +639,7 @@ pub fn check_for_cast( })) = self.tcx.hir().find(self.tcx.hir().get_parent_node(expr.hir_id)) { // `expr` is a literal field for a struct, only suggest if appropriate - for field in fields { + for field in *fields { if field.expr.hir_id == expr.hir_id && field.is_shorthand { // This is a field literal prefix = format!("{}: ", field.ident); @@ -728,7 +732,7 @@ pub fn check_for_cast( expected_ty, if needs_paren { ")" } else { "" }, ); - let literal_is_ty_suffixed = |expr: &hir::Expr| { + let literal_is_ty_suffixed = |expr: &hir::Expr<'_>| { if let hir::ExprKind::Lit(lit) = &expr.kind { lit.node.is_suffixed() } else { diff --git a/src/librustc_typeck/check/expr.rs b/src/librustc_typeck/check/expr.rs index e862971c9e2..4da4ce7680b 100644 --- a/src/librustc_typeck/check/expr.rs +++ b/src/librustc_typeck/check/expr.rs @@ -21,7 +21,6 @@ use rustc::hir; use rustc::hir::def::{CtorKind, DefKind, Res}; use rustc::hir::def_id::DefId; -use rustc::hir::ptr::P; use rustc::hir::{ExprKind, QPath}; use rustc::infer; use rustc::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind}; @@ -43,14 +42,14 @@ use std::fmt::Display; impl<'a, 'tcx> FnCtxt<'a, 'tcx> { - fn check_expr_eq_type(&self, expr: &'tcx hir::Expr, expected: Ty<'tcx>) { + fn check_expr_eq_type(&self, expr: &'tcx hir::Expr<'tcx>, expected: Ty<'tcx>) { let ty = self.check_expr_with_hint(expr, expected); self.demand_eqtype(expr.span, expected, ty); } pub fn check_expr_has_type_or_error( &self, - expr: &'tcx hir::Expr, + expr: &'tcx hir::Expr<'tcx>, expected: Ty<'tcx>, extend_err: impl Fn(&mut DiagnosticBuilder<'_>), ) -> Ty<'tcx> { @@ -59,7 +58,7 @@ pub fn check_expr_has_type_or_error( fn check_expr_meets_expectation_or_error( &self, - expr: &'tcx hir::Expr, + expr: &'tcx hir::Expr<'tcx>, expected: Expectation<'tcx>, extend_err: impl Fn(&mut DiagnosticBuilder<'_>), ) -> Ty<'tcx> { @@ -96,7 +95,7 @@ fn check_expr_meets_expectation_or_error( pub(super) fn check_expr_coercable_to_type( &self, - expr: &'tcx hir::Expr, + expr: &'tcx hir::Expr<'tcx>, expected: Ty<'tcx>, ) -> Ty<'tcx> { let ty = self.check_expr_with_hint(expr, expected); @@ -106,7 +105,7 @@ pub(super) fn check_expr_coercable_to_type( pub(super) fn check_expr_with_hint( &self, - expr: &'tcx hir::Expr, + expr: &'tcx hir::Expr<'tcx>, expected: Ty<'tcx>, ) -> Ty<'tcx> { self.check_expr_with_expectation(expr, ExpectHasType(expected)) @@ -114,17 +113,21 @@ pub(super) fn check_expr_with_hint( pub(super) fn check_expr_with_expectation( &self, - expr: &'tcx hir::Expr, + expr: &'tcx hir::Expr<'tcx>, expected: Expectation<'tcx>, ) -> Ty<'tcx> { self.check_expr_with_expectation_and_needs(expr, expected, Needs::None) } - pub(super) fn check_expr(&self, expr: &'tcx hir::Expr) -> Ty<'tcx> { + pub(super) fn check_expr(&self, expr: &'tcx hir::Expr<'tcx>) -> Ty<'tcx> { self.check_expr_with_expectation(expr, NoExpectation) } - pub(super) fn check_expr_with_needs(&self, expr: &'tcx hir::Expr, needs: Needs) -> Ty<'tcx> { + pub(super) fn check_expr_with_needs( + &self, + expr: &'tcx hir::Expr<'tcx>, + needs: Needs, + ) -> Ty<'tcx> { self.check_expr_with_expectation_and_needs(expr, NoExpectation, needs) } @@ -140,7 +143,7 @@ pub(super) fn check_expr_with_needs(&self, expr: &'tcx hir::Expr, needs: Needs) /// that when err needs to be handled differently. fn check_expr_with_expectation_and_needs( &self, - expr: &'tcx hir::Expr, + expr: &'tcx hir::Expr<'tcx>, expected: Expectation<'tcx>, needs: Needs, ) -> Ty<'tcx> { @@ -208,7 +211,7 @@ fn check_expr_with_expectation_and_needs( fn check_expr_kind( &self, - expr: &'tcx hir::Expr, + expr: &'tcx hir::Expr<'tcx>, expected: Expectation<'tcx>, needs: Needs, ) -> Ty<'tcx> { @@ -274,7 +277,7 @@ fn check_expr_kind( self.check_expr_repeat(element, count, expected, expr) } ExprKind::Tup(ref elts) => self.check_expr_tuple(elts, expected, expr), - ExprKind::Struct(ref qpath, ref fields, ref base_expr) => { + ExprKind::Struct(ref qpath, fields, ref base_expr) => { self.check_expr_struct(expr, expected, qpath, fields, base_expr) } ExprKind::Field(ref base, field) => self.check_field(expr, needs, &base, field), @@ -284,7 +287,7 @@ fn check_expr_kind( } } - fn check_expr_box(&self, expr: &'tcx hir::Expr, expected: Expectation<'tcx>) -> Ty<'tcx> { + fn check_expr_box(&self, expr: &'tcx hir::Expr<'tcx>, expected: Expectation<'tcx>) -> Ty<'tcx> { let expected_inner = expected.to_option(self).map_or(NoExpectation, |ty| match ty.kind { ty::Adt(def, _) if def.is_box() => Expectation::rvalue_hint(self, ty.boxed_ty()), _ => NoExpectation, @@ -296,10 +299,10 @@ fn check_expr_box(&self, expr: &'tcx hir::Expr, expected: Expectation<'tcx>) -> fn check_expr_unary( &self, unop: hir::UnOp, - oprnd: &'tcx hir::Expr, + oprnd: &'tcx hir::Expr<'tcx>, expected: Expectation<'tcx>, needs: Needs, - expr: &'tcx hir::Expr, + expr: &'tcx hir::Expr<'tcx>, ) -> Ty<'tcx> { let tcx = self.tcx; let expected_inner = match unop { @@ -382,9 +385,9 @@ fn check_expr_addr_of( &self, kind: hir::BorrowKind, mutbl: hir::Mutability, - oprnd: &'tcx hir::Expr, + oprnd: &'tcx hir::Expr<'tcx>, expected: Expectation<'tcx>, - expr: &'tcx hir::Expr, + expr: &'tcx hir::Expr<'tcx>, ) -> Ty<'tcx> { let hint = expected.only_has_type(self).map_or(NoExpectation, |ty| { match ty.kind { @@ -437,7 +440,7 @@ fn check_expr_addr_of( /// * Contains a dereference /// Note that the adjustments for the children of `expr` should already /// have been resolved. - fn check_named_place_expr(&self, oprnd: &'tcx hir::Expr) { + fn check_named_place_expr(&self, oprnd: &'tcx hir::Expr<'tcx>) { let is_named = oprnd.is_place_expr(|base| { // Allow raw borrows if there are any deref adjustments. // @@ -466,7 +469,7 @@ fn check_named_place_expr(&self, oprnd: &'tcx hir::Expr) { } } - fn check_expr_path(&self, qpath: &hir::QPath, expr: &'tcx hir::Expr) -> Ty<'tcx> { + fn check_expr_path(&self, qpath: &hir::QPath, expr: &'tcx hir::Expr<'tcx>) -> Ty<'tcx> { let tcx = self.tcx; let (res, opt_ty, segs) = self.resolve_ty_and_res_ufcs(qpath, expr.hir_id, expr.span); let ty = match res { @@ -538,8 +541,8 @@ fn check_expr_path(&self, qpath: &hir::QPath, expr: &'tcx hir::Expr) -> Ty<'tcx> fn check_expr_break( &self, destination: hir::Destination, - expr_opt: Option<&'tcx hir::Expr>, - expr: &'tcx hir::Expr, + expr_opt: Option<&'tcx hir::Expr<'tcx>>, + expr: &'tcx hir::Expr<'tcx>, ) -> Ty<'tcx> { let tcx = self.tcx; if let Ok(target_id) = destination.target_id { @@ -669,8 +672,8 @@ fn check_expr_break( fn check_expr_return( &self, - expr_opt: Option<&'tcx hir::Expr>, - expr: &'tcx hir::Expr, + expr_opt: Option<&'tcx hir::Expr<'tcx>>, + expr: &'tcx hir::Expr<'tcx>, ) -> Ty<'tcx> { if self.ret_coercion.is_none() { struct_span_err!( @@ -710,7 +713,7 @@ fn check_expr_return( self.tcx.types.never } - pub(super) fn check_return_expr(&self, return_expr: &'tcx hir::Expr) { + pub(super) fn check_return_expr(&self, return_expr: &'tcx hir::Expr<'tcx>) { let ret_coercion = self.ret_coercion.as_ref().unwrap_or_else(|| { span_bug!(return_expr.span, "check_return_expr called outside fn body") }); @@ -725,7 +728,7 @@ pub(super) fn check_return_expr(&self, return_expr: &'tcx hir::Expr) { ); } - fn is_destructuring_place_expr(&self, expr: &'tcx hir::Expr) -> bool { + fn is_destructuring_place_expr(&self, expr: &'tcx hir::Expr<'tcx>) -> bool { match &expr.kind { ExprKind::Array(comps) | ExprKind::Tup(comps) => { comps.iter().all(|e| self.is_destructuring_place_expr(e)) @@ -740,7 +743,7 @@ fn is_destructuring_place_expr(&self, expr: &'tcx hir::Expr) -> bool { pub(crate) fn check_lhs_assignable( &self, - lhs: &'tcx hir::Expr, + lhs: &'tcx hir::Expr<'tcx>, err_code: &'static str, expr_span: &Span, ) { @@ -763,10 +766,10 @@ pub(crate) fn check_lhs_assignable( /// The expected type is `()` and is passsed to the function for the purposes of diagnostics. fn check_expr_assign( &self, - expr: &'tcx hir::Expr, + expr: &'tcx hir::Expr<'tcx>, expected: Expectation<'tcx>, - lhs: &'tcx hir::Expr, - rhs: &'tcx hir::Expr, + lhs: &'tcx hir::Expr<'tcx>, + rhs: &'tcx hir::Expr<'tcx>, span: &Span, ) -> Ty<'tcx> { let lhs_ty = self.check_expr_with_needs(&lhs, Needs::MutPlace); @@ -804,10 +807,10 @@ fn check_expr_assign( fn check_expr_loop( &self, - body: &'tcx hir::Block, + body: &'tcx hir::Block<'tcx>, source: hir::LoopSource, expected: Expectation<'tcx>, - expr: &'tcx hir::Expr, + expr: &'tcx hir::Expr<'tcx>, ) -> Ty<'tcx> { let coerce = match source { // you can only use break with a value from a normal `loop { }` @@ -849,10 +852,10 @@ fn check_expr_loop( /// Checks a method call. fn check_method_call( &self, - expr: &'tcx hir::Expr, + expr: &'tcx hir::Expr<'tcx>, segment: &hir::PathSegment, span: Span, - args: &'tcx [hir::Expr], + args: &'tcx [hir::Expr<'tcx>], expected: Expectation<'tcx>, needs: Needs, ) -> Ty<'tcx> { @@ -892,7 +895,7 @@ fn report_extended_method_error( &self, segment: &hir::PathSegment, span: Span, - args: &'tcx [hir::Expr], + args: &'tcx [hir::Expr<'tcx>], rcvr_t: Ty<'tcx>, error: MethodError<'tcx>, ) { @@ -937,9 +940,9 @@ fn report_extended_method_error( fn check_expr_cast( &self, - e: &'tcx hir::Expr, + e: &'tcx hir::Expr<'tcx>, t: &'tcx hir::Ty, - expr: &'tcx hir::Expr, + expr: &'tcx hir::Expr<'tcx>, ) -> Ty<'tcx> { // Find the type of `e`. Supply hints based on the type we are casting to, // if appropriate. @@ -966,9 +969,9 @@ fn check_expr_cast( fn check_expr_array( &self, - args: &'tcx [hir::Expr], + args: &'tcx [hir::Expr<'tcx>], expected: Expectation<'tcx>, - expr: &'tcx hir::Expr, + expr: &'tcx hir::Expr<'tcx>, ) -> Ty<'tcx> { let uty = expected.to_option(self).and_then(|uty| match uty.kind { ty::Array(ty, _) | ty::Slice(ty) => Some(ty), @@ -1001,10 +1004,10 @@ fn check_expr_array( fn check_expr_repeat( &self, - element: &'tcx hir::Expr, + element: &'tcx hir::Expr<'tcx>, count: &'tcx hir::AnonConst, expected: Expectation<'tcx>, - _expr: &'tcx hir::Expr, + _expr: &'tcx hir::Expr<'tcx>, ) -> Ty<'tcx> { let tcx = self.tcx; let count_def_id = tcx.hir().local_def_id(count.hir_id); @@ -1048,9 +1051,9 @@ fn check_expr_repeat( fn check_expr_tuple( &self, - elts: &'tcx [hir::Expr], + elts: &'tcx [hir::Expr<'tcx>], expected: Expectation<'tcx>, - expr: &'tcx hir::Expr, + expr: &'tcx hir::Expr<'tcx>, ) -> Ty<'tcx> { let flds = expected.only_has_type(self).and_then(|ty| { let ty = self.resolve_vars_with_obligations(ty); @@ -1082,11 +1085,11 @@ fn check_expr_tuple( fn check_expr_struct( &self, - expr: &hir::Expr, + expr: &hir::Expr<'_>, expected: Expectation<'tcx>, qpath: &QPath, - fields: &'tcx [hir::Field], - base_expr: &'tcx Option>, + fields: &'tcx [hir::Field<'tcx>], + base_expr: &'tcx Option<&'tcx hir::Expr<'tcx>>, ) -> Ty<'tcx> { // Find the relevant variant let (variant, adt_ty) = if let Some(variant_ty) = self.check_struct_path(qpath, expr.hir_id) @@ -1170,7 +1173,7 @@ fn check_expr_struct_fields( expr_id: hir::HirId, span: Span, variant: &'tcx ty::VariantDef, - ast_fields: &'tcx [hir::Field], + ast_fields: &'tcx [hir::Field<'tcx>], check_completeness: bool, ) -> bool { let tcx = self.tcx; @@ -1288,8 +1291,8 @@ fn check_expr_struct_fields( fn check_struct_fields_on_error( &self, - fields: &'tcx [hir::Field], - base_expr: &'tcx Option>, + fields: &'tcx [hir::Field<'tcx>], + base_expr: &'tcx Option<&'tcx hir::Expr<'tcx>>, ) { for field in fields { self.check_expr(&field.expr); @@ -1303,8 +1306,8 @@ fn report_unknown_field( &self, ty: Ty<'tcx>, variant: &'tcx ty::VariantDef, - field: &hir::Field, - skip_fields: &[hir::Field], + field: &hir::Field<'_>, + skip_fields: &[hir::Field<'_>], kind_name: &str, ty_span: Span, ) { @@ -1441,9 +1444,9 @@ fn name_series_display(&self, names: Vec) -> String { // Check field access expressions fn check_field( &self, - expr: &'tcx hir::Expr, + expr: &'tcx hir::Expr<'tcx>, needs: Needs, - base: &'tcx hir::Expr, + base: &'tcx hir::Expr<'tcx>, field: ast::Ident, ) -> Ty<'tcx> { let expr_t = self.check_expr_with_needs(base, needs); @@ -1522,8 +1525,8 @@ fn check_field( fn ban_nonexisting_field( &self, field: ast::Ident, - base: &'tcx hir::Expr, - expr: &'tcx hir::Expr, + base: &'tcx hir::Expr<'tcx>, + expr: &'tcx hir::Expr<'tcx>, expr_t: Ty<'tcx>, ) { let mut err = self.no_such_field_err(field.span, field, expr_t); @@ -1557,7 +1560,7 @@ fn ban_nonexisting_field( fn ban_private_field_access( &self, - expr: &hir::Expr, + expr: &hir::Expr<'_>, expr_t: Ty<'tcx>, field: ast::Ident, base_did: DefId, @@ -1590,7 +1593,7 @@ fn ban_private_field_access( err.emit(); } - fn ban_take_value_of_method(&self, expr: &hir::Expr, expr_t: Ty<'tcx>, field: ast::Ident) { + fn ban_take_value_of_method(&self, expr: &hir::Expr<'_>, expr_t: Ty<'tcx>, field: ast::Ident) { let mut err = type_error_struct!( self.tcx().sess, field.span, @@ -1664,8 +1667,8 @@ fn suggest_fields_on_recordish( fn maybe_suggest_array_indexing( &self, err: &mut DiagnosticBuilder<'_>, - expr: &hir::Expr, - base: &hir::Expr, + expr: &hir::Expr<'_>, + base: &hir::Expr<'_>, field: ast::Ident, len: &ty::Const<'tcx>, ) { @@ -1692,8 +1695,8 @@ fn maybe_suggest_array_indexing( fn suggest_first_deref_field( &self, err: &mut DiagnosticBuilder<'_>, - expr: &hir::Expr, - base: &hir::Expr, + expr: &hir::Expr<'_>, + base: &hir::Expr<'_>, field: ast::Ident, ) { let base = self @@ -1726,10 +1729,10 @@ fn no_such_field_err( fn check_expr_index( &self, - base: &'tcx hir::Expr, - idx: &'tcx hir::Expr, + base: &'tcx hir::Expr<'tcx>, + idx: &'tcx hir::Expr<'tcx>, needs: Needs, - expr: &'tcx hir::Expr, + expr: &'tcx hir::Expr<'tcx>, ) -> Ty<'tcx> { let base_t = self.check_expr_with_needs(&base, needs); let idx_t = self.check_expr(&idx); @@ -1790,8 +1793,8 @@ fn check_expr_index( fn check_expr_yield( &self, - value: &'tcx hir::Expr, - expr: &'tcx hir::Expr, + value: &'tcx hir::Expr<'tcx>, + expr: &'tcx hir::Expr<'tcx>, src: &'tcx hir::YieldSource, ) -> Ty<'tcx> { match self.yield_ty { diff --git a/src/librustc_typeck/check/generator_interior.rs b/src/librustc_typeck/check/generator_interior.rs index 3fedd19b829..3069f1b1d77 100644 --- a/src/librustc_typeck/check/generator_interior.rs +++ b/src/librustc_typeck/check/generator_interior.rs @@ -27,7 +27,7 @@ fn record( &mut self, ty: Ty<'tcx>, scope: Option, - expr: Option<&'tcx Expr>, + expr: Option<&'tcx Expr<'tcx>>, source_span: Span, ) { use syntax_pos::DUMMY_SP; @@ -196,7 +196,7 @@ fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { NestedVisitorMap::None } - fn visit_pat(&mut self, pat: &'tcx Pat) { + fn visit_pat(&mut self, pat: &'tcx Pat<'tcx>) { intravisit::walk_pat(self, pat); self.expr_count += 1; @@ -208,7 +208,7 @@ fn visit_pat(&mut self, pat: &'tcx Pat) { } } - fn visit_expr(&mut self, expr: &'tcx Expr) { + fn visit_expr(&mut self, expr: &'tcx Expr<'tcx>) { let scope = self.region_scope_tree.temporary_scope(expr.hir_id.local_id); match &expr.kind { @@ -227,7 +227,7 @@ fn visit_expr(&mut self, expr: &'tcx Expr) { self.expr_count += 1; // Record the rest of the call expression normally. - for arg in args { + for arg in *args { self.visit_expr(arg); } } diff --git a/src/librustc_typeck/check/method/confirm.rs b/src/librustc_typeck/check/method/confirm.rs index 0b26933459f..98645b3463e 100644 --- a/src/librustc_typeck/check/method/confirm.rs +++ b/src/librustc_typeck/check/method/confirm.rs @@ -19,8 +19,8 @@ struct ConfirmContext<'a, 'tcx> { fcx: &'a FnCtxt<'a, 'tcx>, span: Span, - self_expr: &'tcx hir::Expr, - call_expr: &'tcx hir::Expr, + self_expr: &'tcx hir::Expr<'tcx>, + call_expr: &'tcx hir::Expr<'tcx>, } impl<'a, 'tcx> Deref for ConfirmContext<'a, 'tcx> { @@ -39,8 +39,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { pub fn confirm_method( &self, span: Span, - self_expr: &'tcx hir::Expr, - call_expr: &'tcx hir::Expr, + self_expr: &'tcx hir::Expr<'tcx>, + call_expr: &'tcx hir::Expr<'tcx>, unadjusted_self_ty: Ty<'tcx>, pick: probe::Pick<'tcx>, segment: &hir::PathSegment, @@ -59,8 +59,8 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> { fn new( fcx: &'a FnCtxt<'a, 'tcx>, span: Span, - self_expr: &'tcx hir::Expr, - call_expr: &'tcx hir::Expr, + self_expr: &'tcx hir::Expr<'tcx>, + call_expr: &'tcx hir::Expr<'tcx>, ) -> ConfirmContext<'a, 'tcx> { ConfirmContext { fcx, span, self_expr, call_expr } } @@ -482,8 +482,8 @@ fn convert_place_derefs_to_mutable(&self) { fn convert_place_op_to_mutable( &self, op: PlaceOp, - expr: &hir::Expr, - base_expr: &hir::Expr, + expr: &hir::Expr<'_>, + base_expr: &hir::Expr<'_>, arg_tys: &[Ty<'tcx>], ) { debug!("convert_place_op_to_mutable({:?}, {:?}, {:?}, {:?})", op, expr, base_expr, arg_tys); diff --git a/src/librustc_typeck/check/method/mod.rs b/src/librustc_typeck/check/method/mod.rs index d0aa709069e..41fd8d46346 100644 --- a/src/librustc_typeck/check/method/mod.rs +++ b/src/librustc_typeck/check/method/mod.rs @@ -180,8 +180,8 @@ pub fn lookup_method( self_ty: Ty<'tcx>, segment: &hir::PathSegment, span: Span, - call_expr: &'tcx hir::Expr, - self_expr: &'tcx hir::Expr, + call_expr: &'tcx hir::Expr<'tcx>, + self_expr: &'tcx hir::Expr<'tcx>, ) -> Result, MethodError<'tcx>> { debug!( "lookup(method_name={}, self_ty={:?}, call_expr={:?}, self_expr={:?})", @@ -260,7 +260,7 @@ pub fn lookup_probe( span: Span, method_name: ast::Ident, self_ty: Ty<'tcx>, - call_expr: &'tcx hir::Expr, + call_expr: &'tcx hir::Expr<'tcx>, scope: ProbeScope, ) -> probe::PickResult<'tcx> { let mode = probe::Mode::MethodCall; diff --git a/src/librustc_typeck/check/method/suggest.rs b/src/librustc_typeck/check/method/suggest.rs index 0c61c24d23a..f19e8c9ab1c 100644 --- a/src/librustc_typeck/check/method/suggest.rs +++ b/src/librustc_typeck/check/method/suggest.rs @@ -72,7 +72,7 @@ pub fn report_method_error<'b>( item_name: ast::Ident, source: SelfSource<'b>, error: MethodError<'tcx>, - args: Option<&'tcx [hir::Expr]>, + args: Option<&'tcx [hir::Expr<'tcx>]>, ) -> Option> { let orig_span = span; let mut span = span; @@ -954,7 +954,7 @@ fn is_local(ty: Ty<'_>) -> bool { #[derive(Copy, Clone)] pub enum SelfSource<'a> { QPath(&'a hir::Ty), - MethodCall(&'a hir::Expr /* rcvr */), + MethodCall(&'a hir::Expr<'a> /* rcvr */), } #[derive(Copy, Clone)] @@ -1131,7 +1131,7 @@ fn nested_visit_map<'this>(&'this mut self) -> hir::intravisit::NestedVisitorMap fn print_disambiguation_help( item_name: ast::Ident, - args: Option<&'tcx [hir::Expr]>, + args: Option<&'tcx [hir::Expr<'tcx>]>, err: &mut DiagnosticBuilder<'_>, trait_name: String, rcvr_ty: Ty<'_>, diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 8e79cc13895..f8e494a6ccd 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -95,7 +95,6 @@ use rustc::hir::def_id::{CrateNum, DefId, LOCAL_CRATE}; use rustc::hir::intravisit::{self, NestedVisitorMap, Visitor}; use rustc::hir::itemlikevisit::ItemLikeVisitor; -use rustc::hir::ptr::P; use rustc::hir::{self, ExprKind, GenericArg, ItemKind, Node, PatKind, QPath}; use rustc::infer::canonical::{Canonical, OriginalQueryValues, QueryResponse}; use rustc::infer::error_reporting::TypeAnnotationNeeded::E0282; @@ -390,7 +389,7 @@ pub fn function(unsafety: hir::Unsafety, def: hir::HirId) -> UnsafetyState { UnsafetyState { def, unsafety, unsafe_push_count: 0, from_fn: true } } - pub fn recurse(&mut self, blk: &hir::Block) -> UnsafetyState { + pub fn recurse(&mut self, blk: &hir::Block<'_>) -> UnsafetyState { match self.unsafety { // If this unsafe, then if the outer function was already marked as // unsafe we shouldn't attribute the unsafe'ness to the block. This @@ -1136,7 +1135,7 @@ fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { } // Add explicitly-declared locals. - fn visit_local(&mut self, local: &'tcx hir::Local) { + fn visit_local(&mut self, local: &'tcx hir::Local<'tcx>) { let local_ty = match local.ty { Some(ref ty) => { let o_ty = self.fcx.to_ty(&ty); @@ -1174,7 +1173,7 @@ fn visit_local(&mut self, local: &'tcx hir::Local) { } // Add pattern bindings. - fn visit_pat(&mut self, p: &'tcx hir::Pat) { + fn visit_pat(&mut self, p: &'tcx hir::Pat<'tcx>) { if let PatKind::Binding(_, _, ident, _) = p.kind { let var_ty = self.assign(p.span, p.hir_id, None); @@ -2934,7 +2933,7 @@ pub fn write_user_type_annotation( } } - pub fn apply_adjustments(&self, expr: &hir::Expr, adj: Vec>) { + pub fn apply_adjustments(&self, expr: &hir::Expr<'_>, adj: Vec>) { debug!("apply_adjustments(expr={:?}, adj={:?})", expr, adj); if adj.is_empty() { @@ -3181,7 +3180,7 @@ pub fn register_wf_obligation( } /// Registers obligations that all types appearing in `substs` are well-formed. - pub fn add_wf_bounds(&self, substs: SubstsRef<'tcx>, expr: &hir::Expr) { + pub fn add_wf_bounds(&self, substs: SubstsRef<'tcx>, expr: &hir::Expr<'_>) { for ty in substs.types() { if !ty.references_error() { self.register_wf_obligation(ty, expr.span, traits::MiscObligation); @@ -3362,8 +3361,8 @@ fn make_overloaded_place_return_type( fn lookup_indexing( &self, - expr: &hir::Expr, - base_expr: &'tcx hir::Expr, + expr: &hir::Expr<'_>, + base_expr: &'tcx hir::Expr<'tcx>, base_ty: Ty<'tcx>, idx_ty: Ty<'tcx>, needs: Needs, @@ -3388,8 +3387,8 @@ fn lookup_indexing( /// is implemented by `lookup_indexing`. fn try_index_step( &self, - expr: &hir::Expr, - base_expr: &hir::Expr, + expr: &hir::Expr<'_>, + base_expr: &hir::Expr<'_>, autoderef: &Autoderef<'a, 'tcx>, needs: Needs, index_ty: Ty<'tcx>, @@ -3513,9 +3512,9 @@ fn try_overloaded_place_op( fn check_method_argument_types( &self, sp: Span, - expr: &'tcx hir::Expr, + expr: &'tcx hir::Expr<'tcx>, method: Result, ()>, - args_no_rcvr: &'tcx [hir::Expr], + args_no_rcvr: &'tcx [hir::Expr<'tcx>], tuple_arguments: TupleArgumentsFlag, expected: Expectation<'tcx>, ) -> Ty<'tcx> { @@ -3641,10 +3640,10 @@ fn type_var_is_sized(&self, self_ty: ty::TyVid) -> bool { fn check_argument_types( &self, sp: Span, - expr: &'tcx hir::Expr, + expr: &'tcx hir::Expr<'tcx>, fn_inputs: &[Ty<'tcx>], expected_arg_tys: &[Ty<'tcx>], - args: &'tcx [hir::Expr], + args: &'tcx [hir::Expr<'tcx>], c_variadic: bool, tuple_arguments: TupleArgumentsFlag, def_span: Option, @@ -3897,7 +3896,7 @@ fn point_at_arg_instead_of_call_if_possible( errors: &mut Vec>, final_arg_types: &[(usize, Ty<'tcx>, Ty<'tcx>)], call_sp: Span, - args: &'tcx [hir::Expr], + args: &'tcx [hir::Expr<'tcx>], ) { // We *do not* do this for desugared call spans to keep good diagnostics when involving // the `?` operator. @@ -3951,7 +3950,7 @@ fn point_at_arg_instead_of_call_if_possible( fn point_at_type_arg_instead_of_call_if_possible( &self, errors: &mut Vec>, - call_expr: &'tcx hir::Expr, + call_expr: &'tcx hir::Expr<'tcx>, ) { if let hir::ExprKind::Call(path, _) = &call_expr.kind { if let hir::ExprKind::Path(qpath) = &path.kind { @@ -4248,8 +4247,8 @@ pub fn resolve_ty_and_res_ufcs<'b>( pub fn check_decl_initializer( &self, - local: &'tcx hir::Local, - init: &'tcx hir::Expr, + local: &'tcx hir::Local<'tcx>, + init: &'tcx hir::Expr<'tcx>, ) -> Ty<'tcx> { // FIXME(tschottdorf): `contains_explicit_ref_binding()` must be removed // for #42640 (default match binding modes). @@ -4275,7 +4274,7 @@ pub fn check_decl_initializer( } } - pub fn check_decl_local(&self, local: &'tcx hir::Local) { + pub fn check_decl_local(&self, local: &'tcx hir::Local<'tcx>) { let t = self.local_ty(local.span, local.hir_id).decl_ty; self.write_ty(local.hir_id, t); @@ -4289,7 +4288,12 @@ pub fn check_decl_local(&self, local: &'tcx hir::Local) { self.overwrite_local_ty_if_err(local, t, pat_ty); } - fn overwrite_local_ty_if_err(&self, local: &'tcx hir::Local, decl_ty: Ty<'tcx>, ty: Ty<'tcx>) { + fn overwrite_local_ty_if_err( + &self, + local: &'tcx hir::Local<'tcx>, + decl_ty: Ty<'tcx>, + ty: Ty<'tcx>, + ) { if ty.references_error() { // Override the types everywhere with `types.err` to avoid knock down errors. self.write_ty(local.hir_id, ty); @@ -4309,7 +4313,7 @@ fn suggest_semicolon_at_end(&self, span: Span, err: &mut DiagnosticBuilder<'_>) ); } - pub fn check_stmt(&self, stmt: &'tcx hir::Stmt) { + pub fn check_stmt(&self, stmt: &'tcx hir::Stmt<'tcx>) { // Don't do all the complex logic below for `DeclItem`. match stmt.kind { hir::StmtKind::Item(..) => return, @@ -4347,7 +4351,7 @@ pub fn check_stmt(&self, stmt: &'tcx hir::Stmt) { self.has_errors.set(self.has_errors.get() | old_has_errors); } - pub fn check_block_no_value(&self, blk: &'tcx hir::Block) { + pub fn check_block_no_value(&self, blk: &'tcx hir::Block<'tcx>) { let unit = self.tcx.mk_unit(); let ty = self.check_block_with_expected(blk, ExpectHasType(unit)); @@ -4365,7 +4369,7 @@ pub fn check_block_no_value(&self, blk: &'tcx hir::Block) { /// if false { return 0i32; } else { 1u32 } /// // ^^^^ point at this instead of the whole `if` expression /// ``` - fn get_expr_coercion_span(&self, expr: &hir::Expr) -> syntax_pos::Span { + fn get_expr_coercion_span(&self, expr: &hir::Expr<'_>) -> syntax_pos::Span { if let hir::ExprKind::Match(_, arms, _) = &expr.kind { let arm_spans: Vec = arms .iter() @@ -4396,7 +4400,7 @@ fn get_expr_coercion_span(&self, expr: &hir::Expr) -> syntax_pos::Span { fn check_block_with_expected( &self, - blk: &'tcx hir::Block, + blk: &'tcx hir::Block<'tcx>, expected: Expectation<'tcx>, ) -> Ty<'tcx> { let prev = { @@ -4426,7 +4430,7 @@ fn check_block_with_expected( let coerce = if blk.targeted_by_break { CoerceMany::new(coerce_to_ty) } else { - let tail_expr: &[P] = match tail_expr { + let tail_expr: &[&hir::Expr<'_>] = match tail_expr { Some(e) => slice::from_ref(e), None => &[], }; @@ -4437,7 +4441,7 @@ fn check_block_with_expected( let ctxt = BreakableCtxt { coerce: Some(coerce), may_break: false }; let (ctxt, ()) = self.with_breakable_ctxt(blk.hir_id, ctxt, || { - for s in &blk.stmts { + for s in blk.stmts { self.check_stmt(s); } @@ -4588,7 +4592,7 @@ pub fn get_fn_decl(&self, blk_id: hir::HirId) -> Option<(&'tcx hir::FnDecl, bool pub fn suggest_mismatched_types_on_tail( &self, err: &mut DiagnosticBuilder<'_>, - expr: &'tcx hir::Expr, + expr: &'tcx hir::Expr<'tcx>, expected: Ty<'tcx>, found: Ty<'tcx>, cause_span: Span, @@ -4613,7 +4617,7 @@ pub fn suggest_mismatched_types_on_tail( fn suggest_fn_call( &self, err: &mut DiagnosticBuilder<'_>, - expr: &hir::Expr, + expr: &hir::Expr<'_>, expected: Ty<'tcx>, found: Ty<'tcx>, ) -> bool { @@ -4756,7 +4760,7 @@ fn suggest_fn_call( pub fn suggest_ref_or_into( &self, err: &mut DiagnosticBuilder<'_>, - expr: &hir::Expr, + expr: &hir::Expr<'_>, expected: Ty<'tcx>, found: Ty<'tcx>, ) { @@ -4819,7 +4823,7 @@ pub fn suggest_ref_or_into( fn suggest_boxing_when_appropriate( &self, err: &mut DiagnosticBuilder<'_>, - expr: &hir::Expr, + expr: &hir::Expr<'_>, expected: Ty<'tcx>, found: Ty<'tcx>, ) { @@ -4864,7 +4868,7 @@ fn suggest_boxing_when_appropriate( fn suggest_missing_semicolon( &self, err: &mut DiagnosticBuilder<'_>, - expression: &'tcx hir::Expr, + expression: &'tcx hir::Expr<'tcx>, expected: Ty<'tcx>, cause_span: Span, ) { @@ -4970,7 +4974,7 @@ fn suggest_missing_return_type( fn suggest_missing_await( &self, err: &mut DiagnosticBuilder<'_>, - expr: &hir::Expr, + expr: &hir::Expr<'_>, expected: Ty<'tcx>, found: Ty<'tcx>, ) { @@ -5033,7 +5037,7 @@ fn suggest_missing_await( /// with `expected_ty`. If so, it suggests removing the semicolon. fn consider_hint_about_removing_semicolon( &self, - blk: &'tcx hir::Block, + blk: &'tcx hir::Block<'tcx>, expected_ty: Ty<'tcx>, err: &mut DiagnosticBuilder<'_>, ) { @@ -5047,7 +5051,11 @@ fn consider_hint_about_removing_semicolon( } } - fn could_remove_semicolon(&self, blk: &'tcx hir::Block, expected_ty: Ty<'tcx>) -> Option { + fn could_remove_semicolon( + &self, + blk: &'tcx hir::Block<'tcx>, + expected_ty: Ty<'tcx>, + ) -> Option { // Be helpful when the user wrote `{... expr;}` and // taking the `;` off is enough to fix the error. let last_stmt = blk.stmts.last()?; diff --git a/src/librustc_typeck/check/op.rs b/src/librustc_typeck/check/op.rs index c5d3aac136b..873a9b86fd6 100644 --- a/src/librustc_typeck/check/op.rs +++ b/src/librustc_typeck/check/op.rs @@ -17,10 +17,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// Checks a `a = b` pub fn check_binop_assign( &self, - expr: &'tcx hir::Expr, + expr: &'tcx hir::Expr<'tcx>, op: hir::BinOp, - lhs: &'tcx hir::Expr, - rhs: &'tcx hir::Expr, + lhs: &'tcx hir::Expr<'tcx>, + rhs: &'tcx hir::Expr<'tcx>, ) -> Ty<'tcx> { let (lhs_ty, rhs_ty, return_ty) = self.check_overloaded_binop(expr, lhs, rhs, op, IsAssign::Yes); @@ -41,10 +41,10 @@ pub fn check_binop_assign( /// Checks a potentially overloaded binary operator. pub fn check_binop( &self, - expr: &'tcx hir::Expr, + expr: &'tcx hir::Expr<'tcx>, op: hir::BinOp, - lhs_expr: &'tcx hir::Expr, - rhs_expr: &'tcx hir::Expr, + lhs_expr: &'tcx hir::Expr<'tcx>, + rhs_expr: &'tcx hir::Expr<'tcx>, ) -> Ty<'tcx> { let tcx = self.tcx; @@ -100,9 +100,9 @@ pub fn check_binop( fn enforce_builtin_binop_types( &self, - lhs_expr: &'tcx hir::Expr, + lhs_expr: &'tcx hir::Expr<'tcx>, lhs_ty: Ty<'tcx>, - rhs_expr: &'tcx hir::Expr, + rhs_expr: &'tcx hir::Expr<'tcx>, rhs_ty: Ty<'tcx>, op: hir::BinOp, ) -> Ty<'tcx> { @@ -137,9 +137,9 @@ fn enforce_builtin_binop_types( fn check_overloaded_binop( &self, - expr: &'tcx hir::Expr, - lhs_expr: &'tcx hir::Expr, - rhs_expr: &'tcx hir::Expr, + expr: &'tcx hir::Expr<'tcx>, + lhs_expr: &'tcx hir::Expr<'tcx>, + rhs_expr: &'tcx hir::Expr<'tcx>, op: hir::BinOp, is_assign: IsAssign, ) -> (Ty<'tcx>, Ty<'tcx>, Ty<'tcx>) { @@ -561,8 +561,8 @@ fn add_type_neq_err_label( /// to print the normal "implementation of `std::ops::Add` might be missing" note fn check_str_addition( &self, - lhs_expr: &'tcx hir::Expr, - rhs_expr: &'tcx hir::Expr, + lhs_expr: &'tcx hir::Expr<'tcx>, + rhs_expr: &'tcx hir::Expr<'tcx>, lhs_ty: Ty<'tcx>, rhs_ty: Ty<'tcx>, err: &mut errors::DiagnosticBuilder<'_>, @@ -659,7 +659,7 @@ fn check_str_addition( pub fn check_user_unop( &self, - ex: &'tcx hir::Expr, + ex: &'tcx hir::Expr<'tcx>, operand_ty: Ty<'tcx>, op: hir::UnOp, ) -> Ty<'tcx> { diff --git a/src/librustc_typeck/check/pat.rs b/src/librustc_typeck/check/pat.rs index d0f1ef7b4ec..3fb6d5227f7 100644 --- a/src/librustc_typeck/check/pat.rs +++ b/src/librustc_typeck/check/pat.rs @@ -3,7 +3,6 @@ use errors::{pluralize, Applicability, DiagnosticBuilder}; use rustc::hir::def::{CtorKind, DefKind, Res}; use rustc::hir::pat_util::EnumerateAndAdjustIterator; -use rustc::hir::ptr::P; use rustc::hir::{self, HirId, Pat, PatKind}; use rustc::infer; use rustc::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind}; @@ -31,7 +30,12 @@ https://doc.rust-lang.org/reference/types.html#trait-objects"; impl<'a, 'tcx> FnCtxt<'a, 'tcx> { - pub fn check_pat_top(&self, pat: &'tcx Pat, expected: Ty<'tcx>, discrim_span: Option) { + pub fn check_pat_top( + &self, + pat: &'tcx Pat<'tcx>, + expected: Ty<'tcx>, + discrim_span: Option, + ) { let def_bm = BindingMode::BindByValue(hir::Mutability::Not); self.check_pat(pat, expected, def_bm, discrim_span); } @@ -54,7 +58,7 @@ pub fn check_pat_top(&self, pat: &'tcx Pat, expected: Ty<'tcx>, discrim_span: Op /// ``` fn check_pat( &self, - pat: &'tcx Pat, + pat: &'tcx Pat<'tcx>, expected: Ty<'tcx>, def_bm: BindingMode, discrim_span: Option, @@ -97,13 +101,13 @@ fn check_pat( self.check_pat_struct(pat, qpath, fields, *etc, expected, def_bm, discrim_span) } PatKind::Or(pats) => { - for pat in pats { + for pat in *pats { self.check_pat(pat, expected, def_bm, discrim_span); } expected } PatKind::Tuple(elements, ddpos) => { - self.check_pat_tuple(pat.span, elements, *ddpos, expected, def_bm, discrim_span) + self.check_pat_tuple(pat.span, *elements, *ddpos, expected, def_bm, discrim_span) } PatKind::Box(inner) => { self.check_pat_box(pat.span, inner, expected, def_bm, discrim_span) @@ -113,7 +117,15 @@ fn check_pat( } PatKind::Slice(before, slice, after) => { let slice = slice.as_deref(); - self.check_pat_slice(pat.span, before, slice, after, expected, def_bm, discrim_span) + self.check_pat_slice( + pat.span, + *before, + slice, + *after, + expected, + def_bm, + discrim_span, + ) } }; @@ -173,7 +185,7 @@ fn check_pat( /// as well as the pattern form we are currently checking. fn calc_default_binding_mode( &self, - pat: &'tcx Pat, + pat: &'tcx Pat<'tcx>, expected: Ty<'tcx>, def_bm: BindingMode, is_non_ref_pat: bool, @@ -203,7 +215,7 @@ fn calc_default_binding_mode( /// Is the pattern a "non reference pattern"? /// When the pattern is a path pattern, `opt_path_res` must be `Some(res)`. - fn is_non_ref_pat(&self, pat: &'tcx Pat, opt_path_res: Option) -> bool { + fn is_non_ref_pat(&self, pat: &'tcx Pat<'tcx>, opt_path_res: Option) -> bool { match pat.kind { PatKind::Struct(..) | PatKind::TupleStruct(..) @@ -242,7 +254,7 @@ fn is_non_ref_pat(&self, pat: &'tcx Pat, opt_path_res: Option) -> bool { /// The adjustments vector, if non-empty is stored in a table. fn peel_off_references( &self, - pat: &'tcx Pat, + pat: &'tcx Pat<'tcx>, expected: Ty<'tcx>, mut def_bm: BindingMode, ) -> (Ty<'tcx>, BindingMode) { @@ -288,7 +300,7 @@ fn peel_off_references( fn check_pat_lit( &self, span: Span, - lt: &hir::Expr, + lt: &hir::Expr<'tcx>, expected: Ty<'tcx>, discrim_span: Option, ) -> Ty<'tcx> { @@ -341,8 +353,8 @@ fn check_pat_lit( fn check_pat_range( &self, span: Span, - begin: &'tcx hir::Expr, - end: &'tcx hir::Expr, + begin: &'tcx hir::Expr<'tcx>, + end: &'tcx hir::Expr<'tcx>, expected: Ty<'tcx>, discrim_span: Option, ) -> Option> { @@ -422,10 +434,10 @@ fn emit_err_pat_range( fn check_pat_ident( &self, - pat: &Pat, + pat: &Pat<'_>, ba: hir::BindingAnnotation, var_id: HirId, - sub: Option<&'tcx Pat>, + sub: Option<&'tcx Pat<'tcx>>, expected: Ty<'tcx>, def_bm: BindingMode, discrim_span: Option, @@ -477,8 +489,8 @@ fn check_pat_ident( fn borrow_pat_suggestion( &self, err: &mut DiagnosticBuilder<'_>, - pat: &Pat, - inner: &Pat, + pat: &Pat<'_>, + inner: &Pat<'_>, expected: Ty<'tcx>, ) { let tcx = self.tcx; @@ -513,7 +525,7 @@ fn borrow_pat_suggestion( } } - pub fn check_dereferenceable(&self, span: Span, expected: Ty<'tcx>, inner: &Pat) -> bool { + pub fn check_dereferenceable(&self, span: Span, expected: Ty<'tcx>, inner: &Pat<'_>) -> bool { if let PatKind::Binding(..) = inner.kind { if let Some(mt) = self.shallow_resolve(expected).builtin_deref(true) { if let ty::Dynamic(..) = mt.ty.kind { @@ -541,9 +553,9 @@ pub fn check_dereferenceable(&self, span: Span, expected: Ty<'tcx>, inner: &Pat) fn check_pat_struct( &self, - pat: &'tcx Pat, + pat: &'tcx Pat<'tcx>, qpath: &hir::QPath, - fields: &'tcx [hir::FieldPat], + fields: &'tcx [hir::FieldPat<'tcx>], etc: bool, expected: Ty<'tcx>, def_bm: BindingMode, @@ -574,7 +586,7 @@ fn check_pat_struct( fn check_pat_path( &self, - pat: &Pat, + pat: &Pat<'_>, path_resolution: (Res, Option>, &'b [hir::PathSegment]), qpath: &hir::QPath, expected: Ty<'tcx>, @@ -609,9 +621,9 @@ fn check_pat_path( fn check_pat_tuple_struct( &self, - pat: &Pat, + pat: &Pat<'_>, qpath: &hir::QPath, - subpats: &'tcx [P], + subpats: &'tcx [&'tcx Pat<'tcx>], ddpos: Option, expected: Ty<'tcx>, def_bm: BindingMode, @@ -713,7 +725,7 @@ fn e0023( pat_span: Span, res: Res, qpath: &hir::QPath, - subpats: &'tcx [P], + subpats: &'tcx [&'tcx Pat<'tcx>], fields: &'tcx [ty::FieldDef], expected: Ty<'tcx>, had_err: bool, @@ -795,7 +807,7 @@ fn e0023( fn check_pat_tuple( &self, span: Span, - elements: &'tcx [P], + elements: &'tcx [&'tcx Pat<'tcx>], ddpos: Option, expected: Ty<'tcx>, def_bm: BindingMode, @@ -843,7 +855,7 @@ fn check_struct_pat_fields( pat_id: HirId, span: Span, variant: &'tcx ty::VariantDef, - fields: &'tcx [hir::FieldPat], + fields: &'tcx [hir::FieldPat<'tcx>], etc: bool, def_bm: BindingMode, ) -> bool { @@ -1069,7 +1081,7 @@ fn error_unmentioned_fields( fn check_pat_box( &self, span: Span, - inner: &'tcx Pat, + inner: &'tcx Pat<'tcx>, expected: Ty<'tcx>, def_bm: BindingMode, discrim_span: Option, @@ -1094,8 +1106,8 @@ fn check_pat_box( fn check_pat_ref( &self, - pat: &Pat, - inner: &'tcx Pat, + pat: &Pat<'_>, + inner: &'tcx Pat<'tcx>, mutbl: hir::Mutability, expected: Ty<'tcx>, def_bm: BindingMode, @@ -1158,9 +1170,9 @@ fn new_ref_ty(&self, span: Span, mutbl: hir::Mutability, ty: Ty<'tcx>) -> Ty<'tc fn check_pat_slice( &self, span: Span, - before: &'tcx [P], - slice: Option<&'tcx Pat>, - after: &'tcx [P], + before: &'tcx [&'tcx Pat<'tcx>], + slice: Option<&'tcx Pat<'tcx>>, + after: &'tcx [&'tcx Pat<'tcx>], expected: Ty<'tcx>, def_bm: BindingMode, discrim_span: Option, @@ -1208,7 +1220,7 @@ fn check_pat_slice( fn check_array_pat_len( &self, span: Span, - slice: Option<&'tcx Pat>, + slice: Option<&'tcx Pat<'tcx>>, len: &ty::Const<'tcx>, min_len: u64, ) -> Option { diff --git a/src/librustc_typeck/check/regionck.rs b/src/librustc_typeck/check/regionck.rs index 149f27ed305..1ce7748badb 100644 --- a/src/librustc_typeck/check/regionck.rs +++ b/src/librustc_typeck/check/regionck.rs @@ -269,7 +269,7 @@ fn resolve_node_type(&self, id: hir::HirId) -> Ty<'tcx> { } /// Try to resolve the type for the given node. - pub fn resolve_expr_type_adjusted(&mut self, expr: &hir::Expr) -> Ty<'tcx> { + pub fn resolve_expr_type_adjusted(&mut self, expr: &hir::Expr<'_>) -> Ty<'tcx> { let ty = self.tables.borrow().expr_ty_adjusted(expr); self.resolve_type(ty) } @@ -367,7 +367,7 @@ fn resolve_regions_and_report_errors(&self, suppress: SuppressRegionErrors) { ); } - fn constrain_bindings_in_pat(&mut self, pat: &hir::Pat) { + fn constrain_bindings_in_pat(&mut self, pat: &hir::Pat<'_>) { debug!("regionck::visit_pat(pat={:?})", pat); pat.each_binding(|_, hir_id, span, _| { // If we have a variable that contains region'd data, that @@ -453,20 +453,20 @@ fn visit_fn( //visit_pat: visit_pat, // (..) see above - fn visit_arm(&mut self, arm: &'tcx hir::Arm) { + fn visit_arm(&mut self, arm: &'tcx hir::Arm<'tcx>) { // see above self.constrain_bindings_in_pat(&arm.pat); intravisit::walk_arm(self, arm); } - fn visit_local(&mut self, l: &'tcx hir::Local) { + fn visit_local(&mut self, l: &'tcx hir::Local<'tcx>) { // see above self.constrain_bindings_in_pat(&l.pat); self.link_local(l); intravisit::walk_local(self, l); } - fn visit_expr(&mut self, expr: &'tcx hir::Expr) { + fn visit_expr(&mut self, expr: &'tcx hir::Expr<'tcx>) { debug!("regionck::visit_expr(e={:?}, repeating_scope={:?})", expr, self.repeating_scope); // No matter what, the type of each expression must outlive the @@ -580,7 +580,7 @@ fn visit_expr(&mut self, expr: &'tcx hir::Expr) { hir::ExprKind::Unary(hir::UnDeref, ref base) => { // For *a, the lifetime of a must enclose the deref if is_method_call { - self.constrain_call(expr, Some(base), None::.iter()); + self.constrain_call(expr, Some(base), None::>.iter()); } // For overloaded derefs, base_ty is the input to `Deref::deref`, // but it's a reference type uing the same region as the output. @@ -594,7 +594,7 @@ fn visit_expr(&mut self, expr: &'tcx hir::Expr) { hir::ExprKind::Unary(_, ref lhs) if is_method_call => { // As above. - self.constrain_call(expr, Some(&lhs), None::.iter()); + self.constrain_call(expr, Some(&lhs), None::>.iter()); intravisit::walk_expr(self, expr); } @@ -670,7 +670,7 @@ fn visit_expr(&mut self, expr: &'tcx hir::Expr) { } impl<'a, 'tcx> RegionCtxt<'a, 'tcx> { - fn constrain_cast(&mut self, cast_expr: &hir::Expr, source_expr: &hir::Expr) { + fn constrain_cast(&mut self, cast_expr: &hir::Expr<'_>, source_expr: &hir::Expr<'_>) { debug!("constrain_cast(cast_expr={:?}, source_expr={:?})", cast_expr, source_expr); let source_ty = self.resolve_node_type(source_expr.hir_id); @@ -679,7 +679,7 @@ fn constrain_cast(&mut self, cast_expr: &hir::Expr, source_expr: &hir::Expr) { self.walk_cast(cast_expr, source_ty, target_ty); } - fn walk_cast(&mut self, cast_expr: &hir::Expr, from_ty: Ty<'tcx>, to_ty: Ty<'tcx>) { + fn walk_cast(&mut self, cast_expr: &hir::Expr<'_>, from_ty: Ty<'tcx>, to_ty: Ty<'tcx>) { debug!("walk_cast(from_ty={:?}, to_ty={:?})", from_ty, to_ty); match (&from_ty.kind, &to_ty.kind) { /*From:*/ @@ -707,13 +707,13 @@ fn walk_cast(&mut self, cast_expr: &hir::Expr, from_ty: Ty<'tcx>, to_ty: Ty<'tcx } } - fn check_expr_fn_block(&mut self, expr: &'tcx hir::Expr, body_id: hir::BodyId) { + fn check_expr_fn_block(&mut self, expr: &'tcx hir::Expr<'tcx>, body_id: hir::BodyId) { let repeating_scope = self.set_repeating_scope(body_id.hir_id); intravisit::walk_expr(self, expr); self.set_repeating_scope(repeating_scope); } - fn constrain_callee(&mut self, callee_expr: &hir::Expr) { + fn constrain_callee(&mut self, callee_expr: &hir::Expr<'_>) { let callee_ty = self.resolve_node_type(callee_expr.hir_id); match callee_ty.kind { ty::FnDef(..) | ty::FnPtr(_) => {} @@ -729,10 +729,10 @@ fn constrain_callee(&mut self, callee_expr: &hir::Expr) { } } - fn constrain_call<'b, I: Iterator>( + fn constrain_call<'b, I: Iterator>>( &mut self, - call_expr: &hir::Expr, - receiver: Option<&hir::Expr>, + call_expr: &hir::Expr<'_>, + receiver: Option<&hir::Expr<'_>>, arg_exprs: I, ) { //! Invoked on every call site (i.e., normal calls, method calls, @@ -786,7 +786,7 @@ fn with_mc(&self, f: F) -> R /// Invoked on any adjustments that occur. Checks that if this is a region pointer being /// dereferenced, the lifetime of the pointer includes the deref expr. - fn constrain_adjustments(&mut self, expr: &hir::Expr) -> mc::McResult> { + fn constrain_adjustments(&mut self, expr: &hir::Expr<'_>) -> mc::McResult> { debug!("constrain_adjustments(expr={:?})", expr); let mut cmt = self.with_mc(|mc| mc.cat_expr_unadjusted(expr))?; @@ -880,7 +880,7 @@ fn check_safety_of_rvalue_destructor_if_necessary( /// Invoked on any index expression that occurs. Checks that if this is a slice /// being indexed, the lifetime of the pointer includes the deref expr. - fn constrain_index(&mut self, index_expr: &hir::Expr, indexed_ty: Ty<'tcx>) { + fn constrain_index(&mut self, index_expr: &hir::Expr<'_>, indexed_ty: Ty<'tcx>) { debug!("constrain_index(index_expr=?, indexed_ty={}", self.ty_to_string(indexed_ty)); let r_index_expr = ty::ReScope(region::Scope { @@ -952,7 +952,12 @@ pub fn type_must_outlive( /// Computes the guarantor for an expression `&base` and then ensures that the lifetime of the /// resulting pointer is linked to the lifetime of its guarantor (if any). - fn link_addr_of(&mut self, expr: &hir::Expr, mutability: hir::Mutability, base: &hir::Expr) { + fn link_addr_of( + &mut self, + expr: &hir::Expr<'_>, + mutability: hir::Mutability, + base: &hir::Expr<'_>, + ) { debug!("link_addr_of(expr={:?}, base={:?})", expr, base); let cmt = ignore_err!(self.with_mc(|mc| mc.cat_expr(base))); @@ -965,7 +970,7 @@ fn link_addr_of(&mut self, expr: &hir::Expr, mutability: hir::Mutability, base: /// Computes the guarantors for any ref bindings in a `let` and /// then ensures that the lifetime of the resulting pointer is /// linked to the lifetime of the initialization expression. - fn link_local(&self, local: &hir::Local) { + fn link_local(&self, local: &hir::Local<'_>) { debug!("regionck::for_local()"); let init_expr = match local.init { None => { @@ -980,7 +985,7 @@ fn link_local(&self, local: &hir::Local) { /// Computes the guarantors for any ref bindings in a match and /// then ensures that the lifetime of the resulting pointer is /// linked to the lifetime of its guarantor (if any). - fn link_match(&self, discr: &hir::Expr, arms: &[hir::Arm]) { + fn link_match(&self, discr: &hir::Expr<'_>, arms: &[hir::Arm<'_>]) { debug!("regionck::for_match()"); let discr_cmt = ignore_err!(self.with_mc(|mc| mc.cat_expr(discr))); debug!("discr_cmt={:?}", discr_cmt); @@ -992,7 +997,7 @@ fn link_match(&self, discr: &hir::Expr, arms: &[hir::Arm]) { /// Computes the guarantors for any ref bindings in a match and /// then ensures that the lifetime of the resulting pointer is /// linked to the lifetime of its guarantor (if any). - fn link_fn_params(&self, params: &[hir::Param]) { + fn link_fn_params(&self, params: &[hir::Param<'_>]) { for param in params { let param_ty = self.node_ty(param.hir_id); let param_cmt = @@ -1004,7 +1009,7 @@ fn link_fn_params(&self, params: &[hir::Param]) { /// Link lifetimes of any ref bindings in `root_pat` to the pointers found /// in the discriminant, if needed. - fn link_pattern(&self, discr_cmt: mc::Place<'tcx>, root_pat: &hir::Pat) { + fn link_pattern(&self, discr_cmt: mc::Place<'tcx>, root_pat: &hir::Pat<'_>) { debug!("link_pattern(discr_cmt={:?}, root_pat={:?})", discr_cmt, root_pat); ignore_err!(self.with_mc(|mc| { mc.cat_pattern(discr_cmt, root_pat, |sub_cmt, hir::Pat { kind, span, hir_id }| { @@ -1024,7 +1029,7 @@ fn link_pattern(&self, discr_cmt: mc::Place<'tcx>, root_pat: &hir::Pat) { /// autoref'd. fn link_autoref( &self, - expr: &hir::Expr, + expr: &hir::Expr<'_>, expr_cmt: &mc::Place<'tcx>, autoref: &adjustment::AutoBorrow<'tcx>, ) { diff --git a/src/librustc_typeck/check/upvar.rs b/src/librustc_typeck/check/upvar.rs index a7cdbd923ae..bdccced42c4 100644 --- a/src/librustc_typeck/check/upvar.rs +++ b/src/librustc_typeck/check/upvar.rs @@ -63,7 +63,7 @@ fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { NestedVisitorMap::None } - fn visit_expr(&mut self, expr: &'tcx hir::Expr) { + fn visit_expr(&mut self, expr: &'tcx hir::Expr<'tcx>) { if let hir::ExprKind::Closure(cc, _, body_id, _, _) = expr.kind { let body = self.fcx.tcx.hir().body(body_id); self.visit_body(body); diff --git a/src/librustc_typeck/check/writeback.rs b/src/librustc_typeck/check/writeback.rs index 5ef5f4c648e..ca9a4763ed0 100644 --- a/src/librustc_typeck/check/writeback.rs +++ b/src/librustc_typeck/check/writeback.rs @@ -132,7 +132,7 @@ fn write_ty_to_tables(&mut self, hir_id: hir::HirId, ty: Ty<'tcx>) { // as potentially overloaded. But then, during writeback, if // we observe that something like `a+b` is (known to be) // operating on scalars, we clear the overload. - fn fix_scalar_builtin_expr(&mut self, e: &hir::Expr) { + fn fix_scalar_builtin_expr(&mut self, e: &hir::Expr<'_>) { match e.kind { hir::ExprKind::Unary(hir::UnNeg, ref inner) | hir::ExprKind::Unary(hir::UnNot, ref inner) => { @@ -181,7 +181,7 @@ fn fix_scalar_builtin_expr(&mut self, e: &hir::Expr) { // Here, correct cases where an indexing expression can be simplified // to use builtin indexing because the index type is known to be // usize-ish - fn fix_index_builtin_expr(&mut self, e: &hir::Expr) { + fn fix_index_builtin_expr(&mut self, e: &hir::Expr<'_>) { if let hir::ExprKind::Index(ref base, ref index) = e.kind { let mut tables = self.fcx.tables.borrow_mut(); @@ -247,7 +247,7 @@ fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { NestedVisitorMap::None } - fn visit_expr(&mut self, e: &'tcx hir::Expr) { + fn visit_expr(&mut self, e: &'tcx hir::Expr<'tcx>) { self.fix_scalar_builtin_expr(e); self.fix_index_builtin_expr(e); @@ -262,7 +262,7 @@ fn visit_expr(&mut self, e: &'tcx hir::Expr) { self.visit_body(body); } - hir::ExprKind::Struct(_, ref fields, _) => { + hir::ExprKind::Struct(_, fields, _) => { for field in fields { self.visit_field_id(field.hir_id); } @@ -276,12 +276,12 @@ fn visit_expr(&mut self, e: &'tcx hir::Expr) { intravisit::walk_expr(self, e); } - fn visit_block(&mut self, b: &'tcx hir::Block) { + fn visit_block(&mut self, b: &'tcx hir::Block<'tcx>) { self.visit_node_id(b.span, b.hir_id); intravisit::walk_block(self, b); } - fn visit_pat(&mut self, p: &'tcx hir::Pat) { + fn visit_pat(&mut self, p: &'tcx hir::Pat<'tcx>) { match p.kind { hir::PatKind::Binding(..) => { let tables = self.fcx.tables.borrow(); @@ -289,7 +289,7 @@ fn visit_pat(&mut self, p: &'tcx hir::Pat) { self.tables.pat_binding_modes_mut().insert(p.hir_id, bm); } } - hir::PatKind::Struct(_, ref fields, _) => { + hir::PatKind::Struct(_, fields, _) => { for field in fields { self.visit_field_id(field.hir_id); } @@ -303,7 +303,7 @@ fn visit_pat(&mut self, p: &'tcx hir::Pat) { intravisit::walk_pat(self, p); } - fn visit_local(&mut self, l: &'tcx hir::Local) { + fn visit_local(&mut self, l: &'tcx hir::Local<'tcx>) { intravisit::walk_local(self, l); let var_ty = self.fcx.local_ty(l.span, l.hir_id).decl_ty; let var_ty = self.resolve(&var_ty, &l.span); diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index c437f4e78d5..01f11f669f7 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -134,7 +134,7 @@ fn visit_generics(&mut self, generics: &'tcx hir::Generics) { intravisit::walk_generics(self, generics); } - fn visit_expr(&mut self, expr: &'tcx hir::Expr) { + fn visit_expr(&mut self, expr: &'tcx hir::Expr<'tcx>) { if let hir::ExprKind::Closure(..) = expr.kind { let def_id = self.tcx.hir().local_def_id(expr.hir_id); self.tcx.generics_of(def_id); diff --git a/src/librustc_typeck/expr_use_visitor.rs b/src/librustc_typeck/expr_use_visitor.rs index 4215348f24c..b1467d508dc 100644 --- a/src/librustc_typeck/expr_use_visitor.rs +++ b/src/librustc_typeck/expr_use_visitor.rs @@ -10,7 +10,6 @@ use rustc::hir::def::Res; use rustc::hir::def_id::DefId; -use rustc::hir::ptr::P; use rustc::hir::{self, PatKind}; use rustc::infer::InferCtxt; use rustc::ty::{self, adjustment, TyCtxt}; diff --git a/src/librustc_typeck/mem_categorization.rs b/src/librustc_typeck/mem_categorization.rs index 8bca422ca18..4f5b55e4cd6 100644 --- a/src/librustc_typeck/mem_categorization.rs +++ b/src/librustc_typeck/mem_categorization.rs @@ -117,7 +117,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 +126,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 +213,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> { + fn expr_ty(&self, expr: &hir::Expr<'_>) -> McResult> { 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> { + crate fn expr_ty_adjusted(&self, expr: &hir::Expr<'_>) -> McResult> { self.resolve_type_vars_or_error(expr.hir_id, self.tables.expr_ty_adjusted_opt(expr)) } @@ -231,7 +231,7 @@ fn expr_ty(&self, expr: &hir::Expr) -> McResult> { /// implicit deref patterns attached (e.g., it is really /// `&Some(x)`). In that case, we return the "outermost" type /// (e.g., `&Option). - crate fn pat_ty_adjusted(&self, pat: &hir::Pat) -> McResult> { + crate fn pat_ty_adjusted(&self, pat: &hir::Pat<'_>) -> McResult> { // 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 +247,7 @@ fn expr_ty(&self, expr: &hir::Expr) -> McResult> { } /// Like `pat_ty`, but ignores implicit `&` patterns. - fn pat_ty_unadjusted(&self, pat: &hir::Pat) -> McResult> { + fn pat_ty_unadjusted(&self, pat: &hir::Pat<'_>) -> McResult> { let base_ty = self.node_ty(pat.hir_id)?; debug!("pat_ty(pat={:?}) base_ty={:?}", pat, base_ty); @@ -280,12 +280,12 @@ fn pat_ty_unadjusted(&self, pat: &hir::Pat) -> McResult> { Ok(ret_ty) } - crate fn cat_expr(&self, expr: &hir::Expr) -> McResult> { + crate fn cat_expr(&self, expr: &hir::Expr<'_>) -> McResult> { // 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> { match adjustments.split_last() { @@ -301,7 +301,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> { @@ -310,7 +310,7 @@ fn helper<'a, 'tcx>( fn cat_expr_adjusted_with( &self, - expr: &hir::Expr, + expr: &hir::Expr<'_>, previous: F, adjustment: &adjustment::Adjustment<'tcx>, ) -> McResult> @@ -342,7 +342,7 @@ fn cat_expr_adjusted_with( } } - crate fn cat_expr_unadjusted(&self, expr: &hir::Expr) -> McResult> { + crate fn cat_expr_unadjusted(&self, expr: &hir::Expr<'_>) -> McResult> { debug!("cat_expr: id={} expr={:?}", expr.hir_id, expr); let expr_ty = self.expr_ty(expr)?; @@ -513,7 +513,11 @@ fn cat_upvar( ret } - fn cat_overloaded_place(&self, expr: &hir::Expr, base: &hir::Expr) -> McResult> { + fn cat_overloaded_place( + &self, + expr: &hir::Expr<'_>, + base: &hir::Expr<'_>, + ) -> McResult> { debug!("cat_overloaded_place(expr={:?}, base={:?})", expr, base); // Reconstruct the output assuming it's a reference with the @@ -557,17 +561,27 @@ fn cat_deref(&self, node: &impl HirNode, base_place: Place<'tcx>) -> McResult(&self, place: Place<'tcx>, pat: &hir::Pat, mut op: F) -> McResult<()> + crate fn cat_pattern( + &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_(&self, mut place: Place<'tcx>, pat: &hir::Pat, op: &mut F) -> McResult<()> + fn cat_pattern_( + &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 +652,7 @@ fn cat_pattern_(&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 +661,7 @@ fn cat_pattern_(&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 +679,7 @@ fn cat_pattern_(&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 => {