Merge pull request #2153 from topecongiro/issue-2152

Return None when a literal exceeds budget
This commit is contained in:
Nick Cameron 2017-11-15 15:43:03 +13:00 committed by GitHub
commit a90b76a731
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 1 deletions

View File

@ -1691,7 +1691,7 @@ fn rewrite_pat_expr(
pub fn rewrite_literal(context: &RewriteContext, l: &ast::Lit, shape: Shape) -> Option<String> {
match l.node {
ast::LitKind::Str(_, ast::StrStyle::Cooked) => rewrite_string_lit(context, l.span, shape),
_ => Some(context.snippet(l.span)),
_ => wrap_str(context.snippet(l.span), context.config.max_width(), shape),
}
}

View File

@ -434,3 +434,11 @@ impl<'tcx> Const<'tcx> {
};
}
}
// #2152
fn issue_2152() {
match m {
"aaaaaaaaaaaaa" | "bbbbbbbbbbbbb" | "cccccccccccccccccccccccccccccccccccccccccccc" if true => {}
"bind" | "writev" | "readv" | "sendmsg" | "recvmsg" if android && (aarch64 || x86_64) => true,
}
}

View File

@ -475,3 +475,14 @@ impl<'tcx> Const<'tcx> {
};
}
}
// #2152
fn issue_2152() {
match m {
"aaaaaaaaaaaaa" | "bbbbbbbbbbbbb" | "cccccccccccccccccccccccccccccccccccccccccccc"
if true => {}
"bind" | "writev" | "readv" | "sendmsg" | "recvmsg" if android && (aarch64 || x86_64) => {
true
}
}
}