-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow crate:: in local paths #50131
Allow crate:: in local paths #50131
Conversation
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
The r=me with tests updated |
Yeah I discussed this with Aaron and he said this was a bug.
…On Sat, Apr 21, 2018, 4:43 AM Vadim Petrochenkov ***@***.***> wrote:
The ::crate:: form is in line with the model from RFC 2126 (#44660
<#44660>), but crate:: fits
better into the updated model from
https://internals.rust-lang.org/t/the-great-module-adventure-continues/6678/183,
so I agree with this change.
We may want to remove the ::crate:: form later.
r=me with tests updated
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#50131 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ABivSN85MO5DF1bhAsmxT6ajMmUJnTGhks5tqxtdgaJpZM4TePYY>
.
|
3760c94
to
8637166
Compare
Ahh, I see why we didn't compile this previously. The problem is within struct fields. So we can fix this everywhere except in tuple struct fields. Gah. Parsing. @aturon @cramertj if we still want to fix this, how should we address that ambiguity? Always parse it as a path? |
@Manishearth It can be trivially resolved by always parsing |
src/librustc_resolve/lib.rs
Outdated
} else if i == 0 && name == keywords::Crate.name() { | ||
format!("{} can only be used in absolute paths", name_str) | ||
} else if name == keywords::Crate.name() && path.len() == 1 { | ||
"`crate` in paths must be followed by a module name".into() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
crate
can be used as a single segment path with the meaning "root module", e.g. in use crate as something.
If this line is removed then keyword-crate-as-identifier.rs
should report a correct error, something like "expected a unit struct or constand, found module".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah. It was, but I thought that was a bug. Will fix.
fd00a97
to
27f5f56
Compare
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
27f5f56
to
0dc4ce7
Compare
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
0dc4ce7
to
3a19e39
Compare
We should be doing the same for |
(I can split that out into a second PR if you r+ the first commit. I'll be fixing the tests for the second commit on Monday) |
17e5d27
to
3a19e39
Compare
Oh, sorry, that's fixed by #49789 |
@bors: p=1 We want to get the edition-related changes landed ASAP. |
|
||
fn main() { | ||
crate struct S; // OK (item in statement position) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you keep this test in some compile-pass/run-pass form?
r=me after restoring the test and probably reverting the unintended (?) |
3a19e39
to
9f5e08e
Compare
@bors r=petrochenkov |
📌 Commit 9f5e08e has been approved by |
Allow crate:: in local paths Currently if you want to use `crate` locally you have to do `::crate::`. This shouldn't be necessary (will fix up tests later) r? @petrochenkov
☀️ Test successful - status-appveyor, status-travis |
Currently if you want to use
crate
locally you have to do::crate::
. This shouldn't be necessary(will fix up tests later)
r? @petrochenkov