Remove a redundant macro

Turn the macro into a function. Also remove unused 'span' argument.
This commit is contained in:
Ömer Sinan Ağacan 2021-02-22 16:55:20 +03:00
parent 8a9f7862bc
commit c0c4436011
1 changed files with 9 additions and 9 deletions

View File

@ -517,21 +517,21 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
if self.is_fn_ty(&rcvr_ty, span) {
macro_rules! report_function {
($span:expr, $name:expr) => {
err.note(&format!(
"`{}` is a function, perhaps you wish to call it",
$name
));
};
fn report_function<T: std::fmt::Display>(
err: &mut DiagnosticBuilder<'_>,
name: T,
) {
err.note(
&format!("`{}` is a function, perhaps you wish to call it", name,),
);
}
if let SelfSource::MethodCall(expr) = source {
if let Ok(expr_string) = tcx.sess.source_map().span_to_snippet(expr.span) {
report_function!(expr.span, expr_string);
report_function(&mut err, expr_string);
} else if let ExprKind::Path(QPath::Resolved(_, ref path)) = expr.kind {
if let Some(segment) = path.segments.last() {
report_function!(expr.span, segment.ident);
report_function(&mut err, segment.ident);
}
}
}