Auto merge of #9069 - flip1995:rustup, r=flip1995

Rustup

r? `@ghost`

changelog: none
This commit is contained in:
bors 2022-06-30 08:32:54 +00:00
commit 0cb0f76368
43 changed files with 267 additions and 289 deletions

View File

@ -1,6 +1,6 @@
[package]
name = "clippy"
version = "0.1.63"
version = "0.1.64"
description = "A bunch of helpful lints to avoid common pitfalls in Rust"
repository = "https://github.com/rust-lang/rust-clippy"
readme = "README.md"

View File

@ -4,12 +4,12 @@
use crate::cargo_clippy_path;
use std::ffi::OsStr;
use std::fs;
use std::lazy::SyncLazy;
use std::path::{Path, PathBuf};
use std::sync::LazyLock;
use walkdir::{DirEntry, WalkDir};
static CLIPPY_BUILD_TIME: SyncLazy<Option<std::time::SystemTime>> =
SyncLazy::new(|| cargo_clippy_path().metadata().ok()?.modified().ok());
static CLIPPY_BUILD_TIME: LazyLock<Option<std::time::SystemTime>> =
LazyLock::new(|| cargo_clippy_path().metadata().ok()?.modified().ok());
/// # Panics
///

View File

@ -1,6 +1,6 @@
[package]
name = "clippy_lints"
version = "0.1.63"
version = "0.1.64"
description = "A bunch of helpful lints to avoid common pitfalls in Rust"
repository = "https://github.com/rust-lang/rust-clippy"
readme = "README.md"

View File

