mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 14:55:26 +00:00
test: Fix tests
This commit is contained in:
parent
f41a510631
commit
b07b36bbf3
@ -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::<f32>("3.14");
|
||||
|
@ -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<T: Circle>(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) } }
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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),
|
||||
|
@ -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`
|
||||
|
@ -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() {}
|
||||
|
@ -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() {}
|
||||
|
@ -12,10 +12,10 @@
|
||||
|
||||
/// Map representation
|
||||
|
||||
use core::io::ReaderUtil;
|
||||
|
||||
extern mod std;
|
||||
|
||||
use core::io::ReaderUtil;
|
||||
|
||||
enum square {
|
||||
bot,
|
||||
wall,
|
||||
|
@ -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 {}
|
||||
|
@ -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 {}
|
||||
|
Loading…
Reference in New Issue
Block a user