Skip to content

Commit 544b286

Browse files
committed
---
yaml --- r: 38572 b: refs/heads/incoming c: 7090953 h: refs/heads/master v: v3
1 parent 15a665e commit 544b286

File tree

2 files changed

+30
-25
lines changed

2 files changed

+30
-25
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: 3d5418789064fdb463e872a4e651af1c628a3650
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: a810c03263670238bccd64cabb12a23a46e3a278
9-
refs/heads/incoming: 9bbff50c14c34d7c0c02f8062747bfedf3d21cd3
9+
refs/heads/incoming: 70909533f09a6d187b7728f970a64c448c79290c
1010
refs/heads/dist-snap: 22efa39382d41b084fde1719df7ae8ce5697d8c9
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/incoming/doc/rust.md

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2748,40 +2748,45 @@ call to the method `to_str`.
27482748

27492749
## Type kinds
27502750

2751-
Types in Rust are categorized into three kinds, based on whether they
2752-
allow copying of their values, and sending to different tasks. The
2753-
kinds are:
2754-
2755-
Sendable
2756-
: Values with a sendable type can be safely sent to another task.
2751+
Types in Rust are categorized into kinds, based on various properties of the components of the type.
2752+
The kinds are:
2753+
2754+
`Const`
2755+
: Types of this kind are deeply immutable;
2756+
they contain no mutable memory locations directly or indirectly via pointers.
2757+
`Send`
2758+
: Types of this kind can be safely sent between tasks.
27572759
This kind includes scalars, owning pointers, owned closures, and
27582760
structural types containing only other sendable types.
2759-
Copyable
2761+
`Owned`
2762+
: Types of this kind do not contain any borrowed pointers;
2763+
this can be a useful guarantee for code that breaks borrowing assumptions using [`unsafe` operations](#unsafe-functions).
2764+
`Copy`
27602765
: This kind includes all types that can be copied. All types with
27612766
sendable kind are copyable, as are managed boxes, managed closures,
27622767
trait types, and structural types built out of these.
2763-
Noncopyable
2764-
: [Resource](#resources) types, and every type that includes a
2765-
resource without storing it in a managed box, may not be copied.
2766-
Types of sendable or copyable type can always be used in places
2767-
where a noncopyable type is expected, so in effect this kind
2768-
includes all types.
2769-
2770-
These form a hierarchy. The noncopyable kind is the widest, including
2771-
all types in the language. The copyable kind is a subset of that, and
2772-
the sendable kind is a subset of the copyable kind.
2773-
2774-
Any operation that causes a value to be copied requires the type of
2775-
that value to be of copyable kind. Type parameter types are assumed to
2776-
be noncopyable, unless one of the special bounds `send` or `copy` is
2777-
declared for it. For example, this is not a valid program:
2768+
_Default_
2769+
: Types with destructors, closure environments,
2770+
and various other _non-first-class_ types,
2771+
are not copyable at all.
2772+
Such types can usually only be accessed through pointers,
2773+
or in some cases, moved between mutable locations.
2774+
2775+
Kinds can be supplied as _bounds_ on type parameters, like traits,
2776+
in which case the parameter is constrained to types satisfying that kind.
2777+
2778+
By default, type parameters do not carry any assumed kind-bounds at all.
2779+
2780+
Any operation that causes a value to be copied requires the type of that value to be of copyable kind,
2781+
so the `Copy` bound is frequently required on function type parameters.
2782+
For example, this is not a valid program:
27782783

27792784
~~~~{.xfail-test}
27802785
fn box<T>(x: T) -> @T { @x }
27812786
~~~~
27822787

2783-
Putting `x` into a managed box involves copying, and the `T` parameter
2784-
is assumed to be noncopyable. To change that, a bound is declared:
2788+
Putting `x` into a managed box involves copying, and the `T` parameter has the default (non-copyable) kind.
2789+
To change that, a bound is declared:
27852790

27862791
~~~~
27872792
fn box<T: Copy>(x: T) -> @T { @x }

0 commit comments

Comments
 (0)