Skip to content

Commit 7a9e443

Browse files
Raw Dedupe Works
1 parent 4d5b3b1 commit 7a9e443

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -684,6 +684,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
684684
let span = init.span(self.body);
685685
if !span.is_dummy() {
686686
spans.push(span);
687+
println!("ADDED: {:?}", span);
687688
}
688689
}
689690

@@ -779,7 +780,12 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
779780
}
780781
}
781782
if !shown {
783+
spans.dedup();
782784
for sp in &spans {
785+
println!("span {:?}", sp);
786+
println!("span {:?}", *sp < span);
787+
println!("COMP: {:?}", span);
788+
println!("COMP: {:?}", !sp.overlaps(span));
783789
if *sp < span && !sp.overlaps(span) {
784790
err.span_label(*sp, "binding initialized here in some conditions");
785791
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
fn main() {
2+
fn test() {
3+
loop {
4+
let blah: Option<String>;
5+
if true {
6+
blah = Some("".to_string());
7+
}
8+
if let Some(blah) = blah.as_ref() { //~ ERROR E0381
9+
}
10+
}
11+
}
12+
println!("{:?}", test())
13+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error[E0381]: used binding `blah` is possibly-uninitialized
2+
--> $DIR/issue-129274.rs:9:33
3+
|
4+
LL | let blah: Option<String>;
5+
| ---- binding declared here but left uninitialized
6+
LL | if true {
7+
LL | blah = Some("".to_string());
8+
| ---- binding initialized here in some conditions
9+
...
10+
LL | if let Some(blah) = blah.as_ref() {
11+
| ^^^^ `blah` used here but it is possibly-uninitialized
12+
13+
error: aborting due to 1 previous error
14+
15+
For more information about this error, try `rustc --explain E0381`.

0 commit comments

Comments
 (0)