@ -1,4 +1,4 @@
use clippy_utils::diagnostics::span_lint_and_sugg_for_edges;
use clippy_utils::diagnostics::span_lint_and_sugg;
use clippy_utils::is_trait_method;
use clippy_utils::source::snippet_with_applicability;
use clippy_utils::ty::is_type_diagnostic_item;
@ -14,17 +14,17 @@ use super::MAP_FLATTEN;
pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, recv: &Expr<'_>, map_arg: &Expr<'_>, map_span: Span) {
if let Some((caller_ty_name, method_to_use)) = try_get_caller_ty_name_and_method_name(cx, expr, recv, map_arg) {
let mut applicability = Applicability::MachineApplicable;
let help_msgs = [
&format!("try replacing `map` with `{}`", method_to_use),
"and remove the `.flatten()`",
];
let closure_snippet = snippet_with_applicability(cx, map_arg.span, "..", &mut applicability);
span_lint_and_sugg_for_edges(
span_lint_and_sugg(
cx,
MAP_FLATTEN,
expr.span.with_lo(map_span.lo()),
&format!("called `map(..).flatten()` on `{}`", caller_ty_name),
&help_msgs,
&format!(
"try replacing `map` with `{}` and remove the `.flatten()`",
method_to_use
),
format!("{}({})", method_to_use, closure_snippet),
applicability,
);

View File

@ -4,7 +4,6 @@ use clippy_utils::source::{snippet, snippet_with_applicability, snippet_with_mac
use clippy_utils::ty::{implements_trait, match_type};
use clippy_utils::{contains_return, is_trait_item, last_path_segment, paths};
use if_chain::if_chain;
use rustc_errors::emitter::MAX_SUGGESTION_HIGHLIGHT_LINES;
use rustc_errors::Applicability;
use rustc_hir as hir;
use rustc_lint::LateContext;
@ -33,7 +32,6 @@ pub(super) fn check<'tcx>(
arg: &hir::Expr<'_>,
or_has_args: bool,
span: Span,
method_span: Span,
) -> bool {
let is_default_default = || is_trait_item(cx, fun, sym::Default);
@ -56,19 +54,14 @@ pub(super) fn check<'tcx>(
then {
let mut applicability = Applicability::MachineApplicable;
let hint = "unwrap_or_default()";
let mut sugg_span = span;
let sugg_span = span;
let mut sugg: String = format!(
let sugg: String = format!(
"{}.{}",
snippet_with_applicability(cx, self_expr.span, "..", &mut applicability),
hint
);
if sugg.lines().count() > MAX_SUGGESTION_HIGHLIGHT_LINES {
sugg_span = method_span.with_hi(span.hi());
sugg = hint.to_string();
}
span_lint_and_sugg(
cx,
OR_FUN_CALL,
@ -178,7 +171,7 @@ pub(super) fn check<'tcx>(
match inner_arg.kind {
hir::ExprKind::Call(fun, or_args) => {
let or_has_args = !or_args.is_empty();
if !check_unwrap_or_default(cx, name, fun, self_arg, arg, or_has_args, expr.span, method_span) {
if !check_unwrap_or_default(cx, name, fun, self_arg, arg, or_has_args, expr.span) {
let fun_span = if or_has_args { None } else { Some(fun.span) };
check_general_case(cx, name, method_span, self_arg, arg, expr.span, fun_span);
}

View File

@ -104,7 +104,7 @@ macro_rules! RENAME_VALUE_TEMPLATE {
};
}
const LINT_EMISSION_FUNCTIONS: [&[&str]; 8] = [
const LINT_EMISSION_FUNCTIONS: [&[&str]; 7] = [
&["clippy_utils", "diagnostics", "span_lint"],
&["clippy_utils", "diagnostics", "span_lint_and_help"],
&["clippy_utils", "diagnostics", "span_lint_and_note"],
@ -112,7 +112,6 @@ const LINT_EMISSION_FUNCTIONS: [&[&str]; 8] = [
&["clippy_utils", "diagnostics", "span_lint_and_sugg"],
&["clippy_utils", "diagnostics", "span_lint_and_then"],
&["clippy_utils", "diagnostics", "span_lint_hir_and_then"],
&["clippy_utils", "diagnostics", "span_lint_and_sugg_for_edges"],
];
const SUGGESTION_DIAGNOSTIC_BUILDER_METHODS: [(&str, bool); 9] = [
("span_suggestion", false),

View File

@ -1,6 +1,6 @@
[package]
name = "clippy_utils"
version = "0.1.63"
version = "0.1.64"
edition = "2021"
publish = false

View File

@ -8,7 +8,7 @@
//! Thank you!
//! ~The `INTERNAL_METADATA_COLLECTOR` lint
use rustc_errors::{emitter::MAX_SUGGESTION_HIGHLIGHT_LINES, Applicability, Diagnostic, MultiSpan};
use rustc_errors::{Applicability, Diagnostic, MultiSpan};
use rustc_hir::HirId;
use rustc_lint::{LateContext, Lint, LintContext};
use rustc_span::source_map::Span;
@ -213,93 +213,6 @@ pub fn span_lint_and_sugg<'a, T: LintContext>(
});
}
/// Like [`span_lint_and_sugg`] with a focus on the edges. The output will either
/// emit single span or multispan suggestion depending on the number of its lines.
///
/// If the given suggestion string has more lines than the maximum display length defined by
/// [`MAX_SUGGESTION_HIGHLIGHT_LINES`][`rustc_errors::emitter::MAX_SUGGESTION_HIGHLIGHT_LINES`],
/// this function will split the suggestion and span to showcase the change for the top and
/// bottom edge of the code. For normal suggestions, in one display window, the help message
/// will be combined with a colon.
///
/// Multipart suggestions like the one being created here currently cannot be
/// applied by rustfix (See [rustfix#141](https://github.com/rust-lang/rustfix/issues/141)).
/// Testing rustfix with this lint emission function might require a file with
/// suggestions that can be fixed and those that can't. See
/// [clippy#8520](https://github.com/rust-lang/rust-clippy/pull/8520/files) for
/// an example and of this.
///
/// # Example for a long suggestion
///
/// ```text
/// error: called `map(..).flatten()` on `Option`
/// --> $DIR/map_flatten.rs:8:10
/// |
/// LL | .map(|x| {
/// | __________^
/// LL | | if x <= 5 {
/// LL | | Some(x)
/// LL | | } else {
/// ... |
/// LL | | })
/// LL | | .flatten();
/// | |__________________^
/// |
/// = note: `-D clippy::map-flatten` implied by `-D warnings`
/// help: try replacing `map` with `and_then`
/// |
/// LL ~ .and_then(|x| {
/// LL + if x <= 5 {
/// LL + Some(x)
/// |
/// help: and remove the `.flatten()`
/// |
/// LL + None
/// LL + }
/// LL ~ });
/// |
/// ```
pub fn span_lint_and_sugg_for_edges(
cx: &LateContext<'_>,
lint: &'static Lint,
sp: Span,
msg: &str,
helps: &[&str; 2],
sugg: String,
applicability: Applicability,
) {
span_lint_and_then(cx, lint, sp, msg, |diag| {
let sugg_lines_count = sugg.lines().count();
if sugg_lines_count > MAX_SUGGESTION_HIGHLIGHT_LINES {
let sm = cx.sess().source_map();
if let (Ok(line_upper), Ok(line_bottom)) = (sm.lookup_line(sp.lo()), sm.lookup_line(sp.hi())) {
let split_idx = MAX_SUGGESTION_HIGHLIGHT_LINES / 2;
let span_upper = sm.span_until_char(
sp.with_hi(line_upper.sf.lines(|lines| lines[line_upper.line + split_idx])),
'\n',
);
let span_bottom = sp.with_lo(line_bottom.sf.lines(|lines| lines[line_bottom.line - split_idx]));
let sugg_lines_vec = sugg.lines().collect::<Vec<&str>>();
let sugg_upper = sugg_lines_vec[..split_idx].join("\n");
let sugg_bottom = sugg_lines_vec[sugg_lines_count - split_idx..].join("\n");
diag.span_suggestion(span_upper, helps[0], sugg_upper, applicability);
diag.span_suggestion(span_bottom, helps[1], sugg_bottom, applicability);
return;
}
}
diag.span_suggestion_with_style(
sp,
&helps.join(", "),
sugg,
applicability,
rustc_errors::SuggestionStyle::ShowAlways,
);
});
}
/// Create a suggestion made from several `span → replacement`.
///
/// Note: in the JSON format (used by `compiletest_rs`), the help message will

View File

@ -16,6 +16,10 @@ use rustc_middle::ty::TypeckResults;
use rustc_span::{sym, Symbol};
use std::hash::{Hash, Hasher};
/// Callback that is called when two expressions are not equal in the sense of `SpanlessEq`, but
/// other conditions would make them equal.
type SpanlessEqCallback<'a> = dyn FnMut(&Expr<'_>, &Expr<'_>) -> bool + 'a;
/// Type used to check whether two ast are the same. This is different from the
/// operator `==` on ast types as this operator would compare true equality with
/// ID and span.
@ -26,7 +30,7 @@ pub struct SpanlessEq<'a, 'tcx> {
cx: &'a LateContext<'tcx>,
maybe_typeck_results: Option<(&'tcx TypeckResults<'tcx>, &'tcx TypeckResults<'tcx>)>,
allow_side_effects: bool,
expr_fallback: Option<Box<dyn FnMut(&Expr<'_>, &Expr<'_>) -> bool + 'a>>,
expr_fallback: Option<Box<SpanlessEqCallback<'a>>>,
}
impl<'a, 'tcx> SpanlessEq<'a, 'tcx> {

View File

@ -64,7 +64,7 @@ pub use self::hir_utils::{
use std::collections::hash_map::Entry;
use std::hash::BuildHasherDefault;
use std::lazy::SyncOnceCell;
use std::sync::OnceLock;
use std::sync::{Mutex, MutexGuard};
use if_chain::if_chain;
@ -2099,7 +2099,7 @@ pub fn is_hir_ty_cfg_dependant(cx: &LateContext<'_>, ty: &hir::Ty<'_>) -> bool {
false
}
static TEST_ITEM_NAMES_CACHE: SyncOnceCell<Mutex<FxHashMap<LocalDefId, Vec<Symbol>>>> = SyncOnceCell::new();
static TEST_ITEM_NAMES_CACHE: OnceLock<Mutex<FxHashMap<LocalDefId, Vec<Symbol>>>> = OnceLock::new();
fn with_test_item_names<'tcx>(tcx: TyCtxt<'tcx>, module: LocalDefId, f: impl Fn(&[Symbol]) -> bool) -> bool {
let cache = TEST_ITEM_NAMES_CACHE.get_or_init(|| Mutex::new(FxHashMap::default()));

View File

@ -771,7 +771,7 @@ impl<T: LintContext> DiagnosticExt<T> for rustc_errors::Diagnostic {
}
}
self.span_suggestion(remove_span, msg, String::new(), applicability);
self.span_suggestion(remove_span, msg, "", applicability);
}
}

View File

@ -1,3 +1,3 @@
[toolchain]
channel = "nightly-2022-06-16"
channel = "nightly-2022-06-30"
components = ["cargo", "llvm-tools-preview", "rust-src", "rust-std", "rustc", "rustc-dev", "rustfmt"]

View File

@ -21,11 +21,11 @@ use rustc_tools_util::VersionInfo;
use std::borrow::Cow;
use std::env;
use std::lazy::SyncLazy;
use std::ops::Deref;
use std::panic;
use std::path::{Path, PathBuf};
use std::process::{exit, Command};
use std::sync::LazyLock;
/// If a command-line option matches `find_arg`, then apply the predicate `pred` on its value. If
/// true, then return it. The parameter is assumed to be either `--arg=value` or `--arg value`.
@ -153,7 +153,8 @@ You can use tool lints to allow or deny lints from your code, eg.:
const BUG_REPORT_URL: &str = "https://github.com/rust-lang/rust-clippy/issues/new";
static ICE_HOOK: SyncLazy<Box<dyn Fn(&panic::PanicInfo<'_>) + Sync + Send + 'static>> = SyncLazy::new(|| {
type PanicCallback = dyn Fn(&panic::PanicInfo<'_>) + Sync + Send + 'static;
static ICE_HOOK: LazyLock<Box<PanicCallback>> = LazyLock::new(|| {
let hook = panic::take_hook();
panic::set_hook(Box::new(|info| report_clippy_ice(info, BUG_REPORT_URL)));
hook
@ -220,7 +221,7 @@ fn toolchain_path(home: Option<String>, toolchain: Option<String>) -> Option<Pat
#[allow(clippy::too_many_lines)]
pub fn main() {
rustc_driver::init_rustc_env_logger();
SyncLazy::force(&ICE_HOOK);
LazyLock::force(&ICE_HOOK);
exit(rustc_driver::catch_with_exit_code(move || {
let mut orig_args: Vec<String> = env::args().collect();

View File

@ -12,8 +12,8 @@ use std::env::{self, remove_var, set_var, var_os};
use std::ffi::{OsStr, OsString};
use std::fs;
use std::io;
use std::lazy::SyncLazy;
use std::path::{Path, PathBuf};
use std::sync::LazyLock;
use test_utils::IS_RUSTC_TEST_SUITE;
mod test_utils;
@ -75,7 +75,7 @@ extern crate tokio;
/// dependencies must be added to Cargo.toml at the project root. Test
/// dependencies that are not *directly* used by this test module require an
/// `extern crate` declaration.
static EXTERN_FLAGS: SyncLazy<String> = SyncLazy::new(|| {
static EXTERN_FLAGS: LazyLock<String> = LazyLock::new(|| {
let current_exe_depinfo = {
let mut path = env::current_exe().unwrap();
path.set_extension("d");

View File

@ -1,9 +1,9 @@
#![allow(dead_code)] // see https://github.com/rust-lang/rust/issues/46379
use std::lazy::SyncLazy;
use std::path::PathBuf;
use std::sync::LazyLock;
pub static CARGO_CLIPPY_PATH: SyncLazy<PathBuf> = SyncLazy::new(|| {
pub static CARGO_CLIPPY_PATH: LazyLock<PathBuf> = LazyLock::new(|| {
let mut path = std::env::current_exe().unwrap();
assert!(path.pop()); // deps
path.set_file_name("cargo-clippy");

View File

@ -56,7 +56,25 @@ LL | if s == "43" {
LL ~ return 43;
LL | }
LL | s == "42"
LL | } {
LL ~ return 45;
LL | }
LL | match s.len() {
LL ~ 10 => 2,
LL | 20 => {
...
LL | if foo() {
LL ~ return 20;
LL | }
LL | println!("foo");
LL ~ 3
LL | };
LL | }
LL ~ 20
LL | },
LL ~ 40 => 30,
LL ~ _ => 1,
|
error: using `Option.and_then(|x| Some(y))`, which is more succinctly expressed as `map(|x| y)`
--> $DIR/bind_instead_of_map_multipart.rs:61:13

View File

@ -98,7 +98,8 @@ LL + id: e_id,
LL + name: "Player 1".to_string(),
LL + some_data: vec![0x12, 0x34, 0x56, 0x78, 0x90],
LL + };
...
LL + process_data(pack);
|
error: all if blocks contain the same code at both the start and the end
--> $DIR/shared_at_top_and_bottom.rs:94:5

View File

@ -28,7 +28,8 @@ LL + v
LL + } else {
LL + v2
LL + }
...
LL + });
|
error: usage of `contains_key` followed by `insert` on a `HashMap`
--> $DIR/entry.rs:38:5
@ -50,7 +51,8 @@ LL + v
LL + } else {
LL + v2
LL + }
...
LL + });
|
error: usage of `contains_key` followed by `insert` on a `HashMap`
--> $DIR/entry.rs:47:5
@ -72,7 +74,9 @@ LL + e.insert(v);
LL + } else {
LL + e.insert(v2);
LL + return;
...
LL + }
LL + }
|
error: usage of `contains_key` followed by `insert` on a `HashMap`
--> $DIR/entry.rs:57:5
@ -111,7 +115,11 @@ LL + 1 if true => {
LL + v
LL + },
LL + _ => {
...
LL + v2
LL + },
LL + }
LL + });
|
error: usage of `contains_key` followed by `insert` on a `HashMap`
--> $DIR/entry.rs:75:5
@ -133,7 +141,9 @@ LL + 0 => foo(),
LL + _ => {
LL + e.insert(v2);
LL + },
...
LL + };
LL + }
|
error: usage of `contains_key` followed by `insert` on a `HashMap`
--> $DIR/entry.rs:85:5
@ -155,7 +165,26 @@ LL + match 0 {
LL + 0 if false => {
LL + v
LL + },
...
LL + 1 => {
LL + foo();
LL + v
LL + },
LL + 2 | 3 => {
LL + for _ in 0..2 {
LL + foo();
LL + }
LL + if true {
LL + v
LL + } else {
LL + v2
LL + }
LL + },
LL + _ => {
LL + v2
LL + },
LL + }
LL + });
|
error: usage of `contains_key` followed by `insert` on a `HashMap`
--> $DIR/entry.rs:119:5

View File

@ -17,7 +17,9 @@ LL + e.insert(v);
LL + }
LL + std::collections::hash_map::Entry::Occupied(mut e) => {
LL + e.insert(v2);
...
LL + }
LL + }
|
error: usage of `contains_key` followed by `insert` on a `HashMap`
--> $DIR/entry_with_else.rs:22:5
@ -37,7 +39,9 @@ LL + e.insert(v);
LL + }
LL + std::collections::hash_map::Entry::Vacant(e) => {
LL + e.insert(v2);
...
LL + }
LL + }
|
error: usage of `contains_key` followed by `insert` on a `HashMap`
--> $DIR/entry_with_else.rs:28:5
@ -95,7 +99,9 @@ LL + e.insert(v);
LL + }
LL + std::collections::hash_map::Entry::Occupied(mut e) => {
LL + e.insert(v2);
...
LL + }
LL + }
|
error: usage of `contains_key` followed by `insert` on a `HashMap`
--> $DIR/entry_with_else.rs:46:5
@ -115,7 +121,10 @@ LL + if true { Some(e.insert(v)) } else { Some(e.insert(v2)) }
LL + }
LL + std::collections::hash_map::Entry::Vacant(e) => {
LL + e.insert(v);
...
LL + None
LL + }
LL ~ };
|
error: usage of `contains_key` followed by `insert` on a `HashMap`
--> $DIR/entry_with_else.rs:52:5

View File

@ -9,7 +9,7 @@ help: use `eprintln!` instead
|
LL - eprint!("Hello/n");
LL + eprintln!("Hello");
|
|
error: using `eprint!()` with a format string that ends in a single newline
--> $DIR/eprint_with_newline.rs:6:5
@ -21,7 +21,7 @@ help: use `eprintln!` instead
|
LL - eprint!("Hello {}/n", "world");
LL + eprintln!("Hello {}", "world");
|
|
error: using `eprint!()` with a format string that ends in a single newline
--> $DIR/eprint_with_newline.rs:7:5
@ -33,7 +33,7 @@ help: use `eprintln!` instead
|
LL - eprint!("Hello {} {}/n", "world", "#2");
LL + eprintln!("Hello {} {}", "world", "#2");
|
|
error: using `eprint!()` with a format string that ends in a single newline
--> $DIR/eprint_with_newline.rs:8:5
@ -45,7 +45,7 @@ help: use `eprintln!` instead
|
LL - eprint!("{}/n", 1265);
LL + eprintln!("{}", 1265);
|
|
error: using `eprint!()` with a format string that ends in a single newline
--> $DIR/eprint_with_newline.rs:9:5
@ -57,7 +57,7 @@ help: use `eprintln!` instead
|
LL - eprint!("/n");
LL + eprintln!();
|
|
error: using `eprint!()` with a format string that ends in a single newline
--> $DIR/eprint_with_newline.rs:28:5
@ -69,7 +69,7 @@ help: use `eprintln!` instead
|
LL - eprint!("//n"); // should fail
LL + eprintln!("/"); // should fail
|
|
error: using `eprint!()` with a format string that ends in a single newline
--> $DIR/eprint_with_newline.rs:35:5
@ -111,7 +111,7 @@ help: use `eprintln!` instead
|
LL - eprint!("/r/n"); //~ ERROR
LL + eprintln!("/r"); //~ ERROR
|
|
error: using `eprint!()` with a format string that ends in a single newline
--> $DIR/eprint_with_newline.rs:48:5
@ -123,7 +123,7 @@ help: use `eprintln!` instead
|
LL - eprint!("foo/rbar/n") // ~ ERROR
LL + eprintln!("foo/rbar") // ~ ERROR
|
|
error: aborting due to 10 previous errors

View File

@ -32,7 +32,8 @@ LL + .map(|i| i * 2)
LL + .filter(|i| i % 2 == 0)
LL + .map(|_| ())
LL + .next()
...
LL + .unwrap();
|
error: this let-binding has unit value
--> $DIR/let_unit.rs:80:5

View File

@ -122,7 +122,14 @@ LL + let a = 42;
LL + let b = 21;
LL + if a < b {
LL + let c = 21;
...
LL + let d = 42;
LL + if c < d {
LL + let _ = 42;
LL + }
LL + }
LL + 42
LL + }
|
error: this function can be simplified using the `async fn` syntax
--> $DIR/manual_async_fn.rs:92:1

