]> git.proxmox.com Git - rustc.git/blobdiff - compiler/rustc_lint/src/non_fmt_panic.rs
New upstream version 1.62.1+dfsg1
[rustc.git] / compiler / rustc_lint / src / non_fmt_panic.rs
index f21f25c35847eb0b6dc0209271ac5c5f27aa0c20..4e7aeca9ce1d5c881baa52d404d08b349c4d4c01 100644 (file)
@@ -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,
                 );
             }
@@ -254,7 +254,10 @@ fn check_panic_str<'tcx>(
     if n_arguments > 0 && fmt_parser.errors.is_empty() {
         let arg_spans: Vec<_> = match &fmt_parser.arg_places[..] {
             [] => vec![fmt_span],
-            v => v.iter().map(|span| fmt_span.from_inner(*span)).collect(),
+            v => v
+                .iter()
+                .map(|span| fmt_span.from_inner(InnerSpan::new(span.start, span.end)))
+                .collect(),
         };
         cx.struct_span_lint(NON_FMT_PANICS, arg_spans, |lint| {
             let mut l = lint.build(match n_arguments {
@@ -266,13 +269,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 +300,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,
                 );
             }