Skip to content

Commit a4252fe

Browse files
authored
Rollup merge of #62595 - ngoldbaum:path-clarity-doc, r=Centril
Document that the crate keyword refers to the project root :wave: this is my first rust contribution so I hope I'm doing everything correctly. Help very much appreciated if I'm not. As far as I can tell this use of `crate` is only documented [in the edition guide for rust 2018](https://doc.rust-lang.org/edition-guide/rust-2018/module-system/path-clarity.html#the-crate-keyword-refers-to-the-current-crate). However it should probably be in the documentation for the `crate` keyword itself. This adds that documentation.
2 parents 992bcd0 + d4fcbb4 commit a4252fe

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/libstd/keyword_docs.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ mod continue_keyword { }
119119
/// The `as` keyword can be used to change what the crate is referred to as in your project. If a
120120
/// crate name includes a dash, it is implicitly imported with the dashes replaced by underscores.
121121
///
122-
/// `crate` is also used as in conjunction with `pub` to signify that the item it's attached to
122+
/// `crate` can also be used as in conjunction with `pub` to signify that the item it's attached to
123123
/// is public only to other members of the same crate it's in.
124124
///
125125
/// ```rust
@@ -131,6 +131,10 @@ mod continue_keyword { }
131131
/// }
132132
/// ```
133133
///
134+
/// `crate` is also used to represent the absolute path of a module, where `crate` refers to the
135+
/// root of the current crate. For instance, `crate::foo::bar` refers to the name `bar` inside the
136+
/// module `foo`, from anywhere else in the same crate.
137+
///
134138
/// [Reference]: ../reference/items/extern-crates.html
135139
mod crate_keyword { }
136140

0 commit comments

Comments
 (0)