forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#10356 - JirkaVebr:let_underscore_untyped, r=l…
…logiq Add `let_underscore_untyped` Fixes rust-lang#6842 This adds a new pedantic `let_underscore_untyped` lint which checks for `let _ = <expr>`, and suggests to either provide a type annotation, or to remove the `let` keyword. That way the author is forced to specify the type they intended to ignore, and thus get forced to re-visit the decision should the type of `<expr>` change. Alternatively, they can drop the `let` keyword to truly just ignore the value no matter what. r? `@llogiq` changelog: New lint: [let_underscore_untyped]
- Loading branch information
Showing
19 changed files
with
199 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#![allow(unused)] | ||
#![warn(clippy::let_underscore_untyped)] | ||
|
||
use std::future::Future; | ||
use std::{boxed::Box, fmt::Display}; | ||
|
||
fn a() -> u32 { | ||
1 | ||
} | ||
|
||
fn b<T>(x: T) -> T { | ||
x | ||
} | ||
|
||
fn c() -> impl Display { | ||
1 | ||
} | ||
|
||
fn d(x: &u32) -> &u32 { | ||
x | ||
} | ||
|
||
fn e() -> Result<u32, ()> { | ||
Ok(1) | ||
} | ||
|
||
fn f() -> Box<dyn Display> { | ||
Box::new(1) | ||
} | ||
|
||
fn main() { | ||
let _ = a(); | ||
let _ = b(1); | ||
let _ = c(); | ||
let _ = d(&1); | ||
let _ = e(); | ||
let _ = f(); | ||
|
||
_ = a(); | ||
_ = b(1); | ||
_ = c(); | ||
_ = d(&1); | ||
_ = e(); | ||
_ = f(); | ||
|
||
let _: u32 = a(); | ||
let _: u32 = b(1); | ||
let _: &u32 = d(&1); | ||
let _: Result<_, _> = e(); | ||
let _: Box<_> = f(); | ||
|
||
#[allow(clippy::let_underscore_untyped)] | ||
let _ = a(); | ||
} |
Oops, something went wrong.