]> git.lizzy.rs Git - rust.git/blob - src/test/ui/issues/issue-39808.rs
Merge commit '9a0c32934ebe376128230aa8da3275697b2053e7' into sync_cg_clif-2021-03-05
[rust.git] / src / test / ui / issues / issue-39808.rs
1 // run-pass
2 #![allow(unreachable_code)]
3
4 // Regression test for #39808. The type parameter of `Owned` was
5 // considered to be "unconstrained" because the type resulting from
6 // `format!` (`String`) was not being propagated upward, owing to the
7 // fact that the expression diverges.
8
9 use std::borrow::Cow;
10
11 fn main() {
12     let _ = if false {
13         Cow::Owned(format!("{:?}", panic!()))
14     } else {
15         Cow::Borrowed("")
16     };
17 }