View File

@ -96,12 +96,12 @@ help: remove the `iter` usages
|
LL - let l = iter.next().unwrap();
LL +
|
|
help: remove the `iter` usages
|
LL - let r = iter.next().unwrap();
LL +
|
|
error: manual implementation of `split_once`
--> $DIR/manual_split_once.rs:49:5
@ -121,12 +121,12 @@ help: remove the `iter` usages
|
LL - let l = iter.next()?;
LL +
|
|
help: remove the `iter` usages
|
LL - let r = iter.next()?;
LL +
|
|
error: manual implementation of `rsplit_once`
--> $DIR/manual_split_once.rs:53:5
@ -146,12 +146,12 @@ help: remove the `iter` usages
|
LL - let r = iter.next().unwrap();
LL +
|
|
help: remove the `iter` usages
|
LL - let l = iter.next().unwrap();
LL +
|
|
error: manual implementation of `rsplit_once`
--> $DIR/manual_split_once.rs:57:5
@ -171,12 +171,12 @@ help: remove the `iter` usages
|
LL - let r = iter.next()?;
LL +
|
|
help: remove the `iter` usages
|
LL - let l = iter.next()?;
LL +
|
|
error: manual implementation of `split_once`
--> $DIR/manual_split_once.rs:142:13
@ -202,12 +202,12 @@ help: remove the `iter` usages
|
LL - let a = iter.next().unwrap();
LL +
|
|
help: remove the `iter` usages
|
LL - let b = iter.next().unwrap();
LL +
|
|
error: aborting due to 19 previous errors

