diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/doc/guide-crates.md | 16 | ||||
| -rw-r--r-- | src/doc/guide-error-handling.md | 6 | ||||
| -rw-r--r-- | src/doc/guide-ownership.md | 4 | ||||
| -rw-r--r-- | src/doc/guide-pointers.md | 4 | ||||
| -rw-r--r-- | src/doc/guide.md | 70 | ||||
| -rw-r--r-- | src/doc/intro.md | 8 | ||||
| -rw-r--r-- | src/libcore/cmp.rs | 2 | ||||
| -rw-r--r-- | src/libcore/option.rs | 3 | ||||
| -rw-r--r-- | src/libstd/os.rs | 6 | ||||
| -rw-r--r-- | src/test/compile-fail/lifetime-elision-return-type-requires-explicit-lifetime.rs | 1 | ||||
| -rw-r--r-- | src/test/run-pass/ufcs-type-params.rs | 2 |
11 files changed, 62 insertions, 60 deletions
diff --git a/src/doc/guide-crates.md b/src/doc/guide-crates.md index 4d3e5e7d8fa..b567c747d6f 100644 --- a/src/doc/guide-crates.md +++ b/src/doc/guide-crates.md @@ -32,7 +32,7 @@ two languages for those phrases to be in. We'll use this module layout: +---------+ | +-----------+ | +---| farewells | +---------+ | +-----------+ -| phrases |---+ +| phrases |---+ +---------+ | +-----------+ | +---| greetings | +----------+ | +-----------+ @@ -219,7 +219,7 @@ Put this in `src/english/greetings.rs`: fn hello() -> String { "Hello!".to_string() -} +} ``` Put this in `src/english/farewells.rs`: @@ -229,7 +229,7 @@ Put this in `src/english/farewells.rs`: fn goodbye() -> String { "Goodbye.".to_string() -} +} ``` Put this in `src/japanese/greetings.rs`: @@ -239,7 +239,7 @@ Put this in `src/japanese/greetings.rs`: fn hello() -> String { "こんにちは".to_string() -} +} ``` Of course, you can copy and paste this from this web page, or just type @@ -253,7 +253,7 @@ Put this in `src/japanese/farewells.rs`: fn goodbye() -> String { "さようなら".to_string() -} +} ``` (This is "Sayoonara", if you're curious.) @@ -381,11 +381,11 @@ $ cargo run /home/you/projects/phrases/src/japanese/greetings.rs:1:1: 3:2 warning: code is never used: `hello`, #[warn(dead_code)] on by default /home/you/projects/phrases/src/japanese/greetings.rs:1 fn hello() -> String { /home/you/projects/phrases/src/japanese/greetings.rs:2 "こんにちは".to_string() -/home/you/projects/phrases/src/japanese/greetings.rs:3 } +/home/you/projects/phrases/src/japanese/greetings.rs:3 } /home/you/projects/phrases/src/japanese/farewells.rs:1:1: 3:2 warning: code is never used: `goodbye`, #[warn(dead_code)] on by default /home/you/projects/phrases/src/japanese/farewells.rs:1 fn goodbye() -> String { /home/you/projects/phrases/src/japanese/farewells.rs:2 "さようなら".to_string() -/home/you/projects/phrases/src/japanese/farewells.rs:3 } +/home/you/projects/phrases/src/japanese/farewells.rs:3 } Running `target/phrases` Hello in English: Hello! Goodbye in English: Goodbye. @@ -452,7 +452,7 @@ fn main() { Rust will give us a compile-time error: -```{ignore} +```{notrust} Compiling phrases v0.0.1 (file:///home/you/projects/phrases) /home/you/projects/phrases/src/main.rs:4:5: 4:40 error: a value named `hello` has already been imported in this module /home/you/projects/phrases/src/main.rs:4 use phrases::japanese::greetings::hello; diff --git a/src/doc/guide-error-handling.md b/src/doc/guide-error-handling.md index 6bb91845f5d..71ca8913ab3 100644 --- a/src/doc/guide-error-handling.md +++ b/src/doc/guide-error-handling.md @@ -2,7 +2,7 @@ > The best-laid plans of mice and men > Often go awry -> +> > "Tae a Moose", Robert Burns Sometimes, things just go wrong. It's important to have a plan for when the @@ -76,7 +76,7 @@ fn main() { This will give us an error: -```{ignore} +```{notrust} error: non-exhaustive patterns: `_` not covered [E0004] ``` @@ -189,7 +189,7 @@ panic!("boom"); gives -```{ignore} +```{notrust} task '<main>' panicked at 'boom', hello.rs:2 ``` diff --git a/src/doc/guide-ownership.md b/src/doc/guide-ownership.md index ff156d9605e..aebafebf98e 100644 --- a/src/doc/guide-ownership.md +++ b/src/doc/guide-ownership.md @@ -130,7 +130,7 @@ fn add_one(mut num: Box<int>) { This does not compile, and gives us an error: -```{ignore} +```{notrust} error: use of moved value: `x` println!("{}", x); ^ @@ -406,7 +406,7 @@ fn main() { We try to make four `Wheel`s, each with a `Car` that it's attached to. But the compiler knows that on the second iteration of the loop, there's a problem: -```{ignore} +```{notrust} error: use of moved value: `car` Wheel { size: 360, owner: car }; ^~~ diff --git a/src/doc/guide-pointers.md b/src/doc/guide-pointers.md index dbb8d6b007d..206df711c1a 100644 --- a/src/doc/guide-pointers.md +++ b/src/doc/guide-pointers.md @@ -84,7 +84,7 @@ println!("{}", x + z); This gives us an error: -```{ignore} +```{notrust} hello.rs:6:24: 6:25 error: mismatched types: expected `int` but found `&int` (expected int but found &-ptr) hello.rs:6 println!("{}", x + z); ^ @@ -398,7 +398,7 @@ fn main() { It gives this error: -```{ignore} +```{notrust} test.rs:5:8: 5:10 error: cannot assign to `*x` because it is borrowed test.rs:5 *x -= 1; ^~ diff --git a/src/doc/guide.md b/src/doc/guide.md index 810d3990812..21043cfef14 100644 --- a/src/doc/guide.md +++ b/src/doc/guide.md @@ -426,7 +426,7 @@ x = 10i; It will give you this error: -```{ignore} +```{notrust} error: re-assignment of immutable variable `x` x = 10i; ^~~~~~~ @@ -486,7 +486,7 @@ fn main() { You can use `cargo build` on the command line to build it. You'll get a warning, but it will still print "Hello, world!": -```{ignore} +```{notrust} Compiling hello_world v0.0.1 (file:///home/you/projects/hello_world) src/main.rs:2:9: 2:10 warning: unused variable: `x`, #[warn(unused_variable)] on by default src/main.rs:2 let x: int; @@ -664,7 +664,7 @@ let y: int = if x == 5i { 10i; } else { 15i; }; Note the semicolons after the 10 and 15. Rust will give us the following error: -```{ignore} +```{notrust} error: mismatched types: expected `int` but found `()` (expected int but found ()) ``` @@ -747,7 +747,7 @@ fn print_number(x, y) { You get this error: -```{ignore} +```{notrust} hello.rs:5:18: 5:19 error: expected `:` but found `,` hello.rs:5 fn print_number(x, y) { ``` @@ -1246,7 +1246,7 @@ So what's the big advantage here? Well, there are a few. First of all, `match` enforces 'exhaustiveness checking.' Do you see that last arm, the one with the underscore (`_`)? If we remove that arm, Rust will give us an error: -```{ignore} +```{notrust} error: non-exhaustive patterns: `_` not covered ``` @@ -1898,7 +1898,7 @@ Before we move on, let me show you one more Cargo command: `run`. `cargo run` is kind of like `cargo build`, but it also then runs the produced executable. Try it out: -```{ignore} +```{notrust} $ cargo run Compiling guessing_game v0.0.1 (file:///home/you/projects/guessing_game) Running `target/guessing_game` @@ -1996,7 +1996,7 @@ for this example, it is not important. Let's try to compile this using `cargo build`: -```{no_run} +```{notrust} $ cargo build Compiling guessing_game v0.0.1 (file:///home/you/projects/guessing_game) src/main.rs:7:26: 7:34 error: the type of this value must be known in this context @@ -2044,7 +2044,7 @@ fn main() { Try running our new program a few times: -```{ignore} +```{notrust} $ cargo run Compiling guessing_game v0.0.1 (file:///home/you/projects/guessing_game) Running `target/guessing_game` @@ -2097,7 +2097,7 @@ fn main() { And trying it out: -```{ignore} +```{notrust} $ cargo run Compiling guessing_game v0.0.1 (file:///home/you/projects/guessing_game) Running `target/guessing_game` @@ -2152,7 +2152,7 @@ fn cmp(a: int, b: int) -> Ordering { If we try to compile, we'll get some errors: -```{ignore} +```{notrust} $ cargo build Compiling guessing_game v0.0.1 (file:///home/you/projects/guessing_game) src/main.rs:20:15: 20:20 error: mismatched types: expected `int` but found `collections::string::String` (expected int but found struct collections::string::String) @@ -2206,7 +2206,7 @@ fn cmp(a: uint, b: uint) -> Ordering { And try compiling again: -```{ignore} +```{notrust} $ cargo build Compiling guessing_game v0.0.1 (file:///home/you/projects/guessing_game) src/main.rs:20:15: 20:20 error: mismatched types: expected `uint` but found `collections::string::String` (expected uint but found struct collections::string::String) @@ -2219,7 +2219,7 @@ This error is similar to the last one: we expected to get a `uint`, but we got a `String` instead! That's because our `input` variable is coming from the standard input, and you can guess anything. Try it: -```{ignore} +```{notrust} $ ./target/guessing_game Guess the number! The secret number is: 73 @@ -2303,7 +2303,7 @@ fn cmp(a: uint, b: uint) -> Ordering { Let's try it out! -```{ignore} +```{notrust} $ cargo build Compiling guessing_game v0.0.1 (file:///home/you/projects/guessing_game) src/main.rs:22:15: 22:24 error: mismatched types: expected `uint` but found `core::option::Option<uint>` (expected uint but found enum core::option::Option) @@ -2362,7 +2362,7 @@ fn cmp(a: uint, b: uint) -> Ordering { We use a `match` to either give us the `uint` inside of the `Option`, or we print an error message and return. Let's give this a shot: -```{ignore} +```{notrust} $ cargo run Compiling guessing_game v0.0.1 (file:///home/you/projects/guessing_game) Running `target/guessing_game` @@ -2427,7 +2427,7 @@ fn cmp(a: uint, b: uint) -> Ordering { Let's try it! -```{ignore} +```{notrust} $ cargo run Compiling guessing_game v0.0.1 (file:///home/you/projects/guessing_game) Running `target/guessing_game` @@ -2504,7 +2504,7 @@ fn cmp(a: uint, b: uint) -> Ordering { And try it out. But wait, didn't we just add an infinite loop? Yup. Remember that `return`? If we give a non-number answer, we'll `return` and quit. Observe: -```{ignore} +```{notrust} $ cargo run Compiling guessing_game v0.0.1 (file:///home/you/projects/guessing_game) Running `target/guessing_game` @@ -2636,7 +2636,7 @@ fn cmp(a: uint, b: uint) -> Ordering { Now we should be good! Let's try: -```{ignore} +```{notrust} $ cargo run Compiling guessing_game v0.0.1 (file:///home/you/projects/guessing_game) Running `target/guessing_game` @@ -2814,7 +2814,7 @@ mod hello { It gives an error: -```{ignore} +```{notrust} Compiling modules v0.0.1 (file:///home/you/projects/modules) src/main.rs:2:5: 2:23 error: function `print_hello` is private src/main.rs:2 hello::print_hello(); @@ -2838,7 +2838,7 @@ mod hello { Usage of the `pub` keyword is sometimes called 'exporting', because we're making the function available for other modules. This will work: -```{ignore} +```{notrust} $ cargo run Compiling modules v0.0.1 (file:///home/you/projects/modules) Running `target/modules` @@ -2972,7 +2972,7 @@ $ cd testing And try it out: -```{ignore} +```{notrust} $ cargo run Compiling testing v0.0.1 (file:///home/you/projects/testing) Running `target/testing` @@ -3004,7 +3004,7 @@ you give them descriptive names. You'll see why in a moment. We then use a macro, `assert!`, to assert that something is true. In this case, we're giving it `false`, so this test should fail. Let's try it! -```{ignore} +```{notrust} $ cargo test Compiling testing v0.0.1 (file:///home/you/projects/testing) /home/you/projects/testing/src/main.rs:1:1: 3:2 warning: function is never used: `main`, #[warn(dead_code)] on by default @@ -3041,7 +3041,7 @@ $ cargo test You can run all of your tests with `cargo test`. This runs both your tests in `tests`, as well as the tests you put inside of your crate. -```{ignore} +```{notrust} /home/you/projects/testing/src/main.rs:1:1: 3:2 warning: function is never used: `main`, #[warn(dead_code)] on by default /home/you/projects/testing/src/main.rs:1 fn main() { /home/you/projects/testing/src/main.rs:2 println!("Hello, world!") @@ -3067,7 +3067,7 @@ with good names? This is why. Here, it says 'test foo' because we called our test 'foo.' If we had given it a good name, it'd be more clear which test failed, especially as we accumulate more tests. -```{ignore} +```{notrust} failures: ---- foo stdout ---- @@ -3169,7 +3169,7 @@ fn math_checks_out() { And try to run the test: -```{ignore} +```{notrust} $ cargo test Compiling testing v0.0.1 (file:///home/you/projects/testing) /home/you/projects/testing/tests/lib.rs:3:18: 3:38 error: unresolved name `add_three_times_four`. @@ -3332,7 +3332,7 @@ fn test_add_three() { We'd get this error: -```{ignore} +```{notrust} Compiling testing v0.0.1 (file:///home/you/projects/testing) /home/you/projects/testing/tests/lib.rs:3:5: 3:24 error: function `add_three` is private /home/you/projects/testing/tests/lib.rs:3 use testing::add_three; @@ -3504,7 +3504,7 @@ let y = &mut x; Rust will complain: -```{ignore} +```{notrust} error: cannot borrow immutable local variable `x` as mutable let y = &mut x; ^ @@ -3531,7 +3531,7 @@ let z = &mut x; It gives us this error: -```{ignore} +```{notrust} error: cannot borrow `x` as mutable more than once at a time let z = &mut x; ^ @@ -3677,7 +3677,7 @@ let z = &mut x; The error: -```{ignore} +```{notrust} error: cannot borrow `x` as mutable more than once at a time let z = &mut x; ^ @@ -3695,7 +3695,7 @@ note: previous borrow ends here This error comes in three parts. Let's go over each in turn. -```{ignore} +```{notrust} error: cannot borrow `x` as mutable more than once at a time let z = &mut x; ^ @@ -3704,7 +3704,7 @@ error: cannot borrow `x` as mutable more than once at a time This error states the restriction: you cannot lend out something mutable more than once at the same time. The borrow checker knows the rules! -```{ignore} +```{notrust} note: previous borrow of `x` occurs here; the mutable borrow prevents subsequent moves, borrows, or modification of `x` until the borrow ends let y = &mut x; ^ @@ -3819,7 +3819,7 @@ let y = &mut x; This gives us this error: -```{ignore} +```{notrust} error: cannot use `*x` because it was mutably borrowed *x; ^~ @@ -4887,7 +4887,7 @@ We can then use `T` inside the rest of the signature: `x` has type `T`, and half of the `Result` has type `T`. However, if we try to compile that example, we'll get an error: -```{ignore} +```{notrust} error: binary operation `==` cannot be applied to type `T` ``` @@ -4943,7 +4943,7 @@ we use `impl Trait for Item`, rather than just `impl Item`. So what's the big deal? Remember the error we were getting with our generic `inverse` function? -```{ignore} +```{notrust} error: binary operation `==` cannot be applied to type `T` ``` @@ -4958,7 +4958,7 @@ fn print_area<T>(shape: T) { Rust complains: -```{ignore} +```{notrust} error: type `T` does not implement any method in scope named `area` ``` @@ -5115,7 +5115,7 @@ fn main() { Now that we've moved the structs and traits into their own module, we get an error: -```{ignore} +```{notrust} error: type `shapes::Circle` does not implement any method in scope named `area` ``` diff --git a/src/doc/intro.md b/src/doc/intro.md index 5574b047d96..e2cccef5b4a 100644 --- a/src/doc/intro.md +++ b/src/doc/intro.md @@ -58,7 +58,7 @@ authors = ["Your Name <you@example.com>"] ``` This is called a **manifest**, and it contains all of the metadata that Cargo -needs to compile your project. +needs to compile your project. Here's what's in `src/main.rs`: @@ -207,7 +207,7 @@ and two... ```{bash} $ g++ hello.cpp -Wall -Werror -$ ./a.out +$ ./a.out Segmentation fault (core dumped) ``` @@ -313,7 +313,7 @@ print `"Hello"`, or does Rust crash? Neither. It refuses to compile: -```{ignore} +```{notrust} $ cargo run Compiling hello_world v0.0.1 (file:///Users/you/src/hello_world) main.rs:8:5: 8:6 error: cannot borrow `v` as mutable because it is also borrowed as immutable @@ -428,7 +428,7 @@ fn main() { It gives us this error: -```{ignore} +```{notrust} 6:71 error: capture of moved value: `numbers` for j in range(0, 3) { numbers[j] += 1 } ^~~~~~~ diff --git a/src/libcore/cmp.rs b/src/libcore/cmp.rs index 87fa44cea66..4235531c199 100644 --- a/src/libcore/cmp.rs +++ b/src/libcore/cmp.rs @@ -44,7 +44,7 @@ pub use self::Ordering::*; use kinds::{Copy, Sized}; -use option::{Option, Some, None}; +use option::Option::{mod, Some, None}; /// Trait for values that can be compared for equality and inequality. /// diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 5e2d6266f0e..0697dfbb0f2 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -143,6 +143,9 @@ #![stable] +#[cfg(stage0)] +pub use self::Option::*; +#[cfg(not(stage0))] use self::Option::*; use cmp::{Eq, Ord}; diff --git a/src/libstd/os.rs b/src/libstd/os.rs index 689ee9349e8..6c91010f4cb 100644 --- a/src/libstd/os.rs +++ b/src/libstd/os.rs @@ -1995,21 +1995,21 @@ mod tests { #[test] fn memory_map_file() { + use libc; use os::*; use io::fs::{File, unlink}; use io::SeekStyle::SeekSet; use io::FileMode::Open; use io::FileAccess::ReadWrite; - use libc::HANDLE; #[cfg(not(windows))] - fn get_fd(file: &File) -> c_int { + fn get_fd(file: &File) -> libc::c_int { use os::unix::AsRawFd; file.as_raw_fd() } #[cfg(windows)] - fn get_fd(file: &File) -> HANDLE { + fn get_fd(file: &File) -> libc::HANDLE { use os::windows::AsRawHandle; file.as_raw_handle() } diff --git a/src/test/compile-fail/lifetime-elision-return-type-requires-explicit-lifetime.rs b/src/test/compile-fail/lifetime-elision-return-type-requires-explicit-lifetime.rs index 5d961764342..817582a877f 100644 --- a/src/test/compile-fail/lifetime-elision-return-type-requires-explicit-lifetime.rs +++ b/src/test/compile-fail/lifetime-elision-return-type-requires-explicit-lifetime.rs @@ -33,7 +33,6 @@ fn h(_x: &Foo) -> &int { //~ ERROR missing lifetime specifier fn i(_x: int) -> &int { //~ ERROR missing lifetime specifier //~^ HELP this function's return type contains a borrowed value -//~^^ HELP consider giving it a 'static lifetime panic!() } diff --git a/src/test/run-pass/ufcs-type-params.rs b/src/test/run-pass/ufcs-type-params.rs index f4ad78da487..ccd5a225222 100644 --- a/src/test/run-pass/ufcs-type-params.rs +++ b/src/test/run-pass/ufcs-type-params.rs @@ -18,5 +18,5 @@ impl Foo<i32> for i32 { fn main() { let x: i32 = 1; - Foo::<i32>::get(&x) + Foo::<i32>::get(&x); } |
