Skip to content

Commit 62c6ad2

Browse files
committed
---
yaml --- r: 139511 b: refs/heads/try2 c: dbeea18 h: refs/heads/master i: 139509: ab296f7 139507: f29f624 139503: 3c43485 v: v3
1 parent 64e9c41 commit 62c6ad2

File tree

5 files changed

+125
-75
lines changed

5 files changed

+125
-75
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: dc60788215afc61b3f5b5e57cf786478218b919e
8+
refs/heads/try2: dbeea18fc5f94d29db74144e55089cc55aa8e11d
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/doc/rust.md

Lines changed: 99 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1420,13 +1420,111 @@ names are effectively reserved. Some significant attributes include:
14201420

14211421
* The `doc` attribute, for documenting code in-place.
14221422
* The `cfg` attribute, for conditional-compilation by build-configuration.
1423+
* The `lang` attribute, for custom definitions of traits and functions that are known to the Rust compiler (see [Language items](#language-items)).
14231424
* The `link` attribute, for describing linkage metadata for a crate.
14241425
* The `test` attribute, for marking functions as unit tests.
1425-
* The `allow`, `warn`, `forbid`, and `deny` attributes, for controling lint checks. Lint checks supported
1426+
* The `allow`, `warn`, `forbid`, and `deny` attributes, for controlling lint checks. Lint checks supported
14261427
by the compiler can be found via `rustc -W help`.
14271428

14281429
Other attributes may be added or removed during development of the language.
14291430

1431+
### Language items
1432+
1433+
Some primitive Rust operations are defined in Rust code,
1434+
rather than being implemented directly in C or assembly language.
1435+
The definitions of these operations have to be easy for the compiler to find.
1436+
The `lang` attribute makes it possible to declare these operations.
1437+
For example, the `str` module in the Rust core library defines the string equality function:
1438+
1439+
~~~
1440+
#[lang="str_eq"]
1441+
pub fn eq_slice(a: &str, b: &str) -> bool {
1442+
true // not actually the implementation
1443+
}
1444+
~~~
1445+
1446+
The name `str_eq` has a special meaning to the Rust compiler,
1447+
and the presence of this definition means that it will use this definition
1448+
when generating calls to the string equality function.
1449+
1450+
A complete list of the built-in language items follows:
1451+
1452+
#### Traits
1453+
1454+
`const`
1455+
: Cannot be mutated.
1456+
`copy`
1457+
: Can be implicitly copied.
1458+
`owned`
1459+
: Are uniquely owned.
1460+
`durable`
1461+
: Contain borrowed pointers.
1462+
`drop`
1463+
: Have finalizers.
1464+
`add`
1465+
: Elements can be added (for example, integers and floats).
1466+
`sub`
1467+
: Elements can be subtracted.
1468+
`mul`
1469+
: Elements can be multiplied.
1470+
`div`
1471+
: Elements can be divided.
1472+
`mod`
1473+
: Elements have a modulo operation.
1474+
`neg`
1475+
: Elements can be negated arithmetically.
1476+
`not`
1477+
: Elements can be negated logically.
1478+
`bitxor`
1479+
: Elements have an exclusive-or operation.
1480+
`bitand`
1481+
: Elements have a bitwise `and` operation.
1482+
`bitor`
1483+
: Elements have a bitwise `or` operation.
1484+
`shl`
1485+
: Elements have a left shift operation.
1486+
`shr`
1487+
: Elements have a right shift operation.
1488+
`index`
1489+
: Elements can be indexed.
1490+
`eq`
1491+
: Elements can be compared for equality.
1492+
`ord`
1493+
: Elements have a partial ordering.
1494+
1495+
#### Operations
1496+
1497+
`str_eq`
1498+
: Compare two strings for equality.
1499+
`uniq_str_eq`
1500+
: Compare two owned strings for equality.
1501+
`annihilate`
1502+
: Destroy a box before freeing it.
1503+
`log_type`
1504+
: Generically print a string representation of any type.
1505+
`fail_`
1506+
: Abort the program with an error.
1507+
`fail_bounds_check`
1508+
: Abort the program with a bounds check error.
1509+
`exchange_malloc`
1510+
: Allocate memory on the exchange heap.
1511+
`exchange_free`
1512+
: Free memory that was allocated on the exchange heap.
1513+
`malloc`
1514+
: Allocate memory on the managed heap.
1515+
`free`
1516+
: Free memory that was allocated on the managed heap.
1517+
`borrow_as_imm`
1518+
: Create an immutable borrowed pointer to a mutable value.
1519+
`return_to_mut`
1520+
: Release a borrowed pointer created with `return_to_mut`
1521+
`check_not_borrowed`
1522+
: Fail if a value has existing borrowed pointers to it.
1523+
`strdup_uniq`
1524+
: Return a new unique string containing a copy of the contents of a unique string.
1525+
1526+
> **Note:** This list is likely to become out of date. We should auto-generate it
1527+
> from `librustc/middle/lang_items.rs`.
14301528
14311529
# Statements and expressions
14321530

branches/try2/doc/tutorial.md

Lines changed: 23 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -2554,65 +2554,26 @@ a hash representing the crate metadata.
25542554

25552555
## The core library
25562556

2557-
The Rust core library provides runtime features required by the language,
2558-
including the task scheduler and memory allocators, as well as library
2559-
support for Rust built-in types, platform abstractions, and other commonly
2560-
used features.
2561-
2562-
[`core`] includes modules corresponding to each of the integer types, each of
2563-
the floating point types, the [`bool`] type, [tuples], [characters], [strings],
2564-
[vectors], [managed boxes], [owned boxes],
2565-
and unsafe and borrowed [pointers]. Additionally, `core` provides
2566-
some pervasive types ([`option`] and [`result`]),
2567-
[task] creation and [communication] primitives,
2568-
platform abstractions ([`os`] and [`path`]), basic
2569-
I/O abstractions ([`io`]), [containers] like [`hashmap`],
2570-
common traits ([`kinds`], [`ops`], [`cmp`], [`num`],
2571-
[`to_str`], [`clone`]), and complete bindings to the C standard library ([`libc`]).
2572-
2573-
### Core injection and the Rust prelude
2574-
2575-
`core` is imported at the topmost level of every crate by default, as
2576-
if the first line of each crate was
2577-
2578-
extern mod core;
2579-
2580-
This means that the contents of core can be accessed from from any context
2581-
with the `core::` path prefix, as in `use core::vec`, `use core::task::spawn`,
2582-
etc.
2583-
2584-
Additionally, `core` contains a `prelude` module that reexports many of the
2585-
most common core modules, types and traits. The contents of the prelude are
2586-
imported into every *module* by default. Implicitly, all modules behave as if
2587-
they contained the following prologue:
2588-
2589-
use core::prelude::*;
2590-
2591-
[`core`]: core/index.html
2592-
[`bool`]: core/bool.html
2593-
[tuples]: core/tuple.html
2594-
[characters]: core/char.html
2595-
[strings]: core/str.html
2557+
The Rust [core] library is the language runtime and contains
2558+
required memory management and task scheduling code as well as a
2559+
number of modules necessary for effective usage of the primitive
2560+
types. Methods on [vectors] and [strings], implementations of most
2561+
comparison and math operators, and pervasive types like [`Option`]
2562+
and [`Result`] live in core.
2563+
2564+
All Rust programs link to the core library and import its contents,
2565+
as if the following were written at the top of the crate.
2566+
2567+
~~~ {.xfail-test}
2568+
extern mod core;
2569+
use core::*;
2570+
~~~
2571+
2572+
[core]: core/index.html
25962573
[vectors]: core/vec.html
2597-
[managed boxes]: core/managed.html
2598-
[owned boxes]: core/owned.html
2599-
[pointers]: core/ptr.html
2600-
[`option`]: core/option.html
2601-
[`result`]: core/result.html
2602-
[task]: core/task.html
2603-
[communication]: core/comm.html
2604-
[`os`]: core/os.html
2605-
[`path`]: core/path.html
2606-
[`io`]: core/io.html
2607-
[containers]: core/container.html
2608-
[`hashmap`]: core/hashmap.html
2609-
[`kinds`]: core/kinds.html
2610-
[`ops`]: core/ops.html
2611-
[`cmp`]: core/cmp.html
2612-
[`num`]: core/num.html
2613-
[`to_str`]: core/to_str.html
2614-
[`clone`]: core/clone.html
2615-
[`libc`]: core/libc.html
2574+
[strings]: core/str.html
2575+
[`Option`]: core/option.html
2576+
[`Result`]: core/result.html
26162577

26172578
# What next?
26182579

@@ -2624,7 +2585,10 @@ tutorials on individual topics.
26242585
* [Macros][macros]
26252586
* [The foreign function interface][ffi]
26262587

2627-
There is further documentation on the [wiki].
2588+
There is further documentation on the [wiki], including articles about
2589+
[unit testing] in Rust, [documenting][rustdoc] and [packaging][cargo]
2590+
Rust code, and a discussion of the [attributes] used to apply metadata
2591+
to code.
26282592

26292593
[borrow]: tutorial-borrowed-ptr.html
26302594
[tasks]: tutorial-tasks.html

branches/try2/src/libcore/core.rc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ etc.
3939

4040
Additionally, `core` contains a `prelude` module that reexports many of the
4141
most common core modules, types and traits. The contents of the prelude are
42-
imported into every *module* by default. Implicitly, all modules behave as if
42+
imported inte every *module* by default. Implicitly, all modules behave as if
4343
they contained the following prologue:
4444

4545
use core::prelude::*;

branches/try2/src/libcore/libc.rs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,7 @@
99
// except according to those terms.
1010

1111
/*!
12-
* Bindings for the C standard library and other platform libraries
13-
*
14-
* This module contains bindings to the C standard library,
15-
* organized into modules by their defining standard.
16-
* Additionally, it contains some assorted platform-specific definitions.
17-
* For convenience, most functions and types are reexported from `core::libc`,
18-
* so `pub use core::libc::*` will import the available
19-
* C bindings as appropriate for the target platform. The exact
20-
* set of functions available are platform specific.
21-
*
22-
* *Note* Rustdoc does not indicate reexports currently. Also, because these
23-
* definitions are platform-specific, some may not
24-
* appear in the generated documentation.
12+
* Bindings for libc.
2513
*
2614
* We consider the following specs reasonably normative with respect
2715
* to interoperating with the C standard library (libc/msvcrt):

0 commit comments

Comments
 (0)