Closed
Description
This is a tracking issue for the RFC "Clarify and streamline paths and visibility" (rust-lang/rfcs#2126).
Steps:
- Implement the RFC. The various implementation steps are broken out into subissues (or will be, in some cases).
- permit
foo.rs
orfoo/mod.rs
to support submodules likefoo/bar.rs
[RFC 2126] permitfoo.rs
orfoo/mod.rs
to support submodules likefoo/bar.rs
#45385 - introduce
crate
as a visibility modifier permitcrate
as a shorthand visibility identifier #45388 - allow
crate
to begin an absolute path permitcrate
in absolute paths #45477 - add a lint for
pub
items that are not visible from crate root add a lint forpub
items that are not reachable from crate root #45521
- permit
- Some implementation issues are blocked on permitting
crate
to begin an absolute path. Neither of these items would take effect unless we are using that extension:- add a lint for absolute paths that do not begin with
crate
(Add epoch breakage lint for fully qualified paths that do not usecrate
,self
, orsuper
#48722) - allow eliding
extern crate
when feature gate is given- Rationale for delaying: if we require all local paths to begin with crate, we don't need to worry about fallback
- This feature also depends on Allowing renaming of crates in the dependencies section
- Add epoch lint for this
extern crate
epoch lint for Path Clarity RFC (2126) #48719
- add a lint for absolute paths that do not begin with
- Adjust documentation (see instructions on forge)
- Stabilization PR (see instructions on forge)
Unresolved questions:
-
How should we approach migration? Via a fallback, as proposed, or via epochs? It is probably best to make this determination with more experience, e.g. after we have a
rustfix
tool in hand. -
The final syntax for absolute paths; there's more bikeshedding to be done here in a context where we can actually try out the various options. In particular, there are some real advantages to having both
crate::
andextern::
paths, but ideally we could do it in a more succinct way.- Currently, we accept
::crate::foo
only. However, we also parsestruct Foo(crate ::foo)
as an illegal path, rather than treatingcrate
as a visibility modifier. @petrochenkov describes some of the reasoning in this comment.
- Currently, we accept