Skip to content

Commit bae1df6

Browse files
committed
fixup! Wrapped inferred context changes in a probe, handle fnOnce trait require error with a fallback, renamed variable to something clearer
1 parent 973da22 commit bae1df6

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

src/librustc_typeck/check/method/suggest.rs

+12-16
Original file line numberDiff line numberDiff line change
@@ -73,20 +73,16 @@ pub fn report_error<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
7373
// snippet
7474
};
7575

76-
macro_rules! span_stored_function {
77-
() => {
78-
cx.sess.span_note(span,
79-
&format!("use `({0}.{1})(...)` if you meant to call \
80-
the function stored in the `{1}` field",
81-
expr_string, item_name));
82-
}
76+
let span_stored_function = || {
77+
cx.sess.span_note(span,
78+
&format!("use `({0}.{1})(...)` if you meant to call \
79+
the function stored in the `{1}` field",
80+
expr_string, item_name));
8381
};
8482

85-
macro_rules! span_did_you_mean {
86-
() => {
87-
cx.sess.span_note(span, &format!("did you mean to write `{0}.{1}`?",
88-
expr_string, item_name));
89-
}
83+
let span_did_you_mean = || {
84+
cx.sess.span_note(span, &format!("did you mean to write `{0}.{1}`?",
85+
expr_string, item_name));
9086
};
9187

9288
// Determine if the field can be used as a function in some way
@@ -106,16 +102,16 @@ pub fn report_error<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
106102
let mut selcx = SelectionContext::new(infcx, fcx);
107103

108104
if selcx.evaluate_obligation(&obligation) {
109-
span_stored_function!();
105+
span_stored_function();
110106
} else {
111-
span_did_you_mean!();
107+
span_did_you_mean();
112108
}
113109
});
114110
} else {
115111
match field_ty.sty {
116112
// fallback to matching a closure or function pointer
117-
ty::TyClosure(_,_) | ty::TyBareFn(None,_) => span_stored_function!(),
118-
_ => span_did_you_mean!(),
113+
ty::TyClosure(..) | ty::TyBareFn(..) => span_stored_function(),
114+
_ => span_did_you_mean(),
119115
}
120116
}
121117
}

0 commit comments

Comments
 (0)