View File

@ -12,14 +12,12 @@ LL | | .flatten();
| |__________________^
|
= note: `-D clippy::map-flatten` implied by `-D warnings`
help: try replacing `map` with `and_then`
help: try replacing `map` with `and_then` and remove the `.flatten()`
|
LL ~ .and_then(|x| {
LL + if x <= 5 {
LL + Some(x)
|
help: and remove the `.flatten()`
|
LL + } else {
LL + None
LL + }
LL ~ });
@ -38,14 +36,12 @@ LL | | })
LL | | .flatten();
| |__________________^
|
help: try replacing `map` with `and_then`
help: try replacing `map` with `and_then` and remove the `.flatten()`
|
LL ~ .and_then(|x| {
LL + if x == 1 {
LL + Ok(x)
|
help: and remove the `.flatten()`
|
LL + } else {
LL + Err(0)
LL + }
LL ~ });
@ -64,14 +60,13 @@ LL | | })
LL | | .flatten();
| |__________________^
|
help: try replacing `map` with `and_then`
help: try replacing `map` with `and_then` and remove the `.flatten()`
|
LL ~ .and_then(|res| {
LL + if res > 0 {
LL + do_something();
|
help: and remove the `.flatten()`
|
LL + Ok(res)
LL + } else {
LL + Err(0)
LL + }
LL ~ });
@ -90,14 +85,12 @@ LL | | })
LL | | .flatten()
| |__________________^
|
help: try replacing `map` with `filter_map`
help: try replacing `map` with `filter_map` and remove the `.flatten()`
|
LL ~ .filter_map(|some_value| {
LL + if some_value > 3 {
LL + Some(some_value)
|
help: and remove the `.flatten()`
|
LL + } else {
LL + None
LL + }
LL + })

