);
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 {
}
}
- 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);
}
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)
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, \
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)
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,
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 {
}
/// 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
}
}
- 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);
}
}
}
- 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 {
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,
fn report_bin_hex_error(
cx: &LateContext<'_, '_>,
- expr: &hir::Expr,
+ expr: &hir::Expr<'_>,
ty: attr::IntType,
repr_str: String,
val: u128,
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,
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,
) {
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 {
}
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
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),
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,
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,
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");
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,
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);
}
}
}
- 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);
&mut self,
destination: &Place<'tcx>,
block: BasicBlock,
- ast_block: &'tcx hir::Block,
+ ast_block: &'tcx hir::Block<'tcx>,
source_info: SourceInfo,
) -> BlockAnd<()> {
let Block {
// 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),
..
})
///////////////////////////////////////////////////////////////////////////
/// 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>,
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() {
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> {
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() {
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 {
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> {
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> {
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);
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> {
}
}
-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 {
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);
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
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);
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>>,
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> {
/// 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()
}
}
- 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),
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> {
}
}
-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> {
}
}
-impl<'tcx, T, U> ToRef for &'tcx P<[T]>
+impl<'tcx, T, U> ToRef for &'tcx [T]
where
&'tcx T: ToRef<Output = U>,
{
arms: Vec<Arm<'tcx>>,
},
Block {
- body: &'tcx hir::Block,
+ body: &'tcx hir::Block<'tcx>,
},
Assign {
lhs: ExprRef<'tcx>,
#[derive(Clone, Debug)]
pub enum ExprRef<'tcx> {
- Hair(&'tcx hir::Expr),
+ Hair(&'tcx hir::Expr<'tcx>),
Mirror(Box<Expr<'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 {
}
}
- 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 {
}
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 {
}
}
- 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);
})
}
- 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 =
/// 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,
}
}
-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)) =
}
/// 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),
/// 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();
}
/// 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;
// 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.
/// - `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.
/// 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> {
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 {
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;
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);
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:
//
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 {
}
}
- 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 {
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>> {
.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))
}
&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);
/// 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);
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 {
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);
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() => {}
}
}
- 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);
}
}
- 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"),
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);
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);
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.
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);
}
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)
}
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)
}
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 {
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;
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);
}
}
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();
});
}
-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)) => {
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.
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)
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);
}
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
}
}
- 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 {
// 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)
// |
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);
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()
}
}
- 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
}
// 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)
fn propagate_through_loop(
&mut self,
- expr: &Expr,
- body: &hir::Block,
+ expr: &Expr<'_>,
+ body: &hir::Block<'_>,
succ: LiveNode,
) -> LiveNode {
/*
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);
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);
}
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);
}
}
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 {
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),
) {
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));
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.
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);
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);
}
// 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;
}
// 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;
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`.
}
// 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> {
// 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>) {}
}
///////////////////////////////////////////////////////////////////////////////
}
/// 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 {
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> {
/// 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 {
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)
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> {
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
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);
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);
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 &[
&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);
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 {
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> {
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> {
#[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>,
/// 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,
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,
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,
fn check_closure(
&self,
- expr: &hir::Expr,
+ expr: &hir::Expr<'_>,
opt_kind: Option<ty::ClosureKind>,
decl: &'tcx hir::FnDecl,
body: &'tcx hir::Body<'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,
cause: &ObligationCause<'tcx>,
exprs: &[E],
prev_ty: Ty<'tcx>,
- new: &hir::Expr,
+ new: &hir::Expr<'_>,
new_ty: Ty<'tcx>,
) -> RelateResult<'tcx, Ty<'tcx>>
where
/// 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]),
}
&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)
&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,
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);
/// 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
}
}
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
}
}
pub fn emit_coerce_suggestions(
&self,
err: &mut DiagnosticBuilder<'_>,
- expr: &hir::Expr,
+ expr: &hir::Expr<'_>,
expr_ty: Ty<'tcx>,
expected: Ty<'tcx>,
) {
pub fn demand_coerce(
&self,
- expr: &hir::Expr,
+ expr: &hir::Expr<'_>,
checked_ty: Ty<'tcx>,
expected: Ty<'tcx>,
allow_two_phase: AllowTwoPhase,
// 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,
(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)
}
/// 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;
}
fn suggest_compatible_variants(
&self,
err: &mut DiagnosticBuilder<'_>,
- expr: &hir::Expr,
+ expr: &hir::Expr<'_>,
expected: Ty<'tcx>,
expr_ty: Ty<'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,
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;
}
/// `&mut`!".
pub fn check_ref(
&self,
- expr: &hir::Expr,
+ expr: &hir::Expr<'_>,
checked_ty: Ty<'tcx>,
expected: Ty<'tcx>,
) -> Option<(Span, &'static str, String)> {
pub fn check_for_cast(
&self,
err: &mut DiagnosticBuilder<'_>,
- expr: &hir::Expr,
+ expr: &hir::Expr<'_>,
checked_ty: Ty<'tcx>,
expected_ty: Ty<'tcx>,
) -> bool {
})) = 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);
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 {
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};
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> {
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> {
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);
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))
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)
}
/// 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> {
fn check_expr_kind(
&self,
- expr: &'tcx hir::Expr,
+ expr: &'tcx hir::Expr<'tcx>,
expected: Expectation<'tcx>,
needs: Needs,
) -> Ty<'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),
}
}
- 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,
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 {
&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 {
/// * 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.
//
}
}
- 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 {
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 {
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!(
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")
});
);
}
- 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))
pub(crate) fn check_lhs_assignable(
&self,
- lhs: &'tcx hir::Expr,
+ lhs: &'tcx hir::Expr<'tcx>,
err_code: &'static str,
expr_span: &Span,
) {
/// 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);
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 { }`
/// 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> {
&self,
segment: &hir::PathSegment,
span: Span,
- args: &'tcx [hir::Expr],
+ args: &'tcx [hir::Expr<'tcx>],
rcvr_t: Ty<'tcx>,
error: MethodError<'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.
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),
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);
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);
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)
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;
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);
&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,
) {
// 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);
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);
fn ban_private_field_access(
&self,
- expr: &hir::Expr,
+ expr: &hir::Expr<'_>,
expr_t: Ty<'tcx>,
field: ast::Ident,
base_did: DefId,
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,
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>,
) {
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
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);
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 {
&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;
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;
}
}
- 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 {
self.expr_count += 1;
// Record the rest of the call expression normally.
- for arg in args {
+ for arg in *args {
self.visit_expr(arg);
}
}
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> {
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,
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 }
}
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);
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={:?})",
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;
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;
#[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)]
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<'_>,
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;
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
}
// 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);
}
// 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);
}
}
- 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() {
}
/// 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);
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,
/// 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>,
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> {
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>,
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.
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 {
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).
}
}
- 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);
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);
);
}
- 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,
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));
/// 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()
fn check_block_with_expected(
&self,
- blk: &'tcx hir::Block,
+ blk: &'tcx hir::Block<'tcx>,
expected: Expectation<'tcx>,
) -> Ty<'tcx> {
let prev = {
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 => &[],
};
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);
}
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,
fn suggest_fn_call(
&self,
err: &mut DiagnosticBuilder<'_>,
- expr: &hir::Expr,
+ expr: &hir::Expr<'_>,
expected: Ty<'tcx>,
found: Ty<'tcx>,
) -> bool {
pub fn suggest_ref_or_into(
&self,
err: &mut DiagnosticBuilder<'_>,
- expr: &hir::Expr,
+ expr: &hir::Expr<'_>,
expected: Ty<'tcx>,
found: Ty<'tcx>,
) {
fn suggest_boxing_when_appropriate(
&self,
err: &mut DiagnosticBuilder<'_>,
- expr: &hir::Expr,
+ expr: &hir::Expr<'_>,
expected: Ty<'tcx>,
found: Ty<'tcx>,
) {
fn suggest_missing_semicolon(
&self,
err: &mut DiagnosticBuilder<'_>,
- expression: &'tcx hir::Expr,
+ expression: &'tcx hir::Expr<'tcx>,
expected: Ty<'tcx>,
cause_span: Span,
) {
fn suggest_missing_await(
&self,
err: &mut DiagnosticBuilder<'_>,
- expr: &hir::Expr,
+ expr: &hir::Expr<'_>,
expected: Ty<'tcx>,
found: Ty<'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<'_>,
) {
}
}
- 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()?;
/// 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);
/// 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;
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> {
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>) {
/// 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<'_>,
pub fn check_user_unop(
&self,
- ex: &'tcx hir::Expr,
+ ex: &'tcx hir::Expr<'tcx>,
operand_ty: Ty<'tcx>,
op: hir::UnOp,
) -> Ty<'tcx> {
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};
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);
}
/// ```
fn check_pat(
&self,
- pat: &'tcx Pat,
+ pat: &'tcx Pat<'tcx>,
expected: Ty<'tcx>,
def_bm: BindingMode,
discrim_span: Option<Span>,
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)
}
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,
+ )
}
};
/// 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,
/// 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(..)
/// 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) {
fn check_pat_lit(
&self,
span: Span,
- lt: &hir::Expr,
+ lt: &hir::Expr<'tcx>,
expected: Ty<'tcx>,
discrim_span: Option<Span>,
) -> Ty<'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>> {
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>,
fn borrow_pat_suggestion(
&self,
err: &mut DiagnosticBuilder<'_>,
- pat: &Pat,
- inner: &Pat,
+ pat: &Pat<'_>,
+ inner: &Pat<'_>,
expected: Ty<'tcx>,
) {
let tcx = self.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 {
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,
fn check_pat_path(
&self,
- pat: &Pat,
+ pat: &Pat<'_>,
path_resolution: (Res, Option<Ty<'tcx>>, &'b [hir::PathSegment]),
qpath: &hir::QPath,
expected: Ty<'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,
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,
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,
pat_id: HirId,
span: Span,
variant: &'tcx ty::VariantDef,
- fields: &'tcx [hir::FieldPat],
+ fields: &'tcx [hir::FieldPat<'tcx>],
etc: bool,
def_bm: BindingMode,
) -> bool {
fn check_pat_box(
&self,
span: Span,
- inner: &'tcx Pat,
+ inner: &'tcx Pat<'tcx>,
expected: Ty<'tcx>,
def_bm: BindingMode,
discrim_span: Option<Span>,
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,
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>,
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> {
}
/// 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)
}
);
}
- 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
//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
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.
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);
}
}
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);
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:*/
}
}
- 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(_) => {}
}
}
- 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,
/// 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))?;
/// 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 {
/// 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)));
/// 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 => {
/// 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);
/// 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 =
/// 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 }| {
/// autoref'd.
fn link_autoref(
&self,
- expr: &hir::Expr,
+ expr: &hir::Expr<'_>,
expr_cmt: &mc::Place<'tcx>,
autoref: &adjustment::AutoBorrow<'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);
// 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) => {
// 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();
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);
self.visit_body(body);
}
- hir::ExprKind::Struct(_, ref fields, _) => {
+ hir::ExprKind::Struct(_, fields, _) => {
for field in fields {
self.visit_field_id(field.hir_id);
}
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();
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);
}
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);
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);
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};
fn span(&self) -> Span;
}
-impl HirNode for hir::Expr {
+impl HirNode for hir::Expr<'_> {
fn hir_id(&self) -> hir::HirId {
self.hir_id
}
}
}
-impl HirNode for hir::Pat {
+impl HirNode for hir::Pat<'_> {
fn hir_id(&self) -> hir::HirId {
self.hir_id
}
self.resolve_type_vars_or_error(hir_id, self.tables.node_type_opt(hir_id))
}
- fn expr_ty(&self, expr: &hir::Expr) -> McResult<Ty<'tcx>> {
+ fn expr_ty(&self, expr: &hir::Expr<'_>) -> McResult<Ty<'tcx>> {
self.resolve_type_vars_or_error(expr.hir_id, self.tables.expr_ty_opt(expr))
}
- crate fn expr_ty_adjusted(&self, expr: &hir::Expr) -> McResult<Ty<'tcx>> {
+ crate fn expr_ty_adjusted(&self, expr: &hir::Expr<'_>) -> McResult<Ty<'tcx>> {
self.resolve_type_vars_or_error(expr.hir_id, self.tables.expr_ty_adjusted_opt(expr))
}
/// implicit deref patterns attached (e.g., it is really
/// `&Some(x)`). In that case, we return the "outermost" type
/// (e.g., `&Option<T>).
- crate fn pat_ty_adjusted(&self, pat: &hir::Pat) -> McResult<Ty<'tcx>> {
+ crate fn pat_ty_adjusted(&self, pat: &hir::Pat<'_>) -> McResult<Ty<'tcx>> {
// Check for implicit `&` types wrapping the pattern; note
// that these are never attached to binding patterns, so
// actually this is somewhat "disjoint" from the code below
}
/// Like `pat_ty`, but ignores implicit `&` patterns.
- fn pat_ty_unadjusted(&self, pat: &hir::Pat) -> McResult<Ty<'tcx>> {
+ fn pat_ty_unadjusted(&self, pat: &hir::Pat<'_>) -> McResult<Ty<'tcx>> {
let base_ty = self.node_ty(pat.hir_id)?;
debug!("pat_ty(pat={:?}) base_ty={:?}", pat, base_ty);
Ok(ret_ty)
}
- crate fn cat_expr(&self, expr: &hir::Expr) -> McResult<Place<'tcx>> {
+ crate fn cat_expr(&self, expr: &hir::Expr<'_>) -> McResult<Place<'tcx>> {
// This recursion helper avoids going through *too many*
// adjustments, since *only* non-overloaded deref recurses.
fn helper<'a, 'tcx>(
mc: &MemCategorizationContext<'a, 'tcx>,
- expr: &hir::Expr,
+ expr: &hir::Expr<'_>,
adjustments: &[adjustment::Adjustment<'tcx>],
) -> McResult<Place<'tcx>> {
match adjustments.split_last() {
crate fn cat_expr_adjusted(
&self,
- expr: &hir::Expr,
+ expr: &hir::Expr<'_>,
previous: Place<'tcx>,
adjustment: &adjustment::Adjustment<'tcx>,
) -> McResult<Place<'tcx>> {
fn cat_expr_adjusted_with<F>(
&self,
- expr: &hir::Expr,
+ expr: &hir::Expr<'_>,
previous: F,
adjustment: &adjustment::Adjustment<'tcx>,
) -> McResult<Place<'tcx>>
}
}
- crate fn cat_expr_unadjusted(&self, expr: &hir::Expr) -> McResult<Place<'tcx>> {
+ crate fn cat_expr_unadjusted(&self, expr: &hir::Expr<'_>) -> McResult<Place<'tcx>> {
debug!("cat_expr: id={} expr={:?}", expr.hir_id, expr);
let expr_ty = self.expr_ty(expr)?;
ret
}
- fn cat_overloaded_place(&self, expr: &hir::Expr, base: &hir::Expr) -> McResult<Place<'tcx>> {
+ fn cat_overloaded_place(
+ &self,
+ expr: &hir::Expr<'_>,
+ base: &hir::Expr<'_>,
+ ) -> McResult<Place<'tcx>> {
debug!("cat_overloaded_place(expr={:?}, base={:?})", expr, base);
// Reconstruct the output assuming it's a reference with the
Ok(ret)
}
- crate fn cat_pattern<F>(&self, place: Place<'tcx>, pat: &hir::Pat, mut op: F) -> McResult<()>
+ crate fn cat_pattern<F>(
+ &self,
+ place: Place<'tcx>,
+ pat: &hir::Pat<'_>,
+ mut op: F,
+ ) -> McResult<()>
where
- F: FnMut(&Place<'tcx>, &hir::Pat),
+ F: FnMut(&Place<'tcx>, &hir::Pat<'_>),
{
self.cat_pattern_(place, pat, &mut op)
}
// FIXME(#19596) This is a workaround, but there should be a better way to do this
- fn cat_pattern_<F>(&self, mut place: Place<'tcx>, pat: &hir::Pat, op: &mut F) -> McResult<()>
+ fn cat_pattern_<F>(
+ &self,
+ mut place: Place<'tcx>,
+ pat: &hir::Pat<'_>,
+ op: &mut F,
+ ) -> McResult<()>
where
- F: FnMut(&Place<'tcx>, &hir::Pat),
+ F: FnMut(&Place<'tcx>, &hir::Pat<'_>),
{
// Here, `place` is the `Place` being matched and pat is the pattern it
// is being matched against.
}
}
- PatKind::Struct(_, ref field_pats, _) => {
+ PatKind::Struct(_, field_pats, _) => {
// S { f1: p1, ..., fN: pN }
for fp in field_pats {
let field_ty = self.pat_ty_adjusted(&fp.pat)?;
}
}
- PatKind::Or(ref pats) => {
+ PatKind::Or(pats) => {
for pat in pats {
self.cat_pattern_(place.clone(), &pat, op)?;
}
self.cat_pattern_(subplace, &subpat, op)?;
}
- PatKind::Slice(ref before, ref slice, ref after) => {
+ PatKind::Slice(before, ref slice, after) => {
let element_ty = match place.ty.builtin_index() {
Some(ty) => ty,
None => {