Skip to content

Commit ac2cb1f

Browse files
committed
Rollup merge of #30224 - matklad:super-docs, r=steveklabnik
Make clear that `super` may be included in the path several times. r? @steveklabnik
2 parents 24a1633 + c8b7e24 commit ac2cb1f

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/doc/reference.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,25 @@ fn bar() {
515515
# fn main() {}
516516
```
517517

518+
Additionally keyword `super` may be repeated several times after the first
519+
`super` or `self` to refer to ancestor modules.
520+
521+
```rust
522+
mod a {
523+
fn foo() {}
524+
525+
mod b {
526+
mod c {
527+
fn foo() {
528+
super::super::foo(); // call a's foo function
529+
self::super::super::foo(); // call a's foo function
530+
}
531+
}
532+
}
533+
}
534+
# fn main() {}
535+
```
536+
518537
# Syntax extensions
519538

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

0 commit comments

Comments
 (0)