From de10113c748825750b421e4ec5e0fe5aaf1d65ec Mon Sep 17 00:00:00 2001 From: topecongiro Date: Thu, 15 Jun 2017 16:26:46 +0900 Subject: [PATCH] Update tests Add more patterns and types --- src/patterns.rs | 1 + src/types.rs | 3 +++ tests/target/closure.rs | 26 ++++++++++---------- tests/target/expr.rs | 24 +++++++++++-------- tests/target/hard-tabs.rs | 6 +++-- tests/target/issue-1021.rs | 28 ++++++++++++++-------- tests/target/issue-913.rs | 6 +++-- tests/target/match.rs | 10 ++++---- tests/target/pattern-condense-wildcards.rs | 12 ++++++---- tests/target/pattern.rs | 5 ++-- 10 files changed, 74 insertions(+), 47 deletions(-) diff --git a/src/patterns.rs b/src/patterns.rs index 88d63af2298..3ca8aa52455 100644 --- a/src/patterns.rs +++ b/src/patterns.rs @@ -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, _) | diff --git a/src/types.rs b/src/types.rs index edeeb1e3b72..57a7b301f54 100644 --- a/src/types.rs +++ b/src/types.rs @@ -802,7 +802,10 @@ pub fn join_bounds(context: &RewriteContext, shape: Shape, type_strs: &Vec 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, } } diff --git a/tests/target/closure.rs b/tests/target/closure.rs index 4f35a7b413a..47d8c6bf166 100644 --- a/tests/target/closure.rs +++ b/tests/target/closure.rs @@ -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 } + }); } } } diff --git a/tests/target/expr.rs b/tests/target/expr.rs index 3b17aee5a78..7741939df45 100644 --- a/tests/target/expr.rs +++ b/tests/target/expr.rs @@ -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 }; diff --git a/tests/target/hard-tabs.rs b/tests/target/hard-tabs.rs index 48c72afd055..68919b1039c 100644 --- a/tests/target/hard-tabs.rs +++ b/tests/target/hard-tabs.rs @@ -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() { diff --git a/tests/target/issue-1021.rs b/tests/target/issue-1021.rs index cc85aa73cae..70347407346 100644 --- a/tests/target/issue-1021.rs +++ b/tests/target/issue-1021.rs @@ -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, + ) => (), } } diff --git a/tests/target/issue-913.rs b/tests/target/issue-913.rs index 98f766e7310..1bfd1cd0041 100644 --- a/tests/target/issue-913.rs +++ b/tests/target/issue-913.rs @@ -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(); } }; } diff --git a/tests/target/match.rs b/tests/target/match.rs index 040fbf155a4..d47e94b6464 100644 --- a/tests/target/match.rs +++ b/tests/target/match.rs @@ -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, } } diff --git a/tests/target/pattern-condense-wildcards.rs b/tests/target/pattern-condense-wildcards.rs index acc41b73e18..9f630f6dada 100644 --- a/tests/target/pattern-condense-wildcards.rs +++ b/tests/target/pattern-condense-wildcards.rs @@ -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", } } diff --git a/tests/target/pattern.rs b/tests/target/pattern.rs index f0cc1c16e14..39a8408a630 100644 --- a/tests/target/pattern.rs +++ b/tests/target/pattern.rs @@ -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), + ) => {} } } }