1
Fork 0

Suggest if let x = y when encountering if x = y

Detect potential cases where `if let` was meant but `let` was left out.

Fix #44990.
This commit is contained in:
Esteban Küber 2020-08-25 20:28:25 -07:00
parent 85fbf49ce0
commit 07112ca62d
11 changed files with 268 additions and 102 deletions

View file

@ -213,6 +213,9 @@ pub struct Session {
known_attrs: Lock<MarkedAttrs>,
used_attrs: Lock<MarkedAttrs>,
/// `Span`s for `if` conditions that we have suggested turning into `if let`.
pub if_let_suggestions: Lock<FxHashSet<Span>>,
}
pub struct PerfStats {
@ -1354,6 +1357,7 @@ pub fn build_session(
target_features: FxHashSet::default(),
known_attrs: Lock::new(MarkedAttrs::new()),
used_attrs: Lock::new(MarkedAttrs::new()),
if_let_suggestions: Default::default(),
};
validate_commandline_args_with_session_available(&sess);