Skip to content

Commit ae0216d

Browse files
committed
Use the traits added to the Rust 2021 Edition prelude
Follow up rust-lang/rust#96861. This PR uses the traits added to the Rust 2021 Edition prelude. > The `TryInto`, `TryFrom` and `FromIterator` traits are now part of the prelude. https://doc.rust-lang.org/edition-guide/rust-2021/prelude.html
1 parent d422baa commit ae0216d

34 files changed

+99
-128
lines changed

clippy_lints/src/checked_conversions.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ declare_clippy_lint! {
3030
/// Could be written:
3131
///
3232
/// ```rust
33-
/// # use std::convert::TryFrom;
3433
/// # let foo = 1;
3534
/// # let _ =
3635
/// i32::try_from(foo).is_ok()

clippy_lints/src/enum_clike.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use rustc_lint::{LateContext, LateLintPass};
88
use rustc_middle::ty::util::IntTypeExt;
99
use rustc_middle::ty::{self, IntTy, UintTy};
1010
use rustc_session::{declare_lint_pass, declare_tool_lint};
11-
use std::convert::TryFrom;
1211

1312
declare_clippy_lint! {
1413
/// ### What it does

clippy_lints/src/excessive_bools.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ use rustc_lint::{EarlyContext, EarlyLintPass};
44
use rustc_session::{declare_tool_lint, impl_lint_pass};
55
use rustc_span::{sym, Span};
66

7-
use std::convert::TryInto;
8-
97
declare_clippy_lint! {
108
/// ### What it does
119
/// Checks for excessive

clippy_lints/src/fallible_impl_from.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ declare_clippy_lint! {
3232
/// // Good
3333
/// struct Foo(i32);
3434
///
35-
/// use std::convert::TryFrom;
3635
/// impl TryFrom<String> for Foo {
3736
/// type Error = ();
3837
/// fn try_from(s: String) -> Result<Self, Self::Error> {

clippy_lints/src/index_refutable_slice.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ use rustc_middle::ty;
1414
use rustc_semver::RustcVersion;
1515
use rustc_session::{declare_tool_lint, impl_lint_pass};
1616
use rustc_span::{symbol::Ident, Span};
17-
use std::convert::TryInto;
1817

1918
declare_clippy_lint! {
2019
/// ### What it does

clippy_lints/src/methods/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1776,8 +1776,6 @@ declare_clippy_lint! {
17761776
///
17771777
/// ### Example
17781778
/// ```rust
1779-
/// use std::iter::FromIterator;
1780-
///
17811779
/// let five_fives = std::iter::repeat(5).take(5);
17821780
///
17831781
/// let v = Vec::from_iter(five_fives);

clippy_lints/src/redundant_clone.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ use rustc_mir_dataflow::{Analysis, AnalysisDomain, CallReturnPlaces, GenKill, Ge
1919
use rustc_session::{declare_lint_pass, declare_tool_lint};
2020
use rustc_span::source_map::{BytePos, Span};
2121
use rustc_span::sym;
22-
use std::convert::TryFrom;
2322
use std::ops::ControlFlow;
2423

2524
macro_rules! unwrap_or_continue {

clippy_lints/src/regex.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use rustc_hir::{BorrowKind, Expr, ExprKind};
77
use rustc_lint::{LateContext, LateLintPass};
88
use rustc_session::{declare_lint_pass, declare_tool_lint};
99
use rustc_span::source_map::{BytePos, Span};
10-
use std::convert::TryFrom;
1110

1211
declare_clippy_lint! {
1312
/// ### What it does

clippy_lints/src/tabs_in_doc_comments.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use rustc_errors::Applicability;
44
use rustc_lint::{EarlyContext, EarlyLintPass};
55
use rustc_session::{declare_lint_pass, declare_tool_lint};
66
use rustc_span::source_map::{BytePos, Span};
7-
use std::convert::TryFrom;
87

98
declare_clippy_lint! {
109
/// ### What it does

clippy_utils/src/consts.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ use rustc_middle::ty::{self, FloatTy, ScalarInt, Ty, TyCtxt};
1313
use rustc_middle::{bug, span_bug};
1414
use rustc_span::symbol::Symbol;
1515
use std::cmp::Ordering::{self, Equal};
16-
use std::convert::TryInto;
1716
use std::hash::{Hash, Hasher};
1817
use std::iter;
1918

clippy_utils/src/sugg.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ use rustc_middle::ty;
1717
use rustc_span::source_map::{BytePos, CharPos, Pos, Span, SyntaxContext};
1818
use rustc_typeck::expr_use_visitor::{Delegate, ExprUseVisitor, PlaceBase, PlaceWithHirId};
1919
use std::borrow::Cow;
20-
use std::convert::TryInto;
2120
use std::fmt::{Display, Write as _};
2221
use std::iter;
2322
use std::ops::{Add, Neg, Not, Sub};

tests/ui-toml/unwrap_used/unwrap_used.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use std::collections::BTreeMap;
88
use std::collections::HashMap;
99
use std::collections::VecDeque;
10-
use std::iter::FromIterator;
1110

1211
struct GetFalsePositive {
1312
arr: [u32; 3],

tests/ui-toml/unwrap_used/unwrap_used.stderr

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise
2-
--> $DIR/unwrap_used.rs:36:17
2+
--> $DIR/unwrap_used.rs:35:17
33
|
44
LL | let _ = boxed_slice.get(1).unwrap();
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&boxed_slice[1]`
@@ -11,7 +11,7 @@ LL | #![deny(clippy::get_unwrap)]
1111
| ^^^^^^^^^^^^^^^^^^
1212

1313
error: used `unwrap()` on `an Option` value
14-
--> $DIR/unwrap_used.rs:36:17
14+
--> $DIR/unwrap_used.rs:35:17
1515
|
1616
LL | let _ = boxed_slice.get(1).unwrap();
1717
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -20,175 +20,175 @@ LL | let _ = boxed_slice.get(1).unwrap();
2020
= help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message
2121

2222
error: called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise
23-
--> $DIR/unwrap_used.rs:37:17
23+
--> $DIR/unwrap_used.rs:36:17
2424
|
2525
LL | let _ = some_slice.get(0).unwrap();
2626
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&some_slice[0]`
2727

2828
error: used `unwrap()` on `an Option` value
29-
--> $DIR/unwrap_used.rs:37:17
29+
--> $DIR/unwrap_used.rs:36:17
3030
|
3131
LL | let _ = some_slice.get(0).unwrap();
3232
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
3333
|
3434
= help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message
3535

3636
error: called `.get().unwrap()` on a Vec. Using `[]` is more clear and more concise
37-
--> $DIR/unwrap_used.rs:38:17
37+
--> $DIR/unwrap_used.rs:37:17
3838
|
3939
LL | let _ = some_vec.get(0).unwrap();
4040
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&some_vec[0]`
4141

4242
error: used `unwrap()` on `an Option` value
43-
--> $DIR/unwrap_used.rs:38:17
43+
--> $DIR/unwrap_used.rs:37:17
4444
|
4545
LL | let _ = some_vec.get(0).unwrap();
4646
| ^^^^^^^^^^^^^^^^^^^^^^^^
4747
|
4848
= help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message
4949

5050
error: called `.get().unwrap()` on a VecDeque. Using `[]` is more clear and more concise
51-
--> $DIR/unwrap_used.rs:39:17
51+
--> $DIR/unwrap_used.rs:38:17
5252
|
5353
LL | let _ = some_vecdeque.get(0).unwrap();
5454
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&some_vecdeque[0]`
5555

5656
error: used `unwrap()` on `an Option` value
57-
--> $DIR/unwrap_used.rs:39:17
57+
--> $DIR/unwrap_used.rs:38:17
5858
|
5959
LL | let _ = some_vecdeque.get(0).unwrap();
6060
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6161
|
6262
= help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message
6363

6464
error: called `.get().unwrap()` on a HashMap. Using `[]` is more clear and more concise
65-
--> $DIR/unwrap_used.rs:40:17
65+
--> $DIR/unwrap_used.rs:39:17
6666
|
6767
LL | let _ = some_hashmap.get(&1).unwrap();
6868
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&some_hashmap[&1]`
6969

7070
error: used `unwrap()` on `an Option` value
71-
--> $DIR/unwrap_used.rs:40:17
71+
--> $DIR/unwrap_used.rs:39:17
7272
|
7373
LL | let _ = some_hashmap.get(&1).unwrap();
7474
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
7575
|
7676
= help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message
7777

7878
error: called `.get().unwrap()` on a BTreeMap. Using `[]` is more clear and more concise
79-
--> $DIR/unwrap_used.rs:41:17
79+
--> $DIR/unwrap_used.rs:40:17
8080
|
8181
LL | let _ = some_btreemap.get(&1).unwrap();
8282
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&some_btreemap[&1]`
8383

8484
error: used `unwrap()` on `an Option` value
85-
--> $DIR/unwrap_used.rs:41:17
85+
--> $DIR/unwrap_used.rs:40:17
8686
|
8787
LL | let _ = some_btreemap.get(&1).unwrap();
8888
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
8989
|
9090
= help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message
9191

9292
error: called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise
93-
--> $DIR/unwrap_used.rs:45:21
93+
--> $DIR/unwrap_used.rs:44:21
9494
|
9595
LL | let _: u8 = *boxed_slice.get(1).unwrap();
9696
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `boxed_slice[1]`
9797

9898
error: used `unwrap()` on `an Option` value
99-
--> $DIR/unwrap_used.rs:45:22
99+
--> $DIR/unwrap_used.rs:44:22
100100
|
101101
LL | let _: u8 = *boxed_slice.get(1).unwrap();
102102
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
103103
|
104104
= help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message
105105

106106
error: called `.get_mut().unwrap()` on a slice. Using `[]` is more clear and more concise
107-
--> $DIR/unwrap_used.rs:50:9
107+
--> $DIR/unwrap_used.rs:49:9
108108
|
109109
LL | *boxed_slice.get_mut(0).unwrap() = 1;
110110
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `boxed_slice[0]`
111111

112112
error: used `unwrap()` on `an Option` value
113-
--> $DIR/unwrap_used.rs:50:10
113+
--> $DIR/unwrap_used.rs:49:10
114114
|
115115
LL | *boxed_slice.get_mut(0).unwrap() = 1;
116116
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
117117
|
118118
= help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message
119119

120120
error: called `.get_mut().unwrap()` on a slice. Using `[]` is more clear and more concise
121-
--> $DIR/unwrap_used.rs:51:9
121+
--> $DIR/unwrap_used.rs:50:9
122122
|
123123
LL | *some_slice.get_mut(0).unwrap() = 1;
124124
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `some_slice[0]`
125125

126126
error: used `unwrap()` on `an Option` value
127-
--> $DIR/unwrap_used.rs:51:10
127+
--> $DIR/unwrap_used.rs:50:10
128128
|
129129
LL | *some_slice.get_mut(0).unwrap() = 1;
130130
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
131131
|
132132
= help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message
133133

134134
error: called `.get_mut().unwrap()` on a Vec. Using `[]` is more clear and more concise
135-
--> $DIR/unwrap_used.rs:52:9
135+
--> $DIR/unwrap_used.rs:51:9
136136
|
137137
LL | *some_vec.get_mut(0).unwrap() = 1;
138138
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `some_vec[0]`
139139

140140
error: used `unwrap()` on `an Option` value
141-
--> $DIR/unwrap_used.rs:52:10
141+
--> $DIR/unwrap_used.rs:51:10
142142
|
143143
LL | *some_vec.get_mut(0).unwrap() = 1;
144144
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
145145
|
146146
= help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message
147147

148148
error: called `.get_mut().unwrap()` on a VecDeque. Using `[]` is more clear and more concise
149-
--> $DIR/unwrap_used.rs:53:9
149+
--> $DIR/unwrap_used.rs:52:9
150150
|
151151
LL | *some_vecdeque.get_mut(0).unwrap() = 1;
152152
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `some_vecdeque[0]`
153153

154154
error: used `unwrap()` on `an Option` value
155-
--> $DIR/unwrap_used.rs:53:10
155+
--> $DIR/unwrap_used.rs:52:10
156156
|
157157
LL | *some_vecdeque.get_mut(0).unwrap() = 1;
158158
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
159159
|
160160
= help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message
161161

162162
error: called `.get().unwrap()` on a Vec. Using `[]` is more clear and more concise
163-
--> $DIR/unwrap_used.rs:65:17
163+
--> $DIR/unwrap_used.rs:64:17
164164
|
165165
LL | let _ = some_vec.get(0..1).unwrap().to_vec();
166166
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `some_vec[0..1]`
167167

168168
error: used `unwrap()` on `an Option` value
169-
--> $DIR/unwrap_used.rs:65:17
169+
--> $DIR/unwrap_used.rs:64:17
170170
|
171171
LL | let _ = some_vec.get(0..1).unwrap().to_vec();
172172
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
173173
|
174174
= help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message
175175

176176
error: called `.get_mut().unwrap()` on a Vec. Using `[]` is more clear and more concise
177-
--> $DIR/unwrap_used.rs:66:17
177+
--> $DIR/unwrap_used.rs:65:17
178178
|
179179
LL | let _ = some_vec.get_mut(0..1).unwrap().to_vec();
180180
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `some_vec[0..1]`
181181

182182
error: used `unwrap()` on `an Option` value
183-
--> $DIR/unwrap_used.rs:66:17
183+
--> $DIR/unwrap_used.rs:65:17
184184
|
185185
LL | let _ = some_vec.get_mut(0..1).unwrap().to_vec();
186186
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
187187
|
188188
= help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message
189189

190190
error: called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise
191-
--> $DIR/unwrap_used.rs:73:13
191+
--> $DIR/unwrap_used.rs:72:13
192192
|
193193
LL | let _ = boxed_slice.get(1).unwrap();
194194
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&boxed_slice[1]`

tests/ui/auxiliary/proc_macro_suspicious_else_formatting.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
extern crate proc_macro;
77
use proc_macro::{token_stream, Delimiter, Group, Ident, Span, TokenStream, TokenTree};
8-
use std::iter::FromIterator;
98

109
fn read_ident(iter: &mut token_stream::IntoIter) -> Ident {
1110
match iter.next() {

tests/ui/checked_conversions.fixed

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
)]
88
#![warn(clippy::checked_conversions)]
99

10-
use std::convert::TryFrom;
11-
1210
// Positive tests
1311

1412
// Signed to unsigned

tests/ui/checked_conversions.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
)]
88
#![warn(clippy::checked_conversions)]
99

10-
use std::convert::TryFrom;
11-
1210
// Positive tests
1311

1412
// Signed to unsigned

0 commit comments

Comments
 (0)