Skip to content

Commit

Permalink
Rename some suggestion/note functions
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
compiler-errors committed May 8, 2023
1 parent a9051d8 commit a283f58
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
16 changes: 8 additions & 8 deletions compiler/rustc_hir_typeck/src/demand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
self.emit_type_mismatch_suggestions(err, expr, expr_ty, expected, expected_ty_expr, error);
self.note_type_is_not_clone(err, expected, expr_ty, expr);
self.note_internal_mutation_in_method(err, expr, Some(expected), expr_ty);
self.check_for_range_as_method_call(err, expr, expr_ty, expected);
self.check_for_binding_assigned_block_without_tail_expression(err, expr, expr_ty, expected);
self.check_wrong_return_type_due_to_generic_arg(err, expr, expr_ty);
self.suggest_method_call_on_range_literal(err, expr, expr_ty, expected);
self.suggest_return_binding_for_missing_tail_expr(err, expr, expr_ty, expected);
self.note_wrong_return_ty_due_to_generic_arg(err, expr, expr_ty);
}

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

pub fn check_for_cast(
pub fn suggest_cast(
&self,
err: &mut Diagnostic,
expr: &hir::Expr<'_>,
Expand Down Expand Up @@ -1939,7 +1939,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}

/// Identify when the user has written `foo..bar()` instead of `foo.bar()`.
pub fn check_for_range_as_method_call(
pub fn suggest_method_call_on_range_literal(
&self,
err: &mut Diagnostic,
expr: &hir::Expr<'tcx>,
Expand Down Expand Up @@ -2008,7 +2008,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {

/// Identify when the type error is because `()` is found in a binding that was assigned a
/// block without a tail expression.
fn check_for_binding_assigned_block_without_tail_expression(
fn suggest_return_binding_for_missing_tail_expr(
&self,
err: &mut Diagnostic,
expr: &hir::Expr<'_>,
Expand Down Expand Up @@ -2050,7 +2050,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
}

fn check_wrong_return_type_due_to_generic_arg(
fn note_wrong_return_ty_due_to_generic_arg(
&self,
err: &mut Diagnostic,
expr: &hir::Expr<'_>,
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
) -> bool {
let expr = expr.peel_blocks();
if let Some((sp, msg, suggestion, applicability, verbose, annotation)) =
self.check_ref(expr, found, expected)
self.suggest_deref_or_ref(expr, found, expected)
{
if verbose {
err.span_suggestion_verbose(sp, msg, suggestion, applicability);
Expand Down Expand Up @@ -342,7 +342,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
err.span_label(sp, format!("{descr} `{name}` defined here"));
}
return true;
} else if self.check_for_cast(err, expr, found, expected, expected_ty_expr) {
} else if self.suggest_cast(err, expr, found, expected, expected_ty_expr) {
return true;
} else {
let methods = self.get_conversion_methods(expr.span, expected, found, expr.hir_id);
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_hir_typeck/src/method/suggest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1045,7 +1045,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
);
}

self.check_for_inner_self(&mut err, source, rcvr_ty, item_name);
self.suggest_unwrapping_inner_self(&mut err, source, rcvr_ty, item_name);

bound_spans.sort();
bound_spans.dedup();
Expand Down Expand Up @@ -1132,7 +1132,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
}

self.check_for_deref_method(&mut err, source, rcvr_ty, item_name, expected);
self.note_derefed_ty_has_method(&mut err, source, rcvr_ty, item_name, expected);
return Some(err);
}

Expand Down Expand Up @@ -1805,7 +1805,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
}

fn check_for_inner_self(
fn suggest_unwrapping_inner_self(
&self,
err: &mut Diagnostic,
source: SelfSource<'tcx>,
Expand Down Expand Up @@ -2175,7 +2175,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
}

fn check_for_deref_method(
fn note_derefed_ty_has_method(
&self,
err: &mut Diagnostic,
self_source: SelfSource<'tcx>,
Expand Down

0 comments on commit a283f58

Please sign in to comment.