Skip to content

Commit b481829

Browse files
committed
docs: update to avoid mention of const.
1 parent 62c1f04 commit b481829

File tree

3 files changed

+22
-21
lines changed

3 files changed

+22
-21
lines changed

doc/rust.md

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -617,8 +617,8 @@ each of which may have some number of [attributes](#attributes) attached to it.
617617
## Items
618618

619619
~~~~~~~~ {.ebnf .gram}
620-
item : mod_item | fn_item | type_item | enum_item
621-
| const_item | trait_item | impl_item | foreign_mod_item ;
620+
item : mod_item | fn_item | type_item | struct_item | enum_item
621+
| static_item | trait_item | impl_item | foreign_mod_item ;
622622
~~~~~~~~
623623

624624
An _item_ is a component of a crate; some module items can be defined in crate
@@ -627,7 +627,7 @@ crate by a nested set of [modules](#modules). Every crate has a single
627627
"outermost" anonymous module; all further items within the crate have
628628
[paths](#paths) within the module tree of the crate.
629629

630-
Items are entirely determined at compile-time, remain constant during
630+
Items are entirely determined at compile-time, generally remain fixed during
631631
execution, and may reside in read-only memory.
632632

633633
There are several kinds of item:
@@ -637,7 +637,7 @@ There are several kinds of item:
637637
* [type definitions](#type-definitions)
638638
* [structures](#structures)
639639
* [enumerations](#enumerations)
640-
* [constants](#constants)
640+
* [static items](#static-items)
641641
* [traits](#traits)
642642
* [implementations](#implementations)
643643

@@ -1091,21 +1091,23 @@ a = Cat{ name: ~"Spotty", weight: 2.7 };
10911091
In this example, `Cat` is a _struct-like enum variant_,
10921092
whereas `Dog` is simply called an enum variant.
10931093

1094-
### Constants
1094+
### Static items
10951095

10961096
~~~~~~~~ {.ebnf .gram}
1097-
const_item : "const" ident ':' type '=' expr ';' ;
1097+
static_item : "static" ident ':' type '=' expr ';' ;
10981098
~~~~~~~~
10991099

1100-
A *constant* is a named value stored in read-only memory in a crate.
1101-
The value bound to a constant is evaluated at compile time.
1102-
Constants are declared with the `static` keyword.
1103-
A constant item must have an expression giving its definition.
1104-
The definition expression of a constant is limited to expression forms that can be evaluated at compile time.
1100+
A *static item* is a named _constant value_ stored in the global data section of a crate.
1101+
Immutable static items are stored in the read-only data section.
1102+
The constant value bound to a static item is, like all constant values, evaluated at compile time.
1103+
Static items have the `static` lifetime, which outlives all other lifetimes in a Rust program.
1104+
Static items are declared with the `static` keyword.
1105+
A static item must have a _constant expression_ giving its definition.
11051106

1106-
Constants must be explicitly typed. The type may be ```bool```, ```char```, a number, or a type derived from those primitive types.
1107-
The derived types are borrowed pointers, static arrays, tuples, and structs.
1108-
Borrowed pointers must be have the `'static` lifetime.
1107+
Static items must be explicitly typed.
1108+
The type may be ```bool```, ```char```, a number, or a type derived from those primitive types.
1109+
The derived types are borrowed pointers with the `'static` lifetime,
1110+
fixed-size arrays, tuples, and structs.
11091111

11101112
~~~~
11111113
static bit1: uint = 1 << 0;
@@ -1456,7 +1458,7 @@ The declared names may denote new slots or new items.
14561458

14571459
An _item declaration statement_ has a syntactic form identical to an
14581460
[item](#items) declaration within a module. Declaring an item -- a function,
1459-
enumeration, type, constant, trait, implementation or module -- locally
1461+
enumeration, structure, type, static, trait, implementation or module -- locally
14601462
within a statement block is simply a way of restricting its scope to a narrow
14611463
region containing all of its uses; it is otherwise identical in meaning to
14621464
declaring the item outside the statement block.

doc/tutorial-borrowed-ptr.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -468,11 +468,10 @@ overwritten for the duration of the borrow. In fact, the compiler
468468
would accept the example we gave earlier. The example is safe because
469469
the shape pointer has type `&Shape`, which means "borrowed pointer to
470470
immutable memory containing a `shape`". If, however, the type of that
471-
pointer were `&const Shape` or `&mut Shape`, then the ref binding
472-
would be ill-typed. Just as with unique boxes, the compiler will
473-
permit `ref` bindings into data owned by the stack frame even if the
474-
data are mutable, but otherwise it requires that the data reside in
475-
immutable memory.
471+
pointer were `&mut Shape`, then the ref binding would be ill-typed.
472+
Just as with unique boxes, the compiler will permit `ref` bindings
473+
into data owned by the stack frame even if the data are mutable,
474+
but otherwise it requires that the data reside in immutable memory.
476475

477476
# Returning borrowed pointers
478477

doc/tutorial.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ while count < 10 {
234234

235235
Although Rust can almost always infer the types of local variables, you
236236
can specify a variable's type by following it with a colon, then the type
237-
name. Constants, on the other hand, always require a type annotation.
237+
name. Static items, on the other hand, always require a type annotation.
238238

239239
~~~~
240240
static monster_factor: float = 57.8;

0 commit comments

Comments
 (0)