) -> bool /* did we suggest to call a function because of missing parentheses? */ {
err.span_label(span, ty.to_string());
if let FnDef(def_id, _) = *ty.kind() {
- let source_map = self.tcx.sess.source_map();
if !self.tcx.has_typeck_results(def_id) {
return false;
}
.lookup_op_method(fn_sig.output(), &[other_ty], Op::Binary(op, is_assign))
.is_ok()
{
- if let Ok(snippet) = source_map.span_to_snippet(span) {
- let (variable_snippet, applicability) = if !fn_sig.inputs().is_empty() {
- (format!("{}( /* arguments */ )", snippet), Applicability::HasPlaceholders)
- } else {
- (format!("{}()", snippet), Applicability::MaybeIncorrect)
- };
+ let (variable_snippet, applicability) = if !fn_sig.inputs().is_empty() {
+ ("( /* arguments */ )".to_string(), Applicability::HasPlaceholders)
+ } else {
+ ("()".to_string(), Applicability::MaybeIncorrect)
+ };
- err.span_suggestion(
- span,
- "you might have forgotten to call this function",
- variable_snippet,
- applicability,
- );
- }
+ err.span_suggestion_verbose(
+ span.shrink_to_hi(),
+ "you might have forgotten to call this function",
+ variable_snippet,
+ applicability,
+ );
return true;
}
}
| --- ^ -- {integer}
| |
| fn() -> i32 {foo}
- | help: you might have forgotten to call this function: `foo()`
+ |
+help: you might have forgotten to call this function
+ |
+LL | foo() > 12;
+ | ++
error[E0308]: mismatched types
--> $DIR/issue-59488.rs:14:11
| --- ^ -- {integer}
| |
| fn(i64) -> i64 {bar}
- | help: you might have forgotten to call this function: `bar( /* arguments */ )`
+ |
+help: you might have forgotten to call this function
+ |
+LL | bar( /* arguments */ ) > 13;
+ | +++++++++++++++++++
error[E0308]: mismatched types
--> $DIR/issue-59488.rs:18:11
help: you might have forgotten to call this function
|
LL | foo() > foo;
- | ~~~~~
+ | ++
help: you might have forgotten to call this function
|
LL | foo > foo();
- | ~~~~~
+ | ++
error[E0369]: binary operation `>` cannot be applied to type `fn() -> i32 {foo}`
--> $DIR/issue-59488.rs:25:9
| |
| fn() -> i32 {a}
| {integer}
- | help: you might have forgotten to call this function: `*left_val()`
|
= note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)
+help: you might have forgotten to call this function
+ |
+LL | if !(*left_val() == *right_val) {
+ | ++
error[E0308]: mismatched types
--> $DIR/issue-70724-add_type_neq_err_label-unwrap.rs:6:5