-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #103749 - est31:reduce_irrefutable_let_else_span, r=c…
…jgillot Reduce span of let else irrefutable_let_patterns warning Huge spans aren't good for IDE users as they underline constructs that are possibly multiline. Similar PR to #90761 which did the same for the `unused_macros` lint.
- Loading branch information
Showing
3 changed files
with
26 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
// check-pass | ||
|
||
|
||
|
||
fn main() { | ||
let x = 1 else { return }; //~ WARN irrefutable `let...else` pattern | ||
|
||
// Multiline else blocks should not get printed | ||
let x = 1 else { //~ WARN irrefutable `let...else` pattern | ||
eprintln!("problem case encountered"); | ||
return | ||
}; | ||
} |
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 |
---|---|---|
@@ -1,12 +1,21 @@ | ||
warning: irrefutable `let...else` pattern | ||
--> $DIR/let-else-irrefutable.rs:6:5 | ||
--> $DIR/let-else-irrefutable.rs:4:5 | ||
| | ||
LL | let x = 1 else { return }; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| ^^^^^^^^^ | ||
| | ||
= note: this pattern will always match, so the `else` clause is useless | ||
= help: consider removing the `else` clause | ||
= note: `#[warn(irrefutable_let_patterns)]` on by default | ||
|
||
warning: 1 warning emitted | ||
warning: irrefutable `let...else` pattern | ||
--> $DIR/let-else-irrefutable.rs:7:5 | ||
| | ||
LL | let x = 1 else { | ||
| ^^^^^^^^^ | ||
| | ||
= note: this pattern will always match, so the `else` clause is useless | ||
= help: consider removing the `else` clause | ||
|
||
warning: 2 warnings emitted | ||
|