diff --git a/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs b/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs index 8b12db071b6ac..fe5e3c5a81b61 100644 --- a/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs @@ -237,7 +237,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { err.span_suggestion_verbose( span, "consider changing this to be mutable", - " mut ".into(), + " mut ", Applicability::MaybeIncorrect, ); } diff --git a/compiler/rustc_builtin_macros/src/deriving/default.rs b/compiler/rustc_builtin_macros/src/deriving/default.rs index 2c5260616c7da..b49331e28753d 100644 --- a/compiler/rustc_builtin_macros/src/deriving/default.rs +++ b/compiler/rustc_builtin_macros/src/deriving/default.rs @@ -235,7 +235,7 @@ fn validate_default_attribute( .span_suggestion_hidden( attr.span, "try using `#[default]`", - "#[default]".into(), + "#[default]", Applicability::MaybeIncorrect, ) .emit(); diff --git a/compiler/rustc_errors/src/diagnostic.rs b/compiler/rustc_errors/src/diagnostic.rs index cd17726c78588..39cb71848ebdd 100644 --- a/compiler/rustc_errors/src/diagnostic.rs +++ b/compiler/rustc_errors/src/diagnostic.rs @@ -605,7 +605,7 @@ impl Diagnostic { &mut self, sp: Span, msg: impl Into, - suggestion: String, + suggestion: impl ToString, applicability: Applicability, ) -> &mut Self { self.span_suggestion_with_style( @@ -623,13 +623,13 @@ impl Diagnostic { &mut self, sp: Span, msg: impl Into, - suggestion: String, + suggestion: impl ToString, applicability: Applicability, style: SuggestionStyle, ) -> &mut Self { self.push_suggestion(CodeSuggestion { substitutions: vec![Substitution { - parts: vec![SubstitutionPart { snippet: suggestion, span: sp }], + parts: vec![SubstitutionPart { snippet: suggestion.to_string(), span: sp }], }], msg: msg.into(), style, @@ -643,7 +643,7 @@ impl Diagnostic { &mut self, sp: Span, msg: impl Into, - suggestion: String, + suggestion: impl ToString, applicability: Applicability, ) -> &mut Self { self.span_suggestion_with_style( @@ -711,7 +711,7 @@ impl Diagnostic { &mut self, sp: Span, msg: impl Into, - suggestion: String, + suggestion: impl ToString, applicability: Applicability, ) -> &mut Self { self.span_suggestion_with_style( @@ -734,7 +734,7 @@ impl Diagnostic { &mut self, sp: Span, msg: impl Into, - suggestion: String, + suggestion: impl ToString, applicability: Applicability, ) -> &mut Self { self.span_suggestion_with_style( @@ -755,7 +755,7 @@ impl Diagnostic { &mut self, sp: Span, msg: impl Into, - suggestion: String, + suggestion: impl ToString, applicability: Applicability, ) -> &mut Self { self.span_suggestion_with_style( diff --git a/compiler/rustc_errors/src/diagnostic_builder.rs b/compiler/rustc_errors/src/diagnostic_builder.rs index d218040847704..efc7693459fc9 100644 --- a/compiler/rustc_errors/src/diagnostic_builder.rs +++ b/compiler/rustc_errors/src/diagnostic_builder.rs @@ -477,7 +477,7 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> { &mut self, sp: Span, msg: impl Into, - suggestion: String, + suggestion: impl ToString, applicability: Applicability, ) -> &mut Self); forward!(pub fn span_suggestions( @@ -497,28 +497,28 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> { &mut self, sp: Span, msg: impl Into, - suggestion: String, + suggestion: impl ToString, applicability: Applicability, ) -> &mut Self); forward!(pub fn span_suggestion_verbose( &mut self, sp: Span, msg: impl Into, - suggestion: String, + suggestion: impl ToString, applicability: Applicability, ) -> &mut Self); forward!(pub fn span_suggestion_hidden( &mut self, sp: Span, msg: impl Into, - suggestion: String, + suggestion: impl ToString, applicability: Applicability, ) -> &mut Self); forward!(pub fn tool_only_span_suggestion( &mut self, sp: Span, msg: impl Into, - suggestion: String, + suggestion: impl ToString, applicability: Applicability, ) -> &mut Self); diff --git a/compiler/rustc_expand/src/config.rs b/compiler/rustc_expand/src/config.rs index a9c7ba5d072d2..c91125105d746 100644 --- a/compiler/rustc_expand/src/config.rs +++ b/compiler/rustc_expand/src/config.rs @@ -511,7 +511,7 @@ pub fn parse_cfg<'a>(meta_item: &'a MetaItem, sess: &Session) -> Option<&'a Meta err.span_suggestion( span, "expected syntax is", - suggestion.into(), + suggestion, Applicability::HasPlaceholders, ); } diff --git a/compiler/rustc_infer/src/infer/error_reporting/mod.rs b/compiler/rustc_infer/src/infer/error_reporting/mod.rs index f9273cc50b70a..14555ad92559d 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/mod.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/mod.rs @@ -2198,7 +2198,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { err.span_suggestion( span.with_hi(before_close).shrink_to_hi(), msg, - ",".into(), + ",", Applicability::MachineApplicable, ); } else { diff --git a/compiler/rustc_lint/src/array_into_iter.rs b/compiler/rustc_lint/src/array_into_iter.rs index a14d602036131..dff2e31c6070c 100644 --- a/compiler/rustc_lint/src/array_into_iter.rs +++ b/compiler/rustc_lint/src/array_into_iter.rs @@ -129,7 +129,7 @@ impl<'tcx> LateLintPass<'tcx> for ArrayIntoIter { diag.span_suggestion( call.ident.span, "use `.iter()` instead of `.into_iter()` to avoid ambiguity", - "iter".into(), + "iter", Applicability::MachineApplicable, ); if self.for_expr_span == expr.span { diff --git a/compiler/rustc_lint/src/context.rs b/compiler/rustc_lint/src/context.rs index 0ffa65b79b584..d7cd5ec04f323 100644 --- a/compiler/rustc_lint/src/context.rs +++ b/compiler/rustc_lint/src/context.rs @@ -738,7 +738,7 @@ pub trait LintContext: Sized { db.span_suggestion_verbose( span.shrink_to_hi(), "insert whitespace here to avoid this being parsed as a prefix in Rust 2021", - " ".into(), + " ", Applicability::MachineApplicable, ); } diff --git a/compiler/rustc_lint/src/non_fmt_panic.rs b/compiler/rustc_lint/src/non_fmt_panic.rs index f21f25c35847e..71769fceec1f2 100644 --- a/compiler/rustc_lint/src/non_fmt_panic.rs +++ b/compiler/rustc_lint/src/non_fmt_panic.rs @@ -176,7 +176,7 @@ fn check_panic<'tcx>(cx: &LateContext<'tcx>, f: &'tcx hir::Expr<'tcx>, arg: &'tc l.span_suggestion_verbose( arg_span.shrink_to_lo(), "add a \"{}\" format string to Display the message", - "\"{}\", ".into(), + "\"{}\", ", fmt_applicability, ); } else if suggest_debug { @@ -186,7 +186,7 @@ fn check_panic<'tcx>(cx: &LateContext<'tcx>, f: &'tcx hir::Expr<'tcx>, arg: &'tc "add a \"{{:?}}\" format string to use the Debug implementation of `{}`", ty, ), - "\"{:?}\", ".into(), + "\"{:?}\", ", fmt_applicability, ); } @@ -266,13 +266,13 @@ fn check_panic_str<'tcx>( l.span_suggestion( arg.span.shrink_to_hi(), &format!("add the missing argument{}", pluralize!(n_arguments)), - ", ...".into(), + ", ...", Applicability::HasPlaceholders, ); l.span_suggestion( arg.span.shrink_to_lo(), "or add a \"{}\" format string to use the message literally", - "\"{}\", ".into(), + "\"{}\", ", Applicability::MachineApplicable, ); } @@ -297,7 +297,7 @@ fn check_panic_str<'tcx>( l.span_suggestion( arg.span.shrink_to_lo(), "add a \"{}\" format string to use the message literally", - "\"{}\", ".into(), + "\"{}\", ", Applicability::MachineApplicable, ); } diff --git a/compiler/rustc_parse/src/lexer/mod.rs b/compiler/rustc_parse/src/lexer/mod.rs index e585c61bf2ee1..ee54dd44f7194 100644 --- a/compiler/rustc_parse/src/lexer/mod.rs +++ b/compiler/rustc_parse/src/lexer/mod.rs @@ -612,14 +612,14 @@ impl<'a> StringReader<'a> { err.span_suggestion_verbose( prefix_span, "use `br` for a raw byte string", - "br".to_string(), + "br", Applicability::MaybeIncorrect, ); } else if expn_data.is_root() { err.span_suggestion_verbose( prefix_span.shrink_to_hi(), "consider inserting whitespace here", - " ".into(), + " ", Applicability::MaybeIncorrect, ); } diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index bdbc25af7fa1e..13e9a5e660fe6 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -1771,7 +1771,7 @@ impl<'a> Parser<'a> { .span_suggestion( token.span, "must have an integer part", - pprust::token_to_string(token).into(), + pprust::token_to_string(token), Applicability::MachineApplicable, ) .emit(); @@ -2324,7 +2324,7 @@ impl<'a> Parser<'a> { .span_suggestion_short( span, msg, - sugg.into(), + sugg, // Has been misleading, at least in the past (closed Issue #48492). Applicability::MaybeIncorrect, ) @@ -2828,7 +2828,7 @@ impl<'a> Parser<'a> { e.span_suggestion( self.prev_token.span.shrink_to_hi(), "try adding a comma", - ",".into(), + ",", Applicability::MachineApplicable, ); } diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs index 746861933d2f0..10f1daf112951 100644 --- a/compiler/rustc_parse/src/parser/item.rs +++ b/compiler/rustc_parse/src/parser/item.rs @@ -332,7 +332,7 @@ impl<'a> Parser<'a> { err.span_suggestion_short( sp, &msg, - " struct ".into(), + " struct ", Applicability::MaybeIncorrect, // speculative ); Err(err) @@ -532,13 +532,13 @@ impl<'a> Parser<'a> { .span_suggestion( span, "add a trait here", - " Trait ".into(), + " Trait ", Applicability::HasPlaceholders, ) .span_suggestion( span.to(self.token.span), "for an inherent impl, drop this `for`", - "".into(), + "", Applicability::MaybeIncorrect, ) .emit(); @@ -1459,7 +1459,7 @@ impl<'a> Parser<'a> { err.span_suggestion( sp, "missing comma here", - ",".into(), + ",", Applicability::MachineApplicable, ); } @@ -1498,7 +1498,7 @@ impl<'a> Parser<'a> { err.span_suggestion( sp, "try adding a comma", - ",".into(), + ",", Applicability::MachineApplicable, ); err.emit(); diff --git a/compiler/rustc_parse/src/parser/mod.rs b/compiler/rustc_parse/src/parser/mod.rs index 96cca68257e7f..cd61584a87662 100644 --- a/compiler/rustc_parse/src/parser/mod.rs +++ b/compiler/rustc_parse/src/parser/mod.rs @@ -802,7 +802,7 @@ impl<'a> Parser<'a> { .span_suggestion_verbose( self.prev_token.span.shrink_to_hi().until(self.token.span), &msg, - " @ ".to_string(), + " @ ", Applicability::MaybeIncorrect, ) .emit(); @@ -818,7 +818,7 @@ impl<'a> Parser<'a> { .span_suggestion_short( sp, &format!("missing `{}`", token_str), - token_str.into(), + token_str, Applicability::MaybeIncorrect, ) .emit(); diff --git a/compiler/rustc_parse/src/parser/pat.rs b/compiler/rustc_parse/src/parser/pat.rs index c7b929bf367dc..8019c5fb67cb9 100644 --- a/compiler/rustc_parse/src/parser/pat.rs +++ b/compiler/rustc_parse/src/parser/pat.rs @@ -606,7 +606,7 @@ impl<'a> Parser<'a> { .span_suggestion( mutref_span, "try switching the order", - "ref mut".into(), + "ref mut", Applicability::MachineApplicable, ) .emit(); diff --git a/compiler/rustc_resolve/src/build_reduced_graph.rs b/compiler/rustc_resolve/src/build_reduced_graph.rs index 291b6645d9aa6..650a0dc82ce23 100644 --- a/compiler/rustc_resolve/src/build_reduced_graph.rs +++ b/compiler/rustc_resolve/src/build_reduced_graph.rs @@ -851,7 +851,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> { .span_suggestion( item.span, "rename the `self` crate to be able to import it", - "extern crate self as name;".into(), + "extern crate self as name;", Applicability::HasPlaceholders, ) .emit(); diff --git a/src/tools/clippy/clippy_lints/src/functions/must_use.rs b/src/tools/clippy/clippy_lints/src/functions/must_use.rs index 0709580c8adfd..5462d913fb441 100644 --- a/src/tools/clippy/clippy_lints/src/functions/must_use.rs +++ b/src/tools/clippy/clippy_lints/src/functions/must_use.rs @@ -108,7 +108,7 @@ fn check_needless_must_use( diag.span_suggestion( attr.span, "remove the attribute", - "".into(), + "", Applicability::MachineApplicable, ); }, diff --git a/src/tools/clippy/clippy_lints/src/needless_pass_by_value.rs b/src/tools/clippy/clippy_lints/src/needless_pass_by_value.rs index 9c734221ebcea..4034079a90c0d 100644 --- a/src/tools/clippy/clippy_lints/src/needless_pass_by_value.rs +++ b/src/tools/clippy/clippy_lints/src/needless_pass_by_value.rs @@ -241,7 +241,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByValue { |x| Cow::from(format!("change `{}` to", x)), ) .as_ref(), - suggestion.into(), + suggestion, Applicability::Unspecified, ); } @@ -271,7 +271,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByValue { |x| Cow::from(format!("change `{}` to", x)) ) .as_ref(), - suggestion.into(), + suggestion, Applicability::Unspecified, ); }