Skip to content

Commit bb0b2ab

Browse files
Make sure all expr checking fns start with check_expr
1 parent 3f1be1e commit bb0b2ab

File tree

6 files changed

+30
-29
lines changed

6 files changed

+30
-29
lines changed

compiler/rustc_hir_typeck/src/_match.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use crate::{Diverges, Expectation, FnCtxt, Needs};
1515

1616
impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1717
#[instrument(skip(self), level = "debug", ret)]
18-
pub(crate) fn check_match(
18+
pub(crate) fn check_expr_match(
1919
&self,
2020
expr: &'tcx hir::Expr<'tcx>,
2121
scrut: &'tcx hir::Expr<'tcx>,

compiler/rustc_hir_typeck/src/callee.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ enum CallStep<'tcx> {
6363
}
6464

6565
impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
66-
pub(crate) fn check_call(
66+
pub(crate) fn check_expr_call(
6767
&self,
6868
call_expr: &'tcx hir::Expr<'tcx>,
6969
callee_expr: &'tcx hir::Expr<'tcx>,

compiler/rustc_hir_typeck/src/check.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ pub(super) fn check_fn<'a, 'tcx>(
137137
}
138138

139139
fcx.is_whole_body.set(true);
140-
fcx.check_return_expr(body.value, false);
140+
fcx.check_return_or_body_tail(body.value, false);
141141

142142
// Finalize the return check by taking the LUB of the return types
143143
// we saw and assigning it to the expected return type. This isn't

compiler/rustc_hir_typeck/src/expr.rs

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -452,15 +452,15 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
452452

453453
let tcx = self.tcx;
454454
match expr.kind {
455-
ExprKind::Lit(ref lit) => self.check_lit(lit, expected),
456-
ExprKind::Binary(op, lhs, rhs) => self.check_binop(expr, op, lhs, rhs, expected),
455+
ExprKind::Lit(ref lit) => self.check_expr_lit(lit, expected),
456+
ExprKind::Binary(op, lhs, rhs) => self.check_expr_binop(expr, op, lhs, rhs, expected),
457457
ExprKind::Assign(lhs, rhs, span) => {
458458
self.check_expr_assign(expr, expected, lhs, rhs, span)
459459
}
460460
ExprKind::AssignOp(op, lhs, rhs) => {
461-
self.check_binop_assign(expr, op, lhs, rhs, expected)
461+
self.check_expr_binop_assign(expr, op, lhs, rhs, expected)
462462
}
463-
ExprKind::Unary(unop, oprnd) => self.check_expr_unary(unop, oprnd, expected, expr),
463+
ExprKind::Unary(unop, oprnd) => self.check_expr_unop(unop, oprnd, expected, expr),
464464
ExprKind::AddrOf(kind, mutbl, oprnd) => {
465465
self.check_expr_addr_of(kind, mutbl, oprnd, expected, expr)
466466
}
@@ -473,7 +473,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
473473
self.deferred_asm_checks.borrow_mut().push((asm, expr.hir_id));
474474
self.check_expr_asm(asm)
475475
}
476-
ExprKind::OffsetOf(container, fields) => self.check_offset_of(container, fields, expr),
476+
ExprKind::OffsetOf(container, fields) => {
477+
self.check_expr_offset_of(container, fields, expr)
478+
}
477479
ExprKind::Break(destination, ref expr_opt) => {
478480
self.check_expr_break(destination, expr_opt.as_deref(), expr)
479481
}
@@ -492,13 +494,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
492494
self.check_expr_loop(body, source, expected, expr)
493495
}
494496
ExprKind::Match(discrim, arms, match_src) => {
495-
self.check_match(expr, discrim, arms, expected, match_src)
497+
self.check_expr_match(expr, discrim, arms, expected, match_src)
496498
}
497499
ExprKind::Closure(closure) => self.check_expr_closure(closure, expr.span, expected),
498-
ExprKind::Block(body, _) => self.check_block_with_expected(body, expected),
499-
ExprKind::Call(callee, args) => self.check_call(expr, callee, args, expected),
500+
ExprKind::Block(body, _) => self.check_expr_block(body, expected),
501+
ExprKind::Call(callee, args) => self.check_expr_call(expr, callee, args, expected),
500502
ExprKind::MethodCall(segment, receiver, args, _) => {
501-
self.check_method_call(expr, segment, receiver, args, expected)
503+
self.check_expr_method_call(expr, segment, receiver, args, expected)
502504
}
503505
ExprKind::Cast(e, t) => self.check_expr_cast(e, t, expr),
504506
ExprKind::Type(e, t) => {
@@ -508,7 +510,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
508510
ascribed_ty
509511
}
510512
ExprKind::If(cond, then_expr, opt_else_expr) => {
511-
self.check_then_else(cond, then_expr, opt_else_expr, expr.span, expected)
513+
self.check_expr_if(cond, then_expr, opt_else_expr, expr.span, expected)
512514
}
513515
ExprKind::DropTemps(e) => self.check_expr_with_expectation(e, expected),
514516
ExprKind::Array(args) => self.check_expr_array(args, expected, expr),
@@ -520,7 +522,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
520522
ExprKind::Struct(qpath, fields, ref base_expr) => {
521523
self.check_expr_struct(expr, expected, qpath, fields, base_expr)
522524
}
523-
ExprKind::Field(base, field) => self.check_field(expr, base, field, expected),
525+
ExprKind::Field(base, field) => self.check_expr_field(expr, base, field, expected),
524526
ExprKind::Index(base, idx, brackets_span) => {
525527
self.check_expr_index(base, idx, expr, brackets_span)
526528
}
@@ -529,7 +531,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
529531
}
530532
}
531533

