Skip to content

Commit e3a74ed

Browse files
committed
Set mir_opt_level=0
This introduces some FNs. But a building Clippy is more important for now
1 parent cadc35a commit e3a74ed

File tree

6 files changed

+27
-56
lines changed

6 files changed

+27
-56
lines changed

src/driver.rs

+2
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ impl rustc_driver::Callbacks for ClippyCallbacks {
7575
clippy_lints::register_pre_expansion_lints(&mut lint_store, &conf);
7676
clippy_lints::register_renamed(&mut lint_store);
7777
}));
78+
79+
config.opts.debugging_opts.mir_opt_level = 0;
7880
}
7981
}
8082

tests/ui/indexing_slicing.stderr

+1-21
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,3 @@
1-
error: index out of bounds: the len is 4 but the index is 4
2-
--> $DIR/indexing_slicing.rs:18:5
3-
|
4-
LL | x[4]; // Ok, let rustc's `const_err` lint handle `usize` indexing on arrays.
5-
| ^^^^
6-
|
7-
= note: `#[deny(const_err)]` on by default
8-
9-
error: index out of bounds: the len is 4 but the index is 8
10-
--> $DIR/indexing_slicing.rs:19:5
11-
|
12-
LL | x[1 << 3]; // Ok, let rustc's `const_err` lint handle `usize` indexing on arrays.
13-
| ^^^^^^^^^
14-
15-
error: index out of bounds: the len is 4 but the index is 15
16-
--> $DIR/indexing_slicing.rs:54:5
17-
|
18-
LL | x[N]; // Ok, let rustc's `const_err` lint handle `usize` indexing on arrays.
19-
| ^^^^
20-
211
error: indexing may panic.
222
--> $DIR/indexing_slicing.rs:13:5
233
|
@@ -209,5 +189,5 @@ LL | v[M];
209189
|
210190
= help: Consider using `.get(n)` or `.get_mut(n)` instead
211191

212-
error: aborting due to 27 previous errors
192+
error: aborting due to 24 previous errors
213193

tests/ui/missing_const_for_fn/cant_be_const.rs

+3
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,11 @@ fn random_caller() -> u32 {
3232

3333
static Y: u32 = 0;
3434

35+
// We should not suggest to make this function `const` because const functions are not allowed to
36+
// refer to a static variable
3537
fn get_y() -> u32 {
3638
Y
39+
//~^ ERROR E0013
3740
}
3841

3942
// Don't lint entrypoint functions

tests/ui/redundant_clone.fixed

+7-2
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ fn main() {
1818

1919
let _s = Path::new("/a/b/").join("c");
2020

21-
let _s = Path::new("/a/b/").join("c");
21+
let _s = Path::new("/a/b/").join("c").to_path_buf();
2222

2323
let _s = OsString::new();
2424

25-
let _s = OsString::new();
25+
let _s = OsString::new().to_os_string();
2626

2727
// Check that lint level works
2828
#[allow(clippy::redundant_clone)]
@@ -47,6 +47,7 @@ fn main() {
4747
let _ = Some(String::new()).unwrap_or_else(|| x.0.clone()); // ok; closure borrows `x`
4848

4949
with_branch(Alpha, true);
50+
cannot_double_move(Alpha);
5051
cannot_move_from_type_with_drop();
5152
borrower_propagation();
5253
}
@@ -61,6 +62,10 @@ fn with_branch(a: Alpha, b: bool) -> (Alpha, Alpha) {
6162
}
6263
}
6364

65+
fn cannot_double_move(a: Alpha) -> (Alpha, Alpha) {
66+
(a.clone(), a)
67+
}
68+
6469
struct TypeWithDrop {
6570
x: String,
6671
}

tests/ui/redundant_clone.rs

+5
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ fn main() {
4747
let _ = Some(String::new()).unwrap_or_else(|| x.0.clone()); // ok; closure borrows `x`
4848

4949
with_branch(Alpha, true);
50+
cannot_double_move(Alpha);
5051
cannot_move_from_type_with_drop();
5152
borrower_propagation();
5253
}
@@ -61,6 +62,10 @@ fn with_branch(a: Alpha, b: bool) -> (Alpha, Alpha) {
6162
}
6263
}
6364

