Make expr_use_ctxt always return Some unless the syntax context changes.
This commit is contained in:
parent
b587871e27
commit
cdc4c697b5
7 changed files with 112 additions and 122 deletions
|
|
@ -1,6 +1,11 @@
|
|||
//@aux-build:proc_macro_derive.rs
|
||||
#![warn(clippy::ignored_unit_patterns)]
|
||||
#![allow(clippy::let_unit_value, clippy::redundant_pattern_matching, clippy::single_match)]
|
||||
#![allow(
|
||||
clippy::let_unit_value,
|
||||
clippy::redundant_pattern_matching,
|
||||
clippy::single_match,
|
||||
clippy::needless_borrow
|
||||
)]
|
||||
|
||||
fn foo() -> Result<(), ()> {
|
||||
unimplemented!()
|
||||
|
|
|
|||
|
|
@ -1,6 +1,11 @@
|
|||
//@aux-build:proc_macro_derive.rs
|
||||
#![warn(clippy::ignored_unit_patterns)]
|
||||
#![allow(clippy::let_unit_value, clippy::redundant_pattern_matching, clippy::single_match)]
|
||||
#![allow(
|
||||
clippy::let_unit_value,
|
||||
clippy::redundant_pattern_matching,
|
||||
clippy::single_match,
|
||||
clippy::needless_borrow
|
||||
)]
|
||||
|
||||
fn foo() -> Result<(), ()> {
|
||||
unimplemented!()
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: matching over `()` is more explicit
|
||||
--> $DIR/ignored_unit_patterns.rs:11:12
|
||||
--> $DIR/ignored_unit_patterns.rs:16:12
|
||||
|
|
||||
LL | Ok(_) => {},
|
||||
| ^ help: use `()` instead of `_`: `()`
|
||||
|
|
@ -8,49 +8,49 @@ LL | Ok(_) => {},
|
|||
= help: to override `-D warnings` add `#[allow(clippy::ignored_unit_patterns)]`
|
||||
|
||||
error: matching over `()` is more explicit
|
||||
--> $DIR/ignored_unit_patterns.rs:12:13
|
||||
--> $DIR/ignored_unit_patterns.rs:17:13
|
||||
|
|
||||
LL | Err(_) => {},
|
||||
| ^ help: use `()` instead of `_`: `()`
|
||||
|
||||
error: matching over `()` is more explicit
|
||||
--> $DIR/ignored_unit_patterns.rs:14:15
|
||||
--> $DIR/ignored_unit_patterns.rs:19:15
|
||||
|
|
||||
LL | if let Ok(_) = foo() {}
|
||||
| ^ help: use `()` instead of `_`: `()`
|
||||
|
||||
error: matching over `()` is more explicit
|
||||
--> $DIR/ignored_unit_patterns.rs:16:28
|
||||
--> $DIR/ignored_unit_patterns.rs:21:28
|
||||
|
|
||||
LL | let _ = foo().map_err(|_| todo!());
|
||||
| ^ help: use `()` instead of `_`: `()`
|
||||
|
||||
error: matching over `()` is more explicit
|
||||
--> $DIR/ignored_unit_patterns.rs:22:16
|
||||
--> $DIR/ignored_unit_patterns.rs:27:16
|
||||
|
|
||||
LL | Ok(_) => {},
|
||||
| ^ help: use `()` instead of `_`: `()`
|
||||
|
||||
error: matching over `()` is more explicit
|
||||
--> $DIR/ignored_unit_patterns.rs:24:17
|
||||
--> $DIR/ignored_unit_patterns.rs:29:17
|
||||
|
|
||||
LL | Err(_) => {},
|
||||
| ^ help: use `()` instead of `_`: `()`
|
||||
|
||||
error: matching over `()` is more explicit
|
||||
--> $DIR/ignored_unit_patterns.rs:36:9
|
||||
--> $DIR/ignored_unit_patterns.rs:41:9
|
||||
|
|
||||
LL | let _ = foo().unwrap();
|
||||
| ^ help: use `()` instead of `_`: `()`
|
||||
|
||||
error: matching over `()` is more explicit
|
||||
--> $DIR/ignored_unit_patterns.rs:45:13
|
||||
--> $DIR/ignored_unit_patterns.rs:50:13
|
||||
|
|
||||
LL | (1, _) => unimplemented!(),
|
||||
| ^ help: use `()` instead of `_`: `()`
|
||||
|
||||
error: matching over `()` is more explicit
|
||||
--> $DIR/ignored_unit_patterns.rs:52:13
|
||||
--> $DIR/ignored_unit_patterns.rs:57:13
|
||||
|
|
||||
LL | for (x, _) in v {
|
||||
| ^ help: use `()` instead of `_`: `()`
|
||||
|
|
|
|||
|
|
@ -131,6 +131,9 @@ fn main() {
|
|||
0
|
||||
}
|
||||
}
|
||||
|
||||
// issue #11786
|
||||
let x: (&str,) = ("",);
|
||||
}
|
||||
|
||||
#[allow(clippy::needless_borrowed_reference)]
|
||||
|
|
|
|||
|
|
@ -131,6 +131,9 @@ fn main() {
|
|||
0
|
||||
}
|
||||
}
|
||||
|
||||
// issue #11786
|
||||
let x: (&str,) = (&"",);
|
||||
}
|
||||
|
||||
#[allow(clippy::needless_borrowed_reference)]
|
||||
|
|
|
|||
|
|
@ -121,41 +121,47 @@ error: this expression creates a reference which is immediately dereferenced by
|
|||
LL | (&&5).foo();
|
||||
| ^^^^^ help: change this to: `(&5)`
|
||||
|
||||
error: this expression creates a reference which is immediately dereferenced by the compiler
|
||||
--> $DIR/needless_borrow.rs:136:23
|
||||
|
|
||||
LL | let x: (&str,) = (&"",);
|
||||
| ^^^ help: change this to: `""`
|
||||
|
||||
error: this expression borrows a value the compiler would automatically borrow
|
||||
--> $DIR/needless_borrow.rs:175:13
|
||||
--> $DIR/needless_borrow.rs:178:13
|
||||
|
|
||||
LL | (&self.f)()
|
||||
| ^^^^^^^^^ help: change this to: `(self.f)`
|
||||
|
||||
error: this expression borrows a value the compiler would automatically borrow
|
||||
--> $DIR/needless_borrow.rs:184:13
|
||||
--> $DIR/needless_borrow.rs:187:13
|
||||
|
|
||||
LL | (&mut self.f)()
|
||||
| ^^^^^^^^^^^^^ help: change this to: `(self.f)`
|
||||
|
||||
error: this expression borrows a value the compiler would automatically borrow
|
||||
--> $DIR/needless_borrow.rs:221:22
|
||||
--> $DIR/needless_borrow.rs:224:22
|
||||
|
|
||||
LL | let _ = &mut (&mut { x.u }).x;
|
||||
| ^^^^^^^^^^^^^^ help: change this to: `{ x.u }`
|
||||
|
||||
error: this expression borrows a value the compiler would automatically borrow
|
||||
--> $DIR/needless_borrow.rs:228:22
|
||||
--> $DIR/needless_borrow.rs:231:22
|
||||
|
|
||||
LL | let _ = &mut (&mut { x.u }).x;
|
||||
| ^^^^^^^^^^^^^^ help: change this to: `{ x.u }`
|
||||
|
||||
error: this expression borrows a value the compiler would automatically borrow
|
||||
--> $DIR/needless_borrow.rs:232:22
|
||||
--> $DIR/needless_borrow.rs:235:22
|
||||
|
|
||||
LL | let _ = &mut (&mut x.u).x;
|
||||
| ^^^^^^^^^^ help: change this to: `x.u`
|
||||
|
||||
error: this expression borrows a value the compiler would automatically borrow
|
||||
--> $DIR/needless_borrow.rs:233:22
|
||||
--> $DIR/needless_borrow.rs:236:22
|
||||
|
|
||||
LL | let _ = &mut (&mut { x.u }).x;
|
||||
| ^^^^^^^^^^^^^^ help: change this to: `{ x.u }`
|
||||
|
||||
error: aborting due to 26 previous errors
|
||||
error: aborting due to 27 previous errors
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue