Skip to content

Commit a510a4b

Browse files
committed
---
yaml --- r: 59124 b: refs/heads/incoming c: 56a1ee8 h: refs/heads/master v: v3
1 parent c6beb3e commit a510a4b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+933
-1085
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: c50a9d5b664478e533ba1d1d353213d70c8ad589
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/incoming: 8d4d2b00c551301348cc09583498c02fdfbd64d7
9+
refs/heads/incoming: 56a1ee8f84e4aa2b9a45fe3fa7425ae8c8e6649a
1010
refs/heads/dist-snap: 00dbbd01c2aee72982b3e0f9511ae1d4428c3ba9
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/incoming/doc/rust.md

Lines changed: 40 additions & 41 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

branches/incoming/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/incoming/src/libcore/cell.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,21 +44,21 @@ pub fn empty_cell<T>() -> Cell<T> {
4444
pub impl<T> Cell<T> {
4545
/// Yields the value, failing if the cell is empty.
4646
fn take(&self) -> T {
47-
let self = unsafe { transmute_mut(self) };
48-
if self.is_empty() {
47+
let this = unsafe { transmute_mut(self) };
48+
if this.is_empty() {
4949
fail!(~"attempt to take an empty cell");
5050
}
5151
52-
replace(&mut self.value, None).unwrap()
52+
replace(&mut this.value, None).unwrap()
5353
}
5454
5555
/// Returns the value, failing if the cell is full.
5656
fn put_back(&self, value: T) {
57-
let self = unsafe { transmute_mut(self) };
58-
if !self.is_empty() {
57+
let this = unsafe { transmute_mut(self) };
58+
if !this.is_empty() {
5959
fail!(~"attempt to put a value back into a full cell");
6060
}
61-
self.value = Some(value);
61+
this.value = Some(value);
6262
}
6363

6464
/// Returns true if the cell is empty and false if the cell is full.

branches/incoming/src/libcore/num/f32.rs

Lines changed: 0 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -450,58 +450,6 @@ impl Hyperbolic for f32 {
450450

451451
#[inline(always)]
452452
fn tanh(&self) -> f32 { tanh(*self) }
453-
454-
///
455-
/// Inverse hyperbolic sine
456-
///
457-
/// # Returns
458-
///
459-
/// - on success, the inverse hyperbolic sine of `self` will be returned
460-
/// - `self` if `self` is `0.0`, `-0.0`, `infinity`, or `neg_infinity`
461-
/// - `NaN` if `self` is `NaN`
462-
///
463-
#[inline(always)]
464-
fn asinh(&self) -> f32 {
465-
match *self {
466-
infinity => infinity,
467-
neg_infinity => neg_infinity,
468-
x => (x + ((x * x) + 1.0).sqrt()).ln(),
469-
}
470-
}
471-
472-
///
473-
/// Inverse hyperbolic cosine
474-
///
475-
/// # Returns
476-
///
477-
/// - on success, the inverse hyperbolic cosine of `self` will be returned
478-
/// - `infinity` if `self` is `infinity`
479-
/// - `NaN` if `self` is `NaN` or `self < 1.0` (including `neg_infinity`)
480-
///
481-
#[inline(always)]
482-
fn acosh(&self) -> f32 {
483-
match *self {
484-
x if x < 1.0 => Float::NaN(),
485-
x => (x + ((x * x) - 1.0).sqrt()).ln(),
486-
}
487-
}
488-
489-
///
490-
/// Inverse hyperbolic tangent
491-
///
492-
/// # Returns
493-
///
494-
/// - on success, the inverse hyperbolic tangent of `self` will be returned
495-
/// - `self` if `self` is `0.0` or `-0.0`
496-
/// - `infinity` if `self` is `1.0`
497-
/// - `neg_infinity` if `self` is `-1.0`
498-
/// - `NaN` if the `self` is `NaN` or outside the domain of `-1.0 <= self <= 1.0`
499-
/// (including `infinity` and `neg_infinity`)
500-
///
501-
#[inline(always)]
502-
fn atanh(&self) -> f32 {
503-
0.5 * ((2.0 * *self) / (1.0 - *self)).ln_1p()
504-
}
505453
}
506454

507455
impl Real for f32 {
@@ -1024,43 +972,6 @@ mod tests {
1024972
assert_approx_eq!((-1.7f32).fract(), -0.7f32);
1025973
}
1026974

1027-
#[test]
1028-
fn test_asinh() {
1029-
assert_eq!(0.0f32.asinh(), 0.0f32);
1030-
assert_eq!((-0.0f32).asinh(), -0.0f32);
1031-
assert_eq!(Float::infinity::<f32>().asinh(), Float::infinity::<f32>());
1032-
assert_eq!(Float::neg_infinity::<f32>().asinh(), Float::neg_infinity::<f32>());
1033-
assert!(Float::NaN::<f32>().asinh().is_NaN());
1034-
assert_approx_eq!(2.0f32.asinh(), 1.443635475178810342493276740273105f32);
1035-
assert_approx_eq!((-2.0f32).asinh(), -1.443635475178810342493276740273105f32);
1036-
}
1037-
1038-
#[test]
1039-
fn test_acosh() {
1040-
assert_eq!(1.0f32.acosh(), 0.0f32);
1041-
assert!(0.999f32.acosh().is_NaN());
1042-
assert_eq!(Float::infinity::<f32>().acosh(), Float::infinity::<f32>());
1043-
assert!(Float::neg_infinity::<f32>().acosh().is_NaN());
1044-
assert!(Float::NaN::<f32>().acosh().is_NaN());
1045-
assert_approx_eq!(2.0f32.acosh(), 1.31695789692481670862504634730796844f32);
1046-
assert_approx_eq!(3.0f32.acosh(), 1.76274717403908605046521864995958461f32);
1047-
}
1048-
1049-
#[test]
1050-
fn test_atanh() {
1051-
assert_eq!(0.0f32.atanh(), 0.0f32);
1052-
assert_eq!((-0.0f32).atanh(), -0.0f32);
1053-
assert_eq!(1.0f32.atanh(), Float::infinity::<f32>());
1054-
assert_eq!((-1.0f32).atanh(), Float::neg_infinity::<f32>());
1055-
assert!(2f64.atanh().atanh().is_NaN());
1056-
assert!((-2f64).atanh().atanh().is_NaN());
1057-
assert!(Float::infinity::<f64>().atanh().is_NaN());
1058-
assert!(Float::neg_infinity::<f64>().atanh().is_NaN());
1059-
assert!(Float::NaN::<f32>().atanh().is_NaN());
1060-
assert_approx_eq!(0.5f32.atanh(), 0.54930614433405484569762261846126285f32);
1061-
assert_approx_eq!((-0.5f32).atanh(), -0.54930614433405484569762261846126285f32);
1062-
}
1063-
1064975
#[test]
1065976
fn test_real_consts() {
1066977
assert_approx_eq!(Real::two_pi::<f32>(), 2f32 * Real::pi::<f32>());

branches/incoming/src/libcore/num/f64.rs

Lines changed: 0 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -463,58 +463,6 @@ impl Hyperbolic for f64 {
463463

464464
#[inline(always)]
465465
fn tanh(&self) -> f64 { tanh(*self) }
466-
467-
///
468-
/// Inverse hyperbolic sine
469-
///
470-
/// # Returns
471-
///
472-
/// - on success, the inverse hyperbolic sine of `self` will be returned
473-
/// - `self` if `self` is `0.0`, `-0.0`, `infinity`, or `neg_infinity`
474-
/// - `NaN` if `self` is `NaN`
475-
///
476-
#[inline(always)]
477-
fn asinh(&self) -> f64 {
478-
match *self {
479-
infinity => infinity,
480-
neg_infinity => neg_infinity,
481-
x => (x + ((x * x) + 1.0).sqrt()).ln(),
482-
}
483-
}
484-
485-
///
486-
/// Inverse hyperbolic cosine
487-
///
488-
/// # Returns
489-
///
490-
/// - on success, the inverse hyperbolic cosine of `self` will be returned
491-
/// - `infinity` if `self` is `infinity`
492-
/// - `NaN` if `self` is `NaN` or `self < 1.0` (including `neg_infinity`)
493-
///
494-
#[inline(always)]
495-
fn acosh(&self) -> f64 {
496-
match *self {
497-
x if x < 1.0 => Float::NaN(),
498-
x => (x + ((x * x) - 1.0).sqrt()).ln(),
499-
}
500-
}
501-
502-
///
503-
/// Inverse hyperbolic tangent
504-
///
505-
/// # Returns
506-
///
507-
/// - on success, the inverse hyperbolic tangent of `self` will be returned
508-
/// - `self` if `self` is `0.0` or `-0.0`
509-
/// - `infinity` if `self` is `1.0`
510-
/// - `neg_infinity` if `self` is `-1.0`
511-
/// - `NaN` if the `self` is `NaN` or outside the domain of `-1.0 <= self <= 1.0`
512-
/// (including `infinity` and `neg_infinity`)
513-
///
514-
#[inline(always)]
515-
fn atanh(&self) -> f64 {
516-
0.5 * ((2.0 * *self) / (1.0 - *self)).ln_1p()
517-
}
518466
}
519467

520468
impl Real for f64 {
@@ -1071,43 +1019,6 @@ mod tests {
10711019
assert_approx_eq!((-1.7f64).fract(), -0.7f64);
10721020
}
10731021

1074-
#[test]
1075-
fn test_asinh() {
1076-
assert_eq!(0.0f64.asinh(), 0.0f64);
1077-
assert_eq!((-0.0f64).asinh(), -0.0f64);
1078-
assert_eq!(Float::infinity::<f64>().asinh(), Float::infinity::<f64>());
1079-
assert_eq!(Float::neg_infinity::<f64>().asinh(), Float::neg_infinity::<f64>());
1080-
assert!(Float::NaN::<f64>().asinh().is_NaN());
1081-
assert_approx_eq!(2.0f64.asinh(), 1.443635475178810342493276740273105f64);
1082-
assert_approx_eq!((-2.0f64).asinh(), -1.443635475178810342493276740273105f64);
1083-
}
1084-
1085-
#[test]
1086-
fn test_acosh() {
1087-
assert_eq!(1.0f64.acosh(), 0.0f64);
1088-
assert!(0.999f64.acosh().is_NaN());
1089-
assert_eq!(Float::infinity::<f64>().acosh(), Float::infinity::<f64>());
1090-
assert!(Float::neg_infinity::<f64>().acosh().is_NaN());
1091-
assert!(Float::NaN::<f64>().acosh().is_NaN());
1092-
assert_approx_eq!(2.0f64.acosh(), 1.31695789692481670862504634730796844f64);
1093-
assert_approx_eq!(3.0f64.acosh(), 1.76274717403908605046521864995958461f64);
1094-
}
1095-
1096-
#[test]
1097-
fn test_atanh() {
1098-
assert_eq!(0.0f64.atanh(), 0.0f64);
1099-
assert_eq!((-0.0f64).atanh(), -0.0f64);
1100-
assert_eq!(1.0f64.atanh(), Float::infinity::<f64>());
1101-
assert_eq!((-1.0f64).atanh(), Float::neg_infinity::<f64>());
1102-
assert!(2f64.atanh().atanh().is_NaN());
1103-
assert!((-2f64).atanh().atanh().is_NaN());
1104-
assert!(Float::infinity::<f64>().atanh().is_NaN());
1105-
assert!(Float::neg_infinity::<f64>().atanh().is_NaN());
1106-
assert!(Float::NaN::<f64>().atanh().is_NaN());
1107-
assert_approx_eq!(0.5f64.atanh(), 0.54930614433405484569762261846126285f64);
1108-
assert_approx_eq!((-0.5f64).atanh(), -0.54930614433405484569762261846126285f64);
1109-
}
1110-
11111022
#[test]
11121023
fn test_real_consts() {
11131024
assert_approx_eq!(Real::two_pi::<f64>(), 2.0 * Real::pi::<f64>());

0 commit comments

Comments
 (0)