-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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 #129340 - stephen-lazaro:u/slazaro/issue-129274, r=co…
…mpiler-errors Remove Duplicate E0381 Label Aims to resolve #129274, and adds a test for the case. Essentially, we are duplicating this span for some reason. For now, I'm just using a set to collect the spans rather than the vec. I imagine there's probably no real reason to inspect duplicates in this area, but if I'm wrong I can adjust to collect "seen spans" in just the point where this label is applied. I'm not sure why it's producing duplicate spans. Looks like this has been this way for a while? I think it gives the duplicate label on 1.75.0 for example.
- Loading branch information
Showing
3 changed files
with
31 additions
and
2 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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
fn main() { | ||
fn test() { | ||
loop { | ||
let blah: Option<String>; | ||
if true { | ||
blah = Some("".to_string()); | ||
} | ||
if let Some(blah) = blah.as_ref() { //~ ERROR E0381 | ||
} | ||
} | ||
} | ||
println!("{:?}", test()) | ||
} |
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,15 @@ | ||
error[E0381]: used binding `blah` is possibly-uninitialized | ||
--> $DIR/duplicate-label-E0381-issue-129274.rs:8:33 | ||
| | ||
LL | let blah: Option<String>; | ||
| ---- binding declared here but left uninitialized | ||
LL | if true { | ||
LL | blah = Some("".to_string()); | ||
| ---- binding initialized here in some conditions | ||
LL | } | ||
LL | if let Some(blah) = blah.as_ref() { | ||
| ^^^^ `blah` used here but it is possibly-uninitialized | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0381`. |