Skip to content

Commit f95059b

Browse files
Rename some methods to make it clear they're only for diagnostics
1 parent d8a646f commit f95059b

File tree

2 files changed

+26
-19
lines changed

2 files changed

+26
-19
lines changed

Diff for: compiler/rustc_hir_typeck/src/expr.rs

+19-15
Original file line numberDiff line numberDiff line change
@@ -2864,13 +2864,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
28642864
(expr_t, "")
28652865
};
28662866
for (found_fields, args) in
2867-
self.get_field_candidates_considering_privacy(span, ty, mod_id, id)
2867+
self.get_field_candidates_considering_privacy_for_diag(span, ty, mod_id, id)
28682868
{
28692869
let field_names = found_fields.iter().map(|field| field.name).collect::<Vec<_>>();
28702870
let mut candidate_fields: Vec<_> = found_fields
28712871
.into_iter()
28722872
.filter_map(|candidate_field| {
2873-
self.check_for_nested_field_satisfying(
2873+
self.check_for_nested_field_satisfying_condition_for_diag(
28742874
span,
28752875
&|candidate_field, _| candidate_field.ident(self.tcx()) == field,
28762876
candidate_field,
@@ -2933,7 +2933,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
29332933
.with_span_label(field.span, "private field")
29342934
}
29352935

2936-
pub(crate) fn get_field_candidates_considering_privacy(
2936+
pub(crate) fn get_field_candidates_considering_privacy_for_diag(
29372937
&self,
29382938
span: Span,
29392939
base_ty: Ty<'tcx>,
@@ -2986,7 +2986,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
29862986

29872987
/// This method is called after we have encountered a missing field error to recursively
29882988
/// search for the field
2989-
pub(crate) fn check_for_nested_field_satisfying(
2989+
pub(crate) fn check_for_nested_field_satisfying_condition_for_diag(
29902990
&self,
29912991
span: Span,
29922992
matches: &impl Fn(&ty::FieldDef, Ty<'tcx>) -> bool,
@@ -3011,20 +3011,24 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
30113011
if matches(candidate_field, field_ty) {
30123012
return Some(field_path);
30133013
} else {
3014-
for (nested_fields, subst) in
3015-
self.get_field_candidates_considering_privacy(span, field_ty, mod_id, hir_id)
3014+
for (nested_fields, subst) in self
3015+
.get_field_candidates_considering_privacy_for_diag(
3016+
span, field_ty, mod_id, hir_id,
3017+
)
30163018
{
30173019
// recursively search fields of `candidate_field` if it's a ty::Adt
30183020
for field in nested_fields {
3019-
if let Some(field_path) = self.check_for_nested_field_satisfying(
3020-
span,
3021-
matches,
3022-
field,
3023-
subst,
3024-
field_path.clone(),
3025-
mod_id,
3026-
hir_id,
3027-
) {
3021+
if let Some(field_path) = self
3022+
.check_for_nested_field_satisfying_condition_for_diag(
3023+
span,
3024+
matches,
3025+
field,
3026+
subst,
3027+
field_path.clone(),
3028+
mod_id,
3029+
hir_id,
3030+
)
3031+
{
30283032
return Some(field_path);
30293033
}
30303034
}

Diff for: compiler/rustc_hir_typeck/src/method/suggest.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -2675,9 +2675,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
26752675
) {
26762676
if let SelfSource::MethodCall(expr) = source {
26772677
let mod_id = self.tcx.parent_module(expr.hir_id).to_def_id();
2678-
for (fields, args) in
2679-
self.get_field_candidates_considering_privacy(span, actual, mod_id, expr.hir_id)
2680-
{
2678+
for (fields, args) in self.get_field_candidates_considering_privacy_for_diag(
2679+
span,
2680+
actual,
2681+
mod_id,
2682+
expr.hir_id,
2683+
) {
26812684
let call_expr = self.tcx.hir().expect_expr(self.tcx.parent_hir_id(expr.hir_id));
26822685

26832686
let lang_items = self.tcx.lang_items();
@@ -2693,7 +2696,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
26932696
let mut candidate_fields: Vec<_> = fields
26942697
.into_iter()
26952698
.filter_map(|candidate_field| {
2696-
self.check_for_nested_field_satisfying(
2699+
self.check_for_nested_field_satisfying_condition_for_diag(
26972700
span,
26982701
&|_, field_ty| {
26992702
self.lookup_probe_for_diagnostic(

0 commit comments

Comments
 (0)