Skip to content

Commit 04b6d4f

Browse files
committed
---
yaml --- r: 30789 b: refs/heads/incoming c: fbf3628 h: refs/heads/master i: 30787: a464537 v: v3
1 parent e69f3a2 commit 04b6d4f

File tree

2 files changed

+15
-87
lines changed

2 files changed

+15
-87
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: d324a424d8f84b1eb049b12cf34182bda91b0024
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: d0c6ce338884ee21843f4b40bf6bf18d222ce5df
9-
refs/heads/incoming: 385c4dfba00411da738aff96592281f0035e05f8
9+
refs/heads/incoming: fbf362809b89a97512c049ba7e4091ff3d404c58
1010
refs/heads/dist-snap: 2f32a1581f522e524009138b33b1c7049ced668d
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/incoming/doc/rust.md

Lines changed: 14 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -783,9 +783,8 @@ link_attrs : link_attr [ ',' link_attrs ] + ;
783783
link_attr : ident '=' literal ;
784784
~~~~~~~~
785785

786-
An _extern mod declaration_ specifies a dependency on an external crate. The
787-
external crate is then imported into the declaring scope as the `ident`
788-
provided in the `extern_mod_decl`.
786+
An _extern mod declaration_ specifies a dependency on an external crate.
787+
The external crate is then bound into the declaring scope as the `ident` provided in the `extern_mod_decl`.
789788

790789
The external crate is resolved to a specific `soname` at compile time, and a
791790
runtime linkage requirement to that `soname` is passed to the linker for
@@ -825,16 +824,16 @@ linkage-dependency with external crates. Linkage dependencies are
825824
independently declared with
826825
[`extern mod` declarations](#extern-mod-declarations).
827826

828-
Imports support a number of "convenience" notations:
827+
Use declarations support a number of "convenience" notations:
829828

830-
* Importing as a different name than the imported name, using the
829+
* Rebinding the target name as a new local name, using the
831830
syntax `use x = p::q::r;`.
832-
* Importing a list of paths differing only in final element, using
833-
the glob-like brace syntax `use a::b::{c,d,e,f};`
834-
* Importing all paths matching a given prefix, using the glob-like
835-
asterisk syntax `use a::b::*;`
831+
* Simultaneously binding a list of paths differing only in final element,
832+
using the glob-like brace syntax `use a::b::{c,d,e,f};`
833+
* Binding all paths matching a given prefix,
834+
using the glob-like asterisk syntax `use a::b::*;`
836835

837-
An example of imports:
836+
An example of `use` declarations:
838837

839838
~~~~
840839
use foo = core::info;
@@ -855,82 +854,11 @@ fn main() {
855854
}
856855
~~~~
857856

858-
##### Export declarations
859-
860-
~~~~~~~~ {.ebnf .gram}
861-
export_decl : "export" ident [ ',' ident ] *
862-
| "export" ident "::{}"
863-
| "export" ident '{' ident [ ',' ident ] * '}' ;
864-
~~~~~~~~
865-
866-
An _export declaration_ restricts the set of local names within a module that
867-
can be accessed from code outside the module. By default, all _local items_ in
868-
a module are exported; imported paths are not automatically re-exported by
869-
default. If a module contains an explicit `export` declaration, this
870-
declaration replaces the default export with the export specified.
871-
872-
An example of an export:
873-
874-
~~~~~~~~
875-
pub mod foo {
876-
#[legacy_exports];
877-
export primary;
878-
879-
fn primary() {
880-
helper(1, 2);
881-
helper(3, 4);
882-
}
883-
884-
fn helper(x: int, y: int) {
885-
...
886-
}
887-
}
888-
889-
fn main() {
890-
foo::primary(); // Will compile.
891-
}
892-
~~~~~~~~
893-
894-
If, instead of calling `foo::primary` in main, you were to call `foo::helper`
895-
then it would fail to compile:
896-
897-
~~~~~~~~{.ignore}
898-
foo::helper(2,3) // ERROR: will not compile.
899-
~~~~~~~~
900-
901-
Multiple names may be exported from a single export declaration:
902-
903-
~~~~~~~~
904-
mod foo {
905-
export primary, secondary;
906-
907-
fn primary() {
908-
helper(1, 2);
909-
helper(3, 4);
910-
}
911-
912-
fn secondary() {
913-
...
914-
}
915-
916-
fn helper(x: int, y: int) {
917-
...
918-
}
919-
}
920-
~~~~~~~~
921-
922-
When exporting the name of an `enum` type `t`, by default, the module does
923-
*not* implicitly export any of `t`'s constructors. For example:
924-
925-
~~~~~~~~
926-
mod foo {
927-
export t;
928-
929-
enum t {a, b, c}
930-
}
931-
~~~~~~~~
932-
933-
Here, `foo` imports `t`, but not `a`, `b`, and `c`.
857+
Like items, `use` declarations are private to the containing module, by default.
858+
Also like items, a `use` declaration can be public, if qualified by the `pub` keyword.
859+
A public `use` declaration can therefore be used to _redirect_ some public name to a different target definition,
860+
even a definition with a private canonical path, inside a different module.
861+
If a sequence of such redirections form a cycle or cannot be unambiguously resolved, they represent a compile-time error.
934862

935863
### Functions
936864

0 commit comments

Comments
 (0)