diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2017-03-18 15:22:48 -0400 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2017-03-30 07:55:29 -0400 |
| commit | f11b7d33bb71a78beb6a4671d53d2e89a2afc0ef (patch) | |
| tree | 6fdc58396fcfc29c5bbc5bdd879e3d71c9ada5e5 | |
| parent | 2f526cc89773d3b14c3d909152697678bc8fa7a1 (diff) | |
| download | rust-f11b7d33bb71a78beb6a4671d53d2e89a2afc0ef.tar.gz rust-f11b7d33bb71a78beb6a4671d53d2e89a2afc0ef.zip | |
add regression test for #39808
Fixes #39808
| -rw-r--r-- | src/test/run-pass/issue-39808.rs | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/test/run-pass/issue-39808.rs b/src/test/run-pass/issue-39808.rs index f83e9328e58..00c2bdc8cc9 100644 --- a/src/test/run-pass/issue-39808.rs +++ b/src/test/run-pass/issue-39808.rs @@ -8,14 +8,19 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// Regression test: even though `Ok` is dead-code, its type needs to -// be influenced by the result of `Err` or else we get a "type -// variable unconstrained" error. +#![allow(unreachable_code)] + +// Regression test for #39808. The type parameter of `Owned` was +// considered to be "unconstrained" because the type resulting from +// `format!` (`String`) was not being propagated upward, owing to the +// fact that the expression diverges. + +use std::borrow::Cow; fn main() { let _ = if false { - Ok(return) + Cow::Owned(format!("{:?}", panic!())) /* as Cow<str> */ // uncomment to fix } else { - Err("") + Cow::Borrowed("") }; } |
