Skip to content

Commit

Permalink
Set mir_opt_level=0
Browse files Browse the repository at this point in the history
This introduces some FNs. But a building Clippy is more important for now
  • Loading branch information
flip1995 committed Nov 22, 2019
1 parent cadc35a commit e3a74ed
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 56 deletions.
2 changes: 2 additions & 0 deletions src/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

This comment was marked as off-topic.

Copy link
@oli-obk

oli-obk Nov 22, 2019

Contributor

Leave a comment as to why we use this

This comment was marked as off-topic.

Copy link
@flip1995

flip1995 Nov 23, 2019

Author Member

Done

}
}

Expand Down
22 changes: 1 addition & 21 deletions tests/ui/indexing_slicing.stderr
Original file line number Diff line number Diff line change
@@ -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
|
Expand Down Expand Up @@ -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

3 changes: 3 additions & 0 deletions tests/ui/missing_const_for_fn/cant_be_const.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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

This comment was marked as off-topic.

Copy link
@oli-obk

oli-obk Nov 22, 2019

Contributor

huh, this shouldn't be errorring, is this being emitted from is_min_const_fn?

This comment was marked as off-topic.

Copy link
@flip1995

flip1995 Nov 22, 2019

Author Member

Playground

This doesn't error. But if we turn the function in a const function error[E0723]: cannot access static items in const fn is emitted. No idea why the comment mentions E0013.

This comment was marked as off-topic.

Copy link
@oli-obk

oli-obk Nov 22, 2019

Contributor

Not sure what the linked playground does ^^

Right, but it isn't a const fn yet. This is happening before changing it to a const fn

This comment was marked as off-topic.

Copy link
@flip1995

flip1995 Nov 22, 2019

Author Member

Oh, I shared the wrong playground 😄 Playground

I think this error is never emitted. ping @phansch since you added this comment originally (c3980bf).

This comment was marked as off-topic.

Copy link
@oli-obk

oli-obk Nov 22, 2019

Contributor

Ah.I thought this was added because the error was being emitted. Ignore this comment then

}

// Don't lint entrypoint functions
Expand Down
9 changes: 7 additions & 2 deletions tests/ui/redundant_clone.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand All @@ -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();
}
Expand All @@ -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,
}
Expand Down
5 changes: 5 additions & 0 deletions tests/ui/redundant_clone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -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,
}
Expand Down
42 changes: 9 additions & 33 deletions tests/ui/redundant_clone.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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
|
Expand All @@ -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
|
Expand All @@ -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

0 comments on commit e3a74ed

Please sign in to comment.