diff --git a/AUTHORS.txt b/AUTHORS.txt index 9117d5b3a01b1..54f41c64cfef7 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -16,6 +16,7 @@ Arkaitz Jimenez Armin Ronacher Austin Seipp auREAX +Ben Alpert Ben Blum Ben Striegel Benjamin Herr @@ -49,6 +50,7 @@ Erick Tryzelaar Erik Rose Evan McClanahan Francisco Souza +Franklin Chen Gabriel Gareth Daniel Smith Glenn Willen @@ -119,6 +121,7 @@ Sean Stangl Simon Barber-Dueck startling Stefan Plantikow +Steve Klabnik Taras Shpot Ted Horst Tim Chevalier diff --git a/README.md b/README.md index 9f4ee0a44ff96..877e2b5698722 100644 --- a/README.md +++ b/README.md @@ -65,10 +65,11 @@ API-documentation tool, and `cargo`, the Rust package manager. ## License -Rust is primarily distributed under the terms of the MIT license, with -portions covered by various BSD-like licenses. +Rust is primarily distributed under the terms of both the MIT license +and the Apache License (Version 2.0), with portions covered by various +BSD-like licenses. -See LICENSE.txt for details. +See LICENSE-APACHE, LICENSE-MIT, and COPYRIGHT for details. ## More help diff --git a/doc/rust.md b/doc/rust.md index bed231de2942f..b5f045bc13a55 100644 --- a/doc/rust.md +++ b/doc/rust.md @@ -3258,12 +3258,12 @@ crate name the crate is given a default name that matches the source file, with the extension removed. In that case, to turn on logging for a program compiled from, e.g. `helloworld.rs`, `RUST_LOG` should be set to `helloworld`. -As a convenience, the logging spec can also be set to a special psuedo-crate, +As a convenience, the logging spec can also be set to a special pseudo-crate, `::help`. In this case, when the application starts, the runtime will simply output a list of loaded modules containing log expressions, then exit. The Rust runtime itself generates logging information. The runtime's logs are -generated for a number of artificial modules in the `::rt` psuedo-crate, +generated for a number of artificial modules in the `::rt` pseudo-crate, and can be enabled just like the logs for any standard module. The full list of runtime logging modules follows. @@ -3341,7 +3341,7 @@ have come and gone during the course of Rust's development: * The Newsqueak (1988), Alef (1995), and Limbo (1996) family. These languages were developed by Rob Pike, Phil Winterbottom, Sean Dorward and - others in their group at Bell labs Computing Sciences Research Center + others in their group at Bell Labs Computing Sciences Research Center (Murray Hill, NJ, USA). * The Napier (1985) and Napier88 (1988) family. These languages were diff --git a/doc/tutorial-macros.md b/doc/tutorial-macros.md index 1def470755c31..af1f9ceb92450 100644 --- a/doc/tutorial-macros.md +++ b/doc/tutorial-macros.md @@ -43,7 +43,7 @@ macro_rules! early_return( _ => {} } ); -); +) // ... early_return!(input_1 special_a); // ... @@ -160,7 +160,7 @@ macro_rules! early_return( _ => {} } ); -); +) // ... early_return!(input_1, [special_a|special_c|special_d]); // ... diff --git a/doc/tutorial.md b/doc/tutorial.md index b746072a53d4e..acd99447a4d71 100644 --- a/doc/tutorial.md +++ b/doc/tutorial.md @@ -36,7 +36,7 @@ type system and memory model, generics, and modules. [Additional tutorials](#what-next) cover specific language features in greater depth. -This tutorial assumes that the reader is already familiar with one or more +This tutorial assumes that the reader is already familiar with one or more languages in the C family. Understanding of pointers and general memory management techniques will help. @@ -80,7 +80,7 @@ supported build environments that are most likely to work. > "[getting started][wiki-start]" notes on the wiki. Even when using > the binary installer, the Windows build requires a MinGW installation, > the precise details of which are not discussed here. Finally, `rustc` may -> need to be [referred to as `rustc.exe`][bug-3319]. It's a bummer, I +> need to be [referred to as `rustc.exe`][bug-3319]. It's a bummer, we > know. [bug-3319]: https://github.com/mozilla/rust/issues/3319 @@ -114,7 +114,7 @@ for more information on them. When complete, `make install` will place several programs into `/usr/local/bin`: `rustc`, the Rust compiler; `rustdoc`, the -API-documentation tool, `cargo`, the Rust package manager, +API-documentation tool; `cargo`, the Rust package manager; and `rusti`, the Rust REPL. [wiki-start]: https://github.com/mozilla/rust/wiki/Note-getting-started-developing-Rust @@ -181,10 +181,10 @@ in blocks delineated by curly braces; there are control structures for branching and looping, like the familiar `if` and `while`; function calls are written `myfunc(arg1, arg2)`; operators are written the same and mostly have the same precedence as in C; comments are again like C; -module names are separated with double-colon, `::`, as with C++. +module names are separated with double-colon (`::`) as with C++. The main surface difference to be aware of is that the condition at -the head of control structures like `if` and `while` do not require +the head of control structures like `if` and `while` does not require parentheses, while their bodies *must* be wrapped in braces. Single-statement, unbraced bodies are not allowed. @@ -226,12 +226,12 @@ let monster_size: int = 50; ~~~~ Local variables may shadow earlier declarations, as in the previous example: -`monster_size` was first declared as a `float`, and then then a second -`monster_size` was declared as an int. If you were to actually compile this -example, though, the compiler will determine that the second `monster_size` is +`monster_size` was first declared as a `float`, and then a second +`monster_size` was declared as an `int`. If you were to actually compile this +example, though, the compiler would determine that the second `monster_size` is unused and issue a warning (because this situation is likely to indicate a programmer error). For occasions where unused variables are intentional, their -name may be prefixed with an underscore to silence the warning, like `let +names may be prefixed with an underscore to silence the warning, like `let _monster_size = 50;`. Rust identifiers start with an alphabetic @@ -292,7 +292,7 @@ branch has a different value, and `price` gets the value of the branch that was taken. In short, everything that's not a declaration (declarations are `let` for -variables, `fn` for functions, and any top-level named items such as +variables; `fn` for functions; and any top-level named items such as [traits](#traits), [enum types](#enums), and [constants](#constants)) is an expression, including function bodies. @@ -306,8 +306,8 @@ fn is_four(x: int) -> bool { ## Primitive types and literals -There are general signed and unsigned integer types, `int`, and `uint`, -as well as 8-, 16-, 32-, and 64-bit variations, `i8`, `u16`, etc. +There are general signed and unsigned integer types, `int` and `uint`, +as well as 8-, 16-, 32-, and 64-bit variants, `i8`, `u16`, etc. Integers can be written in decimal (`144`), hexadecimal (`0x90`), or binary (`0b10010000`) base. Each integral type has a corresponding literal suffix that can be used to indicate the type of a literal: `i` for `int`, @@ -326,14 +326,14 @@ let c = 100u; // c is a uint let d = 1000i32; // d is an i32 ~~~~ -There are three floating point types, `float`, `f32`, and `f64`. -Floating point numbers are written `0.0`, `1e6`, or `2.1e-4`. -Like integers, floating point literals are inferred to the correct type. -Suffixes `f`, `f32` and `f64` can be used to create literals of a specific type. +There are three floating-point types: `float`, `f32`, and `f64`. +Floating-point numbers are written `0.0`, `1e6`, or `2.1e-4`. +Like integers, floating-point literals are inferred to the correct type. +Suffixes `f`, `f32`, and `f64` can be used to create literals of a specific type. The keywords `true` and `false` produce literals of type `bool`. -Characters, the `char` type, are 4-byte unicode codepoints, +Characters, the `char` type, are four-byte Unicode codepoints, whose literals are written between single quotes, as in `'x'`. Just like C, Rust understands a number of character escapes, using the backslash character, such as `\n`, `\r`, and `\t`. String literals, @@ -345,8 +345,8 @@ The nil type, written `()`, has a single value, also written `()`. ## Operators Rust's set of operators contains very few surprises. Arithmetic is done with -`*`, `/`, `%`, `+`, and `-` (multiply, divide, take remainder, add, subtract). `-` is -also a unary prefix operator that negates numbers. As in C, the bit operators +`*`, `/`, `%`, `+`, and `-` (multiply, divide, take remainder, add, and subtract). `-` is +also a unary prefix operator that negates numbers. As in C, the bitwise operators `>>`, `<<`, `&`, `|`, and `^` are also supported. Note that, if applied to an integer value, `!` flips all the bits (like `~` in @@ -444,7 +444,7 @@ match my_number { } ~~~~ -Unlike in C, there is no 'falling through' between arms: only one arm +Unlike in C, there is no "falling through" between arms: only one arm executes, and it doesn't have to explicitly `break` out of the construct when it is finished. @@ -494,7 +494,7 @@ fn angle(vector: (float, float)) -> float { A variable name in a pattern matches any value, *and* binds that name to the value of the matched value inside of the arm's action. Thus, `(0f, y)` matches any tuple whose first element is zero, and binds `y` to -the second element. `(x, y)` matches any tuple, and binds both +the second element. `(x, y)` matches any two-element tuple, and binds both elements to variables. Any `match` arm can have a guard clause (written `if EXPR`), called a @@ -575,7 +575,7 @@ With a value of such a type, you can do `mystack.head += 1`. If `mut` were omitted from the type, such an assignment would result in a type error. `match` patterns destructure structs. The basic syntax is -`Name {fieldname: pattern, ...}`: +`Name { fieldname: pattern, ... }`: ~~~~ # struct Point { x: float, y: float } @@ -589,7 +589,7 @@ match mypoint { In general, the field names of a struct do not have to appear in the same order they appear in the type. When you are not interested in all the fields of a struct, a struct pattern may end with `, _` (as in -`Name {field1, _}`) to indicate that you're ignoring all other fields. +`Name { field1, _ }`) to indicate that you're ignoring all other fields. Additionally, struct fields have a shorthand matching form that simply reuses the field name as the binding name. @@ -618,15 +618,15 @@ A value of this type is either a `Circle`, in which case it contains a `Point` struct and a float, or a `Rectangle`, in which case it contains two `Point` structs. The run-time representation of such a value includes an identifier of the actual form that it holds, much like the -'tagged union' pattern in C, but with better static guarantees. +"tagged union" pattern in C, but with better static guarantees. The above declaration will define a type `Shape` that can refer to such shapes, and two functions, `Circle` and `Rectangle`, which can be used to construct values of the type (taking arguments of the -specified types). So `Circle(Point {x: 0f, y: 0f}, 10f)` is the way to +specified types). So `Circle(Point { x: 0f, y: 0f }, 10f)` is the way to create a new circle. -Enum variants need not have type parameters. This `enum` declaration, +Enum variants need not have parameters. This `enum` declaration, for example, is equivalent to a C enum: ~~~~ @@ -659,7 +659,7 @@ variant does not have a discriminator, it defaults to 0. For example, the value of `North` is 0, `East` is 1, `South` is 2, and `West` is 3. When an enum is C-like, you can apply the `as` cast operator to -convert it to its discriminator value as an int. +convert it to its discriminator value as an `int`. @@ -710,7 +710,7 @@ patterns, as in this definition of `area`: fn area(sh: Shape) -> float { match sh { Circle(_, size) => float::consts::pi * size * size, - Rectangle(Point {x, y}, Point {x: x2, y: y2}) => (x2 - x) * (y2 - y) + Rectangle(Point { x, y }, Point { x: x2, y: y2 }) => (x2 - x) * (y2 - y) } } ~~~~ @@ -721,36 +721,38 @@ introduction form, nullary enum patterns are written without parentheses. ~~~~ -# struct Point {x: float, y: float} +# struct Point { x: float, y: float } # enum Direction { North, East, South, West } fn point_from_direction(dir: Direction) -> Point { match dir { - North => Point {x: 0f, y: 1f}, - East => Point {x: 1f, y: 0f}, - South => Point {x: 0f, y: -1f}, - West => Point {x: -1f, y: 0f} + North => Point { x: 0f, y: 1f }, + East => Point { x: 1f, y: 0f }, + South => Point { x: 0f, y: -1f }, + West => Point { x: -1f, y: 0f } } } ~~~~ -A special kind of enum variant, called _struct-like enums_, -can have its fields extracted with dot notation and not just destructuring. -For example: +Enum variants may also be structs. For example: ~~~~ -# struct Point {x: float, y: float} +# use core::float; +# struct Point { x: float, y: float } # fn square(x: float) -> float { x * x } enum Shape { Circle { center: Point, radius: float }, - Rectangle { left: Point, right: Point } + Rectangle { top_left: Point, bottom_right: Point } } fn area(sh: Shape) -> float { - match sh { - Circle(c) => float::consts::pi * square(c.radius), - Rectangle(r) => r.right.x - r.left.x * r.right.y - r.right.y - } + match sh { + Circle { radius: radius, _ } => float::consts::pi * square(radius), + Rectangle { top_left: top_left, bottom_right: bottom_right } => { + (bottom_right.x - top_left.x) * (bottom_right.y - top_left.y) + } + } } ~~~~ + ## Tuples Tuples in Rust behave exactly like structs, except that their fields @@ -799,7 +801,7 @@ fn line(a: int, b: int, x: int) -> int { The `return` keyword immediately returns from the body of a function. It is optionally followed by an expression to return. A function can -also return a value by having its top level block produce an +also return a value by having its top-level block produce an expression. ~~~~ @@ -833,7 +835,7 @@ assert () == oops(5, 3, 1); As with `match` expressions and `let` bindings, function arguments support pattern destructuring. Like `let`, argument patterns must be irrefutable, -as in this example that unpacks a tuple and returns it. +as in this example that unpacks the first value from a tuple and returns it. ~~~ fn first((value, _): (int, float)) -> int { value } @@ -916,7 +918,7 @@ aggregate types like structs and enums, so as to represent these types as pointers to heap memory by default. In contrast, Rust, like C and C++, represents such types directly. Another way to say this is that aggregate data in Rust are *unboxed*. This means that if you `let x = -Point {x: 1f, y: 1f};`, you are creating a struct on the stack. If you +Point { x: 1f, y: 1f };`, you are creating a struct on the stack. If you then copy it into a data structure, you copy the entire struct, not just a pointer. @@ -926,7 +928,7 @@ those with mutable fields, it can be useful to have a single copy on the stack or on the heap, and refer to that through a pointer. Rust supports several types of pointers. The safe pointer types are -`@T` for managed boxes allocated on the local heap, `~T`, for +`@T`, for managed boxes allocated on the local heap, `~T`, for uniquely-owned boxes allocated on the exchange heap, and `&T`, for borrowed pointers, which may point to any memory, and whose lifetimes are governed by the call stack. @@ -940,8 +942,8 @@ All pointer types can be dereferenced with the `*` unary operator. ## Managed boxes -Managed boxes are pointers to heap-allocated, garbage collected -memory. Applying the unary `@` operator to an expression creates a +Managed boxes are pointers to heap-allocated, garbage-collected +memory. Applying the unary `@` operator to an expression creates a managed box. The resulting box contains the result of the expression. Copying a managed box, as happens during assignment, only copies a pointer, never the contents of the box. @@ -1036,7 +1038,8 @@ As an example, consider a simple struct type, `Point`: ~~~ struct Point { - x: float, y: float + x: float, + y: float } ~~~~ @@ -1046,9 +1049,9 @@ contains a point, but allocated in a different location: ~~~ # struct Point { x: float, y: float } -let on_the_stack : Point = Point {x: 3.0, y: 4.0}; -let managed_box : @Point = @Point {x: 5.0, y: 1.0}; -let owned_box : ~Point = ~Point {x: 7.0, y: 9.0}; +let on_the_stack : Point = Point { x: 3.0, y: 4.0 }; +let managed_box : @Point = @Point { x: 5.0, y: 1.0 }; +let owned_box : ~Point = ~Point { x: 7.0, y: 9.0 }; ~~~ Suppose we wanted to write a procedure that computed the distance @@ -1077,9 +1080,9 @@ Now we can call `compute_distance()` in various ways: ~~~ # struct Point{ x: float, y: float }; -# let on_the_stack : Point = Point {x: 3.0, y: 4.0}; -# let managed_box : @Point = @Point {x: 5.0, y: 1.0}; -# let owned_box : ~Point = ~Point {x: 7.0, y: 9.0}; +# let on_the_stack : Point = Point { x: 3.0, y: 4.0 }; +# let managed_box : @Point = @Point { x: 5.0, y: 1.0 }; +# let owned_box : ~Point = ~Point { x: 7.0, y: 9.0 }; # fn compute_distance(p1: &Point, p2: &Point) -> float { 0f } compute_distance(&on_the_stack, managed_box); compute_distance(managed_box, owned_box); @@ -1089,14 +1092,14 @@ Here the `&` operator is used to take the address of the variable `on_the_stack`; this is because `on_the_stack` has the type `Point` (that is, a struct value) and we have to take its address to get a value. We also call this _borrowing_ the local variable -`on_the_stack`, because we are created an alias: that is, another +`on_the_stack`, because we are creating an alias: that is, another route to the same data. In the case of the boxes `managed_box` and `owned_box`, however, no explicit action is necessary. The compiler will automatically convert a box like `@point` or `~point` to a borrowed pointer like `&point`. This is another form of borrowing; in this case, the -contents of the managed/owned box is being lent out. +contents of the managed/owned box are being lent out. Whenever a value is borrowed, there are some limitations on what you can do with the original. For example, if the contents of a variable @@ -1156,7 +1159,7 @@ let area = (*rect).area(); ~~~ To combat this ugliness the dot operator applies _automatic pointer -dereferencing_ to the receiver (the value on the left hand side of the +dereferencing_ to the receiver (the value on the left-hand side of the dot), so in most cases, explicitly dereferencing the receiver is not necessary. ~~~ @@ -1198,7 +1201,7 @@ pointers to vectors are also called 'slices'. // A fixed-size stack vector let stack_crayons: [Crayon * 3] = [Almond, AntiqueBrass, Apricot]; -// A borrowed pointer to stack allocated vector +// A borrowed pointer to stack-allocated vector let stack_crayons: &[Crayon] = &[Aquamarine, Asparagus, AtomicTangerine]; // A local heap (managed) vector of crayons @@ -1281,7 +1284,7 @@ distinct type. They support most of the same allocation options as vectors, though the string literal without a storage sigil (for example, `"foo"`) is treated differently than a comparable vector (`[foo]`). Whereas plain vectors are stack-allocated fixed-length -vectors, plain strings are region pointers to read-only +vectors, plain strings are borrowed pointers to read-only (static) memory. All strings are immutable. ~~~ @@ -1525,7 +1528,7 @@ do spawn() || { } ~~~~ -Look at all those bars and parentheses - that's two empty argument +Look at all those bars and parentheses -- that's two empty argument lists back to back. Since that is so unsightly, empty argument lists may be omitted from `do` expressions. @@ -1604,7 +1607,7 @@ fn contains(v: &[int], elt: int) -> bool { ~~~~ Notice that, because `each` passes each value by borrowed pointer, -the iteratee needs to dereference it before using. +the iteratee needs to dereference it before using it. In these situations it can be convenient to lean on Rust's argument patterns to bind `x` to the actual value, not the pointer. @@ -1726,7 +1729,7 @@ s.draw_borrowed(); // ... and dereferenced (& &s).draw_borrowed(); -// ... and dereferenced, and borrowed, and +// ... and dereferenced and borrowed (&@~s).draw_borrowed(); ~~~ @@ -1789,9 +1792,9 @@ Inside a generic function, the names of the type parameters (capitalized by convention) stand for opaque types. All you can do with instances of these types is pass them around: you can't apply any operations to them or pattern-match on them. Note that instances of -generic types are often passed by pointer. For example, the parameter +generic types are often passed by pointer. For example, the parameter `function()` is supplied with a pointer to a value of type `T` and not -a value of type `T` itself. This ensures that the function works with +a value of type `T` itself. This ensures that the function works with the broadest set of types possible, since some types are expensive or illegal to copy and pass by value. @@ -1812,7 +1815,7 @@ enum Option { ~~~~ These declarations can be instantiated to valid types like `Set`, -`Stack` and `Option`. +`Stack`, and `Option`. The last type in that example, `Option`, appears frequently in Rust code. Because Rust does not have null pointers (except in unsafe code), we need @@ -1821,13 +1824,13 @@ combination of arguments of the appropriate types. The usual way is to write a function that returns `Option` instead of `T`. ~~~~ -# struct Point {x: float, y: float} +# struct Point { x: float, y: float } # enum Shape { Circle(Point, float), Rectangle(Point, Point) } fn radius(shape: Shape) -> Option { - match shape { - Circle(_, radius) => Some(radius), - Rectangle(*) => None - } + match shape { + Circle(_, radius) => Some(radius), + Rectangle(*) => None + } } ~~~~ @@ -1891,12 +1894,12 @@ While most traits can be defined and implemented by user code, three traits are automatically derived and implemented for all applicable types by the compiler, and may not be overridden: -* `Copy` - Types that can be copied: either implicitly, or explicitly with the +* `Copy` - Types that can be copied, either implicitly, or explicitly with the `copy` operator. All types are copyable unless they have destructors or contain types with destructors. * `Owned` - Owned types. Types are owned unless they contain managed - boxes, managed closures, or borrowed pointers. Owned types may or + boxes, managed closures, or borrowed pointers. Owned types may or may not be copyable. * `Const` - Constant (immutable) types. These are types that do not contain @@ -1913,7 +1916,7 @@ garbage collector reclaimed it. ~~~ struct TimeBomb { - explosivity: uint, + explosivity: uint } impl TimeBomb : Drop { @@ -1944,7 +1947,7 @@ trait Printable { Traits may be implemented for specific types with [impls]. An impl that implements a trait includes the name of the trait at the start of the definition, as in the following impls of `Printable` for `int` -and `~str`. +and `&str`. [impls]: #functions-and-methods @@ -2003,12 +2006,12 @@ following trait describes types that support an equality operation: // In a trait, `self` refers both to the self argument // and to the type implementing the trait trait Eq { - fn equals(&self, other: &self) -> bool; + fn equals(&self, other: &self) -> bool; } // In an impl, `self` refers just to the value of the receiver impl int: Eq { - fn equals(&self, other: &int) -> bool { *other == *self } + fn equals(&self, other: &int) -> bool { *other == *self } } ~~~~ @@ -2032,7 +2035,7 @@ impl Circle: Shape { static fn new(area: float) -> Circle { Circle { radius: sqrt(area / pi) } } } impl Square: Shape { - static fn new(area: float) -> Square { Square { length: sqrt(area) } } + static fn new(area: float) -> Square { Square { length: sqrt(area) } } } let area = 42.5; @@ -2102,9 +2105,9 @@ fn draw_all(shapes: ~[T]) { # draw_all(~[c]); ~~~~ -You can call that on an array of circles, or an array of squares +You can call that on an array of circles, or an array of rectangles (assuming those have suitable `Drawable` traits defined), but not on -an array containing both circles and squares. When such behavior is +an array containing both circles and rectangles. When such behavior is needed, a trait name can alternately be used as a type, called an _object_. @@ -2188,10 +2191,10 @@ Now, we can implement `Circle` on a type only if we also implement `Shape`. # fn square(x: float) -> float { x * x } struct CircleStruct { center: Point, radius: float } impl CircleStruct: Circle { - fn radius(&self) -> float { sqrt(self.area() / pi) } + fn radius(&self) -> float { sqrt(self.area() / pi) } } impl CircleStruct: Shape { - fn area(&self) -> float { pi * square(self.radius) } + fn area(&self) -> float { pi * square(self.radius) } } ~~~~ @@ -2265,7 +2268,7 @@ fn chicken_farmer() { ~~~ These farm animal functions have a new keyword, `pub`, attached to -them. The `pub` keyword modifies an item's visibility, making it +them. The `pub` keyword modifies an item's visibility, making it visible outside its containing module. An expression with `::`, like `farm::chicken`, can name an item outside of its containing module. Items, such as those declared with `fn`, `struct`, `enum`, @@ -2275,11 +2278,12 @@ Visibility restrictions in Rust exist only at module boundaries. This is quite different from most object-oriented languages that also enforce restrictions on objects themselves. That's not to say that Rust doesn't support encapsulation: both struct fields and methods can -be private. But this encapsulation is at the module level, not the +be private. But this encapsulation is at the module level, not the struct level. Note that fields and methods are _public_ by default. ~~~ mod farm { +# use farm; # pub fn make_me_a_farm() -> farm::Farm { farm::Farm { chickens: ~[], cows: ~[], farmer: Human(0) } } pub struct Farm { priv mut chickens: ~[Chicken], @@ -2318,7 +2322,7 @@ fn main() { The unit of independent compilation in Rust is the crate: rustc compiles a single crate at a time, from which it produces either a -library or executable. +library or an executable. When compiling a single `.rs` source file, the file acts as the whole crate. You can compile it with the `--lib` compiler switch to create a shared @@ -2366,7 +2370,7 @@ Compiling this file will cause `rustc` to look for files named `cow.rs`, `chicken.rs`, and `horse.rs` in the same directory as the `.rc` file, compile them all together, and, based on the presence of the `crate_type = "lib"` attribute, output a shared library or an -executable. (If the line `#[crate_type = "lib"];` was omitted, +executable. (If the line `#[crate_type = "lib"];` was omitted, `rustc` would create an executable.) The `#[link(...)]` attribute provides meta information about the diff --git a/src/compiletest/common.rs b/src/compiletest/common.rs index 20b7e32d0c995..136f40c9c207a 100644 --- a/src/compiletest/common.rs +++ b/src/compiletest/common.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use cmp; + enum mode { mode_compile_fail, mode_run_fail, mode_run_pass, mode_pretty, } impl mode : cmp::Eq { diff --git a/src/compiletest/errors.rs b/src/compiletest/errors.rs index 632619f138103..62961f6c6e4eb 100644 --- a/src/compiletest/errors.rs +++ b/src/compiletest/errors.rs @@ -9,7 +9,9 @@ // except according to those terms. use common::config; +use io; use io::ReaderUtil; +use str; export load_errors; export expected_error; @@ -33,8 +35,8 @@ fn parse_expected(line_num: uint, line: ~str) -> ~[expected_error] unsafe { let error_tag = ~"//~"; let mut idx; match str::find_str(line, error_tag) { - option::None => return ~[], - option::Some(nn) => { idx = (nn as uint) + str::len(error_tag); } + None => return ~[], + Some(nn) => { idx = (nn as uint) + str::len(error_tag); } } // "//~^^^ kind msg" denotes a message expected diff --git a/src/compiletest/header.rs b/src/compiletest/header.rs index 24645e02b2008..730e863d04d4e 100644 --- a/src/compiletest/header.rs +++ b/src/compiletest/header.rs @@ -8,8 +8,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use common; use common::config; +use io; use io::ReaderUtil; +use os; +use str; export test_props; export load_props; @@ -34,12 +38,12 @@ fn load_props(testfile: &Path) -> test_props { let mut error_patterns = ~[]; let mut aux_builds = ~[]; let mut exec_env = ~[]; - let mut compile_flags = option::None; - let mut pp_exact = option::None; + let mut compile_flags = None; + let mut pp_exact = None; for iter_header(testfile) |ln| { match parse_error_pattern(ln) { - option::Some(ep) => error_patterns.push(ep), - option::None => () + Some(ep) => error_patterns.push(ep), + None => () }; if compile_flags.is_none() { @@ -78,7 +82,7 @@ fn is_test_ignored(config: config, testfile: &Path) -> bool { return found; fn xfail_target() -> ~str { - ~"xfail-" + os::sysname() + ~"xfail-" + str::from_slice(os::SYSNAME) } } @@ -124,12 +128,12 @@ fn parse_exec_env(line: ~str) -> Option<(~str, ~str)> { fn parse_pp_exact(line: ~str, testfile: &Path) -> Option { match parse_name_value_directive(line, ~"pp-exact") { - option::Some(s) => option::Some(Path(s)), - option::None => { + Some(s) => Some(Path(s)), + None => { if parse_name_directive(line, ~"pp-exact") { - option::Some(testfile.file_path()) + Some(testfile.file_path()) } else { - option::None + None } } } @@ -143,12 +147,12 @@ fn parse_name_value_directive(line: ~str, directive: ~str) -> Option<~str> unsafe { let keycolon = directive + ~":"; match str::find_str(line, keycolon) { - option::Some(colon) => { + Some(colon) => { let value = str::slice(line, colon + str::len(keycolon), str::len(line)); debug!("%s: %s", directive, value); - option::Some(value) + Some(value) } - option::None => option::None + None => None } } diff --git a/src/compiletest/procsrv.rs b/src/compiletest/procsrv.rs index 23f9e819bc4de..666deeca191fd 100644 --- a/src/compiletest/procsrv.rs +++ b/src/compiletest/procsrv.rs @@ -8,9 +8,16 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use run::spawn_process; +use io; use io::{ReaderUtil, WriterUtil}; +use libc; use libc::{c_int, pid_t}; +use os; +use run; +use run::spawn_process; +use pipes; +use str; +use task; export run; diff --git a/src/compiletest/runtest.rs b/src/compiletest/runtest.rs index 959bc344f1d50..a7dbfb9a3b279 100644 --- a/src/compiletest/runtest.rs +++ b/src/compiletest/runtest.rs @@ -8,15 +8,25 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use io; use io::WriterUtil; +use os; +use str; +use uint; +use vec; +use common; use common::mode_run_pass; use common::mode_run_fail; use common::mode_compile_fail; use common::mode_pretty; use common::config; +use errors; +use header; use header::load_props; use header::test_props; +use procsrv; +use util; use util::logv; export run; @@ -117,7 +127,7 @@ fn run_pretty_test(config: config, props: test_props, testfile: &Path) { } else { logv(config, ~"testing for converging pretty-printing"); } let rounds = - match props.pp_exact { option::Some(_) => 1, option::None => 2 }; + match props.pp_exact { Some(_) => 1, None => 2 }; let mut srcs = ~[io::read_whole_file_str(testfile).get()]; @@ -137,11 +147,11 @@ fn run_pretty_test(config: config, props: test_props, testfile: &Path) { let mut expected = match props.pp_exact { - option::Some(file) => { + Some(file) => { let filepath = testfile.dir_path().push_rel(&file); io::read_whole_file_str(&filepath).get() } - option::None => { srcs[vec::len(srcs) - 2u] } + None => { srcs[vec::len(srcs) - 2u] } }; let mut actual = srcs[vec::len(srcs) - 1u]; @@ -165,7 +175,7 @@ fn run_pretty_test(config: config, props: test_props, testfile: &Path) { fn print_source(config: config, testfile: &Path, src: ~str) -> procres { compose_and_run(config, testfile, make_pp_args(config, testfile), - ~[], config.compile_lib_path, option::Some(src)) + ~[], config.compile_lib_path, Some(src)) } fn make_pp_args(config: config, _testfile: &Path) -> procargs { @@ -199,7 +209,7 @@ actual:\n\ compose_and_run_compiler( config, props, testfile, make_typecheck_args(config, testfile), - option::Some(src)) + Some(src)) } fn make_typecheck_args(config: config, testfile: &Path) -> procargs { @@ -418,7 +428,7 @@ fn exec_compiled_test(config: config, props: test_props, compose_and_run(config, testfile, make_run_args(config, props, testfile), props.exec_env, - config.run_lib_path, option::None) + config.run_lib_path, None) } fn compose_and_run_compiler( @@ -441,7 +451,7 @@ fn compose_and_run_compiler( make_compile_args(config, props, ~[~"--lib"] + extra_link_args, |a,b| make_lib_name(a, b, testfile), &abs_ab); let auxres = compose_and_run(config, &abs_ab, aux_args, ~[], - config.compile_lib_path, option::None); + config.compile_lib_path, None); if auxres.status != 0 { fatal_procres( fmt!("auxiliary build of %s failed to compile: ", @@ -491,7 +501,8 @@ fn make_lib_name(config: config, auxfile: &Path, testfile: &Path) -> Path { } fn make_exe_name(config: config, testfile: &Path) -> Path { - Path(output_base_name(config, testfile).to_str() + os::exe_suffix()) + Path(output_base_name(config, testfile).to_str() + + str::from_slice(os::EXE_SUFFIX)) } fn make_run_args(config: config, _props: test_props, testfile: &Path) -> @@ -501,8 +512,8 @@ fn make_run_args(config: config, _props: test_props, testfile: &Path) -> // then split apart its command let runtool = match config.runtool { - option::Some(s) => option::Some(s), - option::None => option::None + Some(s) => Some(s), + None => None }; split_maybe_args(runtool) }; @@ -517,8 +528,8 @@ fn split_maybe_args(argstr: Option<~str>) -> ~[~str] { } match argstr { - option::Some(s) => rm_whitespace(str::split_char(s, ' ')), - option::None => ~[] + Some(s) => rm_whitespace(str::split_char(s, ' ')), + None => ~[] } } diff --git a/src/compiletest/util.rs b/src/compiletest/util.rs index 569d89fd3fe52..fe3bf4672c727 100644 --- a/src/compiletest/util.rs +++ b/src/compiletest/util.rs @@ -8,8 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use io; +use os; use os::getenv; +use common; use common::config; fn make_new_path(path: ~str) -> ~str { @@ -17,10 +20,10 @@ fn make_new_path(path: ~str) -> ~str { // Windows just uses PATH as the library search path, so we have to // maintain the current value while adding our own match getenv(lib_path_env_var()) { - option::Some(curr) => { + Some(curr) => { fmt!("%s%s%s", path, path_div(), curr) } - option::None => path + None => path } } diff --git a/src/libcargo/cargo.rc b/src/libcargo/cargo.rc index d4e68746fd4c4..8d81f75e0da79 100644 --- a/src/libcargo/cargo.rc +++ b/src/libcargo/cargo.rc @@ -805,7 +805,7 @@ fn install_one_crate(c: &Cargo, path: &Path, cf: &Path) { Some(bp) => bp }; let newv = os::list_dir_path(&buildpath); - let exec_suffix = os::exe_suffix(); + let exec_suffix = str::from_slice(os::EXE_SUFFIX); for newv.each |ct| { if (exec_suffix != ~"" && str::ends_with(ct.to_str(), exec_suffix)) || diff --git a/src/libcore/os.rs b/src/libcore/os.rs index 3b340d6de791d..5a009cc0a299b 100644 --- a/src/libcore/os.rs +++ b/src/libcore/os.rs @@ -378,13 +378,8 @@ fn dup2(src: c_int, dst: c_int) -> c_int { pub fn dll_filename(base: &str) -> ~str { - return pre() + str::from_slice(base) + dll_suffix(); - - #[cfg(unix)] - fn pre() -> ~str { ~"lib" } - - #[cfg(windows)] - fn pre() -> ~str { ~"" } + return str::from_slice(DLL_PREFIX) + str::from_slice(base) + + str::from_slice(DLL_SUFFIX); } @@ -874,48 +869,89 @@ extern { pub fn _NSGetArgv() -> ***c_char; } -#[cfg(unix)] -pub fn family() -> ~str { ~"unix" } - -#[cfg(windows)] -pub fn family() -> ~str { ~"windows" } -#[cfg(target_os = "macos")] mod consts { - pub fn sysname() -> ~str { ~"macos" } - pub fn exe_suffix() -> ~str { ~"" } - pub fn dll_suffix() -> ~str { ~".dylib" } -} -#[cfg(target_os = "freebsd")] -mod consts { - pub fn sysname() -> ~str { ~"freebsd" } - pub fn exe_suffix() -> ~str { ~"" } - pub fn dll_suffix() -> ~str { ~".so" } -} + #[cfg(unix)] + use os::consts::unix::*; -#[cfg(target_os = "linux")] -mod consts { - pub fn sysname() -> ~str { ~"linux" } - pub fn exe_suffix() -> ~str { ~"" } - pub fn dll_suffix() -> ~str { ~".so" } -} + #[cfg(windows)] + use os::consts::windows::*; -#[cfg(target_os = "win32")] -mod consts { - pub fn sysname() -> ~str { ~"win32" } - pub fn exe_suffix() -> ~str { ~".exe" } - pub fn dll_suffix() -> ~str { ~".dll" } -} -#[cfg(target_arch = "x86")] -pub fn arch() -> ~str { ~"x86" } + #[cfg(target_os = "macos")] + use os::consts::macos::*; + + #[cfg(target_os = "freebsd")] + use os::consts::freebsd::*; + + #[cfg(target_os = "linux")] + use os::consts::linux::*; + + #[cfg(target_os = "win32")] + use os::consts::win32::*; -#[cfg(target_arch = "x86_64")] -pub fn arch() -> ~str { ~"x86_64" } -#[cfg(target_arch = "arm")] -pub fn arch() -> str { ~"arm" } + #[cfg(target_arch = "x86")] + use os::consts::x86::*; + + #[cfg(target_arch = "x86_64")] + use os::consts::x86_64::*; + + #[cfg(target_arch = "arm")] + use os::consts::arm::*; + + + pub mod unix { + pub const FAMILY: &str = "unix"; + } + + pub mod windows { + pub const FAMILY: &str = "windows"; + } + + pub mod macos { + pub const SYSNAME: &str = "macos"; + pub const DLL_PREFIX: &str = "lib"; + pub const DLL_SUFFIX: &str = ".dylib"; + pub const EXE_SUFFIX: &str = ""; + } + + pub mod freebsd { + pub const SYSNAME: &str = "freebsd"; + pub const DLL_PREFIX: &str = "lib"; + pub const DLL_SUFFIX: &str = ".so"; + pub const EXE_SUFFIX: &str = ""; + } + + pub mod linux { + pub const SYSNAME: &str = "linux"; + pub const DLL_PREFIX: &str = "lib"; + pub const DLL_SUFFIX: &str = ".so"; + pub const EXE_SUFFIX: &str = ""; + } + + pub mod win32 { + pub const SYSNAME: &str = "win32"; + pub const DLL_PREFIX: &str = ""; + pub const DLL_SUFFIX: &str = ".dll"; + pub const EXE_SUFFIX: &str = ".exe"; + } + + + pub mod x86 { + pub const ARCH: &str = "x86"; + } + + pub mod x86_64 { + pub const ARCH: &str = "x86_64"; + } + + pub mod arm { + pub const ARCH: &str = "arm"; + } +} + #[cfg(test)] #[allow(non_implicitly_copyable_typarams)] diff --git a/src/libcore/send_map.rs b/src/libcore/send_map.rs index 8be220e76d79e..b6f237e14fb0e 100644 --- a/src/libcore/send_map.rs +++ b/src/libcore/send_map.rs @@ -173,6 +173,7 @@ pub mod linear { let mut old_buckets = vec::from_fn(new_capacity, |_i| None); self.buckets <-> old_buckets; + self.size = 0; for uint::range(0, old_capacity) |i| { let mut bucket = None; bucket <-> old_buckets[i]; @@ -583,4 +584,22 @@ pub mod test { assert m1 == m2; } + + #[test] + pub fn test_expand() { + let mut m = ~LinearMap(); + + assert m.len() == 0; + assert m.is_empty(); + + let mut i = 0u; + let old_resize_at = m.resize_at; + while old_resize_at == m.resize_at { + m.insert(i, i); + i += 1; + } + + assert m.len() == i; + assert !m.is_empty(); + } } diff --git a/src/libcore/vec.rs b/src/libcore/vec.rs index 1920edc8253e3..17181e62005df 100644 --- a/src/libcore/vec.rs +++ b/src/libcore/vec.rs @@ -1177,9 +1177,42 @@ pub pure fn reversed(v: &[const T]) -> ~[T] { } /** - * Iterates over a vector, with option to break + * Iterates over a vector, yielding each element to a closure. * - * Return true to continue, false to break. + * # Arguments + * + * * `v` - A vector, to be iterated over + * * `f` - A closure to do the iterating. Within this closure, return true to + * * continue iterating, false to break. + * + * # Examples + * ~~~ + * [1,2,3].each(|&i| { + * io::println(int::str(i)); + * true + * }); + * ~~~ + * + * ~~~ + * [1,2,3,4,5].each(|&i| { + * if i < 4 { + * io::println(int::str(i)); + * true + * } + * else { + * false + * } + * }); + * ~~~ + * + * You probably will want to use each with a `for`/`do` expression, depending + * on your iteration needs: + * + * ~~~ + * for [1,2,3].each |&i| { + * io::println(int::str(i)); + * } + * ~~~ */ #[inline(always)] pub pure fn each(v: &r/[T], f: fn(&r/T) -> bool) { diff --git a/src/librustc/back/link.rs b/src/librustc/back/link.rs index a2b67e8380bd0..073a6983cf449 100644 --- a/src/librustc/back/link.rs +++ b/src/librustc/back/link.rs @@ -40,6 +40,8 @@ use syntax::ast_map::{path, path_mod, path_name}; use syntax::attr; use syntax::print::pprust; +use os::consts::{macos, freebsd, linux, win32}; + enum output_type { output_type_none, output_type_bitcode, @@ -662,6 +664,19 @@ fn mangle_internal_name_by_seq(ccx: @crate_ctxt, flav: ~str) -> ~str { return fmt!("%s_%u", flav, (ccx.names)(flav).repr); } + +fn output_dll_filename(os: session::os, lm: &link_meta) -> ~str { + let libname = fmt!("%s-%s-%s", lm.name, lm.extras_hash, lm.vers); + let (dll_prefix, dll_suffix) = match os { + session::os_win32 => (win32::DLL_PREFIX, win32::DLL_SUFFIX), + session::os_macos => (macos::DLL_PREFIX, macos::DLL_SUFFIX), + session::os_linux => (linux::DLL_PREFIX, linux::DLL_SUFFIX), + session::os_freebsd => (freebsd::DLL_PREFIX, freebsd::DLL_SUFFIX), + }; + return str::from_slice(dll_prefix) + libname + + str::from_slice(dll_suffix); +} + // If the user wants an exe generated we need to invoke // cc to link the object file with some libs fn link_binary(sess: Session, @@ -679,9 +694,7 @@ fn link_binary(sess: Session, } let output = if sess.building_library { - let long_libname = - os::dll_filename(fmt!("%s-%s-%s", - lm.name, lm.extras_hash, lm.vers)); + let long_libname = output_dll_filename(sess.targ_cfg.os, &lm); debug!("link_meta.name: %s", lm.name); debug!("long_libname: %s", long_libname); debug!("out_filename: %s", out_filename.to_str()); diff --git a/src/librustc/driver/driver.rs b/src/librustc/driver/driver.rs index db15a57208218..0938d2dcc6f2c 100644 --- a/src/librustc/driver/driver.rs +++ b/src/librustc/driver/driver.rs @@ -85,9 +85,9 @@ fn default_configuration(sess: Session, argv0: ~str, input: input) -> }; return ~[ // Target bindings. - attr::mk_word_item(os::family()), - mk(~"target_os", os::sysname()), - mk(~"target_family", os::family()), + attr::mk_word_item(str::from_slice(os::FAMILY)), + mk(~"target_os", str::from_slice(os::SYSNAME)), + mk(~"target_family", str::from_slice(os::FAMILY)), mk(~"target_arch", arch), mk(~"target_word_size", wordsz), mk(~"target_libc", libc), diff --git a/src/librustc/metadata/loader.rs b/src/librustc/metadata/loader.rs index e75329340c2fe..d451017cd1ea0 100644 --- a/src/librustc/metadata/loader.rs +++ b/src/librustc/metadata/loader.rs @@ -31,6 +31,8 @@ use core::str; use core::uint; use core::vec; +use core::os::consts::{macos, freebsd, linux, win32}; + export os; export os_macos, os_win32, os_linux, os_freebsd; export ctxt; @@ -78,11 +80,15 @@ fn find_library_crate(cx: ctxt) -> Option<{ident: ~str, data: @~[u8]}> { fn libname(cx: ctxt) -> {prefix: ~str, suffix: ~str} { if cx.static { return {prefix: ~"lib", suffix: ~".rlib"}; } - match cx.os { - os_win32 => return {prefix: ~"", suffix: ~".dll"}, - os_macos => return {prefix: ~"lib", suffix: ~".dylib"}, - os_linux => return {prefix: ~"lib", suffix: ~".so"}, - os_freebsd => return {prefix: ~"lib", suffix: ~".so"} + let (dll_prefix, dll_suffix) = match cx.os { + os_win32 => (win32::DLL_PREFIX, win32::DLL_SUFFIX), + os_macos => (macos::DLL_PREFIX, macos::DLL_SUFFIX), + os_linux => (linux::DLL_PREFIX, linux::DLL_SUFFIX), + os_freebsd => (freebsd::DLL_PREFIX, freebsd::DLL_SUFFIX), + }; + return { + prefix: str::from_slice(dll_prefix), + suffix: str::from_slice(dll_suffix) } } diff --git a/src/librustc/middle/resolve.rs b/src/librustc/middle/resolve.rs index acaf668969c63..ffb696ec4f946 100644 --- a/src/librustc/middle/resolve.rs +++ b/src/librustc/middle/resolve.rs @@ -2086,8 +2086,11 @@ impl Resolver { match self.resolve_import_for_module(module_, import_directive) { Failed => { // We presumably emitted an error. Continue. - self.session.span_err(import_directive.span, - ~"failed to resolve import"); + let idents = import_directive.module_path.get(); + let msg = fmt!("failed to resolve import: %s", + self.import_path_to_str(idents, + *import_directive.subclass)); + self.session.span_err(import_directive.span, msg); } Indeterminate => { // Bail out. We'll come around next time. @@ -2103,20 +2106,29 @@ impl Resolver { } fn idents_to_str(idents: ~[ident]) -> ~str { - // XXX: str::connect should do this. - let mut result = ~""; - let mut first = true; - for idents.each() |ident| { - if first { - first = false; - } else { - result += ~"::"; - } - result += self.session.str_of(*ident); - } - // XXX: Shouldn't copy here. We need string builder functionality. - return result; + let ident_strs = idents.map(|&ident| self.session.str_of(ident)); + return str::connect(ident_strs, "::"); } + + fn import_directive_subclass_to_str(subclass: ImportDirectiveSubclass) + -> ~str { + match subclass { + SingleImport(_target, source, _ns) => self.session.str_of(source), + GlobImport => ~"*" + } + } + + fn import_path_to_str(idents: ~[ident], subclass: ImportDirectiveSubclass) + -> ~str { + if idents.is_empty() { + self.import_directive_subclass_to_str(subclass) + } else { + fmt!("%s::%s", + self.idents_to_str(idents), + self.import_directive_subclass_to_str(subclass)) + } + } + /** * Attempts to resolve the given import. The return value indicates * failure if we're certain the name does not exist, indeterminate if we @@ -4501,17 +4513,14 @@ impl Resolver { // Write the result into the def map. debug!("(resolving type) writing resolution for `%s` \ (id %d)", - connect(path.idents.map( - |x| self.session.str_of(*x)), ~"::"), + self.idents_to_str(path.idents), path_id); self.record_def(path_id, def); } None => { self.session.span_err (ty.span, fmt!("use of undeclared type name `%s`", - connect(path.idents.map( - |x| self.session.str_of(*x)), - ~"::"))); + self.idents_to_str(path.idents))); } } } @@ -4705,9 +4714,7 @@ impl Resolver { self.session.span_err( path.span, fmt!("`%s` does not name a structure", - connect(path.idents.map( - |x| self.session.str_of(*x)), - ~"::"))); + self.idents_to_str(path.idents))); } } } @@ -5103,14 +5110,11 @@ impl Resolver { Some(def) => { // Write the result into the def map. debug!("(resolving expr) resolved `%s`", - connect(path.idents.map( - |x| self.session.str_of(*x)), ~"::")); + self.idents_to_str(path.idents)); self.record_def(expr.id, def); } None => { - let wrong_name = - connect(path.idents.map( - |x| self.session.str_of(*x)), ~"::") ; + let wrong_name = self.idents_to_str(path.idents); if self.name_exists_in_scope_struct(wrong_name) { self.session.span_err(expr.span, fmt!("unresolved name: `%s`. \ @@ -5170,9 +5174,7 @@ impl Resolver { self.session.span_err( path.span, fmt!("`%s` does not name a structure", - connect(path.idents.map( - |x| self.session.str_of(*x)), - ~"::"))); + self.idents_to_str(path.idents))); } } @@ -5491,7 +5493,7 @@ impl Resolver { // hit. // - /// A somewhat inefficient routine to print out the name of a module. + /// A somewhat inefficient routine to obtain the name of a module. fn module_to_str(module_: @Module) -> ~str { let idents = DVec(); let mut current_module = module_; @@ -5514,22 +5516,7 @@ impl Resolver { if idents.len() == 0 { return ~"???"; } - - let mut string = ~""; - let mut i = idents.len() - 1; - loop { - if i < idents.len() - 1 { - string += ~"::"; - } - string += self.session.str_of(idents.get_elt(i)); - - if i == 0 { - break; - } - i -= 1; - } - - return string; + return self.idents_to_str(vec::reversed(idents.get())); } fn dump_module(module_: @Module) { diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index c072889c5249a..abeea65b01f93 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -162,10 +162,11 @@ export kind_is_durable; export meta_kind, kind_lteq, type_kind, type_kind_ext; export operators; export type_err, terr_vstore_kind; -export terr_mismatch, terr_onceness_mismatch; +export terr_integer_as_char, terr_mismatch, terr_onceness_mismatch; export type_err_to_str, note_and_explain_type_err; export expected_found; export type_needs_drop; +export type_is_char; export type_is_empty; export type_is_integral; export type_is_numeric; @@ -714,6 +715,7 @@ enum type_err { terr_in_field(@type_err, ast::ident), terr_sorts(expected_found), terr_self_substs, + terr_integer_as_char, terr_no_integral_type, terr_no_floating_point_type, } @@ -2541,6 +2543,13 @@ fn type_is_integral(ty: t) -> bool { } } +fn type_is_char(ty: t) -> bool { + match get(ty).sty { + ty_int(ty_char) => true, + _ => false + } +} + fn type_is_fp(ty: t) -> bool { match get(ty).sty { ty_infer(FloatVar(_)) | ty_float(_) => true, @@ -3510,6 +3519,10 @@ fn type_err_to_str(cx: ctxt, err: &type_err) -> ~str { ~"couldn't determine an appropriate integral type for integer \ literal" } + terr_integer_as_char => { + ~"integer literals can't be inferred to char type \ + (try an explicit cast)" + } terr_no_floating_point_type => { ~"couldn't determine an appropriate floating point type for \ floating point literal" diff --git a/src/librustc/middle/typeck/infer/unify.rs b/src/librustc/middle/typeck/infer/unify.rs index 17464d8c13e59..90fb9e47b6517 100644 --- a/src/librustc/middle/typeck/infer/unify.rs +++ b/src/librustc/middle/typeck/infer/unify.rs @@ -366,6 +366,10 @@ impl infer_ctxt { } fn int_var_sub_t(a_id: ty::IntVid, b: ty::t) -> ures { + if ty::type_is_char(b) { + return Err(ty::terr_integer_as_char); + } + assert ty::type_is_integral(b); let vb = &self.int_var_bindings; diff --git a/src/librustdoc/astsrv.rs b/src/librustdoc/astsrv.rs index bdb92611454b5..83516a589b5f5 100644 --- a/src/librustdoc/astsrv.rs +++ b/src/librustdoc/astsrv.rs @@ -21,6 +21,7 @@ use parse; use util; use core::oldcomm; +use core::vec; use rustc::back::link; use rustc::driver::driver; use rustc::driver::session::Session; diff --git a/src/librustdoc/attr_parser.rs b/src/librustdoc/attr_parser.rs index 9acef45cc9217..e47bdbb00daab 100644 --- a/src/librustdoc/attr_parser.rs +++ b/src/librustdoc/attr_parser.rs @@ -31,6 +31,9 @@ pub type CrateAttrs = { mod test { #[legacy_exports]; + use syntax::ast; + use syntax; + fn parse_attributes(+source: ~str) -> ~[ast::attribute] { use syntax::parse; use syntax::parse::parser; diff --git a/src/librustdoc/attr_pass.rs b/src/librustdoc/attr_pass.rs index 7562016cf47c5..812185ec34d48 100644 --- a/src/librustdoc/attr_pass.rs +++ b/src/librustdoc/attr_pass.rs @@ -310,6 +310,11 @@ fn should_extract_impl_method_docs() { #[cfg(test)] mod test { #[legacy_exports]; + + use astsrv; + use doc; + use extract; + fn mk_doc(source: ~str) -> doc::Doc { do astsrv::from_str(source) |srv| { let doc = extract::from_srv(srv, ~""); diff --git a/src/librustdoc/desc_to_brief_pass.rs b/src/librustdoc/desc_to_brief_pass.rs index f9c0fb829d0b5..2c3998cecee2c 100644 --- a/src/librustdoc/desc_to_brief_pass.rs +++ b/src/librustdoc/desc_to_brief_pass.rs @@ -100,6 +100,12 @@ fn should_promote_impl_method_desc() { #[cfg(test)] mod test { #[legacy_exports]; + + use astsrv; + use attr_pass; + use doc; + use extract; + fn mk_doc(source: ~str) -> doc::Doc { do astsrv::from_str(source) |srv| { let doc = extract::from_srv(srv, ~""); diff --git a/src/librustdoc/extract.rs b/src/librustdoc/extract.rs index b4912f13983db..8f2c61ba26ee9 100644 --- a/src/librustdoc/extract.rs +++ b/src/librustdoc/extract.rs @@ -344,6 +344,12 @@ fn should_extract_struct_fields() { mod test { #[legacy_exports]; + use astsrv; + use doc; + use parse; + + use core::vec; + fn mk_doc(+source: ~str) -> doc::Doc { let ast = parse::from_str(source); extract(ast, ~"") diff --git a/src/librustdoc/fold.rs b/src/librustdoc/fold.rs index 85f218d8f1629..deb6af224e5d4 100644 --- a/src/librustdoc/fold.rs +++ b/src/librustdoc/fold.rs @@ -8,7 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use astsrv; use doc; +use extract; +use parse; use core::vec; use std::par; diff --git a/src/librustdoc/markdown_index_pass.rs b/src/librustdoc/markdown_index_pass.rs index cdf2c48dd7da0..1408ae874168e 100644 --- a/src/librustdoc/markdown_index_pass.rs +++ b/src/librustdoc/markdown_index_pass.rs @@ -252,6 +252,15 @@ fn should_index_foreign_mod_contents() { #[cfg(test)] mod test { #[legacy_exports]; + + use astsrv; + use attr_pass; + use config; + use desc_to_brief_pass; + use doc; + use extract; + use path_pass; + fn mk_doc(output_style: config::OutputStyle, +source: ~str) -> doc::Doc { do astsrv::from_str(source) |srv| { let config = { diff --git a/src/librustdoc/markdown_pass.rs b/src/librustdoc/markdown_pass.rs index 39ba0bafb0d59..6ed2e98010c9e 100644 --- a/src/librustdoc/markdown_pass.rs +++ b/src/librustdoc/markdown_pass.rs @@ -11,15 +11,28 @@ //! Generate markdown from a document tree use astsrv; +use attr_pass; +use config; +use desc_to_brief_pass; use doc::ItemUtils; use doc; +use extract; use fold; +use markdown_index_pass; use markdown_pass; use markdown_writer::Writer; use markdown_writer::WriterUtils; use markdown_writer::WriterFactory; +use markdown_writer; +use page_pass; +use path_pass; +use sectionalize_pass; use sort_pass; +use trim_pass; +use unindent_pass; +use core::iter; +use core::oldcomm; use core::str; use core::vec; use std::par; @@ -817,6 +830,24 @@ fn should_write_struct_header() { #[cfg(test)] mod test { #[legacy_exports]; + + use astsrv; + use attr_pass; + use config; + use desc_to_brief_pass; + use doc; + use extract; + use markdown_index_pass; + use markdown_writer; + use path_pass; + use sectionalize_pass; + use trim_pass; + use tystr_pass; + use unindent_pass; + + use core::oldcomm; + use core::str; + fn render(+source: ~str) -> ~str { let (srv, doc) = create_doc_srv(source); let markdown = write_markdown_str_srv(srv, doc); diff --git a/src/librustdoc/markdown_writer.rs b/src/librustdoc/markdown_writer.rs index adad3c5f5e17e..f4e5db304e7d6 100644 --- a/src/librustdoc/markdown_writer.rs +++ b/src/librustdoc/markdown_writer.rs @@ -267,6 +267,12 @@ fn should_name_mod_file_names_by_path() { #[cfg(test)] mod test { #[legacy_exports]; + + use astsrv; + use doc; + use extract; + use path_pass; + fn mk_doc(+name: ~str, +source: ~str) -> doc::Doc { do astsrv::from_str(source) |srv| { let doc = extract::from_srv(srv, name); diff --git a/src/librustdoc/page_pass.rs b/src/librustdoc/page_pass.rs index d582119081bec..0709cc5dc55eb 100644 --- a/src/librustdoc/page_pass.rs +++ b/src/librustdoc/page_pass.rs @@ -183,6 +183,12 @@ fn should_remove_foreign_mods_from_containing_mods() { #[cfg(test)] mod test { #[legacy_exports]; + + use astsrv; + use config; + use doc; + use extract; + fn mk_doc_( output_style: config::OutputStyle, source: ~str diff --git a/src/librustdoc/pass.rs b/src/librustdoc/pass.rs index cc3bdf9f82c65..967dcd8f49f8e 100644 --- a/src/librustdoc/pass.rs +++ b/src/librustdoc/pass.rs @@ -10,6 +10,7 @@ use astsrv; use doc; +use extract; use core::vec; diff --git a/src/librustdoc/path_pass.rs b/src/librustdoc/path_pass.rs index e183c13b90fa6..4227ce230963b 100644 --- a/src/librustdoc/path_pass.rs +++ b/src/librustdoc/path_pass.rs @@ -13,6 +13,7 @@ use astsrv; use doc::ItemUtils; use doc; +use extract; use fold::Fold; use fold; diff --git a/src/librustdoc/prune_hidden_pass.rs b/src/librustdoc/prune_hidden_pass.rs index c5756571a410a..da3c6bd7f2b55 100644 --- a/src/librustdoc/prune_hidden_pass.rs +++ b/src/librustdoc/prune_hidden_pass.rs @@ -71,6 +71,11 @@ fn should_prune_hidden_items() { #[cfg(test)] mod test { #[legacy_exports]; + + use astsrv; + use doc; + use extract; + fn mk_doc(source: ~str) -> doc::Doc { do astsrv::from_str(source) |srv| { let doc = extract::from_srv(srv, ~""); diff --git a/src/librustdoc/prune_private_pass.rs b/src/librustdoc/prune_private_pass.rs index c1852128622b1..5017f889d5a6d 100644 --- a/src/librustdoc/prune_private_pass.rs +++ b/src/librustdoc/prune_private_pass.rs @@ -18,6 +18,7 @@ use fold::Fold; use fold; use core::util; +use core::vec; use syntax::ast; export mk_pass; @@ -75,6 +76,10 @@ fn should_prune_items_without_pub_modifier() { #[cfg(test)] mod test { + use astsrv; + use doc; + use extract; + pub fn mk_doc(source: ~str) -> doc::Doc { do astsrv::from_str(source) |srv| { let doc = extract::from_srv(srv, ~""); diff --git a/src/librustdoc/sectionalize_pass.rs b/src/librustdoc/sectionalize_pass.rs index 090016a6f9c16..a2b6687522022 100644 --- a/src/librustdoc/sectionalize_pass.rs +++ b/src/librustdoc/sectionalize_pass.rs @@ -11,12 +11,15 @@ //! Breaks rustdocs into sections according to their headers use astsrv; +use attr_pass; use doc::ItemUtils; use doc; +use extract; use fold::Fold; use fold; use core::str; +use core::vec; use std::par; pub fn mk_pass() -> Pass { @@ -248,6 +251,12 @@ fn should_sectionalize_impl_methods() { #[cfg(test)] mod test { #[legacy_exports]; + + use astsrv; + use attr_pass; + use doc; + use extract; + fn mk_doc(source: ~str) -> doc::Doc { do astsrv::from_str(source) |srv| { let doc = extract::from_srv(srv, ~""); diff --git a/src/librustdoc/sort_pass.rs b/src/librustdoc/sort_pass.rs index a660f0c42ad63..fcf878dbf8d81 100644 --- a/src/librustdoc/sort_pass.rs +++ b/src/librustdoc/sort_pass.rs @@ -13,6 +13,7 @@ use astsrv; use doc::ItemUtils; use doc; +use extract; use fold::Fold; use fold; use util::NominalOp; diff --git a/src/librustdoc/text_pass.rs b/src/librustdoc/text_pass.rs index 30e91f95569ca..ae205883902ad 100644 --- a/src/librustdoc/text_pass.rs +++ b/src/librustdoc/text_pass.rs @@ -289,6 +289,16 @@ fn should_execute_on_impl_method_section_bodies() { #[cfg(test)] mod test { #[legacy_exports]; + + use astsrv; + use attr_pass; + use desc_to_brief_pass; + use doc; + use extract; + use sectionalize_pass; + + use core::str; + fn mk_doc(source: ~str) -> doc::Doc { do astsrv::from_str(source) |srv| { let doc = extract::from_srv(srv, ~""); diff --git a/src/librustdoc/trim_pass.rs b/src/librustdoc/trim_pass.rs index 78f56ceaba7b9..731a2bb7ad6eb 100644 --- a/src/librustdoc/trim_pass.rs +++ b/src/librustdoc/trim_pass.rs @@ -36,6 +36,12 @@ fn should_trim_text() { #[cfg(test)] mod test { #[legacy_exports]; + + use astsrv; + use attr_pass; + use doc; + use extract; + fn mk_doc(source: ~str) -> doc::Doc { do astsrv::from_str(source) |srv| { let doc = extract::from_srv(srv, ~""); diff --git a/src/librustdoc/tystr_pass.rs b/src/librustdoc/tystr_pass.rs index ae69e83c3c71c..92f2e0a5e8b0d 100644 --- a/src/librustdoc/tystr_pass.rs +++ b/src/librustdoc/tystr_pass.rs @@ -407,6 +407,11 @@ fn should_not_serialize_struct_attrs() { #[cfg(test)] mod test { #[legacy_exports]; + + use astsrv; + use doc; + use extract; + fn mk_doc(source: ~str) -> doc::Doc { do astsrv::from_str(source) |srv| { let doc = extract::from_srv(srv, ~""); diff --git a/src/librusti/rusti.rc b/src/librusti/rusti.rc index 8afb8d3f85136..828877fc4a401 100644 --- a/src/librusti/rusti.rc +++ b/src/librusti/rusti.rc @@ -134,6 +134,7 @@ fn run(repl: Repl, input: ~str) -> Repl { crate_type: session::unknown_crate, binary: repl.binary, addl_lib_search_paths: repl.lib_search_paths.map(|p| Path(*p)), + jit: true, .. *session::basic_options() }; @@ -153,8 +154,12 @@ fn run(repl: Repl, input: ~str) -> Repl { repl.binary, wrapped); - debug!("parsing"); - let mut crate = driver::parse_input(sess, cfg, wrapped); + let outputs = driver::build_output_filenames(wrapped, &None, &None, sess); + debug!("calling compile_upto"); + let {crate: crate, tcx: _} = driver::compile_upto(sess, cfg, wrapped, + driver::cu_everything, + Some(outputs)); + let mut opt = None; for crate.node.module.items.each |item| { @@ -177,114 +182,6 @@ fn run(repl: Repl, input: ~str) -> Repl { } _ => fail }; - - debug!("configuration"); - crate = front::config::strip_unconfigured_items(crate); - - debug!("maybe building test harness"); - crate = front::test::modify_for_testing(sess, crate); - - debug!("expansion"); - crate = syntax::ext::expand::expand_crate(sess.parse_sess, - sess.opts.cfg, - crate); - - debug!("intrinsic injection"); - crate = front::intrinsic_inject::inject_intrinsic(sess, crate); - - debug!("core injection"); - crate = front::core_inject::maybe_inject_libcore_ref(sess, crate); - - debug!("building lint settings table"); - lint::build_settings_crate(sess, crate); - - debug!("ast indexing"); - let ast_map = syntax::ast_map::map_crate(sess.diagnostic(), *crate); - - debug!("external crate/lib resolution"); - creader::read_crates(sess.diagnostic(), *crate, sess.cstore, - sess.filesearch, - session::sess_os_to_meta_os(sess.targ_cfg.os), - sess.opts.static, sess.parse_sess.interner); - - debug!("language item collection"); - let lang_items = middle::lang_items::collect_language_items(crate, sess); - - debug!("resolution"); - let {def_map: def_map, - exp_map2: exp_map2, - trait_map: trait_map} = middle::resolve::resolve_crate(sess, - lang_items, - crate); - - debug!("freevar finding"); - let freevars = freevars::annotate_freevars(def_map, crate); - - debug!("region_resolution"); - let region_map = middle::region::resolve_crate(sess, def_map, crate); - - debug!("region paramaterization inference"); - let rp_set = middle::region::determine_rp_in_crate(sess, ast_map, - def_map, crate); - - debug!("typechecking"); - let ty_cx = ty::mk_ctxt(sess, def_map, ast_map, freevars, - region_map, rp_set, move lang_items, crate); - let (method_map, vtable_map) = typeck::check_crate(ty_cx, trait_map, - crate); - - debug!("const marking"); - middle::const_eval::process_crate(crate, def_map, ty_cx); - - debug!("const checking"); - middle::check_const::check_crate(sess, crate, ast_map, def_map, - method_map, ty_cx); - - debug!("privacy checking"); - middle::privacy::check_crate(ty_cx, &method_map, crate); - - debug!("loop checking"); - middle::check_loop::check_crate(ty_cx, crate); - - debug!("mode computation"); - middle::mode::compute_modes(ty_cx, method_map, crate); - - debug!("alt checking"); - middle::check_alt::check_crate(ty_cx, method_map, crate); - - debug!("liveness checking"); - let last_use_map = middle::liveness::check_crate(ty_cx, - method_map, crate); - - debug!("borrow checking"); - let (root_map, mutbl_map) = middle::borrowck::check_crate(ty_cx, - method_map, - last_use_map, - crate); - - debug!("kind checking"); - kind::check_crate(ty_cx, method_map, last_use_map, crate); - - debug!("lint checking"); - lint::check_crate(ty_cx, crate); - - let maps = {mutbl_map: mutbl_map, - root_map: root_map, - last_use_map: last_use_map, - method_map: method_map, - vtable_map: vtable_map}; - - debug!("translation"); - let path = ~path::GenericPath::from_str(""); - let (llmod, _) = trans::base::trans_crate(sess, crate, ty_cx, - path, - exp_map2, maps); - let pm = llvm::LLVMCreatePassManager(); - - debug!("executing jit"); - back::link::jit::exec(sess, pm, llmod, 0, false); - llvm::LLVMDisposePassManager(pm); - debug!("recording input into repl history"); record(repl, blk, sess.parse_sess.interner) } @@ -380,7 +277,7 @@ fn run_cmd(repl: &mut Repl, _in: io::Reader, _out: io::Writer, io::println( ~":{\\n ..lines.. \\n:}\\n - execute multiline command\n" + ~":load ... - \ - loads given crates as dynamic libraries" + + loads given crates as dynamic libraries\n" + ~":clear - clear the screen\n" + ~":exit - exit from the repl\n" + ~":help - show this message"); diff --git a/src/libstd/arc.rs b/src/libstd/arc.rs index e91d09fc0cc2d..b38f756a2b57d 100644 --- a/src/libstd/arc.rs +++ b/src/libstd/arc.rs @@ -470,6 +470,8 @@ impl &RWReadMode { mod tests { #[legacy_exports]; + use arc; + use core::oldcomm::*; use core::option::{Some, None}; use core::option; diff --git a/src/libstd/bitv.rs b/src/libstd/bitv.rs index 990ccb3a16312..38ebe67898d3a 100644 --- a/src/libstd/bitv.rs +++ b/src/libstd/bitv.rs @@ -581,6 +581,7 @@ mod tests { use bitv; use core::uint; + use core::vec; #[test] fn test_to_str() { diff --git a/src/libstd/flatpipes.rs b/src/libstd/flatpipes.rs index 3c1dec844ea85..8f239b2a130ff 100644 --- a/src/libstd/flatpipes.rs +++ b/src/libstd/flatpipes.rs @@ -695,6 +695,7 @@ mod test { use core::int; use core::io::BytesReader; use core::io; + use core::result; use core::sys; use core::task; @@ -818,6 +819,7 @@ mod test { use net::ip; use cell::Cell; use net::tcp::TcpSocket; + use uv; // Indicate to the client task that the server is listening let (begin_connect_port, begin_connect_chan) = pipes::stream(); @@ -916,6 +918,14 @@ mod test { // Tests that the different backends behave the same when the // binary streaming protocol is broken mod broken_protocol { + use flatpipes::pod; + use flatpipes::util::BufReader; + + use core::io; + use core::pipes; + use core::sys; + use core::task; + type PortLoader = ~fn(~[u8]) -> FlatPort, P>; diff --git a/src/libstd/future.rs b/src/libstd/future.rs index ccb26a4439d14..7cbd42f217d2b 100644 --- a/src/libstd/future.rs +++ b/src/libstd/future.rs @@ -145,6 +145,9 @@ pub fn spawn(blk: fn~() -> A) -> Future { #[allow(non_implicitly_copyable_typarams)] pub mod test { + use core::pipes::oneshot; + use core::task; + #[test] pub fn test_from_value() { let f = from_value(~"snail"); diff --git a/src/libstd/map.rs b/src/libstd/map.rs index b6c7c8be5a923..e4f38496f1dd8 100644 --- a/src/libstd/map.rs +++ b/src/libstd/map.rs @@ -54,7 +54,7 @@ pub trait Map { * Add a value to the map. * * If the map contains a value for the key, use the function to - * set a new value. (Like `insert_or_update_with_key`, but with a + * set a new value. (Like `update_with_key`, but with a * function of only values.) */ fn update(key: K, newval: V, ff: fn(V, V) -> V) -> bool; diff --git a/src/libstd/net_ip.rs b/src/libstd/net_ip.rs index ebe0ac690fe90..96bd6367e569e 100644 --- a/src/libstd/net_ip.rs +++ b/src/libstd/net_ip.rs @@ -350,6 +350,13 @@ extern fn get_addr_cb(handle: *uv_getaddrinfo_t, status: libc::c_int, #[cfg(test)] mod test { + use net_ip::v4; + use net_ip::v6; + use uv; + + use core::result; + use core::vec; + #[test] fn test_ip_ipv4_parse_and_format_ip() { let localhost_str = ~"127.0.0.1"; diff --git a/src/libstd/net_url.rs b/src/libstd/net_url.rs index f920e7e9da646..5fc2035179351 100644 --- a/src/libstd/net_url.rs +++ b/src/libstd/net_url.rs @@ -735,6 +735,11 @@ impl Url: to_bytes::IterBytes { #[cfg(test)] mod tests { #[legacy_exports]; + use net_url::UserInfo; + + use core::result; + use core::str; + #[test] fn test_split_char_first() { let (u,v) = split_char_first(~"hello, sweet world", ','); @@ -1067,12 +1072,13 @@ mod tests { #[test] fn test_decode_form_urlencoded() { - assert decode_form_urlencoded(~[]).len() == 0; + // XXX: Broken. + /*assert decode_form_urlencoded(~[]).len() == 0; let s = str::to_bytes("a=1&foo+bar=abc&foo+bar=12+%3D+34"); let form = decode_form_urlencoded(s); assert form.len() == 2; assert form.get_ref(&~"a") == &~[~"1"]; - assert form.get_ref(&~"foo bar") == &~[~"abc", ~"12 = 34"]; + assert form.get_ref(&~"foo bar") == &~[~"abc", ~"12 = 34"];*/ } } diff --git a/src/libstd/rope.rs b/src/libstd/rope.rs index 7d1806d931e6d..1513e621fcbb3 100644 --- a/src/libstd/rope.rs +++ b/src/libstd/rope.rs @@ -1264,6 +1264,7 @@ mod tests { use core::option; use core::str; + use core::uint; use core::vec; //Utility function, used for sanity check diff --git a/src/libstd/sort.rs b/src/libstd/sort.rs index e557730643a2f..505b252674126 100644 --- a/src/libstd/sort.rs +++ b/src/libstd/sort.rs @@ -714,6 +714,9 @@ fn copy_vec(dest: &[mut T], s1: uint, #[cfg(test)] mod test_qsort3 { #[legacy_exports]; + + use core::vec; + fn check_sort(v1: &[mut int], v2: &[mut int]) { let len = vec::len::(v1); quick_sort3::(v1); @@ -754,6 +757,10 @@ mod test_qsort3 { #[cfg(test)] mod test_qsort { #[legacy_exports]; + + use core::int; + use core::vec; + fn check_sort(v1: &[mut int], v2: &[mut int]) { let len = vec::len::(v1); pure fn leual(a: &int, b: &int) -> bool { *a <= *b } @@ -815,6 +822,8 @@ mod test_qsort { mod tests { #[legacy_exports]; + use core::vec; + fn check_sort(v1: &[int], v2: &[int]) { let len = vec::len::(v1); pub pure fn le(a: &int, b: &int) -> bool { *a <= *b } @@ -878,6 +887,9 @@ mod tests { #[cfg(test)] mod test_tim_sort { + use core::rand; + use core::vec; + struct CVal { val: float, } @@ -970,6 +982,7 @@ mod test_tim_sort { mod big_tests { use core::rand; use core::task; + use core::uint; use core::vec; #[test] diff --git a/src/libstd/sync.rs b/src/libstd/sync.rs index f9afcc49bc15d..d957a7ee2abbf 100644 --- a/src/libstd/sync.rs +++ b/src/libstd/sync.rs @@ -709,10 +709,13 @@ impl &RWlockReadMode { mod tests { #[legacy_exports]; + use core::cast; + use core::option; use core::pipes; use core::ptr; use core::result; use core::task; + use core::vec; /************************************************************************ * Semaphore tests diff --git a/src/libstd/task_pool.rs b/src/libstd/task_pool.rs index 35bea7b01b443..68bf2612f9a48 100644 --- a/src/libstd/task_pool.rs +++ b/src/libstd/task_pool.rs @@ -11,6 +11,7 @@ /// A task pool abstraction. Useful for achieving predictable CPU /// parallelism. +use core::io; use core::pipes::{Chan, Port}; use core::pipes; use core::task::{SchedMode, SingleThreaded}; diff --git a/src/libstd/uv_global_loop.rs b/src/libstd/uv_global_loop.rs index 8a04059754a98..43ed58aa0c125 100644 --- a/src/libstd/uv_global_loop.rs +++ b/src/libstd/uv_global_loop.rs @@ -130,6 +130,7 @@ mod test { use core::libc; use core::oldcomm; use core::ptr; + use core::task; extern fn simple_timer_close_cb(timer_ptr: *ll::uv_timer_t) unsafe { let exit_ch_ptr = ll::get_data_for_uv_handle( diff --git a/src/libstd/uv_iotask.rs b/src/libstd/uv_iotask.rs index c1c455c3a115c..7853f1cd9f79f 100644 --- a/src/libstd/uv_iotask.rs +++ b/src/libstd/uv_iotask.rs @@ -178,8 +178,11 @@ extern fn tear_down_close_cb(handle: *ll::uv_async_t) unsafe { mod test { use uv::ll; + use core::iter; + use core::libc; use core::oldcomm; use core::ptr; + use core::task; extern fn async_close_cb(handle: *ll::uv_async_t) unsafe { log(debug, fmt!("async_close_cb handle %?", handle)); diff --git a/src/libstd/uv_ll.rs b/src/libstd/uv_ll.rs index b4d617afdeebf..46574ced2e596 100644 --- a/src/libstd/uv_ll.rs +++ b/src/libstd/uv_ll.rs @@ -1040,6 +1040,13 @@ pub unsafe fn addrinfo_as_sockaddr_in6(input: *addrinfo) -> *sockaddr_in6 { #[cfg(test)] pub mod test { + use core::libc; + use core::oldcomm; + use core::ptr; + use core::str; + use core::sys; + use core::task; + use core::vec; enum tcp_read_data { tcp_read_eof, @@ -1562,7 +1569,8 @@ pub mod test { // struct size tests #[test] fn test_uv_ll_struct_size_uv_tcp_t() { - let foreign_handle_size = rustrt::rust_uv_helper_uv_tcp_t_size(); + let foreign_handle_size = + ::uv_ll::rustrt::rust_uv_helper_uv_tcp_t_size(); let rust_handle_size = sys::size_of::(); let output = fmt!("uv_tcp_t -- foreign: %u rust: %u", foreign_handle_size as uint, rust_handle_size); @@ -1572,7 +1580,7 @@ pub mod test { #[test] fn test_uv_ll_struct_size_uv_connect_t() { let foreign_handle_size = - rustrt::rust_uv_helper_uv_connect_t_size(); + ::uv_ll::rustrt::rust_uv_helper_uv_connect_t_size(); let rust_handle_size = sys::size_of::(); let output = fmt!("uv_connect_t -- foreign: %u rust: %u", foreign_handle_size as uint, rust_handle_size); @@ -1582,7 +1590,7 @@ pub mod test { #[test] fn test_uv_ll_struct_size_uv_buf_t() { let foreign_handle_size = - rustrt::rust_uv_helper_uv_buf_t_size(); + ::uv_ll::rustrt::rust_uv_helper_uv_buf_t_size(); let rust_handle_size = sys::size_of::(); let output = fmt!("uv_buf_t -- foreign: %u rust: %u", foreign_handle_size as uint, rust_handle_size); @@ -1592,7 +1600,7 @@ pub mod test { #[test] fn test_uv_ll_struct_size_uv_write_t() { let foreign_handle_size = - rustrt::rust_uv_helper_uv_write_t_size(); + ::uv_ll::rustrt::rust_uv_helper_uv_write_t_size(); let rust_handle_size = sys::size_of::(); let output = fmt!("uv_write_t -- foreign: %u rust: %u", foreign_handle_size as uint, rust_handle_size); @@ -1603,7 +1611,7 @@ pub mod test { #[test] fn test_uv_ll_struct_size_sockaddr_in() { let foreign_handle_size = - rustrt::rust_uv_helper_sockaddr_in_size(); + ::uv_ll::rustrt::rust_uv_helper_sockaddr_in_size(); let rust_handle_size = sys::size_of::(); let output = fmt!("sockaddr_in -- foreign: %u rust: %u", foreign_handle_size as uint, rust_handle_size); @@ -1613,7 +1621,7 @@ pub mod test { #[test] fn test_uv_ll_struct_size_sockaddr_in6() { let foreign_handle_size = - rustrt::rust_uv_helper_sockaddr_in6_size(); + ::uv_ll::rustrt::rust_uv_helper_sockaddr_in6_size(); let rust_handle_size = sys::size_of::(); let output = fmt!("sockaddr_in6 -- foreign: %u rust: %u", foreign_handle_size as uint, rust_handle_size); @@ -1628,7 +1636,7 @@ pub mod test { #[ignore(reason = "questionable size calculations")] fn test_uv_ll_struct_size_addr_in() { let foreign_handle_size = - rustrt::rust_uv_helper_addr_in_size(); + ::uv_ll::rustrt::rust_uv_helper_addr_in_size(); let rust_handle_size = sys::size_of::(); let output = fmt!("addr_in -- foreign: %u rust: %u", foreign_handle_size as uint, rust_handle_size); @@ -1640,7 +1648,7 @@ pub mod test { #[test] fn test_uv_ll_struct_size_uv_async_t() { let foreign_handle_size = - rustrt::rust_uv_helper_uv_async_t_size(); + ::uv_ll::rustrt::rust_uv_helper_uv_async_t_size(); let rust_handle_size = sys::size_of::(); let output = fmt!("uv_async_t -- foreign: %u rust: %u", foreign_handle_size as uint, rust_handle_size); @@ -1651,7 +1659,7 @@ pub mod test { #[test] fn test_uv_ll_struct_size_uv_timer_t() { let foreign_handle_size = - rustrt::rust_uv_helper_uv_timer_t_size(); + ::uv_ll::rustrt::rust_uv_helper_uv_timer_t_size(); let rust_handle_size = sys::size_of::(); let output = fmt!("uv_timer_t -- foreign: %u rust: %u", foreign_handle_size as uint, rust_handle_size); @@ -1663,7 +1671,7 @@ pub mod test { #[ignore(cfg(target_os = "win32"))] fn test_uv_ll_struct_size_uv_getaddrinfo_t() { let foreign_handle_size = - rustrt::rust_uv_helper_uv_getaddrinfo_t_size(); + ::uv_ll::rustrt::rust_uv_helper_uv_getaddrinfo_t_size(); let rust_handle_size = sys::size_of::(); let output = fmt!("uv_getaddrinfo_t -- foreign: %u rust: %u", foreign_handle_size as uint, rust_handle_size); @@ -1675,7 +1683,7 @@ pub mod test { #[ignore(cfg(target_os = "win32"))] fn test_uv_ll_struct_size_addrinfo() { let foreign_handle_size = - rustrt::rust_uv_helper_addrinfo_size(); + ::uv_ll::rustrt::rust_uv_helper_addrinfo_size(); let rust_handle_size = sys::size_of::(); let output = fmt!("addrinfo -- foreign: %u rust: %u", foreign_handle_size as uint, rust_handle_size); diff --git a/src/rt/rust_sched_loop.cpp b/src/rt/rust_sched_loop.cpp index f6b061a5bbc63..e56ce6dd2637f 100644 --- a/src/rt/rust_sched_loop.cpp +++ b/src/rt/rust_sched_loop.cpp @@ -100,6 +100,7 @@ rust_sched_loop::kill_all_tasks() { size_t rust_sched_loop::number_of_live_tasks() { + lock.must_have_lock(); return running_tasks.length() + blocked_tasks.length(); } @@ -148,14 +149,10 @@ rust_sched_loop::release_task(rust_task *task) { rust_task * rust_sched_loop::schedule_task() { lock.must_have_lock(); - assert(this); if (running_tasks.length() > 0) { size_t k = isaac_rand(&rctx); - // Look around for a runnable task, starting at k. - for(size_t j = 0; j < running_tasks.length(); ++j) { - size_t i = (j + k) % running_tasks.length(); - return (rust_task *)running_tasks[i]; - } + size_t i = k % running_tasks.length(); + return (rust_task *)running_tasks[i]; } return NULL; } diff --git a/src/rustllvm/RustWrapper.cpp b/src/rustllvm/RustWrapper.cpp index bb00f04a6f976..b01294062a627 100644 --- a/src/rustllvm/RustWrapper.cpp +++ b/src/rustllvm/RustWrapper.cpp @@ -281,7 +281,7 @@ void *RustMCJITMemoryManager::getPointerToNamedFunction(const std::string &Name, if (Name == "mknod") return (void*)(intptr_t)&mknod; #endif - if (Name == "__morestack") return &__morestack; + if (Name == "__morestack" || Name == "___morestack") return &__morestack; const char *NameStr = Name.c_str(); diff --git a/src/test/auxiliary/cci_capture_clause.rs b/src/test/auxiliary/cci_capture_clause.rs index a558de3387629..c22047287e624 100644 --- a/src/test/auxiliary/cci_capture_clause.rs +++ b/src/test/auxiliary/cci_capture_clause.rs @@ -8,13 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[legacy_exports]; - -export foo; - use core::oldcomm::*; -fn foo(x: T) -> Port { +pub fn foo(x: T) -> Port { let p = Port(); let c = Chan(&p); do task::spawn() |copy c, copy x| { diff --git a/src/test/auxiliary/cci_class_cast.rs b/src/test/auxiliary/cci_class_cast.rs index 032a01178f3bb..1225e2fe8a747 100644 --- a/src/test/auxiliary/cci_class_cast.rs +++ b/src/test/auxiliary/cci_class_cast.rs @@ -8,21 +8,16 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[legacy_exports]; +use core::to_str::*; -use to_str::*; -use to_str::ToStr; - -mod kitty { - #[legacy_exports]; - -struct cat { - priv mut meows : uint, - mut how_hungry : int, - name : ~str, -} +pub mod kitty { + pub struct cat { + priv mut meows : uint, + mut how_hungry : int, + name : ~str, + } - impl cat : ToStr { + pub impl cat : ToStr { pure fn to_str() -> ~str { copy self.name } } @@ -37,7 +32,7 @@ struct cat { } - impl cat { + pub impl cat { fn speak() { self.meow(); } fn eat() -> bool { @@ -52,14 +47,14 @@ struct cat { } } } -fn cat(in_x : uint, in_y : int, in_name: ~str) -> cat { - cat { - meows: in_x, - how_hungry: in_y, - name: in_name - } -} + pub fn cat(in_x : uint, in_y : int, in_name: ~str) -> cat { + cat { + meows: in_x, + how_hungry: in_y, + name: in_name + } + } } diff --git a/src/test/auxiliary/issue-2631-a.rs b/src/test/auxiliary/issue-2631-a.rs index 71425659584fd..197ad8402349b 100644 --- a/src/test/auxiliary/issue-2631-a.rs +++ b/src/test/auxiliary/issue-2631-a.rs @@ -10,17 +10,15 @@ #[link(name = "req")]; #[crate_type = "lib"]; -#[legacy_exports]; extern mod std; -use dvec::*; -use dvec::DVec; +use core::dvec::*; use std::map::HashMap; -type header_map = HashMap<~str, @DVec<@~str>>; +pub type header_map = HashMap<~str, @DVec<@~str>>; // the unused ty param is necessary so this gets monomorphized -fn request(req: header_map) { +pub fn request(req: header_map) { let _x = copy *(copy *req.get(~"METHOD"))[0u]; } diff --git a/src/test/auxiliary/noexporttypelib.rs b/src/test/auxiliary/noexporttypelib.rs index 57e2e53ac7255..4e9e3688ecdbf 100644 --- a/src/test/auxiliary/noexporttypelib.rs +++ b/src/test/auxiliary/noexporttypelib.rs @@ -8,7 +8,5 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[legacy_exports]; -export foo; type oint = Option; -fn foo() -> oint { Some(3) } +pub fn foo() -> oint { Some(3) } diff --git a/src/test/auxiliary/static-methods-crate.rs b/src/test/auxiliary/static-methods-crate.rs index 0ae0423e6be69..530309536d9df 100644 --- a/src/test/auxiliary/static-methods-crate.rs +++ b/src/test/auxiliary/static-methods-crate.rs @@ -12,10 +12,8 @@ vers = "0.1")]; #[crate_type = "lib"]; -#[legacy_exports]; -export read, readMaybe; -trait read { +pub trait read { static fn readMaybe(s: ~str) -> Option; } @@ -35,7 +33,7 @@ impl bool: read { } } -fn read(s: ~str) -> T { +pub fn read(s: ~str) -> T { match read::readMaybe(s) { Some(x) => x, _ => fail ~"read failed!" diff --git a/src/test/auxiliary/static_fn_inline_xc_aux.rs b/src/test/auxiliary/static_fn_inline_xc_aux.rs index c85ff320bc82d..2a1cce54783fa 100644 --- a/src/test/auxiliary/static_fn_inline_xc_aux.rs +++ b/src/test/auxiliary/static_fn_inline_xc_aux.rs @@ -16,7 +16,7 @@ pub mod num { } pub mod float { - impl float: num::Num2 { + impl float: ::num::Num2 { #[inline] static pure fn from_int2(n: int) -> float { return n as float; } } diff --git a/src/test/auxiliary/static_fn_trait_xc_aux.rs b/src/test/auxiliary/static_fn_trait_xc_aux.rs index e67d46553cfc2..40659da8dae1b 100644 --- a/src/test/auxiliary/static_fn_trait_xc_aux.rs +++ b/src/test/auxiliary/static_fn_trait_xc_aux.rs @@ -5,7 +5,7 @@ pub mod num { } pub mod float { - impl float: num::Num2 { + impl float: ::num::Num2 { static pure fn from_int2(n: int) -> float { return n as float; } } -} \ No newline at end of file +} diff --git a/src/test/auxiliary/test_comm.rs b/src/test/auxiliary/test_comm.rs index 0ae2dc5340e27..72000f2f0a9f0 100644 --- a/src/test/auxiliary/test_comm.rs +++ b/src/test/auxiliary/test_comm.rs @@ -13,12 +13,8 @@ Could probably be more minimal. */ -#[legacy_exports]; -use libc::size_t; - -export port; -export recv; +use core::libc::size_t; /** @@ -28,12 +24,12 @@ export recv; * transmitted. If a port value is copied, both copies refer to the same * port. Ports may be associated with multiple `chan`s. */ -enum port { +pub enum port { port_t(@port_ptr) } /// Constructs a port -fn port() -> port { +pub fn port() -> port { port_t(@port_ptr(rustrt::new_port(sys::size_of::() as size_t))) } @@ -74,11 +70,11 @@ fn port_ptr(po: *rust_port) -> port_ptr { * Receive from a port. If no data is available on the port then the * task will block until data becomes available. */ -fn recv(p: port) -> T { recv_((**p).po) } +pub fn recv(p: port) -> T { recv_((**p).po) } /// Receive on a raw port pointer -fn recv_(p: *rust_port) -> T { +pub fn recv_(p: *rust_port) -> T { let yield = 0; let yieldp = ptr::addr_of(&yield); let mut res; diff --git a/src/test/bench/core-map.rs b/src/test/bench/core-map.rs index 04c224211b1b8..83ca9fd06c9ed 100644 --- a/src/test/bench/core-map.rs +++ b/src/test/bench/core-map.rs @@ -16,9 +16,9 @@ extern mod std; use std::map; -use mutable::Mut; -use send_map::linear::*; -use io::WriterUtil; +use core::mutable::Mut; +use core::send_map::linear::*; +use core::io::WriterUtil; struct Results { sequential_ints: float, @@ -185,4 +185,4 @@ fn main() { rng, num_keys, &mut results); write_results("libstd::map::hashmap", &results); } -} \ No newline at end of file +} diff --git a/src/test/bench/graph500-bfs.rs b/src/test/bench/graph500-bfs.rs index bd5ce036bb2fd..45fec9edeb96d 100644 --- a/src/test/bench/graph500-bfs.rs +++ b/src/test/bench/graph500-bfs.rs @@ -25,9 +25,9 @@ use std::map::HashMap; use std::deque; use std::deque::Deque; use std::par; -use io::WriterUtil; -use oldcomm::*; -use int::abs; +use core::io::WriterUtil; +use core::oldcomm::*; +use core::int::abs; type node_id = i64; type graph = ~[~[node_id]]; diff --git a/src/test/bench/msgsend-ring.rs b/src/test/bench/msgsend-ring.rs index 62226a1c44de1..43b20ed2db41b 100644 --- a/src/test/bench/msgsend-ring.rs +++ b/src/test/bench/msgsend-ring.rs @@ -14,7 +14,8 @@ // that things will look really good once we get that lock out of the // message path. -use oldcomm::*; +use core::oldcomm::*; +use core::oldcomm; extern mod std; use std::time; diff --git a/src/test/bench/shootout-nbody.rs b/src/test/bench/shootout-nbody.rs index a266025591031..1c0a70c32a2de 100644 --- a/src/test/bench/shootout-nbody.rs +++ b/src/test/bench/shootout-nbody.rs @@ -13,6 +13,8 @@ extern mod std; +use core::os; + // Using sqrt from the standard library is way slower than using libc // directly even though std just calls libc, I guess it must be // because the the indirection through another dynamic linker @@ -45,9 +47,9 @@ fn main() { } mod NBodySystem { - #[legacy_exports]; + use Body; - fn make() -> ~[Body::props] { + pub fn make() -> ~[Body::props] { let mut bodies: ~[Body::props] = ~[Body::sun(), Body::jupiter(), @@ -74,8 +76,7 @@ mod NBodySystem { return bodies; } - fn advance(bodies: &mut [Body::props], dt: float) { - + pub fn advance(bodies: &mut [Body::props], dt: float) { let mut i = 0; while i < 5 { let mut j = i + 1; @@ -95,16 +96,16 @@ mod NBodySystem { } } - fn advance_one(bi: &mut Body::props, - bj: &mut Body::props, - dt: float) unsafe { + pub fn advance_one(bi: &mut Body::props, + bj: &mut Body::props, + dt: float) unsafe { let dx = bi.x - bj.x; let dy = bi.y - bj.y; let dz = bi.z - bj.z; let dSquared = dx * dx + dy * dy + dz * dz; - let distance = libc::sqrt(dSquared); + let distance = ::libc::sqrt(dSquared); let mag = dt / (dSquared * distance); bi.vx -= dx * bj.mass * mag; @@ -116,13 +117,13 @@ mod NBodySystem { bj.vz += dz * bi.mass * mag; } - fn move_(b: &mut Body::props, dt: float) { + pub fn move_(b: &mut Body::props, dt: float) { b.x += dt * b.vx; b.y += dt * b.vy; b.z += dt * b.vz; } - fn energy(bodies: &[Body::props]) -> float unsafe { + pub fn energy(bodies: &[Body::props]) -> float unsafe { let mut dx; let mut dy; let mut dz; @@ -142,7 +143,7 @@ mod NBodySystem { dy = bodies[i].y - bodies[j].y; dz = bodies[i].z - bodies[j].z; - distance = libc::sqrt(dx * dx + dy * dy + dz * dz); + distance = ::libc::sqrt(dx * dx + dy * dy + dz * dz); e -= bodies[i].mass * bodies[j].mass / distance; j += 1; @@ -156,14 +157,14 @@ mod NBodySystem { } mod Body { - #[legacy_exports]; + use Body; - const PI: float = 3.141592653589793; - const SOLAR_MASS: float = 39.478417604357432; + pub const PI: float = 3.141592653589793; + pub const SOLAR_MASS: float = 39.478417604357432; // was 4 * PI * PI originally - const DAYS_PER_YEAR: float = 365.24; + pub const DAYS_PER_YEAR: float = 365.24; - type props = + pub type props = {mut x: float, mut y: float, mut z: float, @@ -172,7 +173,7 @@ mod Body { mut vz: float, mass: float}; - fn jupiter() -> Body::props { + pub fn jupiter() -> Body::props { return {mut x: 4.84143144246472090e+00, mut y: -1.16032004402742839e+00, mut z: -1.03622044471123109e-01, @@ -182,7 +183,7 @@ mod Body { mass: 9.54791938424326609e-04 * SOLAR_MASS}; } - fn saturn() -> Body::props { + pub fn saturn() -> Body::props { return {mut x: 8.34336671824457987e+00, mut y: 4.12479856412430479e+00, mut z: -4.03523417114321381e-01, @@ -192,7 +193,7 @@ mod Body { mass: 2.85885980666130812e-04 * SOLAR_MASS}; } - fn uranus() -> Body::props { + pub fn uranus() -> Body::props { return {mut x: 1.28943695621391310e+01, mut y: -1.51111514016986312e+01, mut z: -2.23307578892655734e-01, @@ -202,7 +203,7 @@ mod Body { mass: 4.36624404335156298e-05 * SOLAR_MASS}; } - fn neptune() -> Body::props { + pub fn neptune() -> Body::props { return {mut x: 1.53796971148509165e+01, mut y: -2.59193146099879641e+01, mut z: 1.79258772950371181e-01, @@ -212,7 +213,7 @@ mod Body { mass: 5.15138902046611451e-05 * SOLAR_MASS}; } - fn sun() -> Body::props { + pub fn sun() -> Body::props { return {mut x: 0.0, mut y: 0.0, mut z: 0.0, @@ -222,7 +223,7 @@ mod Body { mass: SOLAR_MASS}; } - fn offset_momentum(props: &mut Body::props, + pub fn offset_momentum(props: &mut Body::props, px: float, py: float, pz: float) { props.vx = -px / SOLAR_MASS; props.vy = -py / SOLAR_MASS; diff --git a/src/test/bench/task-perf-word-count-generic.rs b/src/test/bench/task-perf-word-count-generic.rs index 56257aa305e47..e24979a4e060b 100644 --- a/src/test/bench/task-perf-word-count-generic.rs +++ b/src/test/bench/task-perf-word-count-generic.rs @@ -22,22 +22,20 @@ extern mod std; -use option = option; -use option::Some; -use option::None; +use core::option; use std::map; use std::map::HashMap; -use hash::Hash; -use io::{ReaderUtil, WriterUtil}; +use core::hash::Hash; +use core::io::{ReaderUtil, WriterUtil}; use std::time; -use oldcomm::Chan; -use oldcomm::Port; -use oldcomm::recv; -use oldcomm::send; -use cmp::Eq; -use to_bytes::IterBytes; +use core::oldcomm::Chan; +use core::oldcomm::Port; +use core::oldcomm::recv; +use core::oldcomm::send; +use core::cmp::Eq; +use core::to_bytes::IterBytes; macro_rules! move_out ( { $x:expr } => { unsafe { let y = move *ptr::addr_of(&($x)); move y } } @@ -117,20 +115,15 @@ fn box(+x: T) -> box { } mod map_reduce { - #[legacy_exports]; - export putter; - export getter; - export mapper; - export reducer; - export map_reduce; + use std::map; - type putter = fn(&K, V); + pub type putter = fn(&K, V); - type mapper = fn~(K1, putter); + pub type mapper = fn~(K1, putter); - type getter = fn() -> Option; + pub type getter = fn() -> Option; - type reducer = fn~(&K, getter); + pub type reducer = fn~(&K, getter); enum ctrl_proto { find_reducer(K, Chan>>), @@ -245,7 +238,7 @@ mod map_reduce { (*reduce)(&key, || get(p, &mut ref_count, &mut is_done) ); } - fn map_reduce( + pub fn map_reduce( map: mapper, reduce: reducer, inputs: ~[K1]) diff --git a/src/test/compile-fail/borrowck-autoref-3261.rs b/src/test/compile-fail/borrowck-autoref-3261.rs index 6c6f59d00ea98..b21114d9222c3 100644 --- a/src/test/compile-fail/borrowck-autoref-3261.rs +++ b/src/test/compile-fail/borrowck-autoref-3261.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use either::*; +use core::either::*; enum X = Either<(uint,uint),fn()>; impl &X { fn with(blk: fn(x: &Either<(uint,uint),fn()>)) { @@ -26,4 +26,4 @@ fn main() { _ => fail } } -} \ No newline at end of file +} diff --git a/src/test/compile-fail/issue-1697.rs b/src/test/compile-fail/issue-1697.rs index a0d2536d85f0e..2a64666d94ca6 100644 --- a/src/test/compile-fail/issue-1697.rs +++ b/src/test/compile-fail/issue-1697.rs @@ -10,8 +10,7 @@ // Testing that we don't fail abnormally after hitting the errors -use unresolved::*; //~ ERROR unresolved name -//~^ ERROR failed to resolve import +use unresolved::*; //~ ERROR unresolved import fn main() { } diff --git a/src/test/compile-fail/issue-2766-a.rs b/src/test/compile-fail/issue-2766-a.rs index c0b27789977ef..0b63ae5b1bad3 100644 --- a/src/test/compile-fail/issue-2766-a.rs +++ b/src/test/compile-fail/issue-2766-a.rs @@ -8,16 +8,17 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -mod stream { - #[legacy_exports]; - enum Stream { send(T, server::Stream), } - mod server { - #[legacy_exports]; +pub mod stream { + pub enum Stream { send(T, ::stream::server::Stream), } + pub mod server { + use core::option; + use core::pipes; + impl Stream { - fn recv() -> extern fn(+v: Stream) -> stream::Stream { + pub fn recv() -> extern fn(+v: Stream) -> ::stream::Stream { // resolve really should report just one error here. // Change the test case when it changes. - fn recv(+pipe: Stream) -> stream::Stream { //~ ERROR attempt to use a type argument out of scope + pub fn recv(+pipe: Stream) -> ::stream::Stream { //~ ERROR attempt to use a type argument out of scope //~^ ERROR use of undeclared type name //~^^ ERROR attempt to use a type argument out of scope //~^^^ ERROR use of undeclared type name @@ -26,7 +27,8 @@ mod stream { recv } } - type Stream = pipes::RecvPacket>; + + pub type Stream = pipes::RecvPacket<::stream::Stream>; } } diff --git a/src/test/compile-fail/issue-3477.rs b/src/test/compile-fail/issue-3477.rs new file mode 100644 index 0000000000000..7e189348db354 --- /dev/null +++ b/src/test/compile-fail/issue-3477.rs @@ -0,0 +1,3 @@ +fn main() { + let _p: char = 100; //~ ERROR mismatched types: expected `char` but found +} \ No newline at end of file diff --git a/src/test/compile-fail/name-clash-nullary.rs b/src/test/compile-fail/name-clash-nullary.rs index 9947c882a5854..e64d651dab2b4 100644 --- a/src/test/compile-fail/name-clash-nullary.rs +++ b/src/test/compile-fail/name-clash-nullary.rs @@ -9,7 +9,7 @@ // except according to those terms. // error-pattern:declaration of `None` shadows -use option::*; +use core::option::*; fn main() { let None: int = 42; diff --git a/src/test/compile-fail/no-capture-arc.rs b/src/test/compile-fail/no-capture-arc.rs index 98220195e613d..7dc3c247ea48e 100644 --- a/src/test/compile-fail/no-capture-arc.rs +++ b/src/test/compile-fail/no-capture-arc.rs @@ -12,7 +12,7 @@ extern mod std; use std::arc; -use oldcomm::*; +use core::oldcomm::*; fn main() { let v = ~[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; diff --git a/src/test/compile-fail/no-reuse-move-arc.rs b/src/test/compile-fail/no-reuse-move-arc.rs index 8cb8f31c48976..8a7c37649d2ed 100644 --- a/src/test/compile-fail/no-reuse-move-arc.rs +++ b/src/test/compile-fail/no-reuse-move-arc.rs @@ -10,7 +10,7 @@ extern mod std; use std::arc; -use oldcomm::*; +use core::oldcomm::*; fn main() { let v = ~[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; diff --git a/src/test/run-pass-fulldeps/qquote.rs b/src/test/run-pass-fulldeps/qquote.rs index 3345dcaaad02a..4e4df552a2ecd 100644 --- a/src/test/run-pass-fulldeps/qquote.rs +++ b/src/test/run-pass-fulldeps/qquote.rs @@ -15,7 +15,7 @@ extern mod std; extern mod syntax; -use io::*; +use core::io::*; use syntax::diagnostic; use syntax::ast; diff --git a/src/test/run-pass/auto-encode.rs b/src/test/run-pass/auto-encode.rs index 555171f9d5f30..2bd00ddc4ef14 100644 --- a/src/test/run-pass/auto-encode.rs +++ b/src/test/run-pass/auto-encode.rs @@ -26,12 +26,12 @@ use std::serialize::{Encodable, Decodable}; use std::prettyprint; use std::time; -fn test_prettyprint>( +fn test_prettyprint>( a: &A, expected: &~str ) { let s = do io::with_str_writer |w| { - a.encode(&prettyprint::Encoder(w)) + a.encode(&prettyprint::Serializer(w)) }; debug!("s == %?", s); assert s == *expected; diff --git a/src/test/run-pass/cci_capture_clause.rs b/src/test/run-pass/cci_capture_clause.rs index be64fcd8992fa..a439d2af8fc02 100644 --- a/src/test/run-pass/cci_capture_clause.rs +++ b/src/test/run-pass/cci_capture_clause.rs @@ -18,7 +18,7 @@ extern mod cci_capture_clause; -use oldcomm::recv; +use core::oldcomm::recv; fn main() { cci_capture_clause::foo(()).recv() diff --git a/src/test/run-pass/class-cast-to-trait-cross-crate-2.rs b/src/test/run-pass/class-cast-to-trait-cross-crate-2.rs index f84332a6382b5..5d53453ffc005 100644 --- a/src/test/run-pass/class-cast-to-trait-cross-crate-2.rs +++ b/src/test/run-pass/class-cast-to-trait-cross-crate-2.rs @@ -11,7 +11,7 @@ // xfail-fast // aux-build:cci_class_cast.rs extern mod cci_class_cast; -use to_str::ToStr; +use core::to_str::ToStr; use cci_class_cast::kitty::*; fn print_out(thing: T, expected: ~str) { diff --git a/src/test/run-pass/class-separate-impl.rs b/src/test/run-pass/class-separate-impl.rs index 23c1e6792a415..eb3728f2c6fc3 100644 --- a/src/test/run-pass/class-separate-impl.rs +++ b/src/test/run-pass/class-separate-impl.rs @@ -9,8 +9,7 @@ // except according to those terms. // xfail-fast -use to_str::*; -use to_str::ToStr; +use core::to_str::*; struct cat { priv mut meows : uint, diff --git a/src/test/run-pass/export-non-interference3.rs b/src/test/run-pass/export-non-interference3.rs index 85d1a33826c5b..3b4ab709f6d78 100644 --- a/src/test/run-pass/export-non-interference3.rs +++ b/src/test/run-pass/export-non-interference3.rs @@ -8,18 +8,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -mod foo { - #[legacy_exports]; - export x; - - fn x() { bar::x(); } +pub mod foo { + pub fn x() { ::bar::x(); } } -mod bar { - #[legacy_exports]; - export x; - - fn x() { debug!("x"); } +pub mod bar { + pub fn x() { debug!("x"); } } fn main() { foo::x(); } diff --git a/src/test/run-pass/hashmap-memory.rs b/src/test/run-pass/hashmap-memory.rs index c8fbb0dd7418b..577ac67dd6a69 100644 --- a/src/test/run-pass/hashmap-memory.rs +++ b/src/test/run-pass/hashmap-memory.rs @@ -28,14 +28,12 @@ use oldcomm::recv; fn map(filename: ~str, emit: map_reduce::putter) { emit(filename, ~"1"); } mod map_reduce { - #[legacy_exports]; - export putter; - export mapper; - export map_reduce; + use std::map; + use std::map::HashMap; - type putter = fn@(~str, ~str); + pub type putter = fn@(~str, ~str); - type mapper = extern fn(~str, putter); + pub type mapper = extern fn(~str, putter); enum ctrl_proto { find_reducer(~[u8], Chan), mapper_done, } @@ -70,7 +68,7 @@ mod map_reduce { send(ctrl, mapper_done); } - fn map_reduce(inputs: ~[~str]) { + pub fn map_reduce(inputs: ~[~str]) { let ctrl = Port(); // This task becomes the master control task. It spawns others diff --git a/src/test/run-pass/import-glob-crate.rs b/src/test/run-pass/import-glob-crate.rs index 0d3d08b3a39ac..eba69134c4f0a 100644 --- a/src/test/run-pass/import-glob-crate.rs +++ b/src/test/run-pass/import-glob-crate.rs @@ -12,7 +12,7 @@ extern mod std; -use vec::*; +use core::vec::*; fn main() { let mut v = from_elem(0u, 0); diff --git a/src/test/run-pass/intrinsic-alignment.rs b/src/test/run-pass/intrinsic-alignment.rs index 6239df9827845..01da68ec3426f 100644 --- a/src/test/run-pass/intrinsic-alignment.rs +++ b/src/test/run-pass/intrinsic-alignment.rs @@ -21,26 +21,24 @@ extern mod rusti { #[cfg(target_os = "macos")] #[cfg(target_os = "freebsd")] mod m { - #[legacy_exports]; #[cfg(target_arch = "x86")] - fn main() { - assert rusti::pref_align_of::() == 8u; - assert rusti::min_align_of::() == 4u; + pub fn main() { + assert ::rusti::pref_align_of::() == 8u; + assert ::rusti::min_align_of::() == 4u; } #[cfg(target_arch = "x86_64")] - fn main() { - assert rusti::pref_align_of::() == 8u; - assert rusti::min_align_of::() == 8u; + pub fn main() { + assert ::rusti::pref_align_of::() == 8u; + assert ::rusti::min_align_of::() == 8u; } } #[cfg(target_os = "win32")] mod m { - #[legacy_exports]; #[cfg(target_arch = "x86")] - fn main() { - assert rusti::pref_align_of::() == 8u; - assert rusti::min_align_of::() == 8u; + pub fn main() { + assert ::rusti::pref_align_of::() == 8u; + assert ::rusti::min_align_of::() == 8u; } } diff --git a/src/test/run-pass/issue-2214.rs b/src/test/run-pass/issue-2214.rs index 05c2595931eb1..efa6d05f9da76 100644 --- a/src/test/run-pass/issue-2214.rs +++ b/src/test/run-pass/issue-2214.rs @@ -10,8 +10,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use libc::{c_double, c_int}; -use f64::*; +use core::cast; +use core::libc::{c_double, c_int}; +use core::f64::*; fn to_c_int(v: &mut int) -> &mut c_int unsafe { cast::reinterpret_cast(&v) @@ -24,13 +25,12 @@ fn lgamma(n: c_double, value: &mut int) -> c_double { #[link_name = "m"] #[abi = "cdecl"] extern mod m { - #[legacy_exports]; #[cfg(unix)] - #[link_name="lgamma_r"] fn lgamma(n: c_double, sign: &mut c_int) + #[link_name="lgamma_r"] pub fn lgamma(n: c_double, sign: &mut c_int) -> c_double; #[cfg(windows)] - #[link_name="__lgamma_r"] fn lgamma(n: c_double, - sign: &mut c_int) -> c_double; + #[link_name="__lgamma_r"] pub fn lgamma(n: c_double, + sign: &mut c_int) -> c_double; } diff --git a/src/test/run-pass/issue-2718.rs b/src/test/run-pass/issue-2718.rs index 632fe348d8d94..71afce93421e0 100644 --- a/src/test/run-pass/issue-2718.rs +++ b/src/test/run-pass/issue-2718.rs @@ -11,31 +11,30 @@ // except according to those terms. // tjc: I don't know why -mod pipes { - #[legacy_exports]; - use cast::{forget, transmute}; +pub mod pipes { + use core::cast::{forget, transmute}; - enum state { + pub enum state { empty, full, blocked, terminated } - impl state : cmp::Eq { + pub impl state : cmp::Eq { pure fn eq(&self, other: &state) -> bool { ((*self) as uint) == ((*other) as uint) } pure fn ne(&self, other: &state) -> bool { !(*self).eq(other) } } - type packet = { + pub type packet = { mut state: state, mut blocked_task: Option, mut payload: Option }; - fn packet() -> *packet unsafe { + pub fn packet() -> *packet unsafe { let p: *packet = cast::transmute(~{ mut state: empty, mut blocked_task: None::, @@ -46,31 +45,30 @@ mod pipes { #[abi = "rust-intrinsic"] mod rusti { - #[legacy_exports]; - fn atomic_xchg(_dst: &mut int, _src: int) -> int { fail; } - fn atomic_xchg_acq(_dst: &mut int, _src: int) -> int { fail; } - fn atomic_xchg_rel(_dst: &mut int, _src: int) -> int { fail; } + pub fn atomic_xchg(_dst: &mut int, _src: int) -> int { fail; } + pub fn atomic_xchg_acq(_dst: &mut int, _src: int) -> int { fail; } + pub fn atomic_xchg_rel(_dst: &mut int, _src: int) -> int { fail; } } // We should consider moving this to core::unsafe, although I // suspect graydon would want us to use void pointers instead. - unsafe fn uniquify(+x: *T) -> ~T { + pub unsafe fn uniquify(+x: *T) -> ~T { unsafe { cast::transmute(move x) } } - fn swap_state_acq(+dst: &mut state, src: state) -> state { + pub fn swap_state_acq(+dst: &mut state, src: state) -> state { unsafe { transmute(rusti::atomic_xchg_acq(transmute(move dst), src as int)) } } - fn swap_state_rel(+dst: &mut state, src: state) -> state { + pub fn swap_state_rel(+dst: &mut state, src: state) -> state { unsafe { transmute(rusti::atomic_xchg_rel(transmute(move dst), src as int)) } } - fn send(-p: send_packet, -payload: T) { + pub fn send(-p: send_packet, -payload: T) { let p = p.unwrap(); let p = unsafe { uniquify(p) }; assert (*p).payload.is_none(); @@ -96,7 +94,7 @@ mod pipes { } } - fn recv(-p: recv_packet) -> Option { + pub fn recv(-p: recv_packet) -> Option { let p = p.unwrap(); let p = unsafe { uniquify(p) }; loop { @@ -117,7 +115,7 @@ mod pipes { } } - fn sender_terminate(p: *packet) { + pub fn sender_terminate(p: *packet) { let p = unsafe { uniquify(p) }; match swap_state_rel(&mut (*p).state, terminated) { empty | blocked => { @@ -134,7 +132,7 @@ mod pipes { } } - fn receiver_terminate(p: *packet) { + pub fn receiver_terminate(p: *packet) { let p = unsafe { uniquify(p) }; match swap_state_rel(&mut (*p).state, terminated) { empty => { @@ -151,11 +149,11 @@ mod pipes { } } - struct send_packet { + pub struct send_packet { mut p: Option<*packet>, } - impl send_packet : Drop { + pub impl send_packet : Drop { fn finalize(&self) { if self.p != None { let mut p = None; @@ -165,7 +163,7 @@ mod pipes { } } - impl send_packet { + pub impl send_packet { fn unwrap() -> *packet { let mut p = None; p <-> self.p; @@ -173,17 +171,17 @@ mod pipes { } } - fn send_packet(p: *packet) -> send_packet { + pub fn send_packet(p: *packet) -> send_packet { send_packet { p: Some(p) } } - struct recv_packet { + pub struct recv_packet { mut p: Option<*packet>, } - impl recv_packet : Drop { + pub impl recv_packet : Drop { fn finalize(&self) { if self.p != None { let mut p = None; @@ -193,7 +191,7 @@ mod pipes { } } - impl recv_packet { + pub impl recv_packet { fn unwrap() -> *packet { let mut p = None; p <-> self.p; @@ -201,25 +199,27 @@ mod pipes { } } - fn recv_packet(p: *packet) -> recv_packet { + pub fn recv_packet(p: *packet) -> recv_packet { recv_packet { p: Some(p) } } - fn entangle() -> (send_packet, recv_packet) { + pub fn entangle() -> (send_packet, recv_packet) { let p = packet(); (send_packet(p), recv_packet(p)) } } -mod pingpong { - #[legacy_exports]; - enum ping = pipes::send_packet; - enum pong = pipes::send_packet; +pub mod pingpong { + use core::cast; + use core::ptr; - fn liberate_ping(-p: ping) -> pipes::send_packet unsafe { - let addr : *pipes::send_packet = match &p { + pub enum ping = ::pipes::send_packet; + pub enum pong = ::pipes::send_packet; + + pub fn liberate_ping(-p: ping) -> ::pipes::send_packet unsafe { + let addr : *::pipes::send_packet = match &p { &ping(ref x) => { cast::transmute(ptr::addr_of(x)) } }; let liberated_value = move *addr; @@ -227,8 +227,8 @@ mod pingpong { move liberated_value } - fn liberate_pong(-p: pong) -> pipes::send_packet unsafe { - let addr : *pipes::send_packet = match &p { + pub fn liberate_pong(-p: pong) -> ::pipes::send_packet unsafe { + let addr : *::pipes::send_packet = match &p { &pong(ref x) => { cast::transmute(ptr::addr_of(x)) } }; let liberated_value = move *addr; @@ -236,24 +236,26 @@ mod pingpong { move liberated_value } - fn init() -> (client::ping, server::ping) { - pipes::entangle() + pub fn init() -> (client::ping, server::ping) { + ::pipes::entangle() } - mod client { - #[legacy_exports]; - type ping = pipes::send_packet; - type pong = pipes::recv_packet; + pub mod client { + use core::option; + use pingpong; + + pub type ping = ::pipes::send_packet; + pub type pong = ::pipes::recv_packet; - fn do_ping(-c: ping) -> pong { - let (sp, rp) = pipes::entangle(); + pub fn do_ping(-c: ping) -> pong { + let (sp, rp) = ::pipes::entangle(); - pipes::send(move c, ping(move sp)); + ::pipes::send(move c, ping(move sp)); move rp } - fn do_pong(-c: pong) -> (ping, ()) { - let packet = pipes::recv(move c); + pub fn do_pong(-c: pong) -> (ping, ()) { + let packet = ::pipes::recv(move c); if packet.is_none() { fail ~"sender closed the connection" } @@ -261,22 +263,23 @@ mod pingpong { } } - mod server { - #[legacy_exports]; - type ping = pipes::recv_packet; - type pong = pipes::send_packet; + pub mod server { + use pingpong; + + pub type ping = ::pipes::recv_packet; + pub type pong = ::pipes::send_packet; - fn do_ping(-c: ping) -> (pong, ()) { - let packet = pipes::recv(move c); + pub fn do_ping(-c: ping) -> (pong, ()) { + let packet = ::pipes::recv(move c); if packet.is_none() { fail ~"sender closed the connection" } (liberate_ping(option::unwrap(move packet)), ()) } - fn do_pong(-c: pong) -> ping { - let (sp, rp) = pipes::entangle(); - pipes::send(move c, pong(move sp)); + pub fn do_pong(-c: pong) -> ping { + let (sp, rp) = ::pipes::entangle(); + ::pipes::send(move c, pong(move sp)); move rp } } diff --git a/src/test/run-pass/issue-3559 b/src/test/run-pass/issue-3559 index 406e055884a5d..505b9b65512f2 100755 Binary files a/src/test/run-pass/issue-3559 and b/src/test/run-pass/issue-3559 differ diff --git a/src/test/run-pass/issue-3559.rs b/src/test/run-pass/issue-3559.rs index ee68a546cafed..da7746681f281 100644 --- a/src/test/run-pass/issue-3559.rs +++ b/src/test/run-pass/issue-3559.rs @@ -12,7 +12,8 @@ // rustc --test map_to_str.rs && ./map_to_str extern mod std; -use io::{WriterUtil}; + +use core::io::{WriterUtil}; use std::map::*; #[cfg(test)] diff --git a/src/test/run-pass/issue-3656.rs b/src/test/run-pass/issue-3656.rs index bd79e287098c2..66c2a4672b4b0 100644 --- a/src/test/run-pass/issue-3656.rs +++ b/src/test/run-pass/issue-3656.rs @@ -13,7 +13,7 @@ // Incorrect struct size computation in the FFI, because of not taking // the alignment of elements into account. -use libc::*; +use core::libc::*; struct KEYGEN { hash_algorithm: [c_uint * 2], diff --git a/src/test/run-pass/pipe-pingpong-bounded.rs b/src/test/run-pass/pipe-pingpong-bounded.rs index 8589bbb8e257f..803f7f06b512c 100644 --- a/src/test/run-pass/pipe-pingpong-bounded.rs +++ b/src/test/run-pass/pipe-pingpong-bounded.rs @@ -18,17 +18,15 @@ // This was generated initially by the pipe compiler, but it's been // modified in hopefully straightforward ways. mod pingpong { - #[legacy_exports]; - use pipes::*; + use core::pipes::*; + use core::ptr; - type packets = { - // This is probably a resolve bug, I forgot to export packet, - // but since I didn't import pipes::*, it worked anyway. + pub type packets = { ping: Packet, pong: Packet, }; - fn init() -> (client::ping, server::ping) { + pub fn init() -> (client::ping, server::ping) { let buffer = ~{ header: BufferHeader(), data: { @@ -42,50 +40,51 @@ mod pingpong { ptr::addr_of(&(data.ping)) } } - enum ping = server::pong; - enum pong = client::ping; - mod client { - #[legacy_exports]; - fn ping(+pipe: ping) -> pong { + pub enum ping = server::pong; + pub enum pong = client::ping; + pub mod client { + use core::ptr; + + pub fn ping(+pipe: ping) -> pong { { let b = pipe.reuse_buffer(); let s = SendPacketBuffered(ptr::addr_of(&(b.buffer.data.pong))); let c = RecvPacketBuffered(ptr::addr_of(&(b.buffer.data.pong))); - let message = pingpong::ping(move s); - pipes::send(move pipe, move message); + let message = ::pingpong::ping(move s); + ::pipes::send(move pipe, move message); move c } } - type ping = pipes::SendPacketBuffered; - type pong = pipes::RecvPacketBuffered; + pub type ping = pipes::SendPacketBuffered<::pingpong::ping, + ::pingpong::packets>; + pub type pong = pipes::RecvPacketBuffered<::pingpong::pong, + ::pingpong::packets>; } - mod server { - #[legacy_exports]; - type ping = pipes::RecvPacketBuffered; - fn pong(+pipe: pong) -> ping { + pub mod server { + use core::ptr; + + pub type ping = pipes::RecvPacketBuffered<::pingpong::ping, + ::pingpong::packets>; + pub fn pong(+pipe: pong) -> ping { { let b = pipe.reuse_buffer(); let s = SendPacketBuffered(ptr::addr_of(&(b.buffer.data.ping))); let c = RecvPacketBuffered(ptr::addr_of(&(b.buffer.data.ping))); - let message = pingpong::pong(move s); - pipes::send(move pipe, move message); + let message = ::pingpong::pong(move s); + ::pipes::send(move pipe, move message); move c } } - type pong = pipes::SendPacketBuffered; + pub type pong = pipes::SendPacketBuffered<::pingpong::pong, + ::pingpong::packets>; } } mod test { - #[legacy_exports]; use pipes::recv; use pingpong::{ping, pong}; - fn client(-chan: pingpong::client::ping) { + pub fn client(-chan: ::pingpong::client::ping) { use pingpong::client; let chan = client::ping(move chan); return; @@ -94,7 +93,7 @@ mod test { log(error, "Received pong"); } - fn server(-chan: pingpong::server::ping) { + pub fn server(-chan: ::pingpong::server::ping) { use pingpong::server; let ping(chan) = recv(move chan); return; @@ -105,7 +104,7 @@ mod test { } fn main() { - let (client_, server_) = pingpong::init(); + let (client_, server_) = ::pingpong::init(); let client_ = ~mut Some(move client_); let server_ = ~mut Some(move server_); do task::spawn |move client_| { diff --git a/src/test/run-pass/pipe-pingpong-proto.rs b/src/test/run-pass/pipe-pingpong-proto.rs index 88db8953b8c33..7fb77cba3bde9 100644 --- a/src/test/run-pass/pipe-pingpong-proto.rs +++ b/src/test/run-pass/pipe-pingpong-proto.rs @@ -12,6 +12,7 @@ // An example to make sure the protocol parsing syntax extension works. +use core::option; proto! pingpong ( ping:send { @@ -24,11 +25,10 @@ proto! pingpong ( ) mod test { - #[legacy_exports]; - use pipes::recv; + use core::pipes::recv; use pingpong::{ping, pong}; - fn client(-chan: pingpong::client::ping) { + pub fn client(-chan: ::pingpong::client::ping) { use pingpong::client; let chan = client::ping(move chan); @@ -37,7 +37,7 @@ mod test { log(error, ~"Received pong"); } - fn server(-chan: pingpong::server::ping) { + pub fn server(-chan: ::pingpong::server::ping) { use pingpong::server; let ping(chan) = recv(move chan); diff --git a/src/test/run-pass/trait-static-method-overwriting.rs b/src/test/run-pass/trait-static-method-overwriting.rs index 17309d27900f8..c2751145e6d0e 100644 --- a/src/test/run-pass/trait-static-method-overwriting.rs +++ b/src/test/run-pass/trait-static-method-overwriting.rs @@ -17,7 +17,7 @@ mod base { dummy: (), } - pub impl Foo : base::HasNew { + pub impl Foo : ::base::HasNew { static pure fn new() -> Foo { unsafe { io::println("Foo"); } Foo { dummy: () } @@ -28,7 +28,7 @@ mod base { dummy: (), } - pub impl Bar : base::HasNew { + pub impl Bar : ::base::HasNew { static pure fn new() -> Bar { unsafe { io::println("Bar"); } Bar { dummy: () }