Skip to content

Commit

Permalink
Adjust position of rules attached to headers
Browse files Browse the repository at this point in the history
Adjusts the position of rules with headers to match the style from
#1710
  • Loading branch information
ehuss committed Jan 14, 2025
1 parent cff9c6f commit 415cafe
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 138 deletions.
12 changes: 4 additions & 8 deletions src/keywords.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
# Keywords

r[lex.keywords]
# Keywords

Rust divides keywords into three categories:

* [strict](#strict-keywords)
* [reserved](#reserved-keywords)
* [weak](#weak-keywords)

## Strict keywords

r[lex.keywords.strict]
## Strict keywords

r[lex.keywords.strict.intro]
These keywords can only be used in their correct contexts. They cannot
Expand Down Expand Up @@ -71,9 +69,8 @@ The following keywords were added beginning in the 2018 edition.
> KW_AWAIT : `await`\
> KW_DYN : `dyn`
## Reserved keywords

r[lex.keywords.reserved]
## Reserved keywords

r[lex.keywords.reserved.intro]
These keywords aren't used yet, but they are reserved for future use. They have
Expand Down Expand Up @@ -107,9 +104,8 @@ The following keywords are reserved beginning in the 2024 edition.
> **<sup>Lexer 2024+</sup>**\
> KW_GEN : `gen`
## Weak keywords

r[lex.keywords.weak]
## Weak keywords

r[lex.keywords.weak.intro]
These keywords have special meaning only in certain contexts. For example, it
Expand Down
9 changes: 3 additions & 6 deletions src/lifetime-elision.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
# Lifetime elision

r[lifetime-elision]
# Lifetime elision

Rust has rules that allow lifetimes to be elided in various places where the
compiler can infer a sensible default choice.

## Lifetime elision in functions

r[lifetime-elision.function]
## Lifetime elision in functions

r[lifetime-elision.function.intro]
In order to make common patterns more ergonomic, lifetime arguments can be
Expand Down Expand Up @@ -91,9 +89,8 @@ fn frob(s: &str, t: &str) -> &str; // ILLEGAL
# }
```

## Default trait object lifetimes

r[lifetime-elision.trait-object]
## Default trait object lifetimes

r[lifetime-elision.trait-object.intro]
The assumed lifetime of references held by a [trait object] is called its
Expand Down
6 changes: 2 additions & 4 deletions src/macros.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Macros

r[macro]
# Macros

r[macro.intro]
The functionality and syntax of Rust can be extended with custom definitions
Expand All @@ -13,9 +12,8 @@ There are two ways to define new macros:
* [Procedural Macros] define function-like macros, custom derives, and custom
attributes using functions that operate on input tokens.

## Macro Invocation

r[macro.invocation]
## Macro Invocation

r[macro.invocation.syntax]
> **<sup>Syntax</sup>**\
Expand Down
3 changes: 1 addition & 2 deletions src/memory-allocation-and-lifetime.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Memory allocation and lifetime

r[alloc]
# Memory allocation and lifetime

r[alloc.static]
The _items_ of a program are those functions, modules, and types that have their
Expand Down
9 changes: 3 additions & 6 deletions src/names.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Names

r[names]
# Names

r[names.intro]
An *entity* is a language construct that can be referred to in some way within
Expand Down Expand Up @@ -36,9 +35,8 @@ and labels to entity declarations.
r[names.visibility]
Access to certain names may be restricted based on their [*visibility*].

## Explicitly declared entities

r[names.explicit]
## Explicitly declared entities

r[names.explicit.list]
Entities that explicitly introduce a name in the source code are:
Expand Down Expand Up @@ -87,9 +85,8 @@ r[names.explicit.macro-invocation]
Additionally, [macro invocations] and [attributes] can introduce names by
expanding to one of the above items.

## Implicitly declared entities

r[names.implicit]
## Implicitly declared entities

r[names.implicit.list]
The following entities are implicitly defined by the language, or are
Expand Down
39 changes: 13 additions & 26 deletions src/paths.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Paths

r[paths]
# Paths

r[paths.intro]
A *path* is a sequence of one or more path segments separated by `::` tokens.
Expand All @@ -16,9 +15,8 @@ x::y::z;

## Types of paths

### Simple Paths

r[paths.simple]
### Simple Paths

r[paths.simple.syntax]
> **<sup>Syntax</sup>**\
Expand All @@ -40,9 +38,8 @@ mod m {
}
```

### Paths in expressions

r[paths.expr]
### Paths in expressions

r[paths.expr.syntax]
> **<sup>Syntax</sup>**\
Expand Down Expand Up @@ -99,9 +96,8 @@ r[paths.expr.impl-trait-params]
The synthetic type parameters corresponding to `impl Trait` types are implicit,
and these cannot be explicitly specified.

## Qualified paths

r[paths.qualified]
## Qualified paths

r[paths.qualified.syntax]
> **<sup>Syntax</sup>**\
Expand Down Expand Up @@ -137,9 +133,8 @@ S::f(); // Calls the inherent impl.
<S as T2>::f(); // Calls the T2 trait function.
```

### Paths in types

r[paths.type]
### Paths in types

r[paths.type.syntax]
> **<sup>Syntax</sup>**\
Expand Down Expand Up @@ -179,16 +174,14 @@ fn i<'a>() -> impl Iterator<Item = ops::Example<'a>> {
type G = std::boxed::Box<dyn std::ops::FnOnce(isize) -> isize>;
```

## Path qualifiers

r[paths.qualifiers]
## Path qualifiers

Paths can be denoted with various leading qualifiers to change the meaning of
how it is resolved.

### `::`

r[paths.qualifiers.global-root]
### `::`

r[paths.qualifiers.global-root.intro]
Paths starting with `::` are considered to be *global paths* where the segments of the path
Expand Down Expand Up @@ -227,9 +220,8 @@ mod b {
# fn main() {}
```

### `self`

r[paths.qualifiers.mod-self]
### `self`

r[paths.qualifiers.mod-self.intro]
`self` resolves the path relative to the current module.
Expand All @@ -254,9 +246,8 @@ impl S {
# fn main() {}
```

### `Self`

r[paths.qualifiers.type-self]
### `Self`

r[paths.qualifiers.type-self.intro]
`Self`, with a capital "S", is used to refer to the current type being implemented or defined. It may be used in the following situations:
Expand Down Expand Up @@ -319,9 +310,8 @@ struct NonEmptyList<T> {
}
```

### `super`

r[paths.qualifiers.super]
### `super`

r[paths.qualifiers.super.intro]
`super` in a path resolves to the parent module.
Expand Down Expand Up @@ -361,9 +351,8 @@ mod a {
# fn main() {}
```

### `crate`

r[paths.qualifiers.crate]
### `crate`

r[paths.qualifiers.crate.intro]
`crate` resolves the path relative to the current crate.
Expand All @@ -381,9 +370,8 @@ mod a {
# fn main() {}
```

### `$crate`

r[paths.qualifiers.macro-crate]
### `$crate`

r[paths.qualifiers.macro-crate.allowed-positions]
`$crate` is only used within [macro transcribers], and can only be used as the first
Expand All @@ -406,9 +394,8 @@ macro_rules! inc {
# fn main() { }
```

## Canonical paths

r[paths.canonical]
## Canonical paths

r[paths.canonical.intro]
Items defined in a module or implementation have a *canonical path* that
Expand Down
Loading

0 comments on commit 415cafe

Please # to comment.