Allow Foo { .. } patterns to match non-struct types#159295
Allow Foo { .. } patterns to match non-struct types#159295Jules-Bertholet wants to merge 1 commit into
Foo { .. } patterns to match non-struct types#159295Conversation
3bf9294 to
c2e2353
Compare
This comment has been minimized.
This comment has been minimized.
c2e2353 to
62c9fe1
Compare
|
Error: Label needs-rfc can only be set by Rust team members Please file an issue on GitHub at triagebot if there's a problem with this bot, or reach out on #triagebot on Zulip. |
a92adc3 to
fb354ce
Compare
|
This should be ready for at least an initial review—though conditional on t-lang approving the RFC, of course. r? @Nadrieril |
|
|
|
Some changes occurred in match checking cc @Nadrieril |
fb354ce to
54ee721
Compare
54ee721 to
97b2379
Compare
There was a problem hiding this comment.
Can we also add a test with patterns like Option::<i32> { .. } ?
There was a problem hiding this comment.
And a test that Option::Some::<i32> { .. } or Option::<i32>::Some { .. } or Option::Some { .. } still work.
| /// Paths in struct expressions and patterns `Path { .. }`. | ||
| Struct(Option<&'a Expr>), | ||
| /// Paths in patterns matching `Path { .. }` exactly (no fields, with rest pattern). | ||
| TypeOrEnumVariant, |
There was a problem hiding this comment.
I don't think it's a good style to make resolution of a path dependent on some other code next to it.
If we are doing this, then we should resolve paths in Path { .. } and Path { fields, .. } identically and then later say that the referenced type doesn't have fields (because it's e.g. an enum).
Implements rust-lang/rfcs#3753.
r? @ghost
@rustbot label T-lang A-patterns