Skip to content

Commit 1ca3bdf

Browse files
Rename some suggestion/note functions
We really shouldn't be naming functions `fn check_*` unless they're doing *typechecking*. It's especially misleading when we're doing this inside of HIR typeck.
1 parent b540b5f commit 1ca3bdf

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

compiler/rustc_hir_typeck/src/demand.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
8686
self.emit_type_mismatch_suggestions(err, expr, expr_ty, expected, expected_ty_expr, error);
8787
self.note_type_is_not_clone(err, expected, expr_ty, expr);
8888
self.note_internal_mutation_in_method(err, expr, Some(expected), expr_ty);
89-
self.check_for_range_as_method_call(err, expr, expr_ty, expected);
90-
self.check_for_binding_assigned_block_without_tail_expression(err, expr, expr_ty, expected);
91-
self.check_wrong_return_type_due_to_generic_arg(err, expr, expr_ty);
89+
self.suggest_method_call_on_range_literal(err, expr, expr_ty, expected);
90+
self.suggest_return_binding_for_missing_tail_expr(err, expr, expr_ty, expected);
91+
self.note_wrong_return_ty_due_to_generic_arg(err, expr, expr_ty);
9292
}
9393

9494
/// Requires that the two types unify, and prints an error message if
@@ -1217,7 +1217,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
12171217
/// In addition of this check, it also checks between references mutability state. If the
12181218
/// expected is mutable but the provided isn't, maybe we could just say "Hey, try with
12191219
/// `&mut`!".
1220-
pub fn check_ref(
1220+
pub fn suggest_deref_or_ref(
12211221
&self,
12221222
expr: &hir::Expr<'tcx>,
12231223
checked_ty: Ty<'tcx>,
@@ -1572,7 +1572,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
15721572
None
15731573
}
15741574

1575-
pub fn check_for_cast(
1575+
pub fn suggest_cast(
15761576
&self,
15771577
err: &mut Diagnostic,
15781578
expr: &hir::Expr<'_>,
@@ -1942,7 +1942,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
19421942
}
19431943

19441944
/// Identify when the user has written `foo..bar()` instead of `foo.bar()`.
1945-
pub fn check_for_range_as_method_call(
1945+
pub fn suggest_method_call_on_range_literal(
19461946
&self,
19471947
err: &mut Diagnostic,
19481948
expr: &hir::Expr<'tcx>,
@@ -2011,7 +2011,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
20112011

20122012
/// Identify when the type error is because `()` is found in a binding that was assigned a
20132013
/// block without a tail expression.
2014-
fn check_for_binding_assigned_block_without_tail_expression(
2014+
fn suggest_return_binding_for_missing_tail_expr(
20152015
&self,
20162016
err: &mut Diagnostic,
20172017
expr: &hir::Expr<'_>,
@@ -2053,7 +2053,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
20532053
}
20542054
}
20552055

2056-
fn check_wrong_return_type_due_to_generic_arg(
2056+
fn note_wrong_return_ty_due_to_generic_arg(
20572057
&self,
20582058
err: &mut Diagnostic,
20592059
expr: &hir::Expr<'_>,

compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
275275
) -> bool {
276276
let expr = expr.peel_blocks();
277277
if let Some((sp, msg, suggestion, applicability, verbose, annotation)) =
278-
self.check_ref(expr, found, expected)
278+
self.suggest_deref_or_ref(expr, found, expected)
279279
{
280280
if verbose {
281281
err.span_suggestion_verbose(sp, &msg, suggestion, applicability);
@@ -342,7 +342,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
342342
err.span_label(sp, format!("{descr} `{name}` defined here"));
343343
}
344344
return true;
345-
} else if self.check_for_cast(err, expr, found, expected, expected_ty_expr) {
345+
} else if self.suggest_cast(err, expr, found, expected, expected_ty_expr) {
346346
return true;
347347
} else {
348348
let methods = self.get_conversion_methods(expr.span, expected, found, expr.hir_id);

compiler/rustc_hir_typeck/src/method/suggest.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1044,7 +1044,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10441044
);
10451045
}
10461046

1047-
self.check_for_inner_self(&mut err, source, rcvr_ty, item_name);
1047+
self.suggest_unwrapping_inner_self(&mut err, source, rcvr_ty, item_name);
10481048

10491049
bound_spans.sort();
10501050
bound_spans.dedup();
@@ -1131,7 +1131,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
11311131
}
11321132
}
11331133

1134-
self.check_for_deref_method(&mut err, source, rcvr_ty, item_name, expected);
1134+
self.note_derefed_ty_has_method(&mut err, source, rcvr_ty, item_name, expected);
11351135
return Some(err);
11361136
}
11371137

@@ -1804,7 +1804,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
18041804
}
18051805
}
18061806

1807-
fn check_for_inner_self(
1807+
fn suggest_unwrapping_inner_self(
18081808
&self,
18091809
err: &mut Diagnostic,
18101810
source: SelfSource<'tcx>,
@@ -2174,7 +2174,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
21742174
}
21752175
}
21762176

2177-
fn check_for_deref_method(
2177+
fn note_derefed_ty_has_method(
21782178
&self,
21792179
err: &mut Diagnostic,
21802180
self_source: SelfSource<'tcx>,

0 commit comments

Comments
 (0)