Update tests

Add more patterns and types
This commit is contained in:
topecongiro 2017-06-15 16:26:46 +09:00
parent 8a6e9f689b
commit de10113c74
10 changed files with 74 additions and 47 deletions

View File

@ -265,6 +265,7 @@ pub fn can_be_overflowed_pat(context: &RewriteContext, pat: &TuplePatField, len:
match pat {
&TuplePatField::Pat(ref pat) => {
match pat.node {
ast::PatKind::Path(..) |
ast::PatKind::Tuple(..) |
ast::PatKind::Struct(..) => context.use_block_indent() && len == 1,
ast::PatKind::Ref(ref p, _) |

View File

@ -802,7 +802,10 @@ pub fn join_bounds(context: &RewriteContext, shape: Shape, type_strs: &Vec<Strin
pub fn can_be_overflowed_type(context: &RewriteContext, ty: &ast::Ty, len: usize) -> bool {
match ty.node {
ast::TyKind::Path(..) |
ast::TyKind::Tup(..) => context.use_block_indent() && len == 1,
ast::TyKind::Rptr(_, ref mutty) |
ast::TyKind::Ptr(ref mutty) => can_be_overflowed_type(context, &*mutty.ty, len),
_ => false,
}
}

View File

@ -128,18 +128,20 @@ fn issue470() {
{
{
{
let explicit_arg_decls = explicit_arguments.into_iter().enumerate().map(|(index,
(ty,
pattern))| {
let lvalue = Lvalue::Arg(index as u32);
block = this.pattern(
block,
argument_extent,
hair::PatternRef::Hair(pattern),
&lvalue,
);
ArgDecl { ty: ty }
});
let explicit_arg_decls =
explicit_arguments.into_iter().enumerate().map(|(
index,
(ty, pattern),
)| {
let lvalue = Lvalue::Arg(index as u32);
block = this.pattern(
block,
argument_extent,
hair::PatternRef::Hair(pattern),
&lvalue,
);
ArgDecl { ty: ty }
});
}
}
}

View File

@ -52,18 +52,22 @@ fn foo() -> bool {
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)
{}
if let (some_very_large,
tuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuple) = 1 + 2 + 3
{
}
if let (some_very_large,
tuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuple) =
1111 + 2222
if let (
some_very_large,
tuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuple,
) = 1 + 2 + 3
{}
if let (some_very_large,
tuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuple) = 1 + 2 + 3
if let (
some_very_large,
tuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuple,
) = 1111 + 2222
{}
if let (
some_very_large,
tuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuple,
) = 1 + 2 + 3
{}
let test = if true { 5 } else { 3 };

View File

@ -21,8 +21,10 @@ fn main() {
let str = "AAAAAAAAAAAAAAaAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAaAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAaAa";
if let (some_very_large,
tuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuple) = 1 + 2 + 3
if let (
some_very_large,
tuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuple,
) = 1 + 2 + 3
{}
if cond() {

View File

@ -6,11 +6,15 @@ fn main() {
S(.., true) => (),
S(..) => (),
S(_) => (),
S(// ..
..) => (),
S(// ..
..,
true) => (),
S(
// ..
..
) => (),
S(
// ..
..,
true,
) => (),
}
match y {
@ -19,10 +23,14 @@ fn main() {
(.., true) => (),
(..) => (),
(_,) => (),
(// ..
..) => (),
(// ..
..,
true) => (),
(
// ..
..
) => (),
(
// ..
..,
true,
) => (),
}
}

View File

@ -10,11 +10,13 @@ mod client {
};
let next_state = match self.state {
State::V5(v5::State::Command(v5::comand::State::WriteVersion(ref mut response))) => {
State::V5(
v5::State::Command(v5::comand::State::WriteVersion(ref mut response)),
) => {
// The pattern cannot be formatted in a way that the match stays
// within the column limit. The rewrite should therefore be
// skipped.
let x = dont . reformat . meeee();
let x = dont.reformat.meeee();
}
};
}

View File

@ -262,10 +262,12 @@ fn issue507() {
fn issue508() {
match s.type_id() {
Some(NodeTypeId::Element(ElementTypeId::HTMLElement(
HTMLElementTypeId::HTMLCanvasElement))) => true,
Some(NodeTypeId::Element(ElementTypeId::HTMLElement(
HTMLElementTypeId::HTMLObjectElement))) => s.has_object_data(),
Some(
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLCanvasElement)),
) => true,
Some(
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLObjectElement)),
) => s.has_object_data(),
Some(NodeTypeId::Element(_)) => false,
}
}

View File

@ -7,10 +7,12 @@ fn main() {
Tup(_) => "nah",
Quad(_, _, x, _) => " also no rewrite",
Quad(x, ..) => "condense me pls",
Weird(x,
_,
_,
// dont condense before
..) => "pls work",
Weird(
x,
_,
_,
// dont condense before
..
) => "pls work",
}
}

View File

@ -47,8 +47,9 @@ fn main() {
impl<'a, 'b> ResolveGeneratedContentFragmentMutator<'a, 'b> {
fn mutate_fragment(&mut self, fragment: &mut Fragment) {
match **info {
GeneratedContentInfo::ContentItem(ContentItem::Counter(ref counter_name,
counter_style)) => {}
GeneratedContentInfo::ContentItem(
ContentItem::Counter(ref counter_name, counter_style),
) => {}
}
}
}