1
Fork 0

Rollup merge of #82401 - osa1:remove_redundant_macro, r=matthewjasper

Remove a redundant macro

Turn the macro into a function. Also remove unused 'span' argument.
This commit is contained in:
Dylan DPC 2021-02-27 21:56:17 +01:00 committed by GitHub
commit 840622910f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

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