diff --git a/doc/rust.md b/doc/rust.md index 26ea276dd7c..d11153990d7 100644 --- a/doc/rust.md +++ b/doc/rust.md @@ -830,12 +830,12 @@ An example of re-exporting: ~~~~ # fn main() { } mod quux { + pub use quux::foo::*; + pub mod foo { pub fn bar() { } pub fn baz() { } } - - pub use quux::foo::*; } ~~~~ @@ -2008,8 +2008,8 @@ then the expression completes. Some examples of call expressions: ~~~~ -# fn add(x: int, y: int) -> int { 0 } # use core::from_str::FromStr::from_str; +# fn add(x: int, y: int) -> int { 0 } let x: int = add(1, 2); let pi = from_str::("3.14"); diff --git a/doc/tutorial.md b/doc/tutorial.md index 8c0f5f1ebdf..6932cf7e47f 100644 --- a/doc/tutorial.md +++ b/doc/tutorial.md @@ -2054,9 +2054,9 @@ name and a double colon. The compiler uses type inference to decide which implementation to use. ~~~~ -trait Shape { fn new(area: float) -> Self; } # use core::float::consts::pi; # use core::float::sqrt; +trait Shape { fn new(area: float) -> Self; } struct Circle { radius: float } struct Square { length: float } @@ -2211,11 +2211,11 @@ trait Circle : Shape { fn radius(&self) -> float; } Now, we can implement `Circle` on a type only if we also implement `Shape`. ~~~~ +# use core::float::consts::pi; +# use core::float::sqrt; # trait Shape { fn area(&self) -> float; } # trait Circle : Shape { fn radius(&self) -> float; } # struct Point { x: float, y: float } -# use core::float::consts::pi; -# use core::float::sqrt; # fn square(x: float) -> float { x * x } struct CircleStruct { center: Point, radius: float } impl Circle for CircleStruct { @@ -2247,10 +2247,10 @@ fn radius_times_area(c: T) -> float { Likewise, supertrait methods may also be called on trait objects. ~~~ {.xfail-test} -# trait Shape { fn area(&self) -> float; } -# trait Circle : Shape { fn radius(&self) -> float; } # use core::float::consts::pi; # use core::float::sqrt; +# trait Shape { fn area(&self) -> float; } +# trait Circle : Shape { fn radius(&self) -> float; } # struct Point { x: float, y: float } # struct CircleStruct { center: Point, radius: float } # impl Circle for CircleStruct { fn radius(&self) -> float { sqrt(self.area() / pi) } } diff --git a/src/test/auxiliary/pub_use_mods_xcrate.rs b/src/test/auxiliary/pub_use_mods_xcrate.rs index 162f7de4b1b..e085f2312dc 100644 --- a/src/test/auxiliary/pub_use_mods_xcrate.rs +++ b/src/test/auxiliary/pub_use_mods_xcrate.rs @@ -9,13 +9,13 @@ // except according to those terms. pub mod a { + pub use a::b::c; + pub mod b { pub mod c { fn f(){} fn g(){} } } - - pub use a::b::c; } diff --git a/src/test/bench/shootout-binarytrees.rs b/src/test/bench/shootout-binarytrees.rs index 59ee07b2cf8..8d0675d0884 100644 --- a/src/test/bench/shootout-binarytrees.rs +++ b/src/test/bench/shootout-binarytrees.rs @@ -12,7 +12,7 @@ extern mod std; use std::arena; use methods = std::arena::Arena; -enum tree { +enum tree<'self> { nil, node(&'self tree<'self>, &'self tree<'self>, int), } @@ -26,9 +26,10 @@ fn item_check(t: &tree) -> int { } } -fn bottom_up_tree(arena: &'r arena::Arena, - item: int, - depth: int) -> &'r tree<'r> { +fn bottom_up_tree<'r>(arena: &'r arena::Arena, + item: int, + depth: int) + -> &'r tree<'r> { if depth > 0 { return arena.alloc( || node(bottom_up_tree(arena, 2 * item - 1, depth - 1), diff --git a/src/test/compile-fail/issue-4366.rs b/src/test/compile-fail/issue-4366.rs index d4d97c69354..7d97932d9af 100644 --- a/src/test/compile-fail/issue-4366.rs +++ b/src/test/compile-fail/issue-4366.rs @@ -13,6 +13,8 @@ // ensures that 'use foo:*' doesn't import non-public 'use' statements in the // module 'foo' +use m1::*; + mod foo { pub fn foo() {} } @@ -31,7 +33,6 @@ mod a { mod m1 { fn foo() {} } -use m1::*; fn main() { foo(); //~ ERROR: unresolved name: `foo` diff --git a/src/test/compile-fail/regions-in-enums.rs b/src/test/compile-fail/regions-in-enums.rs index 0111be367c2..f189deef32e 100644 --- a/src/test/compile-fail/regions-in-enums.rs +++ b/src/test/compile-fail/regions-in-enums.rs @@ -10,7 +10,7 @@ enum yes0<'lt> { // This will eventually be legal (and in fact the only way): - X3(&'lt uint) //~ ERROR Illegal lifetime 'lt: this lifetime must be declared + X3(&'lt uint) //~ ERROR Illegal lifetime 'lt: only 'self is allowed } enum yes1<'self> { @@ -18,7 +18,7 @@ enum yes1<'self> { } enum yes2 { - X5(&'foo uint) //~ ERROR Illegal lifetime 'foo: this lifetime must be declared + X5(&'foo uint) //~ ERROR Illegal lifetime 'foo: only 'self is allowed } fn main() {} diff --git a/src/test/compile-fail/regions-in-type-items.rs b/src/test/compile-fail/regions-in-type-items.rs index 65bc64815b6..a30a6772bfd 100644 --- a/src/test/compile-fail/regions-in-type-items.rs +++ b/src/test/compile-fail/regions-in-type-items.rs @@ -17,7 +17,7 @@ struct item_ty_yes1<'self> { } struct item_ty_yes2 { - x: &'a uint //~ ERROR this lifetime must be declared + x: &'a uint //~ ERROR only 'self is allowed } fn main() {} diff --git a/src/test/run-pass/issue-2904.rs b/src/test/run-pass/issue-2904.rs index 8a7e2b8a9a9..84a4083a628 100644 --- a/src/test/run-pass/issue-2904.rs +++ b/src/test/run-pass/issue-2904.rs @@ -12,10 +12,10 @@ /// Map representation -use core::io::ReaderUtil; - extern mod std; +use core::io::ReaderUtil; + enum square { bot, wall, diff --git a/src/test/run-pass/trait-inheritance-num.rs b/src/test/run-pass/trait-inheritance-num.rs index 92cb25b8d2b..b800ffefeb6 100644 --- a/src/test/run-pass/trait-inheritance-num.rs +++ b/src/test/run-pass/trait-inheritance-num.rs @@ -10,10 +10,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +extern mod std; + use core::cmp::{Eq, Ord}; use core::num::NumCast::from; - -extern mod std; use std::cmp::FuzzyEq; pub trait NumExt: NumCast + Eq + Ord {} diff --git a/src/test/run-pass/trait-inheritance-num2.rs b/src/test/run-pass/trait-inheritance-num2.rs index 8f8b83c3d76..66d7ee96bb2 100644 --- a/src/test/run-pass/trait-inheritance-num2.rs +++ b/src/test/run-pass/trait-inheritance-num2.rs @@ -12,10 +12,10 @@ // A more complex example of numeric extensions +extern mod std; + use core::cmp::{Eq, Ord}; use core::num::NumCast::from; - -extern mod std; use std::cmp::FuzzyEq; pub trait TypeExt {}