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 upUse Declarations in More Places #1976
Conversation
This comment has been minimized.
This comment has been minimized.
|
I like having match self.0.partial_cmp(other.0) {
None => unreachable!(),
Some(Greater) => Some(Lesser),
use Ordering::*; // 😣
Some(Less) => Some(Greater),
Some(Eq) => Some(Eq)
} |
This comment has been minimized.
This comment has been minimized.
burdges
commented
Apr 18, 2017
|
There is a case for |
This comment has been minimized.
This comment has been minimized.
|
Over IRC @nagisa suggested Having it in trait also makes sense for the same reason as having it in impl. If we go the route of having it in match like as describe, it would also make sense to have it in struct (though not tuple structs) and enum as well...I'll add them to the RFC. For having |
This comment has been minimized.
This comment has been minimized.
Havvy
changed the title
Use Declarations in Implementations and Match Exprs
Use Declarations in More Places
Apr 18, 2017
This comment has been minimized.
This comment has been minimized.
burdges
commented
Apr 18, 2017
|
Just fyi, I think mixing |
withoutboats
added
the
T-lang
label
Apr 19, 2017
This comment has been minimized.
This comment has been minimized.
|
I would say that we should, at least for the time being, keep to just impl blocks. I don't think use in match or elsewhere is all that useful, since you can usually just put it in a block around the match (or the function which the match is in); constraining this RFC to just impl blocks seems like a good start to this. However, I don't feel strongly about this--if we can get it with everything, then perhaps that's better. I do have some concerns about this RFC running into the same problems the else match RFC ran into (scoping issues, primarily; what do we include? What makes sense? etc.). These scoping issues are certainly not as major a problem for this RFC I think since it's changes are more minimal in terms of where they can go. |
This comment has been minimized.
This comment has been minimized.
|
@Mark-Simulacrum its very useful in match, to not having to write the enum name in every case. |
This comment has been minimized.
This comment has been minimized.
|
For
the "match" expr "{" (attr* "use" paths ";")* (pat "=>" (expr "," | block))+ "}"There is no need to allow more things inside the |
This comment has been minimized.
This comment has been minimized.
burdges
commented
Apr 20, 2017
|
It's interesting if you find a complication with adding |
This comment has been minimized.
This comment has been minimized.
|
I agree that there's likely no problem with adding |
This comment has been minimized.
This comment has been minimized.
ghost
commented
Apr 20, 2017
|
Perhaps This also logically deals with the problem of mixing semicolon-terminated statements with comma-separated things. You could logically say that the comma-separated list hasn't started until after all the semicolon-terminated statements. |
This comment has been minimized.
This comment has been minimized.
|
It'd be nice if it was completely generalized to allow |
This comment has been minimized.
This comment has been minimized.
|
@pornel But I wonder if it makes sense for let foo = Foo { // <--
use std::cmp::Ordering::*;
a: Greater,
b: Less,
}(and if yes the question becomes "why not tuples as well") |
This comment has been minimized.
This comment has been minimized.
|
I mean from perspective of learning the language, it's easier to remember "all block-like things can start with |
aturon
self-assigned this
Apr 27, 2017
This comment has been minimized.
This comment has been minimized.
|
There's definitely a sentiment on the lang team that over time, the body of The reason to single out The case for So, |
This comment has been minimized.
This comment has been minimized.
|
I'm in favour of allowing this in impls, but not inside |
This comment has been minimized.
This comment has been minimized.
|
I agree with adding this to traits as well; because it's not as syntactically weird I think that we should at least group One potential conflict though is a potential conflict with #1406. |
This comment has been minimized.
This comment has been minimized.
|
Alright, going by discussion, I removed the I also added a grammar section. Somebody who understands the grammar file better than I, please do so. And likewise, since traits are analogous to implementations, I added traits to it. No examples though, as I couldn't really think of a good one quickly. Not entirely sure it's needed either, as I think if you know how to use |
This comment has been minimized.
This comment has been minimized.
|
@clarcharr I don't think it's a conflict. The syntax they propose would give a completely new meaning to |
This comment has been minimized.
This comment has been minimized.
|
@Havvy fair! Although I think that it's worth mentioning in the drawbacks section that there might be a conflict between these two RFCs. |
This comment has been minimized.
This comment has been minimized.
|
Also @Havvy currently the rendered link is broken. |
This comment has been minimized.
This comment has been minimized.
|
Render link fixed. I don't consider it worth being a drawback worth writing because it's the same as any other RFC proposing syntax where it blocks off any other RFC from using the same syntax. Should the other RFC also add as a drawback that it conflicts with this one? |
This comment has been minimized.
This comment has been minimized.
|
Thanks @Havvy! Lang team: the proposal here is to allow @rfcbot fcp merge |
This comment has been minimized.
This comment has been minimized.
rfcbot
commented
May 7, 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. |
This comment has been minimized.
This comment has been minimized.
|
SUPERSEDED BY #1976 (comment) I have some concerns.
struct S;
impl S {
fn f(&self) {}
use f as g; // or Self::f as g or something
}
S.g(); // Why doesn't it work?!This can be made to work with struct S;
trait Tr {
use S as Z;
}
let s: S = Tr::Z; // OKThis may be a bit surprising, but I think it's better than introducing one more special case into the language, like this RFC does. use Default::default;
let x = default();, but this is legitimately useful, improves consistency and can be easily fixed, so I expect this to be fixed.) The problem with In the end, I can live with |
This comment has been minimized.
This comment has been minimized.
|
Ok, here's why I think this RFC shouldn't be accepted as is. Recap: containers for itemsThere are currently four "containers" in which item names can be defined.
Recap: imports are itemsRFC 1560 did great job harmonizing name resolution system and making it simpler. Consistently introducing
|
This comment has been minimized.
This comment has been minimized.
|
I am inclined to agree with @petrochenkov's objections to the current RFC. It seems to me that, way back when, when we decided to make @petrochenkov's use clauses seem like an interesting way to separate those two items back out again. |
This comment has been minimized.
This comment has been minimized.
|
Right. The question then becomes, is it worth adding the complexity of use clauses to the language right now? I want to say "no" for now, personally. In any case, it'd effectively be its own RFC, so I'm thinking of just closing this one. |
This comment has been minimized.
This comment has been minimized.
phaylon
commented
May 27, 2017
|
In the past there were discussions about having |
This comment has been minimized.
This comment has been minimized.
|
I also fully agree with @petrochenkov's assessment here.
@phaylon: What I find problematic about that syntax is that it defines aliases as a prefix of the item syntax, so it might be more confusing to read if you bring a lot of items into scope, since it takes the code a while to "get to the point" of what these aliases are actually for. |
This comment has been minimized.
This comment has been minimized.
phaylon
commented
May 27, 2017
|
@Kimundi Do you mean having multiple imports? I think having multiple import targets would be a nice solution, e.g.:
Or am I misunderstanding? |
This comment has been minimized.
This comment has been minimized.
|
@phaylon: Basically I mean, that if you have something like this: use foo::Bar, ... in struct X { ... }Then you have to skip over the A syntax like struct X where use foo::Bar, ... { ... }has the advantage that the |
This comment has been minimized.
This comment has been minimized.
crumblingstatue
commented
May 27, 2017
|
My opinion: There are many RFCs with more pressing motivation than this that were postponed. Use declarations at the module and block level suffice for the vast majority of use cases, and this change seems quite controversial, so I propose to postpone this. |
This comment has been minimized.
This comment has been minimized.
phaylon
commented
May 27, 2017
|
@Kimundi Ah, that is true. For me that would be outweighed by the fact that I can use it to apply imports to multiple items, and that the construct is expression compatible as-is. |
This comment has been minimized.
This comment has been minimized.
|
@phaylon: True. Actually I think the block form ( |
This comment has been minimized.
This comment has been minimized.
That's a pretty compelling argument; I think @petrochenkov's counter-proposal is worth keeping in mind, but we should turn our ergonomic attention elsewhere for now. @rfcbot fcp postpone |
This comment has been minimized.
This comment has been minimized.
|
@rfcbot fcp cancel |
This comment has been minimized.
This comment has been minimized.
rfcbot
commented
Jun 2, 2017
|
@aturon proposal cancelled. |
This comment has been minimized.
This comment has been minimized.
|
@rfcbot fcp postpone |
This comment has been minimized.
This comment has been minimized.
rfcbot
commented
Jun 2, 2017
•
|
Team member @aturon has proposed to postpone 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. |
aturon
added
the
S-waiting-on-team
label
Jun 6, 2017
withoutboats
added
the
proposed-final-comment-period
label
Jun 21, 2017
This comment has been minimized.
This comment has been minimized.
qnighy
commented
Jun 22, 2017
|
@nikomatsakis I was interested by your comment in |
crumblingstatue
referenced this pull request
Jun 23, 2017
Open
Language ergonomic/learnability improvements #17
This comment has been minimized.
This comment has been minimized.
rfcbot
commented
Jul 6, 2017
|
|
1 similar comment
This comment has been minimized.
This comment has been minimized.
rfcbot
commented
Jul 6, 2017
|
|
rfcbot
added
final-comment-period
and removed
proposed-final-comment-period
labels
Jul 6, 2017
This comment has been minimized.
This comment has been minimized.
That was the "non-unified" version I was talking about. In the olden days, |
This comment has been minimized.
This comment has been minimized.
rfcbot
commented
Jul 16, 2017
|
The final comment period is now complete. |
This comment has been minimized.
This comment has been minimized.
|
Given the lack of comments for a month, and the FCP being complete w/postpone, I'm going to close this. |
Havvy commentedApr 18, 2017
•
edited
Rendered
I personally care more about
useinimplthan inmatch, but don't see why we cannot really have both, other than potential syntactical ugliness.