Skip to content

Commit 87c7e15

Browse files
committed
auto merge of #12362 : liigo/rust/update-rust-manual, r=alexcrichton
change `extern mod` to `extern crate`, `package id` to `crate id`, and some lines wrapping fix, etc.
2 parents 78d4bf8 + 4e9df9a commit 87c7e15

File tree

2 files changed

+14
-21
lines changed

2 files changed

+14
-21
lines changed

src/doc/rust.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -752,35 +752,35 @@ mod task {
752752
#### View items
753753

754754
~~~~ {.ebnf .gram}
755-
view_item : extern_mod_decl | use_decl ;
755+
view_item : extern_crate_decl | use_decl ;
756756
~~~~
757757

758758
A view item manages the namespace of a module.
759759
View items do not define new items, but rather, simply change other items' visibility.
760760
There are several kinds of view item:
761761

762-
* [`extern crate` declarations](#extern-mod-declarations)
762+
* [`extern crate` declarations](#extern-crate-declarations)
763763
* [`use` declarations](#use-declarations)
764764

765-
##### Extern mod declarations
765+
##### Extern crate declarations
766766

767767
~~~~ {.ebnf .gram}
768-
extern_mod_decl : "extern" "mod" ident [ '(' link_attrs ')' ] ? [ '=' string_lit ] ? ;
768+
extern_crate_decl : "extern" "crate" ident [ '(' link_attrs ')' ] ? [ '=' string_lit ] ? ;
769769
link_attrs : link_attr [ ',' link_attrs ] + ;
770770
link_attr : ident '=' literal ;
771771
~~~~
772772

773773
An _`extern crate` declaration_ specifies a dependency on an external crate.
774-
The external crate is then bound into the declaring scope
775-
as the `ident` provided in the `extern_mod_decl`.
774+
The external crate is then bound into the declaring scope as the `ident` provided
775+
in the `extern_crate_decl`.
776776

777777
The external crate is resolved to a specific `soname` at compile time, and a
778778
runtime linkage requirement to that `soname` is passed to the linker for
779779
loading at runtime. The `soname` is resolved at compile time by scanning the
780780
compiler's library path and matching the optional `crateid` provided as a string literal
781781
against the `crateid` attributes that were declared on the external crate when
782782
it was compiled. If no `crateid` is provided, a default `name` attribute is
783-
assumed, equal to the `ident` given in the `extern_mod_decl`.
783+
assumed, equal to the `ident` given in the `extern_crate_decl`.
784784

785785
Four examples of `extern crate` declarations:
786786

@@ -813,7 +813,7 @@ module item. These declarations may appear at the top of [modules](#modules) and
813813

814814
*Note*: Unlike in many languages,
815815
`use` declarations in Rust do *not* declare linkage dependency with external crates.
816-
Rather, [`extern crate` declarations](#extern-mod-declarations) declare linkage dependencies.
816+
Rather, [`extern crate` declarations](#extern-crate-declarations) declare linkage dependencies.
817817

818818
Use declarations support a number of convenient shortcuts:
819819

src/doc/tutorial.md

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -495,8 +495,7 @@ reject the previous example if the arm with the wildcard pattern was
495495
omitted.
496496

497497
A powerful application of pattern matching is *destructuring*:
498-
matching in order to bind names to the contents of data
499-
types.
498+
matching in order to bind names to the contents of data types.
500499

501500
> ***Note:*** The following code makes use of tuples (`(f64, f64)`) which
502501
> are explained in section 5.3. For now you can think of tuples as a list of
@@ -2726,7 +2725,8 @@ pub mod barn {
27262725

27272726
In short, `mod foo;` is just syntactic sugar for `mod foo { /* content of <...>/foo.rs or <...>/foo/mod.rs */ }`.
27282727

2729-
This also means that having two or more identical `mod foo;` declarations somewhere in your crate hierarchy is generally a bad idea,
2728+
This also means that having two or more identical `mod foo;` declarations
2729+
somewhere in your crate hierarchy is generally a bad idea,
27302730
just like copy-and-paste-ing a module into multiple places is a bad idea.
27312731
Both will result in duplicate and mutually incompatible definitions.
27322732

@@ -3074,11 +3074,6 @@ fn main() {
30743074
It's a bit weird, but it's the result of shadowing rules that have been set that way because
30753075
they model most closely what people expect to shadow.
30763076

3077-
## Package ids
3078-
3079-
If you use `extern crate`, per default `rustc` will look for libraries in the library search path (which you can
3080-
extend with the `-L` switch).
3081-
30823077
## Crate metadata and settings
30833078

30843079
For every crate you can define a number of metadata items, such as link name, version or author.
@@ -3096,14 +3091,13 @@ Therefore, if you plan to compile your crate as a library, you should annotate i
30963091
// `lib.rs`
30973092
30983093
# #[crate_type = "lib"];
3099-
// Package ID
31003094
#[crate_id = "farm#2.5"];
31013095
31023096
// ...
31033097
# fn farm() {}
31043098
~~~~
31053099

3106-
You can also specify package ID information in a `extern crate` statement. For
3100+
You can also specify crate id information in a `extern crate` statement. For
31073101
example, these `extern crate` statements would both accept and select the
31083102
crate define above:
31093103

@@ -3161,7 +3155,7 @@ Now compile and run like this (adjust to your platform if necessary):
31613155
Notice that the library produced contains the version in the file name
31623156
as well as an inscrutable string of alphanumerics. As explained in the previous paragraph,
31633157
these are both part of Rust's library versioning scheme. The alphanumerics are
3164-
a hash representing the crates package ID.
3158+
a hash representing the crates id.
31653159

31663160
## The standard library and the prelude
31673161

@@ -3231,8 +3225,7 @@ library. You can link to a library such as `extra` with an `extern crate extra;
32313225
[extra library]: extra/index.html
32323226

32333227
Right now `extra` contains those definitions directly, but in the future it will likely just
3234-
re-export a bunch of 'officially blessed' crates that get managed with a
3235-
package manager.
3228+
re-export a bunch of 'officially blessed' crates that get managed with a package manager.
32363229

32373230
# What next?
32383231

0 commit comments

Comments
 (0)