-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
Showing
4 changed files
with
75 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/test/ui/pattern/usefulness/issue-78549-ref-pat-and-str.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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", &_) => {}, | ||
(&&_, &_) => {}, | ||
} | ||
} |