-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
core
sometimes is resolved when not defined
#112924
Comments
On 2018+ editions things are exactly as intended by the 2018 import reform - On 2015 edition things were simply frozen in whatever state they were before the reform. |
I tried to change 2015 behavior to be more uniform with modern editions in #57745, but in the end the decision was to just keep legacy things frozen. |
Oh, I noticed an error in my post, I thought |
The following two snippets:
I expected both of them to either compile, or not.
Instead, only the
const
one compiles, while theuse
one doesn't:Note that the
core
crate is not defined in either test, as can be seen by using-Zunpretty=hir
:Similarly to a
const
,impl core::iter::Iterator for ... { ... }
,fn f() { core::option::Option::Some(()) }
,fn f() -> core::option::Option<()> { None }
and others work. The only thing I could find to issue an error is ause
.Edition note:
use
core::option::Option
will work, but both::core::...
andcrate::core::...
will errorcore::option::Option
and::core::...
will work, butcrate::
will erroruse
core::...
,::core::...
andcrate::core
workcore::...
and::core::....
works, whilecrate::core
doesn'tGiven all of that it seems that
core
is in the extern prelude (as documented), butcore
is not present at the crate root, butuse
can access stuff from extern preludeThis is very confusing to say the least.
I'd expect any of the following outcomes:
core
is both in the extern prelude and crate root, anything can refer to it (IMO the best option)core
is neither in the extern prelude nor in the crate root, nothing can refer to itBut not what we currently have...
Meta
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: