Fallout in other crates.

This commit is contained in:
Camille GILLOT 2019-11-30 15:08:22 +01:00
parent 58b908d09c
commit 8284035372
44 changed files with 491 additions and 413 deletions

View File

@ -25,7 +25,7 @@ declare_lint_pass!(
);
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 {

View File

@ -142,7 +142,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BoxPointers {
}
}
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 @@ declare_lint! {
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 @@ declare_lint! {
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 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MutableTransmutes {
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 @@ declare_lint! {
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 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InvalidValue {
type InitError = (String, Option<Span>);
/// 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 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InvalidValue {
}
/// Determine if this expression is a "dangerous initialization".
fn is_dangerous_init(cx: &LateContext<'_, '_>, expr: &hir::Expr) -> Option<InitKind> {
fn is_dangerous_init(cx: &LateContext<'_, '_>, expr: &hir::Expr<'_>) -> Option<InitKind> {
// `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

View File

@ -344,7 +344,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonSnakeCase {
}
}
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 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonUpperCaseGlobals {
}
}
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 {

View File

@ -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<String>
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 @@ fn get_type_suggestion(t: Ty<'_>, val: u128, negative: bool) -> Option<&'static
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 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits {
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),

View File

@ -37,7 +37,7 @@ declare_lint! {
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 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults {
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 @@ declare_lint! {
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 @@ declare_lint! {
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,

View File

@ -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 @@ impl EncodeContext<'tcx> {
}
}
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);

View File

@ -11,7 +11,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
&mut self,
destination: &Place<'tcx>,
block: BasicBlock,
ast_block: &'tcx hir::Block,
ast_block: &'tcx hir::Block<'tcx>,
source_info: SourceInfo,
) -> BlockAnd<()> {
let Block {

View File

@ -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<Span>, Option<&'tcx hir::Param>, Option<ImplicitSelfKind>);
struct ArgInfo<'tcx>(
Ty<'tcx>,
Option<Span>,
Option<&'tcx hir::Param<'tcx>>,
Option<ImplicitSelfKind>,
);
fn construct_fn<'a, 'tcx, A>(
hir: Cx<'a, 'tcx>,
@ -738,7 +745,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
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() {

View File

@ -8,7 +8,7 @@ use rustc::ty;
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 @@ impl<'tcx> Mirror<'tcx> for &'tcx hir::Block {
fn mirror_stmts<'a, 'tcx>(
cx: &mut Cx<'a, 'tcx>,
block_id: hir::ItemLocalId,
stmts: &'tcx [hir::Stmt],
stmts: &'tcx [hir::Stmt<'tcx>],
) -> Vec<StmtRef<'tcx>> {
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 {

View File

@ -14,7 +14,7 @@ use rustc::ty::{self, AdtKind, Ty};
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 @@ impl<'tcx> Mirror<'tcx> for &'tcx hir::Expr {
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 @@ impl ToBorrowKind for hir::Mutability {
}
}
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<ExprRef<'tcx>>,
) -> 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<ExprRef<'tcx>>,
@ -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<FieldExprRef<'tcx>> {
fields
.iter()

View File

@ -151,7 +151,7 @@ impl<'a, 'tcx> Cx<'a, 'tcx> {
}
}
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),

View File

@ -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 @@ impl<'tcx> ToRef for &'tcx hir::Expr {
}
}
impl<'tcx> ToRef for &'tcx P<hir::Expr> {
impl<'tcx> ToRef for &'tcx &'tcx hir::Expr<'tcx> {
type Output = ExprRef<'tcx>;
fn to_ref(self) -> ExprRef<'tcx> {
@ -54,7 +53,7 @@ where
}
}
impl<'tcx, T, U> ToRef for &'tcx P<[T]>
impl<'tcx, T, U> ToRef for &'tcx [T]
where
&'tcx T: ToRef<Output = U>,
{

View File

@ -184,7 +184,7 @@ pub enum ExprKind<'tcx> {
arms: Vec<Arm<'tcx>>,
},
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<Expr<'tcx>>),
}

View File

@ -53,7 +53,7 @@ impl<'tcx> Visitor<'tcx> for MatchVisitor<'_, '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 @@ impl<'tcx> Visitor<'tcx> for MatchVisitor<'_, 'tcx> {
}
}
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 @@ impl PatCtxt<'_, '_> {
}
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 @@ impl<'tcx> MatchVisitor<'_, 'tcx> {
}
}
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 @@ impl<'tcx> MatchVisitor<'_, 'tcx> {
})
}
fn check_irrefutable(&self, pat: &'tcx Pat, origin: &str, sp: Option<Span>) {
fn check_irrefutable(&self, pat: &'tcx Pat<'tcx>, origin: &str, sp: Option<Span>) {
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 @@ impl<'tcx> MatchVisitor<'_, 'tcx> {
/// 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<Span>
}
/// 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 check_legality_of_bindings_in_at_patterns(cx: &MatchVisitor<'_, '_>, pat: &Pa
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 {

View File

@ -11,7 +11,6 @@ use crate::hair::util::UserAnnotatedTyHelpers;
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 @@ impl<'a, 'tcx> Pat<'tcx> {
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 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
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 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
fn lower_range_expr(
&mut self,
expr: &'tcx hir::Expr,
expr: &'tcx hir::Expr<'tcx>,
) -> (PatKind<'tcx>, Option<Ascription<'tcx>>) {
match self.lower_lit(expr) {
PatKind::AscribeUserType {
@ -437,7 +436,7 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
}
}
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 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
fn lower_tuple_subpats(
&mut self,
pats: &'tcx [P<hir::Pat>],
pats: &'tcx [&'tcx hir::Pat<'tcx>],
expected_len: usize,
gap_pos: Option<usize>,
) -> Vec<FieldPat<'tcx>> {
@ -629,11 +628,11 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
.collect()
}
fn lower_patterns(&mut self, pats: &'tcx [P<hir::Pat>]) -> Vec<Pat<'tcx>> {
fn lower_patterns(&mut self, pats: &'tcx [&'tcx hir::Pat<'tcx>]) -> Vec<Pat<'tcx>> {
pats.iter().map(|p| self.lower_pattern(p)).collect()
}
fn lower_opt_pattern(&mut self, pat: &'tcx Option<P<hir::Pat>>) -> Option<Pat<'tcx>> {
fn lower_opt_pattern(&mut self, pat: &'tcx Option<&'tcx hir::Pat<'tcx>>) -> Option<Pat<'tcx>> {
pat.as_ref().map(|p| self.lower_pattern(p))
}
@ -641,9 +640,9 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
&mut self,
span: Span,
ty: Ty<'tcx>,
prefix: &'tcx [P<hir::Pat>],
slice: &'tcx Option<P<hir::Pat>>,
suffix: &'tcx [P<hir::Pat>],
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 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
/// 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);

View File

@ -479,7 +479,7 @@ impl<'a, 'tcx> hir::intravisit::Visitor<'tcx> for UnusedUnsafeVisitor<'a> {
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 {

View File

@ -214,7 +214,7 @@ impl<'tcx> Visitor<'tcx> for CheckConstVisitor<'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 @@ impl<'tcx> Visitor<'tcx> for CheckConstVisitor<'tcx> {
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() => {}

View File

@ -115,7 +115,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
}
}
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 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
}
}
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 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
self.inherited_pub_visibility = had_inherited_pub_visibility;
}
fn mark_as_used_if_union(&mut self, adt: &ty::AdtDef, fields: &hir::HirVec<hir::Field>) {
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 @@ impl<'a, 'tcx> Visitor<'tcx> for MarkSymbolVisitor<'a, 'tcx> {
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 @@ impl<'a, 'tcx> Visitor<'tcx> for MarkSymbolVisitor<'a, 'tcx> {
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 @@ impl<'a, 'tcx> Visitor<'tcx> for MarkSymbolVisitor<'a, 'tcx> {
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);

View File

@ -86,7 +86,7 @@ impl<'k> StatCollector<'k> {
}
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 @@ impl<'v> hir_visit::Visitor<'v> for StatCollector<'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)
}

View File

@ -142,7 +142,7 @@ impl Visitor<'tcx> for ExprVisitor<'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 {

View File

@ -100,7 +100,6 @@ use rustc::hir;
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 @@ impl<'tcx> Visitor<'tcx> for IrMaps<'tcx> {
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<hir::Pat>) {
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<hir::Pat>) {
});
}
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 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
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 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
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 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
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 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
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 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
}
}
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 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
// 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 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
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 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
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 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
}
}
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 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
}
// 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 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
fn propagate_through_loop(
&mut self,
expr: &Expr,
body: &hir::Block,
expr: &Expr<'_>,
body: &hir::Block<'_>,
succ: LiveNode,
) -> LiveNode {
/*
@ -1351,7 +1354,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Liveness<'a, '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 @@ impl<'a, 'tcx> Visitor<'tcx> for Liveness<'a, 'tcx> {
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 @@ impl<'tcx> Liveness<'_, 'tcx> {
fn check_unused_vars_in_pat(
&self,
pat: &hir::Pat,
pat: &hir::Pat<'_>,
entry_ln: Option<LiveNode>,
on_used_on_entry: impl Fn(Vec<Span>, HirId, LiveNode, Variable),
) {

View File

@ -52,7 +52,7 @@ impl<'a, 'hir> Visitor<'hir> for CheckLoopVisitor<'a, 'hir> {
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));

View File

@ -883,7 +883,7 @@ impl Visitor<'tcx> for EmbargoVisitor<'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 @@ impl<'a, 'tcx> Visitor<'tcx> for NamePrivacyVisitor<'a, '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 @@ impl<'a, 'tcx> Visitor<'tcx> for NamePrivacyVisitor<'a, 'tcx> {
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 @@ impl<'a, 'tcx> Visitor<'tcx> for TypePrivacyVisitor<'a, 'tcx> {
}
// 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 @@ impl<'a, 'tcx> Visitor<'tcx> for TypePrivacyVisitor<'a, 'tcx> {
}
// 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 @@ impl<'a, 'tcx> Visitor<'tcx> for TypePrivacyVisitor<'a, 'tcx> {
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 @@ impl<'a, 'b, 'tcx, 'v> Visitor<'v> for ObsoleteCheckTypeForPrivatenessVisitor<'a
}
// 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 @@ impl<'a, 'tcx> Visitor<'tcx> for ObsoleteVisiblePrivateTypesVisitor<'a, '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>) {}
}
///////////////////////////////////////////////////////////////////////////////

View File

@ -2648,7 +2648,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
}
/// 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<DefId> {
pub fn const_param_def_id(&self, expr: &hir::Expr<'_>) -> Option<DefId> {
// 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 {

View File

@ -10,9 +10,9 @@ use syntax_pos::Span;
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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
/// 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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
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

View File

@ -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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
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<CallStep<'tcx>> {
let adjusted_ty = autoderef.unambiguous_final_ty(self);
@ -166,9 +166,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
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<Adjustment<'tcx>>, 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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
&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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
#[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<Adjustment<'tcx>>,
fn_sig: ty::FnSig<'tcx>,

View File

@ -51,7 +51,7 @@ use rustc_error_codes::*;
/// 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,

View File

@ -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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
fn check_closure(
&self,
expr: &hir::Expr,
expr: &hir::Expr<'_>,
opt_kind: Option<ty::ClosureKind>,
decl: &'tcx hir::FnDecl,
body: &'tcx hir::Body<'tcx>,

View File

@ -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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
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<hir::Expr>>;
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 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
&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 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
&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 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
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 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
/// 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<hir::Expr> {
fn as_coercion_site(&self) -> &hir::Expr {
impl AsCoercionSite for P<hir::Expr<'_>> {
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
}
}

View File

@ -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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// 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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
(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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
/// 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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
/// ```
/// 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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
/// `&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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
})) = 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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
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 {

View File

@ -21,7 +21,6 @@ use errors::{pluralize, Applicability, DiagnosticBuilder, DiagnosticId};
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 rustc_error_codes::*;
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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
/// 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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
}
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 @@ impl<'a, 'tcx> FnCtxt<'a, '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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
&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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
/// * 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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
}
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 @@ impl<'a, 'tcx> FnCtxt<'a, '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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
);
}
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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
/// 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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
/// 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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
&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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
fn check_expr_struct(
&self,
expr: &hir::Expr,
expr: &hir::Expr<'_>,
expected: Expectation<'tcx>,
qpath: &QPath,
fields: &'tcx [hir::Field],
base_expr: &'tcx Option<P<hir::Expr>>,
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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
fn check_struct_fields_on_error(
&self,
fields: &'tcx [hir::Field],
base_expr: &'tcx Option<P<hir::Expr>>,
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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
&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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// 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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
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 {

View File

@ -27,7 +27,7 @@ impl<'a, 'tcx> InteriorVisitor<'a, 'tcx> {
&mut self,
ty: Ty<'tcx>,
scope: Option<region::Scope>,
expr: Option<&'tcx Expr>,
expr: Option<&'tcx Expr<'tcx>>,
source_span: Span,
) {
use syntax_pos::DUMMY_SP;
@ -196,7 +196,7 @@ impl<'a, 'tcx> Visitor<'tcx> for InteriorVisitor<'a, '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 @@ impl<'a, 'tcx> Visitor<'tcx> for InteriorVisitor<'a, 'tcx> {
}
}
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 @@ impl<'a, 'tcx> Visitor<'tcx> for InteriorVisitor<'a, 'tcx> {
self.expr_count += 1;
// Record the rest of the call expression normally.
for arg in args {
for arg in *args {
self.visit_expr(arg);
}
}

View File

@ -19,8 +19,8 @@ use std::ops::Deref;
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 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {
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);

View File

@ -180,8 +180,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
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<MethodCallee<'tcx>, MethodError<'tcx>> {
debug!(
"lookup(method_name={}, self_ty={:?}, call_expr={:?}, self_expr={:?})",
@ -260,7 +260,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
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;

View File

@ -72,7 +72,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
item_name: ast::Ident,
source: SelfSource<'b>,
error: MethodError<'tcx>,
args: Option<&'tcx [hir::Expr]>,
args: Option<&'tcx [hir::Expr<'tcx>]>,
) -> Option<DiagnosticBuilder<'_>> {
let orig_span = span;
let mut span = span;
@ -954,7 +954,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
#[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 @@ impl hir::intravisit::Visitor<'tcx> for UsePlacementFinder<'tcx> {
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<'_>,

View File

@ -95,7 +95,6 @@ use rustc::hir::def::{CtorOf, DefKind, Res};
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 @@ impl 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 @@ impl<'a, 'tcx> Visitor<'tcx> for GatherLocalsVisitor<'a, '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 @@ impl<'a, 'tcx> Visitor<'tcx> for GatherLocalsVisitor<'a, 'tcx> {
}
// 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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
}
pub fn apply_adjustments(&self, expr: &hir::Expr, adj: Vec<Adjustment<'tcx>>) {
pub fn apply_adjustments(&self, expr: &hir::Expr<'_>, adj: Vec<Adjustment<'tcx>>) {
debug!("apply_adjustments(expr={:?}, adj={:?})", expr, adj);
if adj.is_empty() {
@ -3181,7 +3180,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
/// 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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
/// 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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
fn check_method_argument_types(
&self,
sp: Span,
expr: &'tcx hir::Expr,
expr: &'tcx hir::Expr<'tcx>,
method: Result<MethodCallee<'tcx>, ()>,
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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
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<Span>,
@ -3897,7 +3896,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
errors: &mut Vec<traits::FulfillmentError<'_>>,
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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
fn point_at_type_arg_instead_of_call_if_possible(
&self,
errors: &mut Vec<traits::FulfillmentError<'_>>,
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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
}
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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
);
}
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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
/// 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<Span> = arms
.iter()
@ -4396,7 +4400,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let coerce = if blk.targeted_by_break {
CoerceMany::new(coerce_to_ty)
} else {
let tail_expr: &[P<hir::Expr>] = match tail_expr {
let tail_expr: &[&hir::Expr<'_>] = match tail_expr {
Some(e) => slice::from_ref(e),
None => &[],
};
@ -4437,7 +4441,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
fn suggest_missing_await(
&self,
err: &mut DiagnosticBuilder<'_>,
expr: &hir::Expr,
expr: &hir::Expr<'_>,
expected: Ty<'tcx>,
found: Ty<'tcx>,
) {
@ -5033,7 +5037,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
/// 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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
}
fn could_remove_semicolon(&self, blk: &'tcx hir::Block, expected_ty: Ty<'tcx>) -> Option<Span> {
fn could_remove_semicolon(
&self,
blk: &'tcx hir::Block<'tcx>,
expected_ty: Ty<'tcx>,
) -> Option<Span> {
// Be helpful when the user wrote `{... expr;}` and
// taking the `;` off is enough to fix the error.
let last_stmt = blk.stmts.last()?;

View File

@ -17,10 +17,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
/// Checks a `a <op>= 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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
/// 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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
/// 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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
pub fn check_user_unop(
&self,
ex: &'tcx hir::Expr,
ex: &'tcx hir::Expr<'tcx>,
operand_ty: Ty<'tcx>,
op: hir::UnOp,
) -> Ty<'tcx> {

View File

@ -3,7 +3,6 @@ use crate::util::nodemap::FxHashMap;
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 @@ You can read more about trait objects in the Trait Objects section of the Refere
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<Span>) {
pub fn check_pat_top(
&self,
pat: &'tcx Pat<'tcx>,
expected: Ty<'tcx>,
discrim_span: Option<Span>,
) {
let def_bm = BindingMode::BindByValue(hir::Mutability::Not);
self.check_pat(pat, expected, def_bm, discrim_span);
}
@ -54,7 +58,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
/// ```
fn check_pat(
&self,
pat: &'tcx Pat,
pat: &'tcx Pat<'tcx>,
expected: Ty<'tcx>,
def_bm: BindingMode,
discrim_span: Option<Span>,
@ -97,13 +101,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
/// 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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
/// 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<Res>) -> bool {
fn is_non_ref_pat(&self, pat: &'tcx Pat<'tcx>, opt_path_res: Option<Res>) -> bool {
match pat.kind {
PatKind::Struct(..)
| PatKind::TupleStruct(..)
@ -242,7 +254,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
/// 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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
fn check_pat_lit(
&self,
span: Span,
lt: &hir::Expr,
lt: &hir::Expr<'tcx>,
expected: Ty<'tcx>,
discrim_span: Option<Span>,
) -> Ty<'tcx> {
@ -341,8 +353,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
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<Span>,
) -> Option<Ty<'tcx>> {
@ -422,10 +434,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
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<Span>,
@ -477,8 +489,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
}
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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
fn check_pat_path(
&self,
pat: &Pat,
pat: &Pat<'_>,
path_resolution: (Res, Option<Ty<'tcx>>, &'b [hir::PathSegment]),
qpath: &hir::QPath,
expected: Ty<'tcx>,
@ -609,9 +621,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
fn check_pat_tuple_struct(
&self,
pat: &Pat,
pat: &Pat<'_>,
qpath: &hir::QPath,
subpats: &'tcx [P<Pat>],
subpats: &'tcx [&'tcx Pat<'tcx>],
ddpos: Option<usize>,
expected: Ty<'tcx>,
def_bm: BindingMode,
@ -713,7 +725,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
pat_span: Span,
res: Res,
qpath: &hir::QPath,
subpats: &'tcx [P<Pat>],
subpats: &'tcx [&'tcx Pat<'tcx>],
fields: &'tcx [ty::FieldDef],
expected: Ty<'tcx>,
had_err: bool,
@ -795,7 +807,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
fn check_pat_tuple(
&self,
span: Span,
elements: &'tcx [P<Pat>],
elements: &'tcx [&'tcx Pat<'tcx>],
ddpos: Option<usize>,
expected: Ty<'tcx>,
def_bm: BindingMode,
@ -843,7 +855,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
fn check_pat_box(
&self,
span: Span,
inner: &'tcx Pat,
inner: &'tcx Pat<'tcx>,
expected: Ty<'tcx>,
def_bm: BindingMode,
discrim_span: Option<Span>,
@ -1094,8 +1106,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
fn check_pat_slice(
&self,
span: Span,
before: &'tcx [P<Pat>],
slice: Option<&'tcx Pat>,
after: &'tcx [P<Pat>],
before: &'tcx [&'tcx Pat<'tcx>],
slice: Option<&'tcx Pat<'tcx>>,
after: &'tcx [&'tcx Pat<'tcx>],
expected: Ty<'tcx>,
def_bm: BindingMode,
discrim_span: Option<Span>,
@ -1208,7 +1220,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
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<u64> {

View File

@ -269,7 +269,7 @@ impl<'a, 'tcx> RegionCtxt<'a, '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 @@ impl<'a, 'tcx> RegionCtxt<'a, 'tcx> {
);
}
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 @@ impl<'a, 'tcx> Visitor<'tcx> for RegionCtxt<'a, 'tcx> {
//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 @@ impl<'a, 'tcx> Visitor<'tcx> for RegionCtxt<'a, 'tcx> {
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::<hir::Expr>.iter());
self.constrain_call(expr, Some(base), None::<hir::Expr<'_>>.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 @@ impl<'a, 'tcx> Visitor<'tcx> for RegionCtxt<'a, 'tcx> {
hir::ExprKind::Unary(_, ref lhs) if is_method_call => {
// As above.
self.constrain_call(expr, Some(&lhs), None::<hir::Expr>.iter());
self.constrain_call(expr, Some(&lhs), None::<hir::Expr<'_>>.iter());
intravisit::walk_expr(self, expr);
}
@ -670,7 +670,7 @@ impl<'a, 'tcx> Visitor<'tcx> for RegionCtxt<'a, 'tcx> {
}
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 @@ impl<'a, 'tcx> RegionCtxt<'a, 'tcx> {
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 @@ impl<'a, 'tcx> RegionCtxt<'a, '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 @@ impl<'a, 'tcx> RegionCtxt<'a, 'tcx> {
}
}
fn constrain_call<'b, I: Iterator<Item = &'b hir::Expr>>(
fn constrain_call<'b, I: Iterator<Item = &'b hir::Expr<'b>>>(
&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 @@ impl<'a, 'tcx> RegionCtxt<'a, 'tcx> {
/// 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<mc::Place<'tcx>> {
fn constrain_adjustments(&mut self, expr: &hir::Expr<'_>) -> mc::McResult<mc::Place<'tcx>> {
debug!("constrain_adjustments(expr={:?})", expr);
let mut cmt = self.with_mc(|mc| mc.cat_expr_unadjusted(expr))?;
@ -880,7 +880,7 @@ impl<'a, 'tcx> RegionCtxt<'a, 'tcx> {
/// 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 @@ impl<'a, 'tcx> RegionCtxt<'a, 'tcx> {
/// 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 @@ impl<'a, 'tcx> RegionCtxt<'a, 'tcx> {
/// 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 @@ impl<'a, 'tcx> RegionCtxt<'a, 'tcx> {
/// 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 @@ impl<'a, 'tcx> RegionCtxt<'a, 'tcx> {
/// 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 @@ impl<'a, 'tcx> RegionCtxt<'a, 'tcx> {
/// 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 @@ impl<'a, 'tcx> RegionCtxt<'a, 'tcx> {
/// autoref'd.
fn link_autoref(
&self,
expr: &hir::Expr,
expr: &hir::Expr<'_>,
expr_cmt: &mc::Place<'tcx>,
autoref: &adjustment::AutoBorrow<'tcx>,
) {

View File

@ -63,7 +63,7 @@ impl<'a, 'tcx> Visitor<'tcx> for InferBorrowKindVisitor<'a, '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);

View File

@ -132,7 +132,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, '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 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
// 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 @@ impl<'cx, 'tcx> Visitor<'tcx> for WritebackCx<'cx, '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 @@ impl<'cx, 'tcx> Visitor<'tcx> for WritebackCx<'cx, 'tcx> {
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 @@ impl<'cx, 'tcx> Visitor<'tcx> for WritebackCx<'cx, 'tcx> {
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 @@ impl<'cx, 'tcx> Visitor<'tcx> for WritebackCx<'cx, 'tcx> {
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 @@ impl<'cx, 'tcx> Visitor<'tcx> for WritebackCx<'cx, 'tcx> {
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);

View File

@ -134,7 +134,7 @@ impl Visitor<'tcx> for CollectItemTypesVisitor<'tcx> {
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);

View File

@ -10,7 +10,6 @@ pub use mc::{Place, PlaceBase, Projection};
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};

View File

@ -117,7 +117,7 @@ crate trait HirNode {
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 @@ impl HirNode for hir::Expr {
}
}
impl HirNode for hir::Pat {
impl HirNode for hir::Pat<'_> {
fn hir_id(&self) -> hir::HirId {
self.hir_id
}
@ -213,11 +213,11 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
self.resolve_type_vars_or_error(hir_id, self.tables.node_type_opt(hir_id))
}
fn expr_ty(&self, expr: &hir::Expr) -> McResult<Ty<'tcx>> {
fn expr_ty(&self, expr: &hir::Expr<'_>) -> McResult<Ty<'tcx>> {
self.resolve_type_vars_or_error(expr.hir_id, self.tables.expr_ty_opt(expr))
}
crate fn expr_ty_adjusted(&self, expr: &hir::Expr) -> McResult<Ty<'tcx>> {
crate fn expr_ty_adjusted(&self, expr: &hir::Expr<'_>) -> McResult<Ty<'tcx>> {
self.resolve_type_vars_or_error(expr.hir_id, self.tables.expr_ty_adjusted_opt(expr))
}
@ -231,7 +231,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
/// implicit deref patterns attached (e.g., it is really
/// `&Some(x)`). In that case, we return the "outermost" type
/// (e.g., `&Option<T>).
crate fn pat_ty_adjusted(&self, pat: &hir::Pat) -> McResult<Ty<'tcx>> {
crate fn pat_ty_adjusted(&self, pat: &hir::Pat<'_>) -> McResult<Ty<'tcx>> {
// Check for implicit `&` types wrapping the pattern; note
// that these are never attached to binding patterns, so
// actually this is somewhat "disjoint" from the code below
@ -247,7 +247,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
}
/// Like `pat_ty`, but ignores implicit `&` patterns.
fn pat_ty_unadjusted(&self, pat: &hir::Pat) -> McResult<Ty<'tcx>> {
fn pat_ty_unadjusted(&self, pat: &hir::Pat<'_>) -> McResult<Ty<'tcx>> {
let base_ty = self.node_ty(pat.hir_id)?;
debug!("pat_ty(pat={:?}) base_ty={:?}", pat, base_ty);
@ -280,12 +280,12 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
Ok(ret_ty)
}
crate fn cat_expr(&self, expr: &hir::Expr) -> McResult<Place<'tcx>> {
crate fn cat_expr(&self, expr: &hir::Expr<'_>) -> McResult<Place<'tcx>> {
// This recursion helper avoids going through *too many*
// adjustments, since *only* non-overloaded deref recurses.
fn helper<'a, 'tcx>(
mc: &MemCategorizationContext<'a, 'tcx>,
expr: &hir::Expr,
expr: &hir::Expr<'_>,
adjustments: &[adjustment::Adjustment<'tcx>],
) -> McResult<Place<'tcx>> {
match adjustments.split_last() {
@ -301,7 +301,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
crate fn cat_expr_adjusted(
&self,
expr: &hir::Expr,
expr: &hir::Expr<'_>,
previous: Place<'tcx>,
adjustment: &adjustment::Adjustment<'tcx>,
) -> McResult<Place<'tcx>> {
@ -310,7 +310,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
fn cat_expr_adjusted_with<F>(
&self,
expr: &hir::Expr,
expr: &hir::Expr<'_>,
previous: F,
adjustment: &adjustment::Adjustment<'tcx>,
) -> McResult<Place<'tcx>>
@ -342,7 +342,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
}
}
crate fn cat_expr_unadjusted(&self, expr: &hir::Expr) -> McResult<Place<'tcx>> {
crate fn cat_expr_unadjusted(&self, expr: &hir::Expr<'_>) -> McResult<Place<'tcx>> {
debug!("cat_expr: id={} expr={:?}", expr.hir_id, expr);
let expr_ty = self.expr_ty(expr)?;
@ -513,7 +513,11 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
ret
}
fn cat_overloaded_place(&self, expr: &hir::Expr, base: &hir::Expr) -> McResult<Place<'tcx>> {
fn cat_overloaded_place(
&self,
expr: &hir::Expr<'_>,
base: &hir::Expr<'_>,
) -> McResult<Place<'tcx>> {
debug!("cat_overloaded_place(expr={:?}, base={:?})", expr, base);
// Reconstruct the output assuming it's a reference with the
@ -557,17 +561,27 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
Ok(ret)
}
crate fn cat_pattern<F>(&self, place: Place<'tcx>, pat: &hir::Pat, mut op: F) -> McResult<()>
crate fn cat_pattern<F>(
&self,
place: Place<'tcx>,
pat: &hir::Pat<'_>,
mut op: F,
) -> McResult<()>
where
F: FnMut(&Place<'tcx>, &hir::Pat),
F: FnMut(&Place<'tcx>, &hir::Pat<'_>),
{
self.cat_pattern_(place, pat, &mut op)
}
// FIXME(#19596) This is a workaround, but there should be a better way to do this
fn cat_pattern_<F>(&self, mut place: Place<'tcx>, pat: &hir::Pat, op: &mut F) -> McResult<()>
fn cat_pattern_<F>(
&self,
mut place: Place<'tcx>,
pat: &hir::Pat<'_>,
op: &mut F,
) -> McResult<()>
where
F: FnMut(&Place<'tcx>, &hir::Pat),
F: FnMut(&Place<'tcx>, &hir::Pat<'_>),
{
// Here, `place` is the `Place` being matched and pat is the pattern it
// is being matched against.
@ -638,7 +652,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
}
}
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 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
}
}
PatKind::Or(ref pats) => {
PatKind::Or(pats) => {
for pat in pats {
self.cat_pattern_(place.clone(), &pat, op)?;
}
@ -665,7 +679,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
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 => {