]> git.lizzy.rs Git - rust.git/commitdiff
clippy::useless_format
authorMatthias Krüger <matthias.krueger@famsik.de>
Wed, 21 Jul 2021 20:43:19 +0000 (22:43 +0200)
committerMatthias Krüger <matthias.krueger@famsik.de>
Sun, 25 Jul 2021 10:26:03 +0000 (12:26 +0200)
14 files changed:
compiler/rustc_lint/src/types.rs
compiler/rustc_macros/src/symbols.rs
compiler/rustc_mir/src/borrow_check/diagnostics/conflict_errors.rs
compiler/rustc_mir/src/borrow_check/diagnostics/mutability_errors.rs
compiler/rustc_mir/src/transform/check_consts/ops.rs
compiler/rustc_mir/src/transform/coverage/debug.rs
compiler/rustc_mir/src/transform/lower_intrinsics.rs
compiler/rustc_mir/src/util/pretty.rs
compiler/rustc_passes/src/check_attr.rs
compiler/rustc_passes/src/entry.rs
compiler/rustc_query_system/src/query/plumbing.rs
compiler/rustc_resolve/src/late/diagnostics.rs
compiler/rustc_target/src/spec/mod.rs
compiler/rustc_typeck/src/check/method/prelude2021.rs

index a3a87a48768dcde44bfa80ff9e1dc482229a38bb..55961636f3216bd8b27c9bc0a84cecd14378e543 100644 (file)
@@ -906,7 +906,7 @@ fn check_type_for_ffi(&self, cache: &mut FxHashSet<Ty<'tcx>>, ty: Ty<'tcx>) -> F
                     } else {
                         return FfiUnsafe {
                             ty,
-                            reason: format!("box cannot be represented as a single pointer"),
+                            reason: "box cannot be represented as a single pointer".to_string(),
                             help: None,
                         };
                     }
index 2f063f75eb0ef792634ff566eae9fbb2c5bfbf1d..c52304e54742112b0d548877e0288766f7bdc71f 100644 (file)
@@ -135,7 +135,7 @@ fn symbols_with_errors(input: TokenStream) -> (TokenStream, Vec<syn::Error>) {
     let mut check_dup = |span: Span, str: &str, errors: &mut Errors| {
         if let Some(prev_span) = keys.get(str) {
             errors.error(span, format!("Symbol `{}` is duplicated", str));
-            errors.error(*prev_span, format!("location of previous definition"));
+            errors.error(*prev_span, "location of previous definition".to_string());
         } else {
             keys.insert(str.to_string(), span);
         }
index 2e854ea5be7df7046321a33dde452c5a84a38d30..e43973b8db40c53c7a38c0bd7636121e72875f0b 100644 (file)
@@ -320,7 +320,7 @@ pub(in crate::borrow_check) fn report_use_of_moved_or_uninitialized(
                                         .map(|n| format!("`{}`", n))
                                         .unwrap_or_else(|| "the mutable reference".to_string()),
                                 ),
-                                format!("&mut *"),
+                                "&mut *".to_string(),
                                 Applicability::MachineApplicable,
                             );
                         }
index 671d947d1b1321f2ac7d1797e53e9914794520d3..d3f9e49816ade304bf2393abe25422a84c81d80e 100644 (file)
@@ -721,7 +721,7 @@ fn maybe_body_id_of_fn(hir_map: &Map<'tcx>, id: HirId) -> Option<BodyId> {
                     if suggestions.peek().is_some() {
                         err.span_suggestions(
                             path_segment.ident.span,
-                            &format!("use mutable method"),
+                            "use mutable method",
                             suggestions,
                             Applicability::MaybeIncorrect,
                         );
index fd72ec4340f9f2a7f9c462c9039f3888998e70c2..92de8bd292c3d96ee28d7ec2692d2d9ccac39bee 100644 (file)
@@ -255,7 +255,7 @@ fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<
         );
         err.span_label(
             span,
-            format!("this borrow of an interior mutable value may end up in the final value"),
+            "this borrow of an interior mutable value may end up in the final value",
         );
         if let hir::ConstContext::Static(_) = ccx.const_kind() {
             err.help(
index f6672335cb1385d6e80b58767dd6a7755524c66b..6fd7d29d7779712860d0c0be87da30b943d36e37 100644 (file)
@@ -344,7 +344,7 @@ fn format_counter_kind(&self, counter_kind: &CoverageKind) -> String {
                 return if counter_format.id {
                     format!("{}#{}", block_label, id.index())
                 } else {
-                    format!("{}", block_label)
+                    block_label.to_string()
                 };
             }
         }
@@ -369,7 +369,7 @@ fn format_operand(&self, operand: ExpressionOperandId) -> String {
                     }
                     return format!("({})", self.format_counter_kind(counter_kind));
                 }
-                return format!("{}", self.format_counter_kind(counter_kind));
+                return self.format_counter_kind(counter_kind).to_string();
             }
         }
         format!("#{}", operand.index().to_string())