532-
fn check_expr_unary(
534+
fn check_expr_unop(
533535
&self,
534536
unop: hir::UnOp,
535537
oprnd: &'tcx hir::Expr<'tcx>,
@@ -952,7 +954,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
952954
if self.ret_coercion_span.get().is_none() {
953955
self.ret_coercion_span.set(Some(e.span));
954956
}
955-
self.check_return_expr(e, true);
957+
self.check_return_or_body_tail(e, true);
956958
} else {
957959
let mut coercion = self.ret_coercion.as_ref().unwrap().borrow_mut();
958960
if self.ret_coercion_span.get().is_none() {
@@ -1015,7 +1017,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10151017
///
10161018
/// `explicit_return` is `true` if we're checking an explicit `return expr`,
10171019
/// and `false` if we're checking a trailing expression.
1018-
pub(super) fn check_return_expr(
1020+
pub(super) fn check_return_or_body_tail(
10191021
&self,
10201022
return_expr: &'tcx hir::Expr<'tcx>,
10211023
explicit_return: bool,
@@ -1239,7 +1241,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
12391241

12401242
// A generic function for checking the 'then' and 'else' clauses in an 'if'
12411243
// or 'if-else' expression.
1242-
fn check_then_else(
1244+
fn check_expr_if(
12431245
&self,
12441246
cond_expr: &'tcx hir::Expr<'tcx>,
12451247
then_expr: &'tcx hir::Expr<'tcx>,
@@ -1522,7 +1524,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
15221524
}
15231525

15241526
/// Checks a method call.
1525-
fn check_method_call(
1527+
fn check_expr_method_call(
15261528
&self,
15271529
expr: &'tcx hir::Expr<'tcx>,
15281530
segment: &'tcx hir::PathSegment<'tcx>,
@@ -2574,7 +2576,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
25742576
}
25752577

25762578
// Check field access expressions
2577-
fn check_field(
2579+
fn check_expr_field(
25782580
&self,
25792581
expr: &'tcx hir::Expr<'tcx>,
25802582
base: &'tcx hir::Expr<'tcx>,
@@ -3515,8 +3517,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
35153517
let previous_diverges = self.diverges.get();
35163518

35173519
// The label blocks should have unit return value or diverge.
3518-
let ty =
3519-
self.check_block_with_expected(block, ExpectHasType(self.tcx.types.unit));
3520+
let ty = self.check_expr_block(block, ExpectHasType(self.tcx.types.unit));
35203521
if !ty.is_never() {
35213522
self.demand_suptype(block.span, self.tcx.types.unit, ty);
35223523
diverge = false;
@@ -3531,7 +3532,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
35313532
if diverge { self.tcx.types.never } else { self.tcx.types.unit }
35323533
}
35333534

3534-
fn check_offset_of(
3535+
fn check_expr_offset_of(
35353536
&self,
35363537
container: &'tcx hir::Ty<'tcx>,
35373538
fields: &[Ident],

compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1565,7 +1565,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
15651565
}
15661566

15671567
// AST fragment checking
1568-
pub(in super::super) fn check_lit(
1568+
pub(in super::super) fn check_expr_lit(
15691569
&self,
15701570
lit: &hir::Lit,
15711571
expected: Expectation<'tcx>,
@@ -1747,7 +1747,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
17471747

17481748
if let Some(blk) = decl.origin.try_get_else() {
17491749
let previous_diverges = self.diverges.get();
1750-
let else_ty = self.check_block_with_expected(blk, NoExpectation);
1750+
let else_ty = self.check_expr_block(blk, NoExpectation);
17511751
let cause = self.cause(blk.span, ObligationCauseCode::LetElse);
17521752
if let Err(err) = self.demand_eqtype_with_origin(&cause, self.tcx.types.never, else_ty)
17531753
{
@@ -1805,7 +1805,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
18051805

18061806
pub(crate) fn check_block_no_value(&self, blk: &'tcx hir::Block<'tcx>) {
18071807
let unit = self.tcx.types.unit;
1808-
let ty = self.check_block_with_expected(blk, ExpectHasType(unit));
1808+
let ty = self.check_expr_block(blk, ExpectHasType(unit));
18091809

18101810
// if the block produces a `!` value, that can always be
18111811
// (effectively) coerced to unit.
@@ -1814,7 +1814,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
18141814
}
18151815
}
18161816

1817-
pub(in super::super) fn check_block_with_expected(
1817+
pub(in super::super) fn check_expr_block(
18181818
&self,
18191819
blk: &'tcx hir::Block<'tcx>,
18201820
expected: Expectation<'tcx>,

compiler/rustc_hir_typeck/src/op.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use crate::Expectation;
2626

2727
impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
2828
/// Checks a `a <op>= b`
29-
pub(crate) fn check_binop_assign(
29+
pub(crate) fn check_expr_binop_assign(
3030
&self,
3131
expr: &'tcx hir::Expr<'tcx>,
3232
op: hir::BinOp,
@@ -85,7 +85,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
8585
}
8686

8787
/// Checks a potentially overloaded binary operator.
88-
pub(crate) fn check_binop(
88+
pub(crate) fn check_expr_binop(
8989
&self,
9090
expr: &'tcx hir::Expr<'tcx>,
9191
op: hir::BinOp,

0 commit comments

Comments
 (0)