Skip to content

Commit 36016fc

Browse files
ehusstraviscross
authored andcommitted
Rename the ".general" rules
The "general" suffix seemed too generic to me, and also didn't quite fit with some of the style in the rest of the grammar. Some of these are difficult to come up with good names for, and I'm not entirely happy with this. My thinking is: - `.intro` is for informative introductions to a section. My intention is that every normative rule is testable. However, many of these `.intro` rules define terms, and I think those should possibly be normative (like [ISO/IEC Directives](https://www.iso.org/sites/directives/current/part2/index.xhtml#_idTextAnchor212)). I would like to rethink how `.intro` works. I appreciate having introductions that are more generalized, but it is often very difficult to introduce a section without defining some terms first. I would also like to come up with a better strategy of "this is a testable rule" versus "this rule defines a term, but that by isn't testable". - Switched some of these to be more specific words tailored to their context. - Used `.def` for some of these that *define* a thing. `.def` is used in a variety of other places. We have not standardized on it, and I'm not sure it is working in a way that is clear (is it defining a term? behavior? rule? general principle?). I think this is being used in ways that are inconsistent, and would like to figure out something better.
1 parent 8d6d1be commit 36016fc

6 files changed

Lines changed: 22 additions & 22 deletions

File tree

src/behavior-considered-undefined.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
r[undefined]
22
# Behavior considered undefined
33

4-
r[undefined.general]
4+
r[undefined.intro]
55
Rust code is incorrect if it exhibits any of the behaviors in the following
66
list. This includes code within `unsafe` blocks and `unsafe` functions.
77
`unsafe` only means that avoiding undefined behavior is on the programmer; it
@@ -93,7 +93,7 @@ r[undefined.misaligned]
9393
## Places based on misaligned pointers
9494
[based on a misaligned pointer]: #places-based-on-misaligned-pointers
9595

96-
r[undefined.misaligned.general]
96+
r[undefined.misaligned.ptr]
9797
A place is said to be "based on a misaligned pointer" if the last `*` projection
9898
during place computation was performed on a pointer that was not aligned for its
9999
type. (If there is no `*` projection in the place expression, then this is
@@ -133,7 +133,7 @@ r[undefined.dangling]
133133
## Dangling pointers
134134
[dangling]: #dangling-pointers
135135

136-
r[undefined.dangling.general]
136+
r[undefined.dangling.def]
137137
A reference/pointer is "dangling" if not all of the bytes it
138138
[points to] are part of the same live allocation (so in particular they all have to be
139139
part of *some* allocation).
@@ -155,7 +155,7 @@ r[undefined.validity]
155155
## Invalid values
156156
[invalid-values]: #invalid-values
157157

158-
r[undefined.validity.general]
158+
r[undefined.validity.def]
159159
The Rust compiler assumes that all values produced during program execution are
160160
"valid", and producing an invalid value is hence immediate UB.
161161

src/conditional-compilation.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ ConfigurationPredicateList ->
2727
ConfigurationPredicate (`,` ConfigurationPredicate)* `,`?
2828
```
2929

30-
r[cfg.general]
30+
r[cfg.intro]
3131
*Conditionally compiled source code* is source code that is compiled only under certain conditions.
3232

3333
r[cfg.attributes-macro]
@@ -72,7 +72,7 @@ Keys do not need to be unique. For example, both `feature = "std"` and `feature
7272
r[cfg.options.set]
7373
## Set configuration options
7474

75-
r[cfg.options.general]
75+
r[cfg.options.intro]
7676
Which configuration options are set is determined statically during the compilation of the crate.
7777

7878
r[cfg.options.target]
@@ -93,7 +93,7 @@ It is not possible to set a configuration option from within the source code of
9393
r[cfg.target_arch]
9494
### `target_arch`
9595

96-
r[cfg.target_arch.gen]
96+
r[cfg.target_arch.def]
9797
Key-value option set once with the target's CPU architecture. The value is similar to the first element of the platform's target triple, but not identical.
9898

9999
r[cfg.target_arch.values]
@@ -110,7 +110,7 @@ Example values:
110110
r[cfg.target_feature]
111111
### `target_feature`
112112

113-
r[cfg.target_feature.general]
113+
r[cfg.target_feature.def]
114114
Key-value option set for each platform feature available for the current compilation target.
115115

116116
r[cfg.target_feature.values]
@@ -132,7 +132,7 @@ An additional feature of `crt-static` is available to the `target_feature` optio
132132
r[cfg.target_os]
133133
### `target_os`
134134

135-
r[cfg.target_os.general]
135+
r[cfg.target_os.def]
136136
Key-value option set once with the target's operating system. This value is similar to the second and third element of the platform's target triple.
137137

138138
r[cfg.target_os.values]
@@ -152,7 +152,7 @@ Example values:
152152
r[cfg.target_family]
153153
### `target_family`
154154

155-
r[cfg.target_family.general]
155+
r[cfg.target_family.def]
156156
Key-value option providing a more generic description of a target, such as the family of the operating systems or architectures that the target generally falls into. Any number of `target_family` key-value pairs can be set.
157157

158158
r[cfg.target_family.values]
@@ -174,7 +174,7 @@ r[cfg.target_family.windows]
174174
r[cfg.target_env]
175175
### `target_env`
176176

177-
r[cfg.target_env.general]
177+
r[cfg.target_env.def]
178178
Key-value option set with further disambiguating information about the target platform with information about the ABI or `libc` used. For historical reasons, this value is only defined as not the empty-string when actually needed for disambiguation. Thus, for example, on many GNU platforms, this value will be empty. This value is similar to the fourth element of the platform's target triple. One difference is that embedded ABIs such as `gnueabihf` will simply define `target_env` as `"gnu"`.
179179

180180
r[cfg.target_env.values]
@@ -191,7 +191,7 @@ Example values:
191191
r[cfg.target_abi]
192192
### `target_abi`
193193

194-
r[cfg.target_abi.general]
194+
r[cfg.target_abi.def]
195195
Key-value option set to further disambiguate the target with information about the target ABI.
196196

197197
r[cfg.target_abi.disambiguation]
@@ -213,7 +213,7 @@ Key-value option set once with either a value of "little" or "big" depending on
213213
r[cfg.target_pointer_width]
214214
### `target_pointer_width`
215215

216-
r[cfg.target_pointer_width.general]
216+
r[cfg.target_pointer_width.def]
217217
Key-value option set once with the target's pointer width in bits.
218218

219219
r[cfg.target_pointer_width.values]
@@ -226,7 +226,7 @@ Example values:
226226
r[cfg.target_vendor]
227227
### `target_vendor`
228228

229-
r[cfg.target_vendor.general]
229+
r[cfg.target_vendor.def]
230230
Key-value option set once with the vendor of the target.
231231

232232
r[cfg.target_vendor.values]
@@ -240,7 +240,7 @@ Example values:
240240
r[cfg.target_has_atomic]
241241
### `target_has_atomic`
242242

243-
r[cfg.target_has_atomic.general]
243+
r[cfg.target_has_atomic.def]
244244
Key-value option set for each bit width that the target supports atomic loads, stores, and compare-and-swap operations.
245245

246246
r[cfg.target_has_atomic.stdlib]
@@ -274,7 +274,7 @@ Set when the crate being compiled is being compiled with the `proc_macro` [crate
274274
r[cfg.panic]
275275
### `panic`
276276

277-
r[cfg.panic.general]
277+
r[cfg.panic.def]
278278
Key-value option set depending on the [panic strategy]. Note that more values may be added in the future.
279279

280280
r[cfg.panic.values]

src/const_eval.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
r[const-eval]
22
# Constant evaluation
33

4-
r[const-eval.general]
4+
r[const-eval.intro]
55
Constant evaluation is the process of computing the result of [expressions] during compilation. Only a subset of all expressions can be evaluated at compile-time.
66

77
r[const-eval.const-expr]
88
## Constant expressions
99

10-
r[const-eval.const-expr.general]
10+
r[const-eval.const-expr.intro]
1111
Certain forms of expressions, called constant expressions, can be evaluated at compile time.
1212

1313
r[const-eval.const-expr.const-context]
@@ -236,7 +236,7 @@ r[const-eval.const-context]
236236
## Const context
237237
[const context]: #const-context
238238

239-
r[const-eval.const-context.general]
239+
r[const-eval.const-context.def]
240240
A _const context_ is one of the following:
241241

242242
r[const-eval.const-context.array-length]

src/crates-and-source-files.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ The anonymous crate module can have additional attributes that apply to the crat
5353
r[crate.main]
5454
## Main functions
5555

56-
r[crate.main.general]
56+
r[crate.main.executable]
5757
A crate that contains a `main` [function] can be compiled to an executable.
5858

5959
r[crate.main.restriction]

src/items/implementations.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ An orphan implementation is one that implements a foreign trait for a foreign ty
180180

181181
The orphan rule enables library authors to add new implementations to their traits without fear that they'll break downstream code. Without these restrictions, a library couldn't add an implementation like `impl<T: Display> MyTrait for T` without potentially conflicting with downstream implementations.
182182

183-
r[items.impl.trait.orphan-rule.general]
183+
r[items.impl.trait.orphan-rule.def]
184184
Given `impl<P1..=Pn> Trait<T1..=Tn> for T0`, an `impl` is valid only if at
185185
least one of the following is true:
186186

src/type-layout.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ String slices are a UTF-8 representation of characters that have the same layout
114114
r[layout.tuple]
115115
## Tuple layout
116116

117-
r[layout.tuple.general]
117+
r[layout.tuple.def]
118118
Tuples are laid out according to the [`Rust` representation][`Rust`].
119119

120120
r[layout.tuple.unit]

0 commit comments

Comments
 (0)