Skip to content

Commit faa0576

Browse files
committed
moved renamed docs | diverging-fallback-option.rs
1 parent 35239c3 commit faa0576

File tree

2 files changed

+19
-14
lines changed

2 files changed

+19
-14
lines changed

tests/ui/diverging-fallback-option.rs

Lines changed: 0 additions & 14 deletions
This file was deleted.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//@ run-pass
2+
3+
#![allow(warnings)]
4+
5+
//! Tests type inference fallback to `!` (never type) in `Option` context.
6+
//!
7+
//! Regression test for issues:
8+
//! - https://github.com/rust-lang/rust/issues/39808
9+
//! - https://github.com/rust-lang/rust/issues/39984
10+
//!
11+
//! Checks that when creating `Option` from a diverging expression,
12+
//! the type parameter defaults to `!` without requiring explicit annotations.
13+
14+
fn main() {
15+
// This expression diverges, so its type is `!`
16+
let c = Some({ return; });
17+
// The type of `c` is inferred as `Option<!>`
18+
c.unwrap();
19+
}

0 commit comments

Comments
 (0)