diff options
| author | Stephen Lazaro <stephen.lazaro@gmail.com> | 2024-08-20 17:53:30 -0700 |
|---|---|---|
| committer | Stephen Lazaro <stephen.lazaro@gmail.com> | 2024-08-22 09:36:14 -0700 |
| commit | e91f32829ccfb60e13fcb07dab4947c382a376c9 (patch) | |
| tree | 734fad18f39011ddd1e8f7b88c81f52dc41a85fb /tests | |
| parent | 4d5b3b196284aded6ae99d12bcf149ffdc8ef379 (diff) | |
| download | rust-e91f32829ccfb60e13fcb07dab4947c382a376c9.tar.gz rust-e91f32829ccfb60e13fcb07dab4947c382a376c9.zip | |
Deduplicate Spans in Uninitialized Check
Prevents reporting labels or diagnostics on spans that are produced multiple times.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ui/duplicate-label-E0381-issue-129274.rs | 13 | ||||
| -rw-r--r-- | tests/ui/duplicate-label-E0381-issue-129274.stderr | 15 |
2 files changed, 28 insertions, 0 deletions
diff --git a/tests/ui/duplicate-label-E0381-issue-129274.rs b/tests/ui/duplicate-label-E0381-issue-129274.rs new file mode 100644 index 00000000000..b2156e630c8 --- /dev/null +++ b/tests/ui/duplicate-label-E0381-issue-129274.rs @@ -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()) +} diff --git a/tests/ui/duplicate-label-E0381-issue-129274.stderr b/tests/ui/duplicate-label-E0381-issue-129274.stderr new file mode 100644 index 00000000000..7f8bddb17c5 --- /dev/null +++ b/tests/ui/duplicate-label-E0381-issue-129274.stderr @@ -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`. |
