Skip to content

Commit

Permalink
Install new pub/priv/export rules as defaults, old rules accessible u…
Browse files Browse the repository at this point in the history
…nder #[legacy_exports];
  • Loading branch information
graydon committed Sep 22, 2012
1 parent 60443d4 commit dffe188
Show file tree
Hide file tree
Showing 277 changed files with 1,174 additions and 120 deletions.
3 changes: 2 additions & 1 deletion doc/rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -875,7 +875,8 @@ declaration replaces the default export with the export specified.
An example of an export:

~~~~~~~~
mod foo {
pub mod foo {
#[legacy_exports];
export primary;
fn primary() {
Expand Down
8 changes: 6 additions & 2 deletions doc/tutorial-ffi.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,9 @@ null pointers.
The `sha1` function is the most obscure part of the program.

~~~~
# mod crypto { fn SHA1(src: *u8, sz: uint, out: *u8) -> *u8 { out } }
# pub mod crypto {
# pub fn SHA1(src: *u8, sz: uint, out: *u8) -> *u8 { out }
# }
# fn as_hex(data: ~[u8]) -> ~str { ~"hi" }
fn sha1(data: ~str) -> ~str {
unsafe {
Expand Down Expand Up @@ -166,7 +168,9 @@ Rust's safety mechanisms.
Let's look at our `sha1` function again.

~~~~
# mod crypto { fn SHA1(src: *u8, sz: uint, out: *u8) -> *u8 { out } }
# pub mod crypto {
# pub fn SHA1(src: *u8, sz: uint, out: *u8) -> *u8 { out }
# }
# fn as_hex(data: ~[u8]) -> ~str { ~"hi" }
# fn x(data: ~str) -> ~str {
# unsafe {
Expand Down
2 changes: 2 additions & 0 deletions doc/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -1820,6 +1820,7 @@ explicitly import it, you must refer to it by its long name,
`farm::chicken`.

~~~~
#[legacy_exports]
mod farm {
fn chicken() -> ~str { ~"cluck cluck" }
fn cow() -> ~str { ~"mooo" }
Expand Down Expand Up @@ -2004,6 +2005,7 @@ Rust uses three different namespaces: one for modules, one for types,
and one for values. This means that this code is valid:

~~~~
#[legacy_exports]
mod buffalo {
type buffalo = int;
fn buffalo<buffalo>(+buffalo: buffalo) -> buffalo { buffalo }
Expand Down
2 changes: 2 additions & 0 deletions src/cargo/cargo.rc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#[crate_type = "bin"];

#[no_core];
#[legacy_exports];

#[allow(vecs_implicitly_copyable,
non_implicitly_copyable_typarams)];
Expand All @@ -29,4 +30,5 @@ extern mod syntax(vers = "0.4");

use core::*;

#[legacy_exports]
mod pgp;
2 changes: 2 additions & 0 deletions src/cargo/cargo.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// cargo.rs - Rust package manager

#[legacy_exports];

use syntax::{ast, codemap, parse, visit, attr};
use syntax::diagnostic::span_handler;
use codemap::span;
Expand Down
7 changes: 7 additions & 0 deletions src/compiletest/compiletest.rc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#[crate_type = "bin"];

#[no_core];
#[legacy_exports];

#[allow(vecs_implicitly_copyable)];
#[allow(non_camel_case_types)];
Expand All @@ -10,11 +11,17 @@ extern mod std(vers = "0.4");

use core::*;

#[legacy_exports]
mod procsrv;
#[legacy_exports]
mod util;
#[legacy_exports]
mod header;
#[legacy_exports]
mod runtest;
#[legacy_exports]
mod common;
#[legacy_exports]
mod errors;

// Local Variables:
Expand Down
1 change: 1 addition & 0 deletions src/fuzzer/fuzzer.rc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#[no_core];

#[legacy_modes];
#[legacy_exports];

#[allow(vecs_implicitly_copyable)];
#[allow(non_camel_case_types)];
Expand Down
2 changes: 2 additions & 0 deletions src/fuzzer/fuzzer.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#[legacy_exports];

use io::WriterUtil;

use syntax::{ast, ast_util, fold, visit, codemap};
Expand Down
7 changes: 6 additions & 1 deletion src/libcore/at_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ export traits;

#[abi = "cdecl"]
extern mod rustrt {
#[legacy_exports];
fn vec_reserve_shared_actual(++t: *sys::TypeDesc,
++v: **vec::raw::VecRepr,
++n: libc::size_t);
}

#[abi = "rust-intrinsic"]
extern mod rusti {
#[legacy_exports];
fn move_val_init<T>(&dst: T, -src: T);
}

Expand Down Expand Up @@ -135,6 +137,7 @@ pure fn from_elem<T: Copy>(n_elts: uint, t: T) -> @[T] {

#[cfg(notest)]
mod traits {
#[legacy_exports];
#[cfg(stage0)]
impl<T: Copy> @[T]: Add<&[const T],@[T]> {
#[inline(always)]
Expand All @@ -153,9 +156,11 @@ mod traits {
}

#[cfg(test)]
mod traits {}
mod traits {
#[legacy_exports];}

mod raw {
#[legacy_exports];
type VecRepr = vec::raw::VecRepr;
type SliceRepr = vec::raw::SliceRepr;

Expand Down
1 change: 1 addition & 0 deletions src/libcore/box.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use intrinsic::TyDesc;
export ptr_eq, raw;

mod raw {
#[legacy_exports];

struct BoxHeaderRepr {
ref_count: uint,
Expand Down
2 changes: 2 additions & 0 deletions src/libcore/cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export copy_lifetime, copy_lifetime_vec;

#[abi = "rust-intrinsic"]
extern mod rusti {
#[legacy_exports];
fn forget<T>(-x: T);
fn reinterpret_cast<T, U>(e: T) -> U;
}
Expand Down Expand Up @@ -97,6 +98,7 @@ unsafe fn copy_lifetime_vec<S,T>(_ptr: &a/[S], ptr: &T) -> &a/T {

#[cfg(test)]
mod tests {
#[legacy_exports];

#[test]
fn test_reinterpret_cast() {
Expand Down
1 change: 1 addition & 0 deletions src/libcore/cleanup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ pub unsafe fn annihilate() {

/// Bindings to the runtime
extern mod rustrt {
#[legacy_exports];
#[rust_stack]
/*priv*/ fn rust_get_task() -> *c_void;
}
Expand Down
8 changes: 8 additions & 0 deletions src/libcore/cmath.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use libc::c_double;
#[link_name = "m"]
#[abi = "cdecl"]
extern mod c_double {
#[legacy_exports];

// Alpabetically sorted by link_name

Expand Down Expand Up @@ -98,6 +99,7 @@ extern mod c_double {
#[link_name = "m"]
#[abi = "cdecl"]
extern mod c_float {
#[legacy_exports];

// Alpabetically sorted by link_name

Expand Down Expand Up @@ -166,6 +168,7 @@ extern mod c_float {
// FIXME obtain machine float/math constants automatically (Issue #1986)

mod c_float_targ_consts {
#[legacy_exports];
const radix: uint = 2u;
const mantissa_digits: uint = 24u;
const digits: uint = 6u;
Expand All @@ -181,6 +184,7 @@ mod c_float_targ_consts {
}

mod c_double_targ_consts {
#[legacy_exports];
const radix: uint = 2u;
const mantissa_digits: uint = 53u;
const digits: uint = 15u;
Expand All @@ -200,6 +204,7 @@ mod c_double_targ_consts {
FIXME use these once they can be parsed (see Issue #1433)
mod c_float_math_consts {
#[legacy_exports];
const pi: c_float = 0x1.921fb6p+1_f32;
const div_1_pi: c_float = 0x1.45f306p-2_f32;
const div_2_pi: c_float = 0x1.45f306p-1_f32;
Expand All @@ -216,6 +221,7 @@ mod c_float_math_consts {
}
mod c_double_math_consts {
#[legacy_exports];
const pi: c_double = 0x1.921fb54442d18p+1_f64;
const div_1_pi: c_double = 0x1.45f306dc9c883p-2_f64;
const div_2_pi: c_double = 0x1.45f306dc9c883p-1_f64;
Expand All @@ -232,6 +238,7 @@ mod c_double_math_consts {
}
mod c_float_targ_consts {
#[legacy_exports];
const radix: uint = 2u;
const mantissa_digits: uint = 24u;
const digits: uint = 6u;
Expand All @@ -245,6 +252,7 @@ mod c_float_targ_consts {
}
mod c_double_targ_consts {
#[legacy_exports];
const radix: uint = 2u;
const mantissa_digits: uint = 53u;
const digits: uint = 15u;
Expand Down
8 changes: 6 additions & 2 deletions src/libcore/cmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export Eq;
// Awful hack to work around duplicate lang items in core test.
#[cfg(notest)]
mod nounittest {
#[legacy_exports];
/**
* Trait for values that can be compared for a sort-order.
*
Expand Down Expand Up @@ -75,10 +76,12 @@ mod nounittest {
}

#[cfg(test)]
mod nounittest {}
mod nounittest {
#[legacy_exports];}

#[cfg(test)]
mod unittest {
#[legacy_exports];
#[cfg(stage0)]
trait Ord {
pure fn lt(&&other: self) -> bool;
Expand Down Expand Up @@ -111,7 +114,8 @@ mod unittest {
}

#[cfg(notest)]
mod unittest {}
mod unittest {
#[legacy_exports];}

#[cfg(stage0)]
pure fn lt<T: Ord>(v1: &T, v2: &T) -> bool {
Expand Down
2 changes: 2 additions & 0 deletions src/libcore/comm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ type port_id = int;

#[abi = "cdecl"]
extern mod rustrt {
#[legacy_exports];
fn rust_port_id_send(target_port: port_id, data: *()) -> libc::uintptr_t;

fn new_port(unit_sz: libc::size_t) -> *rust_port;
Expand All @@ -297,6 +298,7 @@ extern mod rustrt {

#[abi = "rust-intrinsic"]
extern mod rusti {
#[legacy_exports];
fn init<T>() -> T;
}

Expand Down
Loading

0 comments on commit dffe188

Please sign in to comment.