Skip to content

Commit e1bc117

Browse files
committed
Update redundant_type_annotations doc and tests to remove String
1 parent aa0a94d commit e1bc117

File tree

3 files changed

+7
-25
lines changed

3 files changed

+7
-25
lines changed

src/tools/clippy/clippy_lints/src/redundant_type_annotations.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ declare_clippy_lint! {
2525
///
2626
/// ### Example
2727
/// ```no_run
28-
/// let foo: String = String::new();
28+
/// let foo: usize = usize::MAX;
2929
/// ```
3030
/// Use instead:
3131
/// ```no_run
32-
/// let foo = String::new();
32+
/// let foo = usize::MAX;
3333
/// ```
3434
#[clippy::version = "1.72.0"]
3535
pub REDUNDANT_TYPE_ANNOTATIONS,

src/tools/clippy/tests/ui/redundant_type_annotations.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,10 @@ fn test_complex_types<T>() {
154154
}
155155

156156
fn test_functions() {
157-
// Everything here should be lint
157+
// Everything here should be lint, except for String, due to #101551
158158

159+
// FIXME: if generics support is added, the lint should fire here
159160
let _return: String = return_a_string();
160-
//~^ ERROR: redundant type annotation
161161

162162
let _return: Pie = return_a_struct();
163163
//~^ ERROR: redundant type annotation
@@ -168,8 +168,8 @@ fn test_functions() {
168168
let _return: u32 = return_an_int();
169169
//~^ ERROR: redundant type annotation
170170

171+
// FIXME: if generics support is added, the lint should fire here
171172
let _return: String = String::new();
172-
//~^ ERROR: redundant type annotation
173173

174174
let new_pie: Pie = Pie::new();
175175
//~^ ERROR: redundant type annotation
@@ -180,8 +180,8 @@ fn test_functions() {
180180
let _return: u32 = Pie::associated_return_an_int();
181181
//~^ ERROR: redundant type annotation
182182

183+
// FIXME: if generics support is added, the lint should fire here
183184
let _return: String = Pie::associated_return_a_string();
184-
//~^ ERROR: redundant type annotation
185185
}
186186

187187
fn test_simple_types() {

src/tools/clippy/tests/ui/redundant_type_annotations.stderr

+1-19
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,6 @@ error: redundant type annotation
1919
LL | let v: &Slice = self.return_a_ref_to_struct();
2020
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2121

22-
error: redundant type annotation
23-
--> tests/ui/redundant_type_annotations.rs:159:5
24-
|
25-
LL | let _return: String = return_a_string();
26-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
27-
2822
error: redundant type annotation
2923
--> tests/ui/redundant_type_annotations.rs:162:5
3024
|
@@ -43,12 +37,6 @@ error: redundant type annotation
4337
LL | let _return: u32 = return_an_int();
4438
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4539

46-
error: redundant type annotation
47-
--> tests/ui/redundant_type_annotations.rs:171:5
48-
|
49-
LL | let _return: String = String::new();
50-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
51-
5240
error: redundant type annotation
5341
--> tests/ui/redundant_type_annotations.rs:174:5
5442
|
@@ -67,12 +55,6 @@ error: redundant type annotation
6755
LL | let _return: u32 = Pie::associated_return_an_int();
6856
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6957

70-
error: redundant type annotation
71-
--> tests/ui/redundant_type_annotations.rs:183:5
72-
|
73-
LL | let _return: String = Pie::associated_return_a_string();
74-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
75-
7658
error: redundant type annotation
7759
--> tests/ui/redundant_type_annotations.rs:190:5
7860
|
@@ -103,5 +85,5 @@ error: redundant type annotation
10385
LL | let _var: bool = false;
10486
| ^^^^^^^^^^^^^^^^^^^^^^^
10587

106-
error: aborting due to 17 previous errors
88+
error: aborting due to 14 previous errors
10789

0 commit comments

Comments
 (0)