Skip to content

Commit 5bad333

Browse files
committed
auto merge of rust-lang#16175 : EduardoBautista/rust/fix-guessing-game-appearing-early, r=steveklabnik
Solves: rust-lang#16162
2 parents 1b44c5b + 69267b1 commit 5bad333

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/doc/guide.md

+14-14
Original file line numberDiff line numberDiff line change
@@ -449,9 +449,9 @@ let x;
449449
...we'll get an error:
450450

451451
```{ignore}
452-
src/guessing_game.rs:2:9: 2:10 error: cannot determine a type for this local variable: unconstrained type
453-
src/guessing_game.rs:2 let x;
454-
^
452+
src/hello_world.rs:2:9: 2:10 error: cannot determine a type for this local variable: unconstrained type
453+
src/hello_world.rs:2 let x;
454+
^
455455
```
456456

457457
Giving it a type will compile, though:
@@ -460,7 +460,7 @@ Giving it a type will compile, though:
460460
let x: int;
461461
```
462462

463-
Let's try it out. Change your `src/guessing_game.rs` file to look like this:
463+
Let's try it out. Change your `src/hello_world.rs` file to look like this:
464464

465465
```{rust}
466466
fn main() {
@@ -474,10 +474,10 @@ You can use `cargo build` on the command line to build it. You'll get a warning,
474474
but it will still print "Hello, world!":
475475

476476
```{ignore,notrust}
477-
Compiling guessing_game v0.1.0 (file:/home/you/projects/guessing_game)
478-
src/guessing_game.rs:2:9: 2:10 warning: unused variable: `x`, #[warn(unused_variable)] on by default
479-
src/guessing_game.rs:2 let x: int;
480-
^
477+
Compiling hello_world v0.1.0 (file:/home/you/projects/hello_world)
478+
src/hello_world.rs:2:9: 2:10 warning: unused variable: `x`, #[warn(unused_variable)] on by default
479+
src/hello_world.rs:2 let x: int;
480+
^
481481
```
482482

483483
Rust warns us that we never use the variable binding, but since we never use it,
@@ -496,16 +496,16 @@ And try to build it. You'll get an error:
496496

497497
```{bash}
498498
$ cargo build
499-
Compiling guessing_game v0.1.0 (file:/home/you/projects/guessing_game)
500-
src/guessing_game.rs:4:39: 4:40 error: use of possibly uninitialized variable: `x`
501-
src/guessing_game.rs:4 println!("The value of x is: {}", x);
502-
^
499+
Compiling hello_world v0.1.0 (file:/home/you/projects/hello_world)
500+
src/hello_world.rs:4:39: 4:40 error: use of possibly uninitialized variable: `x`
501+
src/hello_world.rs:4 println!("The value of x is: {}", x);
502+
^
503503
note: in expansion of format_args!
504504
<std macros>:2:23: 2:77 note: expansion site
505505
<std macros>:1:1: 3:2 note: in expansion of println!
506-
src/guessing_game.rs:4:5: 4:42 note: expansion site
506+
src/hello_world.rs:4:5: 4:42 note: expansion site
507507
error: aborting due to previous error
508-
Could not execute process `rustc src/guessing_game.rs --crate-type bin --out-dir /home/you/projects/guessing_game/target -L /home/you/projects/guessing_game/target -L /home/you/projects/guessing_game/target/deps` (status=101)
508+
Could not execute process `rustc src/hello_world.rs --crate-type bin --out-dir /home/you/projects/hello_world/target -L /home/you/projects/hello_world/target -L /home/you/projects/hello_world/target/deps` (status=101)
509509
```
510510

511511
Rust will not let us use a value that has not been initialized. So why let us

0 commit comments

Comments
 (0)