Set mir_opt_level=0

This introduces some FNs. But a building Clippy is more important for now
This commit is contained in:
flip1995 2019-11-22 14:24:38 +01:00
parent cadc35af5a
commit e3a74ed2b5
No known key found for this signature in database
GPG key ID: 693086869D506637
6 changed files with 27 additions and 56 deletions

View file

@ -75,6 +75,8 @@ impl rustc_driver::Callbacks for ClippyCallbacks {
clippy_lints::register_pre_expansion_lints(&mut lint_store, &conf);
clippy_lints::register_renamed(&mut lint_store);
}));
config.opts.debugging_opts.mir_opt_level = 0;
}
}

View file

@ -1,23 +1,3 @@
error: index out of bounds: the len is 4 but the index is 4
--> $DIR/indexing_slicing.rs:18:5
|
LL | x[4]; // Ok, let rustc's `const_err` lint handle `usize` indexing on arrays.
| ^^^^
|
= note: `#[deny(const_err)]` on by default
error: index out of bounds: the len is 4 but the index is 8
--> $DIR/indexing_slicing.rs:19:5
|
LL | x[1 << 3]; // Ok, let rustc's `const_err` lint handle `usize` indexing on arrays.
| ^^^^^^^^^
error: index out of bounds: the len is 4 but the index is 15
--> $DIR/indexing_slicing.rs:54:5
|
LL | x[N]; // Ok, let rustc's `const_err` lint handle `usize` indexing on arrays.
| ^^^^
error: indexing may panic.
--> $DIR/indexing_slicing.rs:13:5
|
@ -209,5 +189,5 @@ LL | v[M];
|
= help: Consider using `.get(n)` or `.get_mut(n)` instead
error: aborting due to 27 previous errors
error: aborting due to 24 previous errors

View file

@ -32,8 +32,11 @@ fn random_caller() -> u32 {
static Y: u32 = 0;
// We should not suggest to make this function `const` because const functions are not allowed to
// refer to a static variable
fn get_y() -> u32 {
Y
//~^ ERROR E0013
}
// Don't lint entrypoint functions

View file

@ -18,11 +18,11 @@ fn main() {
let _s = Path::new("/a/b/").join("c");
let _s = Path::new("/a/b/").join("c");
let _s = Path::new("/a/b/").join("c").to_path_buf();
let _s = OsString::new();
let _s = OsString::new();
let _s = OsString::new().to_os_string();
// Check that lint level works
#[allow(clippy::redundant_clone)]
@ -47,6 +47,7 @@ fn main() {
let _ = Some(String::new()).unwrap_or_else(|| x.0.clone()); // ok; closure borrows `x`
with_branch(Alpha, true);
cannot_double_move(Alpha);
cannot_move_from_type_with_drop();
borrower_propagation();
}
@ -61,6 +62,10 @@ fn with_branch(a: Alpha, b: bool) -> (Alpha, Alpha) {
}
}
fn cannot_double_move(a: Alpha) -> (Alpha, Alpha) {
(a.clone(), a)
}
struct TypeWithDrop {
x: String,
}

View file

@ -47,6 +47,7 @@ fn main() {
let _ = Some(String::new()).unwrap_or_else(|| x.0.clone()); // ok; closure borrows `x`
with_branch(Alpha, true);
cannot_double_move(Alpha);
cannot_move_from_type_with_drop();
borrower_propagation();
}
@ -61,6 +62,10 @@ fn with_branch(a: Alpha, b: bool) -> (Alpha, Alpha) {
}
}
fn cannot_double_move(a: Alpha) -> (Alpha, Alpha) {
(a.clone(), a)
}
struct TypeWithDrop {
x: String,
}

View file

@ -59,18 +59,6 @@ note: this value is dropped without further use
LL | let _s = Path::new("/a/b/").join("c").to_owned();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: redundant clone
--> $DIR/redundant_clone.rs:21:42
|
LL | let _s = Path::new("/a/b/").join("c").to_path_buf();
| ^^^^^^^^^^^^^^ help: remove this
|
note: this value is dropped without further use
--> $DIR/redundant_clone.rs:21:14
|
LL | let _s = Path::new("/a/b/").join("c").to_path_buf();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: redundant clone
--> $DIR/redundant_clone.rs:23:29
|
@ -83,18 +71,6 @@ note: this value is dropped without further use
LL | let _s = OsString::new().to_owned();
| ^^^^^^^^^^^^^^^
error: redundant clone
--> $DIR/redundant_clone.rs:25:29
|
LL | let _s = OsString::new().to_os_string();
| ^^^^^^^^^^^^^^^ help: remove this
|
note: this value is dropped without further use
--> $DIR/redundant_clone.rs:25:14
|
LL | let _s = OsString::new().to_os_string();
| ^^^^^^^^^^^^^^^
error: redundant clone
--> $DIR/redundant_clone.rs:32:19
|
@ -108,52 +84,52 @@ LL | let _t = tup.0.clone();
| ^^^^^
error: redundant clone
--> $DIR/redundant_clone.rs:58:22
--> $DIR/redundant_clone.rs:59:22
|
LL | (a.clone(), a.clone())
| ^^^^^^^^ help: remove this
|
note: this value is dropped without further use
--> $DIR/redundant_clone.rs:58:21
--> $DIR/redundant_clone.rs:59:21
|
LL | (a.clone(), a.clone())
| ^
error: redundant clone
--> $DIR/redundant_clone.rs:114:15
--> $DIR/redundant_clone.rs:119:15
|
LL | let _s = s.clone();
| ^^^^^^^^ help: remove this
|
note: this value is dropped without further use
--> $DIR/redundant_clone.rs:114:14
--> $DIR/redundant_clone.rs:119:14
|
LL | let _s = s.clone();
| ^
error: redundant clone
--> $DIR/redundant_clone.rs:115:15
--> $DIR/redundant_clone.rs:120:15
|
LL | let _t = t.clone();
| ^^^^^^^^ help: remove this
|
note: this value is dropped without further use
--> $DIR/redundant_clone.rs:115:14
--> $DIR/redundant_clone.rs:120:14
|
LL | let _t = t.clone();
| ^
error: redundant clone
--> $DIR/redundant_clone.rs:125:19
--> $DIR/redundant_clone.rs:130:19
|
LL | let _f = f.clone();
| ^^^^^^^^ help: remove this
|
note: this value is dropped without further use
--> $DIR/redundant_clone.rs:125:18
--> $DIR/redundant_clone.rs:130:18
|
LL | let _f = f.clone();
| ^
error: aborting due to 13 previous errors
error: aborting due to 11 previous errors