View File

@ -59,8 +59,6 @@ fn issue8878() {
.and_then(|_| {
// we need some newlines
// so that the span is big enough
// we need some newlines
// so that the span is big enough
// for a splitted output of the diagnostic
Some("")
// whitespace beforehand is important as well

View File

@ -2,79 +2,45 @@ error: called `map(..).flatten()` on `Iterator`
--> $DIR/map_flatten_fixable.rs:18:47
|
LL | let _: Vec<_> = vec![5_i8; 6].into_iter().map(option_id).flatten().collect();
| ^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try replacing `map` with `filter_map` and remove the `.flatten()`: `filter_map(option_id)`
|
= note: `-D clippy::map-flatten` implied by `-D warnings`
help: try replacing `map` with `filter_map`, and remove the `.flatten()`
|
LL | let _: Vec<_> = vec![5_i8; 6].into_iter().filter_map(option_id).collect();
| ~~~~~~~~~~~~~~~~~~~~~
error: called `map(..).flatten()` on `Iterator`
--> $DIR/map_flatten_fixable.rs:19:47
|
LL | let _: Vec<_> = vec![5_i8; 6].into_iter().map(option_id_ref).flatten().collect();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: try replacing `map` with `filter_map`, and remove the `.flatten()`
|
LL | let _: Vec<_> = vec![5_i8; 6].into_iter().filter_map(option_id_ref).collect();
| ~~~~~~~~~~~~~~~~~~~~~~~~~
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try replacing `map` with `filter_map` and remove the `.flatten()`: `filter_map(option_id_ref)`
error: called `map(..).flatten()` on `Iterator`
--> $DIR/map_flatten_fixable.rs:20:47
|
LL | let _: Vec<_> = vec![5_i8; 6].into_iter().map(option_id_closure).flatten().collect();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: try replacing `map` with `filter_map`, and remove the `.flatten()`
|
LL | let _: Vec<_> = vec![5_i8; 6].into_iter().filter_map(option_id_closure).collect();
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try replacing `map` with `filter_map` and remove the `.flatten()`: `filter_map(option_id_closure)`
error: called `map(..).flatten()` on `Iterator`
--> $DIR/map_flatten_fixable.rs:21:47
|
LL | let _: Vec<_> = vec![5_i8; 6].into_iter().map(|x| x.checked_add(1)).flatten().collect();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: try replacing `map` with `filter_map`, and remove the `.flatten()`
|
LL | let _: Vec<_> = vec![5_i8; 6].into_iter().filter_map(|x| x.checked_add(1)).collect();
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try replacing `map` with `filter_map` and remove the `.flatten()`: `filter_map(|x| x.checked_add(1))`
error: called `map(..).flatten()` on `Iterator`
--> $DIR/map_flatten_fixable.rs:24:47
|
LL | let _: Vec<_> = vec![5_i8; 6].into_iter().map(|x| 0..x).flatten().collect();
| ^^^^^^^^^^^^^^^^^^^^^^^
|
help: try replacing `map` with `flat_map`, and remove the `.flatten()`
|
LL | let _: Vec<_> = vec![5_i8; 6].into_iter().flat_map(|x| 0..x).collect();
| ~~~~~~~~~~~~~~~~~~
| ^^^^^^^^^^^^^^^^^^^^^^^ help: try replacing `map` with `flat_map` and remove the `.flatten()`: `flat_map(|x| 0..x)`
error: called `map(..).flatten()` on `Option`
--> $DIR/map_flatten_fixable.rs:27:40
|
LL | let _: Option<_> = (Some(Some(1))).map(|x| x).flatten();
| ^^^^^^^^^^^^^^^^^^^^
|
help: try replacing `map` with `and_then`, and remove the `.flatten()`
|
LL | let _: Option<_> = (Some(Some(1))).and_then(|x| x);
| ~~~~~~~~~~~~~~~
| ^^^^^^^^^^^^^^^^^^^^ help: try replacing `map` with `and_then` and remove the `.flatten()`: `and_then(|x| x)`
error: called `map(..).flatten()` on `Result`
--> $DIR/map_flatten_fixable.rs:30:42
|
LL | let _: Result<_, &str> = (Ok(Ok(1))).map(|x| x).flatten();
| ^^^^^^^^^^^^^^^^^^^^
|
help: try replacing `map` with `and_then`, and remove the `.flatten()`
|
LL | let _: Result<_, &str> = (Ok(Ok(1))).and_then(|x| x);
| ~~~~~~~~~~~~~~~
| ^^^^^^^^^^^^^^^^^^^^ help: try replacing `map` with `and_then` and remove the `.flatten()`: `and_then(|x| x)`
error: called `map(..).flatten()` on `Option`
--> $DIR/map_flatten_fixable.rs:59:10
@ -89,14 +55,12 @@ LL | | })
LL | | .flatten();
| |__________________^
|
help: try replacing `map` with `and_then`
help: try replacing `map` with `and_then` and remove the `.flatten()`
|
LL ~ .and_then(|_| {
LL + // we need some newlines
LL + // so that the span is big enough
|
help: and remove the `.flatten()`
|
LL + // for a splitted output of the diagnostic
LL + Some("")
LL + // whitespace beforehand is important as well
LL ~ });

View File

@ -12,7 +12,7 @@ help: use `map_or(<a>, <f>)` instead
|
LL - let _ = opt.map(|x| x + 1)
LL + let _ = opt.map_or(0, |x| x + 1);
|
|
error: called `map(<f>).unwrap_or(<a>)` on an `Option` value. This can be done more directly by calling `map_or(<a>, <f>)` instead
--> $DIR/map_unwrap_or.rs:20:13
@ -59,7 +59,7 @@ help: use `and_then(<f>)` instead
|
LL - let _ = opt.map(|x| Some(x + 1)).unwrap_or(None);
LL + let _ = opt.and_then(|x| Some(x + 1));
|
|
error: called `map(<f>).unwrap_or(None)` on an `Option` value. This can be done more directly by calling `and_then(<f>)` instead
--> $DIR/map_unwrap_or.rs:31:13
@ -92,7 +92,7 @@ help: use `and_then(<f>)` instead
|
LL - .map(|x| Some(x + 1))
LL + .and_then(|x| Some(x + 1));
|
|
error: called `map(<f>).unwrap_or(<a>)` on an `Option` value. This can be done more directly by calling `map_or(<a>, <f>)` instead
--> $DIR/map_unwrap_or.rs:46:13
@ -104,7 +104,7 @@ help: use `map_or(<a>, <f>)` instead
|
LL - let _ = Some("prefix").map(|p| format!("{}.", p)).unwrap_or(id);
LL + let _ = Some("prefix").map_or(id, |p| format!("{}.", p));
|
|
error: called `map(<f>).unwrap_or_else(<g>)` on an `Option` value. This can be done more directly by calling `map_or_else(<g>, <f>)` instead
--> $DIR/map_unwrap_or.rs:50:13

View File

@ -19,7 +19,8 @@ LL + return;
LL + } else {
LL + println!("{}", v);
LL + }
...
LL + }
|
help: ...and replace `return` with `continue`
|
LL | continue;