index 6d7e4cdb1c6efcd282c64f293a03aadb97de9167..aff2df31b1c96cb4f0ae80e2419761f7e2652668 100644 (file)
@@ -147,8 +147,8 @@ fn validate_simd_shuffle(tcx: TyCtxt<'tcx>, args: &[Operand<'tcx>], span: Span)
     match &args[2] {
         Operand::Constant(_) => {} // all good
         _ => {
-            let msg = format!("last argument of `simd_shuffle` is required to be a `const` item");
-            tcx.sess.span_err(span, &msg);
+            let msg = "last argument of `simd_shuffle` is required to be a `const` item";
+            tcx.sess.span_err(span, msg);
         }
     }
 }
index d0b1bc47ea80063cf6a7ea21651653915cebfc31..7598a011bb6771619541fbab1865cdcd1b2f23da 100644 (file)
@@ -479,7 +479,7 @@ fn visit_const(&mut self, constant: &&'tcx ty::Const<'tcx>, _: Location) {
                     uv.promoted
                 ),
                 ty::ConstKind::Value(val) => format!("Value({:?})", val),
-                ty::ConstKind::Error(_) => format!("Error"),
+                ty::ConstKind::Error(_) => "Error".to_string(),
             };
             self.push(&format!("+ val: {}", val));
         }
index 71231830e99a7afe2b2746264eec5efbf97efc87..cd3e6e2f48cfd801af3f1321352c8946b2780bda 100644 (file)
@@ -855,7 +855,7 @@ fn check_doc_attrs(
                         hir_id,
                         meta.span(),
                         |lint| {
-                            lint.build(&format!("invalid `doc` attribute")).emit();
+                            lint.build(&"invalid `doc` attribute").emit();
                         },
                     );
                     is_valid = false;
index 550f4f148fd24abc74d07c4280a6e1ebb044a8a4..0b5dcd1a087dd7ade873564acc394e83962c3345 100644 (file)
@@ -229,7 +229,7 @@ fn no_main_err(tcx: TyCtxt<'_>, visitor: &EntryContext<'_, '_>) {
     if let Some(main_def) = tcx.resolutions(()).main_def {
         if main_def.opt_fn_def_id().is_none() {
             // There is something at `crate::main`, but it is not a function definition.
-            err.span_label(main_def.span, &format!("non-function item at `crate::main` is found"));
+            err.span_label(main_def.span, "non-function item at `crate::main` is found");
         }
     }
 
index c227c2aaff549164f2101449b12dac782666132e..a0c2b3d82abce1a8bf30850f940c6420d53927d4 100644 (file)
@@ -618,8 +618,8 @@ fn incremental_verify_ich<CTX, K, V: Debug>(
         };
         tcx.sess().struct_err(&format!("internal compiler error: encountered incremental compilation error with {:?}", dep_node))
             .help(&format!("This is a known issue with the compiler. Run {} to allow your project to compile", run_cmd))
-            .note(&format!("Please follow the instructions below to create a bug report with the provided information"))
-            .note(&format!("See <https://github.com/rust-lang/rust/issues/84970> for more information"))
+            .note(&"Please follow the instructions below to create a bug report with the provided information")
+            .note(&"See <https://github.com/rust-lang/rust/issues/84970> for more information")
             .emit();
         panic!("Found unstable fingerprints for {:?}: {:?}", dep_node, result);
     }
index 76979ab50b9e6654b2778b47428670a034e2f522..e3ab858541af412c73bf4882a00637c925f4316f 100644 (file)
@@ -1061,7 +1061,7 @@ fn smart_resolve_context_dependent_help(
                         }
                         err.span_suggestion(
                             span,
-                            &format!("use this syntax instead"),
+                            &"use this syntax instead",
                             format!("{path_str}"),
                             Applicability::MaybeIncorrect,
                         );
index ad84e07edfba620ce90423e76861f287734f817e..7f349ef10d348ddd8799540b6baae5d2b759e96c 100644 (file)
@@ -2018,7 +2018,7 @@ macro_rules! key {
 
         if base.is_builtin {
             // This can cause unfortunate ICEs later down the line.
-            return Err(format!("may not set is_builtin for targets not built-in"));
+            return Err("may not set is_builtin for targets not built-in".to_string());
         }
         // Each field should have been read using `Json::remove_key` so any keys remaining are unused.
         let remaining_keys = obj.as_object().ok_or("Expected JSON object for target")?.keys();
index f13e23914f7ab54b35a31737c680405943c000a4..f4644f7514d2a94c52f7aed81594e4df6da8e0bd 100644 (file)
@@ -342,7 +342,7 @@ fn adjust_expr(&self, pick: &Pick<'tcx>, expr: &hir::Expr<'tcx>) -> (String, boo
             if let Ok(expr_text) = self.sess().source_map().span_to_snippet(expr.span) {
                 (expr_text, true)
             } else {
-                (format!("(..)"), false)
+                ("(..)".to_string(), false)
             };
 
         let adjusted_text = if let Some(probe::AutorefOrPtrAdjustment::ToConstPtr) =