Skip to content

Commit f11b7d3

Browse files
committed
add regression test for rust-lang#39808
Fixes rust-lang#39808
1 parent 2f526cc commit f11b7d3

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/test/run-pass/issue-39808.rs

+10-5
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,19 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// Regression test: even though `Ok` is dead-code, its type needs to
12-
// be influenced by the result of `Err` or else we get a "type
13-
// variable unconstrained" error.
11+
#![allow(unreachable_code)]
12+
13+
// Regression test for #39808. The type parameter of `Owned` was
14+
// considered to be "unconstrained" because the type resulting from
15+
// `format!` (`String`) was not being propagated upward, owing to the
16+
// fact that the expression diverges.
17+
18+
use std::borrow::Cow;
1419

1520
fn main() {
1621
let _ = if false {
17-
Ok(return)
22+
Cow::Owned(format!("{:?}", panic!())) /* as Cow<str> */ // uncomment to fix
1823
} else {
19-
Err("")
24+
Cow::Borrowed("")
2025
};
2126
}

0 commit comments

Comments
 (0)