65+
fn cannot_double_move(a: Alpha) -> (Alpha, Alpha) {
66+
(a.clone(), a)
67+
}
68+
6469
struct TypeWithDrop {
6570
x: String,
6671
}

tests/ui/redundant_clone.stderr

+9-33
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,6 @@ note: this value is dropped without further use
5959
LL | let _s = Path::new("/a/b/").join("c").to_owned();
6060
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6161

62-
error: redundant clone
63-
--> $DIR/redundant_clone.rs:21:42
64-
|
65-
LL | let _s = Path::new("/a/b/").join("c").to_path_buf();
66-
| ^^^^^^^^^^^^^^ help: remove this
67-
|
68-
note: this value is dropped without further use
69-
--> $DIR/redundant_clone.rs:21:14
70-
|
71-
LL | let _s = Path::new("/a/b/").join("c").to_path_buf();
72-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
73-
7462
error: redundant clone
7563
--> $DIR/redundant_clone.rs:23:29
7664
|
@@ -83,18 +71,6 @@ note: this value is dropped without further use
8371
LL | let _s = OsString::new().to_owned();
8472
| ^^^^^^^^^^^^^^^
8573

86-
error: redundant clone
87-
--> $DIR/redundant_clone.rs:25:29
88-
|
89-
LL | let _s = OsString::new().to_os_string();
90-
| ^^^^^^^^^^^^^^^ help: remove this
91-
|
92-
note: this value is dropped without further use
93-
--> $DIR/redundant_clone.rs:25:14
94-
|
95-
LL | let _s = OsString::new().to_os_string();
96-
| ^^^^^^^^^^^^^^^
97-
9874
error: redundant clone
9975
--> $DIR/redundant_clone.rs:32:19
10076
|
@@ -108,52 +84,52 @@ LL | let _t = tup.0.clone();
10884
| ^^^^^
10985

11086
error: redundant clone
111-
--> $DIR/redundant_clone.rs:58:22
87+
--> $DIR/redundant_clone.rs:59:22
11288
|
11389
LL | (a.clone(), a.clone())
11490
| ^^^^^^^^ help: remove this
11591
|
11692
note: this value is dropped without further use
117-
--> $DIR/redundant_clone.rs:58:21
93+
--> $DIR/redundant_clone.rs:59:21
11894
|
11995
LL | (a.clone(), a.clone())
12096
| ^
12197

12298
error: redundant clone
123-
--> $DIR/redundant_clone.rs:114:15
99+
--> $DIR/redundant_clone.rs:119:15
124100
|
125101
LL | let _s = s.clone();
126102
| ^^^^^^^^ help: remove this
127103
|
128104
note: this value is dropped without further use
129-
--> $DIR/redundant_clone.rs:114:14
105+
--> $DIR/redundant_clone.rs:119:14
130106
|
131107
LL | let _s = s.clone();
132108
| ^
133109

134110
error: redundant clone
135-
--> $DIR/redundant_clone.rs:115:15
111+
--> $DIR/redundant_clone.rs:120:15
136112
|
137113
LL | let _t = t.clone();
138114
| ^^^^^^^^ help: remove this
139115
|
140116
note: this value is dropped without further use
141-
--> $DIR/redundant_clone.rs:115:14
117+
--> $DIR/redundant_clone.rs:120:14
142118
|
143119
LL | let _t = t.clone();
144120
| ^
145121

146122
error: redundant clone
147-
--> $DIR/redundant_clone.rs:125:19
123+
--> $DIR/redundant_clone.rs:130:19
148124
|
149125
LL | let _f = f.clone();
150126
| ^^^^^^^^ help: remove this
151127
|
152128
note: this value is dropped without further use
153-
--> $DIR/redundant_clone.rs:125:18
129+
--> $DIR/redundant_clone.rs:130:18
154130
|
155131
LL | let _f = f.clone();
156132
| ^
157133

158-
error: aborting due to 13 previous errors
134+
error: aborting due to 11 previous errors
159135

0 commit comments

Comments
 (0)