Fixes to the roll-up

This commit is contained in:
Jakub Bukaj 2014-11-19 23:06:53 +01:00
parent 2e9f705b93
commit ee66c84165
4 changed files with 16 additions and 13 deletions

View File

@ -84,6 +84,8 @@ While we know that we've covered all possible cases, Rust can't tell. It
doesn't know that probability is between 0.0 and 1.0. So we add another case:
```rust
use Event::NewRelease;
enum Event {
NewRelease,
}
@ -106,7 +108,7 @@ fn descriptive_probability(event: Event) -> &'static str {
}
fn main() {
std::io::println(descriptive_probability(NewRelease));
println!("{}", descriptive_probability(NewRelease));
}
```
@ -151,15 +153,14 @@ enum Version { Version1, Version2 }
#[deriving(Show)]
enum ParseError { InvalidHeaderLength, InvalidVersion }
fn parse_version(header: &[u8]) -> Result<Version, ParseError> {
if header.len() < 1 {
return Err(InvalidHeaderLength);
return Err(ParseError::InvalidHeaderLength);
}
match header[0] {
1 => Ok(Version1),
2 => Ok(Version2),
_ => Err(InvalidVersion)
1 => Ok(Version::Version1),
2 => Ok(Version::Version2),
_ => Err(ParseError::InvalidVersion)
}
}

View File

@ -212,7 +212,7 @@ pub fn walk_local<'v, V: Visitor<'v>>(visitor: &mut V, local: &'v Local) {
pub fn walk_lifetime_def<'v, V: Visitor<'v>>(visitor: &mut V,
lifetime_def: &'v LifetimeDef) {
visitor.visit_lifetime_ref(&lifetime_def.lifetime);
visitor.visit_name(lifetime_def.lifetime.span, lifetime_def.lifetime.name);
for bound in lifetime_def.bounds.iter() {
visitor.visit_lifetime_ref(bound);
}

View File

@ -36,6 +36,6 @@ fn main() {
1234suffix; //~ ERROR illegal suffix `suffix` for numeric literal
0b101suffix; //~ ERROR illegal suffix `suffix` for numeric literal
1.0suffix; //~ ERROR illegal suffix `suffix` for numeric literal
1.0e10suffix; //~ ERROR illegal suffix `suffix` for numeric literal
1.0suffix; //~ ERROR illegal suffix `suffix` for float literal
1.0e10suffix; //~ ERROR illegal suffix `suffix` for float literal
}

View File

@ -8,11 +8,13 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn main() {
enum Foo {
FooB { x: i32, y: i32 }
}
use Foo::FooB;
enum Foo {
FooB { x: i32, y: i32 }
}
fn main() {
let f = FooB { x: 3, y: 4 };
match f {
FooB(a, b) => println!("{} {}", a, b),