Skip to content

Commit a456d59

Browse files
committed
---
yaml --- r: 140759 b: refs/heads/try2 c: 06ef889 h: refs/heads/master i: 140757: bd080b7 140755: 31a95fc 140751: 3094429 v: v3
1 parent 08f3b82 commit a456d59

File tree

30 files changed

+236
-436
lines changed

30 files changed

+236
-436
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: 1b883365bc0813f5775c8207e414b7973e947a76
8+
refs/heads/try2: 06ef889cdc77db862d526bf6a607ecdf3ee80beb
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: 40 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@ each of which may have some number of [attributes](#attributes) attached to it.
618618

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

624624
An _item_ is a component of a crate; some module items can be defined in crate
@@ -752,10 +752,11 @@ link_attr : ident '=' literal ;
752752
~~~~~~~~
753753

754754
An _`extern mod` declaration_ specifies a dependency on an external crate.
755-
The external crate is then bound into the declaring scope as the `ident` provided in the `extern_mod_decl`.
755+
The external crate is then bound into the declaring scope
756+
as the `ident` provided in the `extern_mod_decl`.
756757

757-
The external crate is resolved to a specific `soname` at compile time, and a
758-
runtime linkage requirement to that `soname` is passed to the linker for
758+
The external crate is resolved to a specific `soname` at compile time,
759+
and a runtime linkage requirement to that `soname` is passed to the linker for
759760
loading at runtime. The `soname` is resolved at compile time by scanning the
760761
compiler's library path and matching the `link_attrs` provided in the
761762
`use_decl` against any `#link` attributes that were declared on the external
@@ -992,10 +993,10 @@ Thus the return type on `f` only needs to reflect the `if` branch of the conditi
992993
#### Extern functions
993994

994995
Extern functions are part of Rust's foreign function interface,
995-
providing the opposite functionality to [foreign modules](#foreign-modules).
996-
Whereas foreign modules allow Rust code to call foreign code,
997-
extern functions with bodies defined in Rust code _can be called by foreign code_.
998-
They are defined in the same way as any other Rust function,
996+
providing the opposite functionality to [external blocks](#external-blocks).
997+
Whereas external blocks allow Rust code to call foreign code,
998+
extern functions with bodies defined in Rust code _can be called by foreign
999+
code_. They are defined in the same way as any other Rust function,
9991000
except that they have the `extern` modifier.
10001001

10011002
~~~
@@ -1011,7 +1012,8 @@ let fptr: *u8 = new_vec;
10111012
~~~
10121013

10131014
The primary motivation for extern functions is
1014-
to create callbacks for foreign functions that expect to receive function pointers.
1015+
to create callbacks for foreign functions that expect to receive function
1016+
pointers.
10151017

10161018
### Type definitions
10171019

@@ -1308,64 +1310,61 @@ impl Seq<bool> for u32 {
13081310
}
13091311
~~~~
13101312

1311-
### Foreign modules
1313+
### External blocks
13121314

13131315
~~~ {.ebnf .gram}
1314-
foreign_mod_item : "extern mod" ident '{' foreign_mod '} ;
1315-
foreign_mod : [ foreign_fn ] * ;
1316+
extern_block_item : "extern" '{' extern_block '} ;
1317+
extern_block : [ foreign_fn ] * ;
13161318
~~~
13171319

1318-
Foreign modules form the basis for Rust's foreign function interface. A
1319-
foreign module describes functions in external, non-Rust
1320-
libraries.
1321-
Functions within foreign modules are declared in the same way as other Rust functions,
1322-
with the exception that they may not have a body and are instead terminated by a semicolon.
1320+
External blocks form the basis for Rust's foreign function interface.
1321+
Declarations in an external block describe symbols
1322+
in external, non-Rust libraries.
1323+
1324+
Functions within external blocks
1325+
are declared in the same way as other Rust functions,
1326+
with the exception that they may not have a body
1327+
and are instead terminated by a semicolon.
13231328

13241329
~~~
13251330
# use core::libc::{c_char, FILE};
13261331
# #[nolink]
13271332
1328-
extern mod c {
1333+
extern {
13291334
fn fopen(filename: *c_char, mode: *c_char) -> *FILE;
13301335
}
13311336
~~~
13321337

1333-
Functions within foreign modules may be called by Rust code, just like functions defined in Rust.
1334-
The Rust compiler automatically translates between the Rust ABI and the foreign ABI.
1335-
1336-
The name of the foreign module has special meaning to the Rust compiler in
1337-
that it will treat the module name as the name of a library to link to,
1338-
performing the linking as appropriate for the target platform. The name
1339-
given for the foreign module will be transformed in a platform-specific way
1340-
to determine the name of the library. For example, on Linux the name of the
1341-
foreign module is prefixed with 'lib' and suffixed with '.so', so the
1342-
foreign mod 'rustrt' would be linked to a library named 'librustrt.so'.
1338+
Functions within external blocks may be called by Rust code,
1339+
just like functions defined in Rust.
1340+
The Rust compiler automatically translates
1341+
between the Rust ABI and the foreign ABI.
13431342

1344-
A number of [attributes](#attributes) control the behavior of foreign
1345-
modules.
1343+
A number of [attributes](#attributes) control the behavior of external
1344+
blocks.
13461345

1347-
By default foreign modules assume that the library they are calling use the
1348-
standard C "cdecl" ABI. Other ABIs may be specified using the `abi`
1349-
attribute as in
1346+
By default external blocks assume
1347+
that the library they are calling uses the standard C "cdecl" ABI.
1348+
Other ABIs may be specified using the `abi` attribute as in
13501349

13511350
~~~{.xfail-test}
13521351
// Interface to the Windows API
13531352
#[abi = "stdcall"]
1354-
extern mod kernel32 { }
1353+
extern { }
13551354
~~~
13561355

1357-
The `link_name` attribute allows the default library naming behavior to
1358-
be overridden by explicitly specifying the name of the library.
1356+
The `link_name` attribute allows the name of the library to be specified.
13591357

13601358
~~~{.xfail-test}
13611359
#[link_name = "crypto"]
1362-
extern mod mycrypto { }
1360+
extern { }
13631361
~~~
13641362

1365-
The `nolink` attribute tells the Rust compiler not to do any linking for the foreign module.
1366-
This is particularly useful for creating foreign
1367-
modules for libc, which tends to not follow standard library naming
1368-
conventions and is linked to all Rust programs anyway.
1363+
The `nolink` attribute tells the Rust compiler
1364+
not to do any linking for the external block.
1365+
This is particularly useful for creating external blocks for libc,
1366+
which tends to not follow standard library naming conventions
1367+
and is linked to all Rust programs anyway.
13691368

13701369
## Attributes
13711370

@@ -1425,8 +1424,6 @@ names are effectively reserved. Some significant attributes include:
14251424
* The `test` attribute, for marking functions as unit tests.
14261425
* The `allow`, `warn`, `forbid`, and `deny` attributes, for controlling lint checks. Lint checks supported
14271426
by the compiler can be found via `rustc -W help`.
1428-
* The `deriving` attribute, for automatically generating
1429-
implementations of certain traits.
14301427

14311428
Other attributes may be added or removed during development of the language.
14321429

@@ -1528,47 +1525,6 @@ A complete list of the built-in language items follows:
15281525
> **Note:** This list is likely to become out of date. We should auto-generate it
15291526
> from `librustc/middle/lang_items.rs`.
15301527
1531-
### Deriving
1532-
1533-
The `deriving` attribute allows certain traits to be automatically
1534-
implemented for data structures. For example, the following will
1535-
create an `impl` for the `Eq` and `Clone` traits for `Foo`, the type
1536-
parameter `T` will be given the `Eq` or `Clone` constraints for the
1537-
appropriate `impl`:
1538-
1539-
~~~
1540-
#[deriving(Eq, Clone)]
1541-
struct Foo<T> {
1542-
a: int,
1543-
b: T
1544-
}
1545-
~~~
1546-
1547-
The generated `impl` for `Eq` is equivalent to
1548-
1549-
~~~
1550-
# struct Foo<T> { a: int, b: T }
1551-
impl<T: Eq> Eq for Foo<T> {
1552-
fn eq(&self, other: &Foo<T>) -> bool {
1553-
self.a == other.a && self.b == other.b
1554-
}
1555-
1556-
fn ne(&self, other: &Foo<T>) -> bool {
1557-
self.a != other.a || self.b != other.b
1558-
}
1559-
}
1560-
~~~
1561-
1562-
Supported traits for `deriving` are:
1563-
1564-
* Comparison traits: `Eq`, `TotalEq`, `Ord`, `TotalOrd`.
1565-
* Serialization: `Encodable`, `Decodable`. These require `std`.
1566-
* `Clone`, to perform deep copies.
1567-
* `IterBytes`, to iterate over the bytes in a data type.
1568-
* `Rand`, to create a random instance of a data type.
1569-
* `ToStr`, to convert to a string. For a type with this instance,
1570-
`obj.to_str()` has the same output as `fmt!("%?", obj)`.
1571-
15721528
# Statements and expressions
15731529

15741530
Rust is _primarily_ an expression language. This means that most forms of

branches/try2/doc/tutorial-ffi.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,8 @@ convention to use:
237237
~~~~
238238
#[cfg(target_os = "win32")]
239239
#[abi = "stdcall"]
240-
extern mod kernel32 {
240+
#[link_name = "kernel32"]
241+
extern {
241242
fn SetEnvironmentVariableA(n: *u8, v: *u8) -> int;
242243
}
243244
~~~~

branches/try2/doc/tutorial.md

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2290,27 +2290,6 @@ let nonsense = mycircle.radius() * mycircle.area();
22902290

22912291
> ***Note:*** Trait inheritance does not actually work with objects yet
22922292
2293-
## Deriving implementations for traits
2294-
2295-
A small number of traits in `core` and `std` can have implementations
2296-
that can be automatically derived. These instances are specified by
2297-
placing the `deriving` attribute on a data type declaration. For
2298-
example, the following will mean that `Circle` has an implementation
2299-
for `Eq` and can be used with the equality operators, and that a value
2300-
of type `ABC` can be randomly generated and converted to a string:
2301-
2302-
~~~
2303-
#[deriving(Eq)]
2304-
struct Circle { radius: float }
2305-
2306-
#[deriving(Rand, ToStr)]
2307-
enum ABC { A, B, C }
2308-
~~~
2309-
2310-
The full list of derivable traits is `Eq`, `TotalEq`, `Ord`,
2311-
`TotalOrd`, `Encodable` `Decodable`, `Clone`, `IterBytes`, `Rand` and
2312-
`ToStr`.
2313-
23142293
# Modules and crates
23152294

23162295
The Rust namespace is arranged in a hierarchy of modules. Each source

branches/try2/mk/tools.mk

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,6 @@ $$(TLIB$(1)_T_$(4)_H_$(3))/$(CFG_LIBRUST_$(4)): \
111111
$$(TSREQ$(1)_T_$(4)_H_$(3)) \
112112
$$(TLIB$(1)_T_$(4)_H_$(3))/$(CFG_CORELIB_$(4)) \
113113
$$(TLIB$(1)_T_$(4)_H_$(3))/$(CFG_STDLIB_$(4)) \
114-
$$(TLIB$(1)_T_$(4)_H_$(3))/$(CFG_LIBRUSTPKG_$(4)) \
115-
$$(TLIB$(1)_T_$(4)_H_$(3))/$(CFG_LIBRUSTI_$(4)) \
116-
$$(TLIB$(1)_T_$(4)_H_$(3))/$(CFG_LIBRUSTDOC_$(4)) \
117114
$$(TLIB$(1)_T_$(4)_H_$(3))/$(CFG_LIBRUSTC_$(4))
118115
@$$(call E, compile_and_link: $$@)
119116
$$(STAGE$(1)_T_$(4)_H_$(3)) -o $$@ $$< && touch $$@

branches/try2/src/driver/driver.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#[no_core];
12+
extern mod core(vers = "0.7-pre");
13+
1114
#[cfg(rustpkg)]
1215
extern mod this(name = "rustpkg", vers = "0.7-pre");
1316

branches/try2/src/libcore/os.rs

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -196,10 +196,10 @@ pub fn env() -> ~[(~str,~str)] {
196196
}
197197
#[cfg(unix)]
198198
unsafe fn get_env_pairs() -> ~[~str] {
199-
extern mod rustrt {
199+
extern {
200200
unsafe fn rust_env_pairs() -> **libc::c_char;
201201
}
202-
let environ = rustrt::rust_env_pairs();
202+
let environ = rust_env_pairs();
203203
if (environ as uint == 0) {
204204
fail!(fmt!("os::env() failure getting env string from OS: %s",
205205
os::last_os_error()));
@@ -685,9 +685,8 @@ pub fn list_dir(p: &Path) -> ~[~str] {
685685
unsafe fn get_list(p: &Path) -> ~[~str] {
686686
use libc::{dirent_t};
687687
use libc::{opendir, readdir, closedir};
688-
extern mod rustrt {
689-
unsafe fn rust_list_dir_val(ptr: *dirent_t)
690-
-> *libc::c_char;
688+
extern {
689+
unsafe fn rust_list_dir_val(ptr: *dirent_t) -> *libc::c_char;
691690
}
692691
let input = p.to_str();
693692
let mut strings = ~[];
@@ -698,10 +697,8 @@ pub fn list_dir(p: &Path) -> ~[~str] {
698697
debug!("os::list_dir -- opendir() SUCCESS");
699698
let mut entry_ptr = readdir(dir_ptr);
700699
while (entry_ptr as uint != 0) {
701-
strings.push(
702-
str::raw::from_c_str(
703-
rustrt::rust_list_dir_val(
704-
entry_ptr)));
700+
strings.push(str::raw::from_c_str(rust_list_dir_val(
701+
entry_ptr)));
705702
entry_ptr = readdir(dir_ptr);
706703
}
707704
closedir(dir_ptr);
@@ -729,25 +726,23 @@ pub fn list_dir(p: &Path) -> ~[~str] {
729726
};
730727
use unstable::exchange_alloc::{malloc_raw, free_raw};
731728
#[nolink]
732-
extern mod rustrt {
729+
extern {
733730
unsafe fn rust_list_dir_wfd_size() -> libc::size_t;
734731
unsafe fn rust_list_dir_wfd_fp_buf(wfd: *libc::c_void)
735732
-> *u16;
736733
}
737734
fn star(p: &Path) -> Path { p.push("*") }
738735
do as_utf16_p(star(p).to_str()) |path_ptr| {
739736
let mut strings = ~[];
740-
let wfd_ptr = malloc_raw(
741-
rustrt::rust_list_dir_wfd_size() as uint);
737+
let wfd_ptr = malloc_raw(rust_list_dir_wfd_size() as uint);
742738
let find_handle =
743739
FindFirstFileW(
744740
path_ptr,
745741
::cast::transmute(wfd_ptr));
746742
if find_handle as int != INVALID_HANDLE_VALUE {
747743
let mut more_files = 1 as libc::c_int;
748744
while more_files != 0 {
749-
let fp_buf = rustrt::rust_list_dir_wfd_fp_buf(
750-
wfd_ptr);
745+
let fp_buf = rust_list_dir_wfd_fp_buf(wfd_ptr);
751746
if fp_buf as uint == 0 {
752747
fail!(~"os::list_dir() failure:"+
753748
~" got null ptr from wfd");

branches/try2/src/libcore/unstable/intrinsics.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,6 @@ pub extern "rust-intrinsic" {
2020
pub fn atomic_cxchg_acq(dst: &mut int, old: int, src: int) -> int;
2121
pub fn atomic_cxchg_rel(dst: &mut int, old: int, src: int) -> int;
2222

23-
#[cfg(not(stage0))]
24-
pub fn atomic_load(src: &int) -> int;
25-
#[cfg(not(stage0))]
26-
pub fn atomic_load_acq(src: &int) -> int;
27-
28-
#[cfg(not(stage0))]
29-
pub fn atomic_store(dst: &mut int, val: int);
30-
#[cfg(not(stage0))]
31-
pub fn atomic_store_rel(dst: &mut int, val: int);
32-
3323
pub fn atomic_xchg(dst: &mut int, src: int) -> int;
3424
pub fn atomic_xchg_acq(dst: &mut int, src: int) -> int;
3525
pub fn atomic_xchg_rel(dst: &mut int, src: int) -> int;

branches/try2/src/libcore/util.rs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -132,20 +132,6 @@ impl Drop for NonCopyable {
132132

133133
pub fn NonCopyable() -> NonCopyable { NonCopyable { i: () } }
134134

135-
136-
/// A type with no inhabitants
137-
pub enum Void { }
138-
139-
pub impl Void {
140-
/// A utility function for ignoring this uninhabited type
141-
fn uninhabited(&self) -> ! {
142-
match *self {
143-
// Nothing to match on
144-
}
145-
}
146-
}
147-
148-
149135
/**
150136
A utility function for indicating unreachable code. It will fail if
151137
executed. This is occasionally useful to put after loops that never

0 commit comments

Comments
 (0)