diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs index f13d67b9c1584..eec88707d7cee 100644 --- a/compiler/rustc_ast/src/ast.rs +++ b/compiler/rustc_ast/src/ast.rs @@ -2003,7 +2003,6 @@ impl fmt::Display for InlineAsmTemplatePiece { impl InlineAsmTemplatePiece { /// Rebuilds the asm template string from its pieces. pub fn to_string(s: &[Self]) -> String { - use fmt::Write; let mut out = String::new(); for p in s.iter() { let _ = write!(out, "{}", p); diff --git a/compiler/rustc_ast_lowering/src/expr.rs b/compiler/rustc_ast_lowering/src/expr.rs index a6ac056b93b5e..e910e496dab95 100644 --- a/compiler/rustc_ast_lowering/src/expr.rs +++ b/compiler/rustc_ast_lowering/src/expr.rs @@ -14,7 +14,6 @@ use rustc_span::source_map::{respan, DesugaringKind, Span, Spanned}; use rustc_span::symbol::{sym, Ident, Symbol}; use rustc_target::asm; use std::collections::hash_map::Entry; -use std::fmt::Write; impl<'hir> LoweringContext<'_, 'hir> { fn lower_exprs(&mut self, exprs: &[AstP]) -> &'hir [hir::Expr<'hir>] { diff --git a/compiler/rustc_builtin_macros/src/format_foreign.rs b/compiler/rustc_builtin_macros/src/format_foreign.rs index b69b00d65f2be..ff0a42f6280fe 100644 --- a/compiler/rustc_builtin_macros/src/format_foreign.rs +++ b/compiler/rustc_builtin_macros/src/format_foreign.rs @@ -71,8 +71,6 @@ pub mod printf { /// Returns `None` in cases where the `printf` directive does not have an exact Rust /// equivalent, rather than guessing. pub fn translate(&self) -> Option { - use std::fmt::Write; - let (c_alt, c_zero, c_left, c_plus) = { let mut c_alt = false; let mut c_zero = false; @@ -245,7 +243,6 @@ pub mod printf { } fn translate(&self, s: &mut String) -> std::fmt::Result { - use std::fmt::Write; match *self { Num::Num(n) => write!(s, "{}", n), Num::Arg(n) => { diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs b/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs index 454d43fd4e7dc..e47866d719579 100644 --- a/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs +++ b/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs @@ -45,7 +45,7 @@ use tracing::debug; use libc::{c_longlong, c_uint}; use std::collections::hash_map::Entry; -use std::fmt::{self, Write}; +use std::fmt; use std::hash::{Hash, Hasher}; use std::iter; use std::path::{Path, PathBuf}; diff --git a/compiler/rustc_codegen_llvm/src/type_of.rs b/compiler/rustc_codegen_llvm/src/type_of.rs index e0754d21df1f0..9233f1144aa9e 100644 --- a/compiler/rustc_codegen_llvm/src/type_of.rs +++ b/compiler/rustc_codegen_llvm/src/type_of.rs @@ -11,8 +11,6 @@ use rustc_target::abi::{Int, Pointer, F32, F64}; use rustc_target::abi::{LayoutOf, PointeeInfo, Scalar, Size, TyAndLayoutMethods, Variants}; use tracing::debug; -use std::fmt::Write; - fn uncached_llvm_type<'a, 'tcx>( cx: &CodegenCx<'a, 'tcx>, layout: TyAndLayout<'tcx>, diff --git a/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs b/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs index c4c51d146a606..0bd20a6c54ba4 100644 --- a/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs +++ b/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs @@ -5,8 +5,6 @@ use rustc_hir as hir; use rustc_hir::def_id::DefId; use rustc_middle::ty::{self, subst::SubstsRef, Ty, TyCtxt}; -use std::fmt::Write; - // Compute the name of the type as it should be stored in debuginfo. Does not do // any caching, i.e., calling the function twice with the same type will also do // the work twice. The `qualified` parameter only affects the first level of the diff --git a/compiler/rustc_feature/src/active.rs b/compiler/rustc_feature/src/active.rs index ad926a810e6bf..30282df186446 100644 --- a/compiler/rustc_feature/src/active.rs +++ b/compiler/rustc_feature/src/active.rs @@ -610,6 +610,9 @@ declare_features! ( /// Allows unsized fn parameters. (active, unsized_fn_params, "1.49.0", Some(48055), None), + /// Allow `#[may_ignore]` attribute. + (active, may_ignore, "1.49.0", Some(99999999), None), + // ------------------------------------------------------------------------- // feature-group-end: actual feature gates // ------------------------------------------------------------------------- diff --git a/compiler/rustc_feature/src/builtin_attrs.rs b/compiler/rustc_feature/src/builtin_attrs.rs index 57ae534590ddf..ff7d66b83b829 100644 --- a/compiler/rustc_feature/src/builtin_attrs.rs +++ b/compiler/rustc_feature/src/builtin_attrs.rs @@ -206,6 +206,7 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[ ungated!(forbid, Normal, template!(List: r#"lint1, lint2, ..., /*opt*/ reason = "...""#)), ungated!(deny, Normal, template!(List: r#"lint1, lint2, ..., /*opt*/ reason = "...""#)), ungated!(must_use, AssumedUsed, template!(Word, NameValueStr: "reason")), + gated!(may_ignore, AssumedUsed, template!(Word), experimental!(may_ignore)), // FIXME(#14407) ungated!( deprecated, Normal, diff --git a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/placeholder_error.rs b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/placeholder_error.rs index 2187064ec5ecf..dd30e88e40b7b 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/placeholder_error.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/placeholder_error.rs @@ -11,7 +11,7 @@ use rustc_middle::ty::print::{FmtPrinter, Print, RegionHighlightMode}; use rustc_middle::ty::subst::SubstsRef; use rustc_middle::ty::{self, TyCtxt}; -use std::fmt::{self, Write}; +use std::fmt; impl NiceRegionError<'me, 'tcx> { /// When given a `ConcreteFailure` for a function with arguments containing a named region and diff --git a/compiler/rustc_lint/src/builtin.rs b/compiler/rustc_lint/src/builtin.rs index c65cf65b1c777..1f9274e57346a 100644 --- a/compiler/rustc_lint/src/builtin.rs +++ b/compiler/rustc_lint/src/builtin.rs @@ -54,7 +54,6 @@ use rustc_trait_selection::traits::misc::can_type_implement_copy; use crate::nonstandard_style::{method_context, MethodLateContext}; -use std::fmt::Write; use tracing::{debug, trace}; // hardwired lints from librustc_middle diff --git a/compiler/rustc_lint/src/unused.rs b/compiler/rustc_lint/src/unused.rs index 4bbc180b226a5..a8b24154f1728 100644 --- a/compiler/rustc_lint/src/unused.rs +++ b/compiler/rustc_lint/src/unused.rs @@ -101,11 +101,6 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults { return; } - let ty = cx.typeck_results().expr_ty(&expr); - let type_permits_lack_of_use = check_must_use_ty(cx, ty, &expr, s.span, "", "", 1); - - let mut fn_warned = false; - let mut op_warned = false; let maybe_def_id = match expr.kind { hir::ExprKind::Call(ref callee, _) => { match callee.kind { @@ -123,6 +118,21 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults { hir::ExprKind::MethodCall(..) => cx.typeck_results().type_dependent_def_id(expr.hir_id), _ => None, }; + + if let Some(def_id) = maybe_def_id { + for attr in cx.tcx.get_attrs(def_id).iter() { + if cx.sess().check_name(attr, sym::may_ignore) { + // Don't warn if the function was marked as #[may_ignore]. + return; + } + } + } + + let ty = cx.typeck_results().expr_ty(&expr); + let type_permits_lack_of_use = check_must_use_ty(cx, ty, &expr, s.span, "", "", 1); + + let mut fn_warned = false; + let mut op_warned = false; if let Some(def_id) = maybe_def_id { fn_warned = check_must_use_def(cx, def_id, s.span, "return value of ", ""); } else if type_permits_lack_of_use { diff --git a/compiler/rustc_middle/src/mir/mono.rs b/compiler/rustc_middle/src/mir/mono.rs index 1e70f7605045e..be2163bc2e3c9 100644 --- a/compiler/rustc_middle/src/mir/mono.rs +++ b/compiler/rustc_middle/src/mir/mono.rs @@ -453,8 +453,6 @@ impl CodegenUnitNameBuilder<'tcx> { C: fmt::Display, S: fmt::Display, { - use std::fmt::Write; - let mut cgu_name = String::with_capacity(64); // Start out with the crate name and disambiguator diff --git a/compiler/rustc_mir/src/interpret/validity.rs b/compiler/rustc_mir/src/interpret/validity.rs index 2d235d65c4d38..87b4a551659c2 100644 --- a/compiler/rustc_mir/src/interpret/validity.rs +++ b/compiler/rustc_mir/src/interpret/validity.rs @@ -5,7 +5,6 @@ //! to be const-safe. use std::convert::TryFrom; -use std::fmt::Write; use std::num::NonZeroUsize; use std::ops::RangeInclusive; diff --git a/compiler/rustc_mir/src/util/pretty.rs b/compiler/rustc_mir/src/util/pretty.rs index 8bee8417c51fa..309b7a58384d2 100644 --- a/compiler/rustc_mir/src/util/pretty.rs +++ b/compiler/rustc_mir/src/util/pretty.rs @@ -1,5 +1,4 @@ use std::collections::BTreeSet; -use std::fmt::Write as _; use std::fmt::{Debug, Display}; use std::fs; use std::io::{self, Write}; diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index 1a6c45b6c80d2..d39badefa471c 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -674,6 +674,7 @@ symbols! { maxnumf32, maxnumf64, may_dangle, + may_ignore, maybe_uninit, maybe_uninit_uninit, maybe_uninit_zeroed, diff --git a/compiler/rustc_symbol_mangling/src/v0.rs b/compiler/rustc_symbol_mangling/src/v0.rs index c28c2fecfbb43..08d3cf81fc67b 100644 --- a/compiler/rustc_symbol_mangling/src/v0.rs +++ b/compiler/rustc_symbol_mangling/src/v0.rs @@ -9,7 +9,6 @@ use rustc_middle::ty::subst::{GenericArg, GenericArgKind, Subst}; use rustc_middle::ty::{self, Instance, Ty, TyCtxt, TypeFoldable}; use rustc_target::spec::abi::Abi; -use std::fmt::Write; use std::ops::Range; pub(super) fn mangle( diff --git a/compiler/rustc_trait_selection/src/traits/specialize/mod.rs b/compiler/rustc_trait_selection/src/traits/specialize/mod.rs index 4d81a3baa0edc..961a33dd1b1da 100644 --- a/compiler/rustc_trait_selection/src/traits/specialize/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/specialize/mod.rs @@ -462,8 +462,6 @@ fn report_conflicting_impls( /// Recovers the "impl X for Y" signature from `impl_def_id` and returns it as a /// string. fn to_pretty_impl_header(tcx: TyCtxt<'_>, impl_def_id: DefId) -> Option { - use std::fmt::Write; - let trait_ref = tcx.impl_trait_ref(impl_def_id)?; let mut w = "impl".to_owned(); diff --git a/library/alloc/src/lib.rs b/library/alloc/src/lib.rs index 405667e0b2aa6..c96e34cc4e21b 100644 --- a/library/alloc/src/lib.rs +++ b/library/alloc/src/lib.rs @@ -106,6 +106,7 @@ #![feature(int_bits_const)] #![feature(lang_items)] #![feature(layout_for_ptr)] +#![cfg_attr(not(bootstrap), feature(may_ignore))] #![feature(maybe_uninit_ref)] #![feature(negative_impls)] #![feature(never_type)] diff --git a/library/alloc/src/string.rs b/library/alloc/src/string.rs index ce216e5336eb8..db183a4d709ba 100644 --- a/library/alloc/src/string.rs +++ b/library/alloc/src/string.rs @@ -1587,6 +1587,14 @@ impl String { let slice = self.vec.into_boxed_slice(); unsafe { from_boxed_utf8_unchecked(slice) } } + + #[doc(hidden)] + #[inline] + #[cfg_attr(not(bootstrap), may_ignore)] + #[stable(feature = "string_write_fmt", since = "1.49.0")] + pub fn write_fmt(mut self: &mut Self, args: fmt::Arguments<'_>) -> fmt::Result { + fmt::write(&mut self, args) + } } impl FromUtf8Error { @@ -2198,7 +2206,6 @@ impl ToString for T { // to try to remove it. #[inline] default fn to_string(&self) -> String { - use fmt::Write; let mut buf = String::new(); buf.write_fmt(format_args!("{}", self)) .expect("a Display implementation returned an error unexpectedly"); diff --git a/library/core/src/fmt/mod.rs b/library/core/src/fmt/mod.rs index 506d778068682..5cec5cc8495f8 100644 --- a/library/core/src/fmt/mod.rs +++ b/library/core/src/fmt/mod.rs @@ -1048,11 +1048,8 @@ pub trait UpperExp { /// Please note that using [`write!`] might be preferable. Example: /// /// ``` -/// use std::fmt::Write; -/// /// let mut output = String::new(); -/// write!(&mut output, "Hello {}!", "world") -/// .expect("Error occurred while trying to write in String"); +/// write!(&mut output, "Hello {}!", "world"); /// assert_eq!(output, "Hello world!"); /// ``` /// diff --git a/library/core/src/macros/mod.rs b/library/core/src/macros/mod.rs index 079d9f6006a32..ed2edde4cf772 100644 --- a/library/core/src/macros/mod.rs +++ b/library/core/src/macros/mod.rs @@ -348,25 +348,6 @@ macro_rules! r#try { /// } /// ``` /// -/// A module can import both `std::fmt::Write` and `std::io::Write` and call `write!` on objects -/// implementing either, as objects do not typically implement both. However, the module must -/// import the traits qualified so their names do not conflict: -/// -/// ``` -/// use std::fmt::Write as FmtWrite; -/// use std::io::Write as IoWrite; -/// -/// fn main() -> Result<(), Box> { -/// let mut s = String::new(); -/// let mut v = Vec::new(); -/// -/// write!(&mut s, "{} {}", "abc", 123)?; // uses fmt::Write::write_fmt -/// write!(&mut v, "s = {:?}", s)?; // uses io::Write::write_fmt -/// assert_eq!(v, b"s = \"abc 123\""); -/// Ok(()) -/// } -/// ``` -/// /// Note: This macro can be used in `no_std` setups as well. /// In a `no_std` setup you are responsible for the implementation details of the components. /// @@ -416,25 +397,6 @@ macro_rules! write { /// Ok(()) /// } /// ``` -/// -/// A module can import both `std::fmt::Write` and `std::io::Write` and call `write!` on objects -/// implementing either, as objects do not typically implement both. However, the module must -/// import the traits qualified so their names do not conflict: -/// -/// ``` -/// use std::fmt::Write as FmtWrite; -/// use std::io::Write as IoWrite; -/// -/// fn main() -> Result<(), Box> { -/// let mut s = String::new(); -/// let mut v = Vec::new(); -/// -/// writeln!(&mut s, "{} {}", "abc", 123)?; // uses fmt::Write::write_fmt -/// writeln!(&mut v, "s = {:?}", s)?; // uses io::Write::write_fmt -/// assert_eq!(v, b"s = \"abc 123\\n\"\n"); -/// Ok(()) -/// } -/// ``` #[macro_export] #[stable(feature = "rust1", since = "1.0.0")] #[allow_internal_unstable(format_args_nl)] diff --git a/library/core/tests/fmt/builders.rs b/library/core/tests/fmt/builders.rs index 129c121e8ceac..c3df105b038b1 100644 --- a/library/core/tests/fmt/builders.rs +++ b/library/core/tests/fmt/builders.rs @@ -398,8 +398,6 @@ mod debug_map { #[test] fn test_entry_err() { // Ensure errors in a map entry don't trigger panics (#65231) - use std::fmt::Write; - struct ErrorFmt; impl fmt::Debug for ErrorFmt { diff --git a/library/std/src/panicking.rs b/library/std/src/panicking.rs index fbbc61f4e600b..64048f6e8bf5d 100644 --- a/library/std/src/panicking.rs +++ b/library/std/src/panicking.rs @@ -452,8 +452,6 @@ pub fn begin_panic_handler(info: &PanicInfo<'_>) -> ! { } fn fill(&mut self) -> &mut String { - use crate::fmt::Write; - let inner = self.inner; // Lazily, the first time this gets called, run the actual string formatting. self.string.get_or_insert_with(|| { diff --git a/library/test/src/bench.rs b/library/test/src/bench.rs index 10546de17641d..a5fe99e2ff1e1 100644 --- a/library/test/src/bench.rs +++ b/library/test/src/bench.rs @@ -55,7 +55,6 @@ pub struct BenchSamples { } pub fn fmt_bench_samples(bs: &BenchSamples) -> String { - use std::fmt::Write; let mut output = String::new(); let median = bs.ns_iter_summ.median as usize; @@ -76,7 +75,6 @@ pub fn fmt_bench_samples(bs: &BenchSamples) -> String { // Format a number with thousands separators fn fmt_thousands_sep(mut n: usize, sep: char) -> String { - use std::fmt::Write; let mut output = String::new(); let mut trailing = false; for &pow in &[9, 6, 3, 0] { diff --git a/src/bootstrap/setup.rs b/src/bootstrap/setup.rs index 55d2445fc492c..07c0b478e3c0b 100644 --- a/src/bootstrap/setup.rs +++ b/src/bootstrap/setup.rs @@ -1,4 +1,5 @@ use crate::{t, VERSION}; +#[allow(unused_imports)] use std::fmt::Write as _; use std::path::{Path, PathBuf}; use std::process::Command; diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index d18282d6e675d..fd1ce497f4fe6 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -92,7 +92,6 @@ impl Buffer { // the fmt::Result return type imposed by fmt::Write (and avoiding the trait // import). crate fn write_fmt(&mut self, v: fmt::Arguments<'_>) { - use fmt::Write; self.buffer.write_fmt(v).unwrap(); } diff --git a/src/librustdoc/html/highlight.rs b/src/librustdoc/html/highlight.rs index 4769edc50ff07..45bb3911c16ee 100644 --- a/src/librustdoc/html/highlight.rs +++ b/src/librustdoc/html/highlight.rs @@ -7,7 +7,7 @@ use crate::html::escape::Escape; -use std::fmt::{Display, Write}; +use std::fmt::Display; use std::iter::Peekable; use rustc_lexer::{LiteralKind, TokenKind}; diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs index ca8b811681cc9..8ada0f02d0e82 100644 --- a/src/librustdoc/html/markdown.rs +++ b/src/librustdoc/html/markdown.rs @@ -29,7 +29,6 @@ use rustc_span::Span; use std::borrow::Cow; use std::collections::VecDeque; use std::default::Default; -use std::fmt::Write; use std::ops::Range; use std::str; diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index 5ac0ffcfbf1c2..66b1586d17339 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -36,7 +36,7 @@ use std::cmp::Ordering; use std::collections::{BTreeMap, VecDeque}; use std::default::Default; use std::ffi::OsStr; -use std::fmt::{self, Write}; +use std::fmt; use std::fs::{self, File}; use std::io::prelude::*; use std::io::{self, BufReader}; diff --git a/src/test/ui/feature-gate-may_ignore.rs b/src/test/ui/feature-gate-may_ignore.rs new file mode 100644 index 0000000000000..4494961090849 --- /dev/null +++ b/src/test/ui/feature-gate-may_ignore.rs @@ -0,0 +1,4 @@ +#[may_ignore] +//~^ ERROR the `#[may_ignore]` attribute is an experimental feature [E0658] +fn main() { +} diff --git a/src/test/ui/feature-gate-may_ignore.stderr b/src/test/ui/feature-gate-may_ignore.stderr new file mode 100644 index 0000000000000..cf4735bc3ef28 --- /dev/null +++ b/src/test/ui/feature-gate-may_ignore.stderr @@ -0,0 +1,12 @@ +error[E0658]: the `#[may_ignore]` attribute is an experimental feature + --> $DIR/feature-gate-may_ignore.rs:1:1 + | +LL | #[may_ignore] + | ^^^^^^^^^^^^^ + | + = note: see issue #99999999 for more information + = help: add `#![feature(may_ignore)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/impl-trait/example-calendar.rs b/src/test/ui/impl-trait/example-calendar.rs index 238f3fa31ed72..b7bcf92e172c1 100644 --- a/src/test/ui/impl-trait/example-calendar.rs +++ b/src/test/ui/impl-trait/example-calendar.rs @@ -11,8 +11,6 @@ //! //! Originally converted to Rust by [Daniel Keep](https://github.com/DanielKeep). -use std::fmt::Write; - /// Date representation. #[derive(Copy, Clone, Debug, Eq, Ord, PartialEq, PartialOrd)] struct NaiveDate(i32, u32, u32); diff --git a/src/test/ui/macros/must-use-in-macro-55516.rs b/src/test/ui/macros/must-use-in-macro-55516.rs deleted file mode 100644 index e7c3462867b59..0000000000000 --- a/src/test/ui/macros/must-use-in-macro-55516.rs +++ /dev/null @@ -1,10 +0,0 @@ -// check-pass -// compile-flags: -Wunused - -// make sure write!() can't hide its unused Result - -fn main() { - use std::fmt::Write; - let mut example = String::new(); - write!(&mut example, "{}", 42); //~WARN must be used -} diff --git a/src/test/ui/macros/must-use-in-macro-55516.stderr b/src/test/ui/macros/must-use-in-macro-55516.stderr deleted file mode 100644 index a694c887085f0..0000000000000 --- a/src/test/ui/macros/must-use-in-macro-55516.stderr +++ /dev/null @@ -1,12 +0,0 @@ -warning: unused `std::result::Result` that must be used - --> $DIR/must-use-in-macro-55516.rs:9:5 - | -LL | write!(&mut example, "{}", 42); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: `-W unused-must-use` implied by `-W unused` - = note: this `Result` may be an `Err` variant, which should be handled - = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) - -warning: 1 warning emitted - diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index d46f905e6cc52..57a1f324c5959 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -179,6 +179,7 @@ pub fn make_diff(expected: &str, actual: &str, context_size: usize) -> Vec String { + #[allow(unused_imports)] use std::fmt::Write; let mut output = String::new(); let diff_results = make_diff(expected, actual, context_size); @@ -3300,6 +3301,7 @@ impl<'test> TestCx<'test> { let after = self.normalize_output(&after, &[]); let mut dumped_string = String::new(); for result in diff::lines(&before, &after) { + #[allow(unused_imports)] use std::fmt::Write; match result { diff::Result::Left(s) => writeln!(dumped_string, "- {}", s).unwrap(),