Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upDeprecate anonymous parameters #1685
Conversation
matklad
referenced this pull request
Jul 24, 2016
Closed
require argument names in trait method signatures? #1351
petrochenkov
referenced this pull request
Jul 24, 2016
Merged
Properly enforce the "patterns aren't allowed in foreign functions" rule #35015
nrc
added
the
T-lang
label
Jul 25, 2016
This comment has been minimized.
This comment has been minimized.
WaDelma
commented
Jul 26, 2016
|
Well I have used these quite few times when parameter name wasn't nessary to understand the purpose. Didn't even realise that they cause this much problems. |
nikomatsakis
self-assigned this
Jul 28, 2016
bors
added a commit
to rust-lang/rust
that referenced
this pull request
Aug 4, 2016
This comment has been minimized.
This comment has been minimized.
|
So I'm torn here. On the one hand, I wish we had removed them long ago, or found another way to resolve the parser ambiguities. I am not happy with the arbitrary limitations! On the other hand, those could be overcome with more parser lookahead -- maybe a cover grammar too? -- and I worry a lot about this affecting a lot of people. I'm not sure it's really feasible. (I mean, it's only a deprecation, but still.) |
This comment has been minimized.
This comment has been minimized.
|
@nikomatsakis parser lookahead is bad :( Deprecations are easy. We can leave them in for a long time, only taking them out when we're sure that people have stopped using them, or almost all people have stopped using them. |
This comment has been minimized.
This comment has been minimized.
But unavoidable. |
This comment has been minimized.
This comment has been minimized.
|
Is there perhaps any script to download the source code of all crates.io packages locally? It shouldn't be that much data, right? I may try to quantify "a lot of people". |
This comment has been minimized.
This comment has been minimized.
|
@matklad indeed there is https://github.com/brson/stabworld |
This comment has been minimized.
This comment has been minimized.
|
Here are the results:
Here is the full report: https://gist.github.com/matklad/3ab67778a15778717e8b28bb01f7bacf (warning, 700kb of XML) EDIT: Note that it does not report anonymous parameters inside macro invocations, macro definitions and macro expansions. |
This comment has been minimized.
This comment has been minimized.
|
I think it makes sense to deprecate, put it on the breakage wishlist, then revisit in a few years. |
This comment has been minimized.
This comment has been minimized.
|
I feel mildly uncomfortable with the impact of this deprecation -- particularly since it seems useful to be able to elide parameter names. The main downside of today's setup is patterns, right? So another option would be to basically require more lookahead (or a cover grammar for patterns/types, etc), so that we could support anonymous parameters without some of their downsides, right? I haven't investigated this deeply, but it seems worth considering. |
This comment has been minimized.
This comment has been minimized.
I personally think that anonymous parameters are a language feature of negative value, even if we forget about all the problems the RFC mentions.
Almost zero benefit + two syntaxes for the same thing + usual bias of not adding features < 0 |
This comment has been minimized.
This comment has been minimized.
And yet another option is to do both parser tricks and a deprecation, to allow using full range of patterns today, and to be able to remove old syntax and tricks somewhere in the distant future. |
petrochenkov
referenced this pull request
Oct 24, 2016
Merged
Prohibit patterns in trait methods without bodies #37378
Manishearth
added a commit
to Manishearth/rust
that referenced
this pull request
Oct 26, 2016
bors
added a commit
to rust-lang/rust
that referenced
this pull request
Oct 29, 2016
bors
added a commit
to rust-lang/rust
that referenced
this pull request
Oct 29, 2016
This comment has been minimized.
This comment has been minimized.
|
Looks like discussion has died down. FCP maybe? |
This comment has been minimized.
This comment has been minimized.
mglagla
commented
Nov 28, 2016
|
Whenever i'm implementing a trait, i usually copy-paste the function signature into my code. Doing this with fmt::Display often makes me stumble a bit because of the anonymous parameter, as this is surprising. |
This comment has been minimized.
This comment has been minimized.
I also want to do this, but fear the size of the breakage. Although I agree it is not nice to have alternate syntaxes around (especially when |
This comment has been minimized.
This comment has been minimized.
|
@rfcbot close There has not been much discussion on this thread, although it has quite a few upvotes. There seems to be a viable alternative for some of the motivation (parser lookahead), and the pain of deprecation (this would affect 7.5% of all crates on crates.io (#1685 (comment))) does not seem to be out-weighed by the benefits. OTOH, I have to say that I also don't feel strongly about this and wouldn't argue strongly against accepting, if the lang team think it is worth the user pain. |
This comment has been minimized.
This comment has been minimized.
vi
commented
Nov 29, 2016
|
So is it for Rust 2.0? |
This comment has been minimized.
This comment has been minimized.
|
I feel like if somebody just sent a PR implementing a compatibility lint instead on an RFC, this would have higher chances. |
This comment has been minimized.
This comment has been minimized.
vi
commented
Nov 29, 2016
•
|
Maybe add the lint to the Clippy first? |
This comment has been minimized.
This comment has been minimized.
Whatever helps to get this out of the language eventually. |
This comment has been minimized.
This comment has been minimized.
There's already an inspection/quick fix in IntelliJ Rust, though it's not enabled yet :) |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
@aturon rightfully argued that:
But the "fix" for a hard deprecation warning is just As @aturon mentions, that is indeed some irritation and/or churn, but... it looks like pretty minor churn to me. I think that the following 3 things are very important:
|
This comment has been minimized.
This comment has been minimized.
Just noting that some people have started getting rustc from their distro, and while I think its not the best way to obtain rust as rust is evolving at a rapid pace (nor do I want to support anything older than the latest stable in my crates), they only update it in large intervals, e.g. every 6 months, or for LTS distros every 4-5 years. For them it won't be smooth. |
This comment has been minimized.
This comment has been minimized.
By smooth I meant a "bugless" hard warning experience, not time-continuous kind of smooth. |
petrochenkov
referenced this pull request
Mar 1, 2017
Closed
Destructuring isn't supported in default trait methods' arguments. #14267
This comment has been minimized.
This comment has been minimized.
porky11
commented
Mar 1, 2017
|
I like the ability to define type signatures without names, when the names aren't used anyway. |
This comment has been minimized.
This comment has been minimized.
|
Let's see if this works: @rfcbot fcp cancel |
This comment has been minimized.
This comment has been minimized.
rfcbot
commented
Mar 4, 2017
|
@aturon proposal cancelled. |
This comment has been minimized.
This comment has been minimized.
|
@rfcbot fcp merge (As per @nikomatsakis's comment) |
This comment has been minimized.
This comment has been minimized.
rfcbot
commented
Mar 4, 2017
•
|
Team member @aturon has proposed to merge this. The next step is review by the rest of the tagged teams: No concerns currently listed. Once these reviewers reach consensus, this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
pnkfelix
reviewed
Mar 15, 2017
| # Motivation | ||
| [motivation]: #motivation | ||
|
|
||
| Anonymous parameters are a [historic accident]. They cause a number of technical |
This comment has been minimized.
This comment has been minimized.
pnkfelix
Mar 15, 2017
Member
This claim is misrepresenting the text it references.
What Niko wrote there was:
I don't believe it was intended that parameter names can be omitted in trait methods with a body
(emphasis added)
I do not think it was ever an accident that the design allowed anonymous parameters for trait methods without a body.
This comment has been minimized.
This comment has been minimized.
matklad
Mar 15, 2017
Author
Member
I was referring to another part of the comment, but maybe I've misinterpreted it
I thought we planned to require parameter names in trait definitions for this reason -- but I guess that never happened?
@nikomatsakis what would be the right way to phrase this in the RFC? Or we can just drop this sentence: it does not add anything to the current situation, it just an interesting historical detail :)
This comment has been minimized.
This comment has been minimized.
matklad
Mar 15, 2017
•
Author
Member
Or perhaps I was intending to provide this link instead? https://internals.rust-lang.org/t/pre-rfc-deprecating-anonymous-parameters/3710/9?u=matklad
This comment has been minimized.
This comment has been minimized.
nikomatsakis
Apr 25, 2017
Contributor
Either way. I do remember discussing this at some point but -- as you say -- it never happened.
This comment has been minimized.
This comment has been minimized.
|
@rfcbot reviewed |
This comment has been minimized.
This comment has been minimized.
rfcbot
commented
Apr 19, 2017
|
|
rfcbot
added
the
final-comment-period
label
Apr 19, 2017
carols10cents
added this to FCP
in Tracker
Apr 26, 2017
This comment has been minimized.
This comment has been minimized.
rfcbot
commented
Apr 29, 2017
|
The final comment period is now complete. |
aturon
referenced this pull request
May 1, 2017
Closed
Tracking issue for RFC#1685: Deprecate anonymous parameters #41686
aturon
merged commit cef568c
into
rust-lang:master
May 1, 2017
This comment has been minimized.
This comment has been minimized.
frewsxcv
added a commit
to frewsxcv/rust
that referenced
this pull request
May 2, 2017
This comment has been minimized.
This comment has been minimized.
gbutler69
commented
Jun 4, 2017
|
@ubsan - I would disagree with your comment:
The problem with this is, they NEVER get removed. See the situation with Java. Almost nothing that is deprecated is EVER removed (years later). Over time, it has become a problem for the language and JVM designers because they need to continue to support things that have been deprecated for years even though it keeps them from migrating the language the way they would like to easily. Deprecations should come with a promise to remove/disable the feature at a pre-defined time in the future. Ideally, deprecation should say which version the feature will be removed/disabled at the time it is deprecated. At that version it should be removed. Otherwise, the notion of deprecation is meaningless. |
This comment has been minimized.
This comment has been minimized.
WaDelma
commented
Jun 4, 2017
|
As far as I understand the plan is to only remove deprecated items in rust 2.0 as removing it 1.* would be a breaking change, but I could be wrong. |
matklad commentedJul 24, 2016
Rendered
Issue: #1351