View File

@ -164,7 +164,7 @@ help: remove the assignments from the `match` arms
|
LL - 1 => f = "three",
LL + 1 => "three",
|
|
error: unneeded late initialization
--> $DIR/needless_late_init.rs:76:5
@ -180,7 +180,7 @@ help: remove the assignments from the branches
|
LL - g = 5;
LL + 5
|
|
help: add a semicolon after the `if` expression
|
LL | };

View File

@ -117,7 +117,8 @@ LL + Self::new()
LL + }
LL + }
LL +
...
LL ~ impl<T> Foo<T> {
|
error: aborting due to 7 previous errors

View File

@ -185,8 +185,7 @@ mod issue8239 {
.reduce(|mut acc, f| {
acc.push_str(&f);
acc
})
.unwrap_or_default();
}).unwrap_or_default();
}
fn more_to_max_suggestion_highest_lines_1() {
@ -198,8 +197,7 @@ mod issue8239 {
let _ = "";
acc.push_str(&f);
acc
})
.unwrap_or_default();
}).unwrap_or_default();
}
fn equal_to_max_suggestion_highest_lines() {

View File

@ -109,16 +109,50 @@ LL | None.unwrap_or( unsafe { ptr_to_ref(s) } );
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| unsafe { ptr_to_ref(s) })`
error: use of `unwrap_or` followed by a call to `new`
--> $DIR/or_fun_call.rs:189:14
--> $DIR/or_fun_call.rs:182:9
|
LL | / frames
LL | | .iter()
LL | | .map(|f: &String| f.to_lowercase())
LL | | .reduce(|mut acc, f| {
... |
LL | | })
LL | | .unwrap_or(String::new());
| |_____________________________________^
|
help: try this
|
LL ~ frames
LL + .iter()
LL + .map(|f: &String| f.to_lowercase())
LL + .reduce(|mut acc, f| {
LL + acc.push_str(&f);
LL + acc
LL ~ }).unwrap_or_default();
|
LL | .unwrap_or(String::new());
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_default()`
error: use of `unwrap_or` followed by a call to `new`
--> $DIR/or_fun_call.rs:202:14
--> $DIR/or_fun_call.rs:195:9
|
LL | / iter.map(|f: &String| f.to_lowercase())
LL | | .reduce(|mut acc, f| {
LL | | let _ = "";
LL | | let _ = "";
... |
LL | | })
LL | | .unwrap_or(String::new());
| |_____________________________________^
|
help: try this
|
LL ~ iter.map(|f: &String| f.to_lowercase())
LL + .reduce(|mut acc, f| {
LL + let _ = "";
LL + let _ = "";
LL + acc.push_str(&f);
LL + acc
LL ~ }).unwrap_or_default();
|
LL | .unwrap_or(String::new());
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_default()`
error: use of `unwrap_or` followed by a call to `new`
--> $DIR/or_fun_call.rs:208:9

View File

@ -9,7 +9,7 @@ help: try this
|
LL - print!("Hello {}", "world");
LL + print!("Hello world");
|
|
error: literal with an empty format string
--> $DIR/print_literal.rs:26:36
@ -21,7 +21,7 @@ help: try this
|
LL - println!("Hello {} {}", world, "world");
LL + println!("Hello {} world", world);
|
|
error: literal with an empty format string
--> $DIR/print_literal.rs:27:26
@ -33,7 +33,7 @@ help: try this
|
LL - println!("Hello {}", "world");
LL + println!("Hello world");
|
|
error: literal with an empty format string
--> $DIR/print_literal.rs:32:25
@ -45,7 +45,7 @@ help: try this
|
LL - println!("{0} {1}", "hello", "world");
LL + println!("hello {1}", "world");
|
|
error: literal with an empty format string
--> $DIR/print_literal.rs:32:34
@ -57,7 +57,7 @@ help: try this
|
LL - println!("{0} {1}", "hello", "world");
LL + println!("{0} world", "hello");
|
|
error: literal with an empty format string
--> $DIR/print_literal.rs:33:25
@ -69,7 +69,7 @@ help: try this
|
LL - println!("{1} {0}", "hello", "world");
LL + println!("{1} hello", "world");
|
|
error: literal with an empty format string
--> $DIR/print_literal.rs:33:34
@ -81,7 +81,7 @@ help: try this
|
LL - println!("{1} {0}", "hello", "world");
LL + println!("world {0}", "hello");
|
|
error: literal with an empty format string
--> $DIR/print_literal.rs:36:29
@ -93,7 +93,7 @@ help: try this
|
LL - println!("{foo} {bar}", foo = "hello", bar = "world");
LL + println!("hello {bar}", bar = "world");
|
|
error: literal with an empty format string
--> $DIR/print_literal.rs:36:44
@ -105,7 +105,7 @@ help: try this
|
LL - println!("{foo} {bar}", foo = "hello", bar = "world");
LL + println!("{foo} world", foo = "hello");
|
|
error: literal with an empty format string
--> $DIR/print_literal.rs:37:29
@ -117,7 +117,7 @@ help: try this
|
LL - println!("{bar} {foo}", foo = "hello", bar = "world");
LL + println!("{bar} hello", bar = "world");
|
|
error: literal with an empty format string
--> $DIR/print_literal.rs:37:44
@ -129,7 +129,7 @@ help: try this
|
LL - println!("{bar} {foo}", foo = "hello", bar = "world");
LL + println!("world {foo}", foo = "hello");
|
|
error: aborting due to 11 previous errors

View File

@ -9,7 +9,7 @@ help: use `println!` instead
|
LL - print!("Hello/n");
LL + println!("Hello");
|
|
error: using `print!()` with a format string that ends in a single newline
--> $DIR/print_with_newline.rs:9:5
@ -21,7 +21,7 @@ help: use `println!` instead
|
LL - print!("Hello {}/n", "world");
LL + println!("Hello {}", "world");
|
|
error: using `print!()` with a format string that ends in a single newline
--> $DIR/print_with_newline.rs:10:5
@ -33,7 +33,7 @@ help: use `println!` instead
|
LL - print!("Hello {} {}/n", "world", "#2");
LL + println!("Hello {} {}", "world", "#2");
|
|
error: using `print!()` with a format string that ends in a single newline
--> $DIR/print_with_newline.rs:11:5
@ -45,7 +45,7 @@ help: use `println!` instead
|
LL - print!("{}/n", 1265);
LL + println!("{}", 1265);
|
|
error: using `print!()` with a format string that ends in a single newline
--> $DIR/print_with_newline.rs:12:5
@ -57,7 +57,7 @@ help: use `println!` instead
|
LL - print!("/n");
LL + println!();
|
|
error: using `print!()` with a format string that ends in a single newline
--> $DIR/print_with_newline.rs:31:5
@ -69,7 +69,7 @@ help: use `println!` instead
|
LL - print!("//n"); // should fail
LL + println!("/"); // should fail
|
|
error: using `print!()` with a format string that ends in a single newline
--> $DIR/print_with_newline.rs:38:5
@ -111,7 +111,7 @@ help: use `println!` instead
|
LL - print!("/r/n"); //~ ERROR
LL + println!("/r"); //~ ERROR
|
|
error: using `print!()` with a format string that ends in a single newline
--> $DIR/print_with_newline.rs:51:5
@ -123,7 +123,7 @@ help: use `println!` instead
|
LL - print!("foo/rbar/n") // ~ ERROR
LL + println!("foo/rbar") // ~ ERROR
|
|
error: aborting due to 10 previous errors

View File

@ -56,7 +56,8 @@ LL | let f = e.clone(); // OK
LL | let g = x;
LL ~ let h = g.to_owned();
LL | let i = (e).clone();
...
LL ~ x.to_owned()
|
error: writing `&String` instead of `&str` involves a new object where a slice will do
--> $DIR/ptr_arg.rs:58:18

View File

@ -311,7 +311,9 @@ LL + _ => mutex2.lock().unwrap(),
LL + }
LL + .s
LL + .len()
...
LL + > 1;
LL ~ match value
|
error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression
--> $DIR/significant_drop_in_scrutinee.rs:410:11
@ -341,7 +343,10 @@ LL + } else {
LL + mutex2.lock().unwrap()
LL + }
LL + .s
...
LL + .len()
LL + > 1;
LL ~ match value
|
error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression
--> $DIR/significant_drop_in_scrutinee.rs:464:11

View File

@ -137,7 +137,13 @@ LL + foo(1);
LL + };
LL + {
LL + foo(2);
...
LL + foo(3);
LL + };
LL + taking_multiple_units(
LL + (),
LL + (),
LL ~ );
|
error: passing a unit value to a function
--> $DIR/unit_arg.rs:85:13

View File

@ -13,7 +13,7 @@ help: remove this `&`
|
LL - let other = match get_file_path(&t) {
LL + let other = match get_file_path(t) {
|
|
error: unnecessary use of `copied`
--> $DIR/unnecessary_iter_cloned.rs:46:22
@ -29,7 +29,7 @@ help: remove this `&`
|
LL - let other = match get_file_path(&t) {
LL + let other = match get_file_path(t) {
|
|
error: aborting due to 2 previous errors

View File

@ -489,7 +489,7 @@ help: remove this `&`
|
LL - let path = match get_file_path(&t) {
LL + let path = match get_file_path(t) {
|
|
error: unnecessary use of `to_vec`
--> $DIR/unnecessary_to_owned.rs:221:14

View File

@ -23,7 +23,8 @@ LL | if a {
LL | Some(-1);
LL ~ 2
LL | } else {
...
LL ~ return 1337;
|
error: this function's return value is unnecessarily wrapped by `Option`
--> $DIR/unnecessary_wraps.rs:21:1
@ -122,7 +123,8 @@ LL | if a {
LL | Some(());
LL ~
LL | } else {
...
LL ~ return ;
|
error: this function's return value is unnecessary
--> $DIR/unnecessary_wraps.rs:117:1

View File

@ -9,7 +9,7 @@ help: try this
|
LL - write!(v, "Hello {}", "world");
LL + write!(v, "Hello world");
|
|
error: literal with an empty format string
--> $DIR/write_literal.rs:31:39
@ -21,7 +21,7 @@ help: try this
|
LL - writeln!(v, "Hello {} {}", world, "world");
LL + writeln!(v, "Hello {} world", world);
|
|
error: literal with an empty format string
--> $DIR/write_literal.rs:32:29
@ -33,7 +33,7 @@ help: try this
|
LL - writeln!(v, "Hello {}", "world");
LL + writeln!(v, "Hello world");
|
|
error: literal with an empty format string
--> $DIR/write_literal.rs:37:28
@ -45,7 +45,7 @@ help: try this
|
LL - writeln!(v, "{0} {1}", "hello", "world");
LL + writeln!(v, "hello {1}", "world");
|
|
error: literal with an empty format string
--> $DIR/write_literal.rs:37:37
@ -57,7 +57,7 @@ help: try this
|
LL - writeln!(v, "{0} {1}", "hello", "world");
LL + writeln!(v, "{0} world", "hello");
|
|
error: literal with an empty format string
--> $DIR/write_literal.rs:38:28
@ -69,7 +69,7 @@ help: try this
|
LL - writeln!(v, "{1} {0}", "hello", "world");
LL + writeln!(v, "{1} hello", "world");
|
|
error: literal with an empty format string
--> $DIR/write_literal.rs:38:37
@ -81,7 +81,7 @@ help: try this
|
LL - writeln!(v, "{1} {0}", "hello", "world");
LL + writeln!(v, "world {0}", "hello");
|
|
error: literal with an empty format string
--> $DIR/write_literal.rs:41:32
@ -93,7 +93,7 @@ help: try this
|
LL - writeln!(v, "{foo} {bar}", foo = "hello", bar = "world");
LL + writeln!(v, "hello {bar}", bar = "world");
|
|
error: literal with an empty format string
--> $DIR/write_literal.rs:41:47
@ -105,7 +105,7 @@ help: try this
|
LL - writeln!(v, "{foo} {bar}", foo = "hello", bar = "world");
LL + writeln!(v, "{foo} world", foo = "hello");
|
|
error: literal with an empty format string
--> $DIR/write_literal.rs:42:32
@ -117,7 +117,7 @@ help: try this
|
LL - writeln!(v, "{bar} {foo}", foo = "hello", bar = "world");
LL + writeln!(v, "{bar} hello", bar = "world");
|
|
error: literal with an empty format string
--> $DIR/write_literal.rs:42:47
@ -129,7 +129,7 @@ help: try this
|
LL - writeln!(v, "{bar} {foo}", foo = "hello", bar = "world");
LL + writeln!(v, "world {foo}", foo = "hello");
|
|
error: aborting due to 11 previous errors

View File

@ -9,7 +9,7 @@ help: try this
|
LL - writeln!(v, "{}", "{hello}");
LL + writeln!(v, "{{hello}}");
|
|
error: literal with an empty format string
--> $DIR/write_literal_2.rs:10:24
@ -21,7 +21,7 @@ help: try this
|
LL - writeln!(v, r"{}", r"{hello}");
LL + writeln!(v, r"{{hello}}");
|
|
error: literal with an empty format string
--> $DIR/write_literal_2.rs:11:23
@ -33,7 +33,7 @@ help: try this
|
LL - writeln!(v, "{}", '/'');
LL + writeln!(v, "'");
|
|
error: literal with an empty format string
--> $DIR/write_literal_2.rs:12:23
@ -45,7 +45,7 @@ help: try this
|
LL - writeln!(v, "{}", '"');
LL + writeln!(v, "/"");
|
|
error: literal with an empty format string
--> $DIR/write_literal_2.rs:14:24
@ -57,7 +57,7 @@ help: try this
|
LL - writeln!(v, r"{}", '/'');
LL + writeln!(v, r"'");
|
|
error: literal with an empty format string
--> $DIR/write_literal_2.rs:18:9

View File

@ -9,7 +9,7 @@ help: use `writeln!()` instead
|
LL - write!(v, "Hello/n");
LL + writeln!(v, "Hello");
|
|
error: using `write!()` with a format string that ends in a single newline
--> $DIR/write_with_newline.rs:14:5
@ -21,7 +21,7 @@ help: use `writeln!()` instead
|
LL - write!(v, "Hello {}/n", "world");
LL + writeln!(v, "Hello {}", "world");
|
|
error: using `write!()` with a format string that ends in a single newline
--> $DIR/write_with_newline.rs:15:5
@ -33,7 +33,7 @@ help: use `writeln!()` instead
|
LL - write!(v, "Hello {} {}/n", "world", "#2");
LL + writeln!(v, "Hello {} {}", "world", "#2");
|
|
error: using `write!()` with a format string that ends in a single newline
--> $DIR/write_with_newline.rs:16:5
@ -45,7 +45,7 @@ help: use `writeln!()` instead
|
LL - write!(v, "{}/n", 1265);
LL + writeln!(v, "{}", 1265);
|
|
error: using `write!()` with a format string that ends in a single newline
--> $DIR/write_with_newline.rs:17:5
@ -57,7 +57,7 @@ help: use `writeln!()` instead
|
LL - write!(v, "/n");
LL + writeln!(v);
|
|
error: using `write!()` with a format string that ends in a single newline
--> $DIR/write_with_newline.rs:36:5
@ -69,7 +69,7 @@ help: use `writeln!()` instead
|
LL - write!(v, "//n"); // should fail
LL + writeln!(v, "/"); // should fail
|
|
error: using `write!()` with a format string that ends in a single newline
--> $DIR/write_with_newline.rs:43:5
@ -115,7 +115,7 @@ help: use `writeln!()` instead
|
LL - write!(v, "/r/n"); //~ ERROR
LL + writeln!(v, "/r"); //~ ERROR
|
|
error: using `write!()` with a format string that ends in a single newline
--> $DIR/write_with_newline.rs:58:5
@ -127,7 +127,7 @@ help: use `writeln!()` instead
|
LL - write!(v, "foo/rbar/n");
LL + writeln!(v, "foo/rbar");
|
|
error: aborting due to 10 previous errors