Skip to content

Commit 06acfe0

Browse files
committed
---
yaml --- r: 110508 b: refs/heads/snap-stage3 c: c83afb9 h: refs/heads/master v: v3
1 parent 7620b43 commit 06acfe0

File tree

2 files changed

+47
-2
lines changed

2 files changed

+47
-2
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: e415c25bcd81dc1f9a5a3d25d9b48ed2d545336b
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: bc234ae1307f6c1ff72782a82b8222691bf67525
4+
refs/heads/snap-stage3: c83afb9719ad6e2ae7d819b8096524e1147c4065
55
refs/heads/try: 597a645456b55e1c886ce15d23a192abdf4d55cf
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/doc/rust.md

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ operators](#binary-operator-expressions), or [keywords](#keywords).
432432
## Paths
433433

434434
~~~~ {.notrust .ebnf .gram}
435-
expr_path : ident [ "::" expr_path_tail ] + ;
435+
expr_path : [ "::" ] ident [ "::" expr_path_tail ] + ;
436436
expr_path_tail : '<' type_expr [ ',' type_expr ] + '>'
437437
| expr_path ;
438438
@@ -475,6 +475,51 @@ let x = id::<int>(10); // Type arguments used in a call expression
475475
# }
476476
~~~~
477477

478+
Paths can be denoted with various leading qualifiers to change the meaning of
479+
how it is resolved:
480+
481+
* Paths starting with `::` are considered to be global paths where the
482+
components of the path start being resolved from the crate root. Each
483+
identifier in the path must resolve to an item.
484+
485+
```rust
486+
mod a {
487+
pub fn foo() {}
488+
}
489+
mod b {
490+
pub fn foo() {
491+
::a::foo(); // call a's foo function
492+
}
493+
}
494+
# fn main() {}
495+
```
496+
497+
* Paths starting with the keyword `super` begin resolution relative to the
498+
parent module. Each further identifier must resolve to an item
499+
500+
```rust
501+
mod a {
502+
pub fn foo() {}
503+
}
504+
mod b {
505+
pub fn foo() {
506+
super::a::foo(); // call a's foo function
507+
}
508+
}
509+
# fn main() {}
510+
```
511+
512+
* Paths starting with the keyword `self` begin resolution relative to the
513+
current module. Each further identifier must resolve to an item.
514+
515+
```rust
516+
fn foo() {}
517+
fn bar() {
518+
self::foo();
519+
}
520+
# fn main() {}
521+
```
522+
478523
# Syntax extensions
479524

480525
A number of minor features of Rust are not central enough to have their own

0 commit comments

Comments
 (0)