format and fix examples

This commit is contained in:
Jacherr 2023-11-11 00:21:35 +00:00
parent cb90674aed
commit 7bc39f3af8

View File

@ -1,6 +1,7 @@
use clippy_utils::paths::{HASHMAP_KEYS, HASHMAP_VALUES, HASHSET_ITER_TY};
use clippy_utils::{diagnostics::span_lint, match_def_path};
use clippy_utils::diagnostics::span_lint;
use clippy_utils::higher::ForLoop;
use clippy_utils::match_def_path;
use clippy_utils::paths::{HASHMAP_KEYS, HASHMAP_VALUES, HASHSET_ITER_TY};
use clippy_utils::ty::is_type_diagnostic_item;
use rustc_lint::{LateContext, LateLintPass};
use rustc_session::{declare_lint_pass, declare_tool_lint};
@ -18,16 +19,16 @@
///
/// ### Example
/// ```no_run
/// let my_map = new Hashmap<i32, String>();
/// let my_map = std::collections::HashMap::<i32, String>::new();
/// for (key, value) in my_map { /* ... */ }
/// ```
/// Use instead:
/// ```no_run
/// let my_map = new Hashmap<i32, String>();
/// let mut keys = my_map.keys().clone().collect::<Vec<_>();
/// let my_map = std::collections::HashMap::<i32, String>::new();
/// let mut keys = my_map.keys().clone().collect::<Vec<_>>();
/// keys.sort();
/// for key in keys {
/// let value = &my_map[value];
/// let value = &my_map[key];
/// }
/// ```
#[clippy::version = "1.75.0"]
@ -60,4 +61,3 @@ fn check_expr(&mut self, cx: &LateContext<'_>, expr: &'_ rustc_hir::Expr<'_>) {
};
}
}