File tree 1 file changed +10
-5
lines changed
1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change 8
8
// option. This file may not be copied, modified, or distributed
9
9
// except according to those terms.
10
10
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 ;
14
19
15
20
fn main ( ) {
16
21
let _ = if false {
17
- Ok ( return )
22
+ Cow :: Owned ( format ! ( "{:?}" , panic! ( ) ) ) /* as Cow<str> */ // uncomment to fix
18
23
} else {
19
- Err ( "" )
24
+ Cow :: Borrowed ( "" )
20
25
} ;
21
26
}
You can’t perform that action at this time.
0 commit comments