You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 a use.
Edition note:
non-use
On 2015 core::option::Option will work, but both ::core::... and crate::core::... will error
On 2018 and 2021 core::option::Option and ::core::... will work, but crate:: will error
use
On 2015 none of core::..., ::core::... and crate::core work
On 2018 and 2021 only core::... and ::core::.... works, while crate::core doesn't
On 2018+ editions things are exactly as intended by the 2018 import reform - core is in extern prelude, all paths can refer to it regardless of being import or not (that's why the feature was called "uniform paths"), and core is NOT placed into the crate root module.
(And :: means extern prelude.)
On 2015 edition things were simply frozen in whatever state they were before the reform.
(And :: means crate::.)
Oh, I noticed an error in my post, I thought use core... doesn't work on edition >= 2018, but it actually does work. Yeah, then the edition >= 2018 looks sane.
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: