2015-08-14 03:00:22 -05:00
|
|
|
// Match expressions.
|
|
|
|
|
|
|
|
fn foo() {
|
|
|
|
// A match expression.
|
|
|
|
match x {
|
|
|
|
// Some comment.
|
|
|
|
a => foo(),
|
|
|
|
b if 0 < 42 => foo(),
|
|
|
|
c => { // Another comment.
|
|
|
|
// Comment.
|
|
|
|
an_expression;
|
|
|
|
foo()
|
|
|
|
}
|
|
|
|
// Perhaps this should introduce braces?
|
|
|
|
Foo(ref bar) =>
|
|
|
|
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
|
|
|
|
Pattern1 | Pattern2 | Pattern3 => false,
|
|
|
|
Paternnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn |
|
|
|
|
Paternnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn => {
|
|
|
|
blah
|
|
|
|
}
|
|
|
|
Patternnnnnnnnnnnnnnnnnnn |
|
|
|
|
Patternnnnnnnnnnnnnnnnnnn |
|
|
|
|
Patternnnnnnnnnnnnnnnnnnn |
|
|
|
|
Patternnnnnnnnnnnnnnnnnnn => meh,
|
|
|
|
|
|
|
|
Patternnnnnnnnnnnnnnnnnnn |
|
|
|
|
Patternnnnnnnnnnnnnnnnnnn if looooooooooooooooooong_guard => meh,
|
|
|
|
|
|
|
|
Patternnnnnnnnnnnnnnnnnnnnnnnnn |
|
2015-08-16 16:41:45 -05:00
|
|
|
Patternnnnnnnnnnnnnnnnnnnnnnnnn if looooooooooooooooooooooooooooooooooooooooong_guard =>
|
|
|
|
meh,
|
|
|
|
|
|
|
|
// Test that earlier patterns can take the guard space
|
|
|
|
(aaaa, bbbbb, ccccccc, aaaaa, bbbbbbbb, cccccc, aaaa, bbbbbbbb, cccccc, dddddd) |
|
|
|
|
Patternnnnnnnnnnnnnnnnnnnnnnnnn if loooooooooooooooooooooooooooooooooooooooooong_guard => {}
|
|
|
|
|
2015-08-14 03:00:22 -05:00
|
|
|
_ => {}
|
2015-08-18 22:15:54 -05:00
|
|
|
ast::PathParameters::AngleBracketedParameters(ref data) if data.lifetimes.len() > 0 ||
|
|
|
|
data.types.len() > 0 ||
|
|
|
|
data.bindings.len() > 0 => {
|
|
|
|
}
|
2015-08-14 03:00:22 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
let whatever = match something {
|
|
|
|
/// DOC COMMENT!
|
|
|
|
Some(_) => 42,
|
2015-08-18 22:15:54 -05:00
|
|
|
// Comment on an attribute.
|
2015-08-14 03:00:22 -05:00
|
|
|
#[an_attribute]
|
2015-08-16 16:41:45 -05:00
|
|
|
// Comment after an attribute.
|
2015-08-14 03:00:22 -05:00
|
|
|
None => 0,
|
2015-08-16 16:41:45 -05:00
|
|
|
#[rustfmt_skip]
|
|
|
|
Blurb => { }
|
2015-08-14 03:00:22 -05:00
|
|
|
};
|
|
|
|
}
|
2015-09-01 21:29:47 -05:00
|
|
|
|
|
|
|
// Test that a match on an overflow line is laid out properly.
|
|
|
|
fn main() {
|
|
|
|
let sub_span =
|
2015-09-09 16:15:37 -05:00
|
|
|
match xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx {
|
2015-09-01 21:29:47 -05:00
|
|
|
Some(sub_span) => Some(sub_span),
|
|
|
|
None => sub_span,
|
|
|
|
};
|
|
|
|
}
|
2015-09-01 21:45:56 -05:00
|
|
|
|
|
|
|
// Test that one-line bodies align.
|
|
|
|
fn main() {
|
|
|
|
match r {
|
|
|
|
Variableeeeeeeeeeeeeeeeee => ("variable",
|
|
|
|
vec!("id","name","qualname","value","type","scopeid"),
|
|
|
|
true,
|
|
|
|
true),
|
|
|
|
Enummmmmmmmmmmmmmmmmmmmm => ("enum", vec!("id","qualname","scopeid","value"), true, true),
|
|
|
|
Variantttttttttttttttttttttttt => ("variant",
|
|
|
|
vec!("id","name","qualname","type","value","scopeid"),
|
|
|
|
true,
|
|
|
|
true),
|
|
|
|
}
|
|
|
|
}
|