- err.cancel();
- self.struct_span_err(
- span,
- "invalid `struct` delimiters or `fn` call arguments",
- )
- .multipart_suggestion(
- &format!("if `{}` is a struct, use braces as delimiters", name),
- vec![(open_paren, " { ".to_string()), (close_paren, " }".to_string())],
- Applicability::MaybeIncorrect,
- )
- .multipart_suggestion(
- &format!("if `{}` is a function, use the arguments directly", name),
- fields
- .into_iter()
- .map(|field| (field.span.until(field.expr.span), String::new()))
- .collect(),
- Applicability::MaybeIncorrect,
- )
- .emit();
+ if !fields.is_empty() {
+ err.cancel();
+ let mut err = self.struct_span_err(
+ span,
+ "invalid `struct` delimiters or `fn` call arguments",
+ );
+ err.multipart_suggestion(
+ &format!("if `{}` is a struct, use braces as delimiters", name),
+ vec![
+ (open_paren, " { ".to_string()),
+ (close_paren, " }".to_string()),
+ ],
+ Applicability::MaybeIncorrect,
+ );
+ err.multipart_suggestion(
+ &format!("if `{}` is a function, use the arguments directly", name),
+ fields
+ .into_iter()
+ .map(|field| (field.span.until(field.expr.span), String::new()))
+ .collect(),
+ Applicability::MaybeIncorrect,
+ );
+ err.emit();
+ } else {
+ err.emit();
+ }