Uh oh!
There was an error while loading. Please reload this page.
Accept interpolated patterns in trait method parameters - #45775
Conversation
rust-highfive
commented
Nov 5, 2017
r? @eddyb (rust_highfive has picked a reviewer for you, use r? to override) |
eddyb
commented
Nov 5, 2017
LGTM. r? @nikomatsakis |
durka
commented
Nov 6, 2017
So is this also the "make #35203 a hard error" PR (skipping the deny-by-default step)? |
@durka The only patterns transitioning from warning to error are |
The code seems fine, the bigger question is the policy decision about moving to a hard error for at least some patterns. @petrochenkov what kind of crater runs do you have? Maybe we should do a pre-emptive run with this PR? |
petrochenkov
commented
Nov 6, 2017
From Jun 28, this year: #42894 (comment)#42894 (comment) |
durka
commented
Nov 6, 2017
Ah I see. So this is only one of the places that a #35203 warning can be generated and the other one is still a warning. |
Wait, I'm a little confused still, sorry. Is this the behavior I should expect after this PR? macro_rules! m {($pat: pat, $ty: ty) => {traitTr{fn f($pat: $ty);// changed to have no body so #35203 is triggered}}}m!(x,u8);// OKm!(mut x,u8);// warning #35203m!(&x,&u8);// errorm!((x, y),(u8,u8)):// error |
nikomatsakis
commented
Nov 6, 2017
@durka that is what I expect, from reading the source anyway. |
nikomatsakis
commented
Nov 6, 2017
@durka In particular, this PR makes "complex" patterns like |
durka
commented
Nov 6, 2017
OK. I don't think it fully addresses #35203 (comment) then (for me that's a compelling use case), but it matches the previous plan. |
petrochenkov
commented
Nov 6, 2017
Yes |
nikomatsakis
commented
Nov 6, 2017
Ah, I was misremembering. It's anonymous parameters that I was thinking of. |
Just for completeness, the reason it doesn't address that comment is even though you'll be able to write |
petrochenkov
commented
Nov 7, 2017
That's future proofing for type ascription in patterns let(x: u8, y) = ...;(and totally separate issue from this PR). |
durka
commented
Nov 7, 2017
I know the reasoning, I just wanted to point it out. |
nikomatsakis
commented
Nov 8, 2017
@rfcbot fcp merge OK, well, I'd like to get formal approval on moving to a hard error, even for a limited number of cases. But I think it probably makes sense to go forward here. To summarize the situation:
|
petrochenkov
commented
Nov 8, 2017
@rfcbot is on vacation
From 20 |
nikomatsakis
commented
Nov 9, 2017
Sigh. No @rfcbot? OK, I will nominate for discussion at today's mtg. |
nikomatsakis
commented
Nov 9, 2017
@petrochenkov have we tried to patch |
nikomatsakis
commented
Nov 9, 2017
Discussed in @rust-lang/compiler meeting and decided to go forward with this PR. |
nikomatsakis
commented
Nov 10, 2017
@bors r+ |
bors
commented
Nov 10, 2017
📌 Commit 10c0de3 has been approved by |
bors
commented
Nov 11, 2017
⌛ Testing commit 10c0de365d9cc61547ba66f3ea938688757a95f7 with merge d550e9f20fa647e7d1698d44627d77f240f73136... |
bors
commented
Nov 11, 2017
💔 Test failed - status-appveyor |
kennytm
commented
Nov 11, 2017
Needs to change the error code. |
Remove some outdated messages from "no patterns allowed" errors
petrochenkov
commented
Nov 11, 2017
@bors r=nikomatsakis |
bors
commented
Nov 11, 2017
📌 Commit f7b4b88 has been approved by |
bors
commented
Nov 11, 2017
Accept interpolated patterns in trait method parameters
Permit this, basically
```rust
macro_rules! m {
($pat: pat) => {
trait Tr {
fn f($pat: u8) {}
}
}
}
```
it previously caused a parsing error during expansion because trait methods accept only very restricted set of patterns during parsing due to ambiguities caused by [anonymous parameters](#41686), and this set didn't include interpolated patterns.
Some outdated messages from "no patterns allowed" errors are also removed.
Addresses #35203 (comment)petrochenkov
commented
Nov 11, 2017
I've sent a PR for |
bors
commented
Nov 11, 2017
☀️ Test successful - status-appveyor, status-travis |
nikomatsakis
commented
Nov 14, 2017
Marking for relnotes. This PR moves along the process of making argument patterns in functions without bodies a hard error (see #35203 for details). In particular, we now only support |
Permit this, basically
it previously caused a parsing error during expansion because trait methods accept only very restricted set of patterns during parsing due to ambiguities caused by anonymous parameters, and this set didn't include interpolated patterns.
Some outdated messages from "no patterns allowed" errors are also removed.
Addresses #35203 (comment)