diff options
| author | Nadrieril <nadrieril+git@gmail.com> | 2020-11-01 01:58:48 +0000 |
|---|---|---|
| committer | Nadrieril <nadrieril+git@gmail.com> | 2020-11-01 02:04:42 +0000 |
| commit | 4cd30197eb126727b791a1c845c5ec47dbd3b1de (patch) | |
| tree | 0b3e2d94cf67c154f2c3b92b7a51737fe3a9accd /src/test/ui/pattern | |
| parent | a53fb30e3bf2655b0563da6d561c23cda5f3ec11 (diff) | |
Fix #78549
Before #78430, string literals worked because `specialize_constructor` didn't actually care too much which constructor was passed to it unless needed. Since then, string literals are special cased and a bit hacky. I did not anticipate patterns for the `&str` type other than string literals, hence this bug. This makes string literals less hacky.
Diffstat (limited to 'src/test/ui/pattern')
| -rw-r--r-- | src/test/ui/pattern/usefulness/issue-78549-ref-pat-and-str.rs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/test/ui/pattern/usefulness/issue-78549-ref-pat-and-str.rs b/src/test/ui/pattern/usefulness/issue-78549-ref-pat-and-str.rs new file mode 100644 index 00000000000..2879caf2c4c --- /dev/null +++ b/src/test/ui/pattern/usefulness/issue-78549-ref-pat-and-str.rs @@ -0,0 +1,25 @@ +// check-pass +// From https://github.com/rust-lang/rust/issues/78549 + +fn main() { + match "foo" { + "foo" => {}, + &_ => {}, + } + + match "foo" { + &_ => {}, + "foo" => {}, + } + + match ("foo", 0, "bar") { + (&_, 0, &_) => {}, + ("foo", _, "bar") => {}, + (&_, _, &_) => {}, + } + + match (&"foo", "bar") { + (&"foo", &_) => {}, + (&&_, &_) => {}, + } +} |
