new_ty.to_string(),
Applicability::Unspecified,
)
- .span_label(span, format!("lifetime `{}` required", named))
- .emit();
+ .span_label(span, format!("lifetime `{}` required", named))
+ .emit();
return Some(ErrorReported);
}
DiagnosticBuilderMethod::SpanSuggestion(suggestion) => {
let span = span_maybe.expect("span_suggestion_* needs a span");
diag_builder.span_suggestion_with_applicability(
- span,
- message,
- suggestion,
- Applicability::Unspecified,
- );
+ span,
+ message,
+ suggestion,
+ Applicability::Unspecified,
+ );
}
}
}
db.note(fn_closure_msg);
} else {
db.span_suggestion_with_applicability(
- sp,
- msg,
- suggestion,
- Applicability::Unspecified,
- );
+ sp,
+ msg,
+ suggestion,
+ Applicability::Unspecified,
+ );
}
} else {
db.span_suggestion_with_applicability(
- sp,
- msg,
- suggestion,
- Applicability::Unspecified,
- );
+ sp,
+ msg,
+ suggestion,
+ Applicability::Unspecified,
+ );
}
}
_ => {
capture_span,
Origin::Ast)
.span_suggestion_with_applicability(
- err.span,
- &format!("to force the closure to take ownership of {} \
- (and any other referenced variables), \
- use the `move` keyword",
- cmt_path_or_string),
- suggestion,
- Applicability::MachineApplicable,
+ err.span,
+ &format!("to force the closure to take ownership of {} \
+ (and any other referenced variables), \
+ use the `move` keyword",
+ cmt_path_or_string),
+ suggestion,
+ Applicability::MachineApplicable,
)
.emit();
self.signal_error();
suggestion: Vec<(Span, String)>,
) -> &mut Self {
self.multipart_suggestion_with_applicability(
- msg,
- suggestion,
- Applicability::Unspecified,
+ msg,
+ suggestion,
+ Applicability::Unspecified,
)
}
"can only break with a value inside \
`loop` or breakable block")
.span_suggestion_with_applicability(
- e.span,
- &format!("instead, use `break` on its own \
- without a value inside this `{}` loop",
- kind.name()),
- "break".to_string(),
- Applicability::MaybeIncorrect,
+ e.span,
+ &format!(
+ "instead, use `break` on its own \
+ without a value inside this `{}` loop",
+ kind.name()
+ ),
+ "break".to_string(),
+ Applicability::MaybeIncorrect,
)
.emit();
}
"expecting a type here because of type ascription");
if line_sp != line_base_sp {
err.span_suggestion_short_with_applicability(
- sp,
- "did you mean to use `;` here instead?",
- ";".to_string(),
- Applicability::MaybeIncorrect,
- );
+ sp,
+ "did you mean to use `;` here instead?",
+ ";".to_string(),
+ Applicability::MaybeIncorrect,
+ );
}
break;
} else if snippet.trim().len() != 0 {
*candidate = format!("use {};\n{}", candidate, additional_newline);
}
- err.span_suggestions_with_applicability(span, &msg, path_strings,
- Applicability::Unspecified);
+ err.span_suggestions_with_applicability(
+ span,
+ &msg,
+ path_strings,
+ Applicability::Unspecified,
+ );
} else {
let mut msg = msg;
msg.push(':');
err.note("The type information given here is insufficient to check whether \
the pointer cast is valid");
if unknown_cast_to {
- err.span_suggestion_short_with_applicability(self.cast_span,
- "consider giving more type information",
- String::new(),
- Applicability::Unspecified,
- );
+ err.span_suggestion_short_with_applicability(
+ self.cast_span,
+ "consider giving more type information",
+ String::new(),
+ Applicability::Unspecified,
+ );
}
err.emit();
}
if self.cast_ty.is_trait() {
match fcx.tcx.sess.source_map().span_to_snippet(self.cast_span) {
Ok(s) => {
- err.span_suggestion_with_applicability(self.cast_span,
- "try casting to a reference instead",
- format!("&{}{}", mtstr, s),
- Applicability::MachineApplicable,
- );
+ err.span_suggestion_with_applicability(
+ self.cast_span,
+ "try casting to a reference instead",
+ format!("&{}{}", mtstr, s),
+ Applicability::MachineApplicable,
+ );
}
Err(_) => {
span_help!(err, self.cast_span, "did you mean `&{}{}`?", mtstr, tstr)
ty::Adt(def, ..) if def.is_box() => {
match fcx.tcx.sess.source_map().span_to_snippet(self.cast_span) {
Ok(s) => {
- err.span_suggestion_with_applicability(self.cast_span,
- "try casting to a `Box` instead",
- format!("Box<{}>", s),
- Applicability::MachineApplicable,
- );
+ err.span_suggestion_with_applicability(
+ self.cast_span,
+ "try casting to a `Box` instead",
+ format!("Box<{}>", s),
+ Applicability::MachineApplicable,
+ );
}
Err(_) => span_help!(err, self.cast_span, "did you mean `Box<{}>`?", tstr),
}
let suggestions = compatible_variants.iter()
.map(|v| format!("{}({})", v, expr_text)).collect::<Vec<_>>();
err.span_suggestions_with_applicability(
- expr.span,
- "try using a variant of the expected type",
- suggestions,
- Applicability::MaybeIncorrect,
+ expr.span,
+ "try using a variant of the expected type",
+ suggestions,
+ Applicability::MaybeIncorrect,
);
}
}
let msg = format!("`{}` is a native pointer; try dereferencing it", base);
let suggestion = format!("(*{}).{}", base, field);
err.span_suggestion_with_applicability(
- field.span,
- &msg,
- suggestion,
- Applicability::MaybeIncorrect,
- );
+ field.span,
+ &msg,
+ suggestion,
+ Applicability::MaybeIncorrect,
+ );
}
_ => {}
}
) {
if let Some((sp, msg, suggestion)) = self.check_ref(expr, found, expected) {
err.span_suggestion_with_applicability(
- sp,
- msg,
- suggestion,
- Applicability::MachineApplicable,
- );
+ sp,
+ msg,
+ suggestion,
+ Applicability::MachineApplicable,
+ );
} else if !self.check_for_cast(err, expr, found, expected) {
let methods = self.get_conversion_methods(expr.span, expected, found);
if let Ok(expr_text) = self.sess().source_map().span_to_snippet(expr.span) {
}) .collect::<Vec<_>>();
if !suggestions.is_empty() {
err.span_suggestions_with_applicability(
- expr.span,
- "try using a conversion method",
- suggestions,
- Applicability::MaybeIncorrect,
- );
+ expr.span,
+ "try using a conversion method",
+ suggestions,
+ Applicability::MaybeIncorrect,
+ );
}
}
}
"`+` can't be used to concatenate two `&str` strings");
match source_map.span_to_snippet(lhs_expr.span) {
Ok(lstring) => err.span_suggestion_with_applicability(
- lhs_expr.span,
- msg,
- format!("{}.to_owned()", lstring),
- Applicability::MachineApplicable,
+ lhs_expr.span,
+ msg,
+ format!("{}.to_owned()", lstring),
+ Applicability::MachineApplicable,
),
_ => err.help(msg),
};
) {
(Ok(l), Ok(r), false) => {
err.multipart_suggestion_with_applicability(
- msg,
- vec![
- (lhs_expr.span, format!("{}.to_owned()", l)),
- (rhs_expr.span, format!("&{}", r)),
- ],
- Applicability::MachineApplicable,
+ msg,
+ vec![
+ (lhs_expr.span, format!("{}.to_owned()", l)),
+ (rhs_expr.span, format!("&{}", r)),
+ ],
+ Applicability::MachineApplicable,
);
}
_ => {
let mut err = self.sess.span_diagnostic.struct_span_err(span, msg);
if !suggestion.is_empty() {
err.span_suggestion_with_applicability(
- span,
- "expected syntax is",
- suggestion.into(),
- Applicability::MaybeIncorrect,
+ span,
+ "expected syntax is",
+ suggestion.into(),
+ Applicability::MaybeIncorrect,
);
}
err.emit();
err.note("you might be missing a comma");
} else {
err.span_suggestion_short_with_applicability(
- comma_span,
- "missing comma here",
- ", ".to_string(),
- Applicability::MachineApplicable,
+ comma_span,
+ "missing comma here",
+ ", ".to_string(),
+ Applicability::MachineApplicable,
);
}
}
// If the struct looks otherwise well formed, recover and continue.
if let Some(sp) = comma_sp {
err.span_suggestion_short_with_applicability(
- sp,
- "remove this comma",
- String::new(),
- Applicability::MachineApplicable,
- );
+ sp,
+ "remove this comma",
+ String::new(),
+ Applicability::MachineApplicable,
+ );
}
err.emit();
break;
}
if suggestions.len() > 0 {
diag.multipart_suggestion_with_applicability(
- "format specifiers use curly braces",
- suggestions,
- Applicability::MachineApplicable,
+ "format specifiers use curly braces",
+ suggestions,
+ Applicability::MachineApplicable,
);
}
}};