mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-27 17:24:06 +00:00
Merge pull request #2751 from topecongiro/issue-2749
Fix treating the delimiter right after repeat as repeat as well
This commit is contained in:
commit
4e09e5479c
19
Cargo.lock
generated
19
Cargo.lock
generated
@ -42,7 +42,7 @@ name = "backtrace"
|
||||
version = "0.3.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"backtrace-sys 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"backtrace-sys 0.1.23 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cfg-if 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.41 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-demangle 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -51,12 +51,11 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "backtrace-sys"
|
||||
version = "0.1.22"
|
||||
version = "0.1.23"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cc 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cc 1.0.17 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.41 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"pkg-config 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -83,7 +82,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.0.15"
|
||||
version = "1.0.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
@ -339,11 +338,6 @@ dependencies = [
|
||||
"winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pkg-config"
|
||||
version = "0.3.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "0.3.8"
|
||||
@ -805,11 +799,11 @@ dependencies = [
|
||||
"checksum assert_cli 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3f731a115f8e5ec3a316c711f220656aec2db609797048aec6ae4d3934f048fe"
|
||||
"checksum atty 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "2fc4a1aa4c24c0718a250f0681885c1af91419d242f29eb8f2ab28502d80dbd1"
|
||||
"checksum backtrace 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "dbdd17cd962b570302f5297aea8648d5923e22e555c2ed2d8b2e34eca646bf6d"
|
||||
"checksum backtrace-sys 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)" = "5fd343a2466c4603f76f38de264bc0526cffc7fa38ba52fb9f13237eccc1ced2"
|
||||
"checksum backtrace-sys 0.1.23 (registry+https://github.com/rust-lang/crates.io-index)" = "bff67d0c06556c0b8e6b5f090f0eac52d950d9dfd1d35ba04e4ca3543eaf6a7e"
|
||||
"checksum bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d0c54bb8f454c567f21197eefcdbf5679d0bd99f2ddbe52e84c77061952e6789"
|
||||
"checksum byteorder 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "74c0b906e9446b0a2e4f760cdb3fa4b2c48cdc6db8766a845c54b6ff063fd2e9"
|
||||
"checksum cargo_metadata 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)" = "6ebd6272a2ca4fd39dbabbd6611eb03df45c2259b3b80b39a9ff8fbdcf42a4b3"
|
||||
"checksum cc 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)" = "0ebb87d1116151416c0cf66a0e3fb6430cccd120fd6300794b4dfaa050ac40ba"
|
||||
"checksum cc 1.0.17 (registry+https://github.com/rust-lang/crates.io-index)" = "49ec142f5768efb5b7622aebc3fdbdbb8950a4b9ba996393cb76ef7466e8747d"
|
||||
"checksum cfg-if 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "405216fd8fe65f718daa7102ea808a946b6ce40c742998fbfd3463645552de18"
|
||||
"checksum colored 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b0aa3473e85a3161b59845d6096b289bb577874cafeaf75ea1b1beaa6572c7fc"
|
||||
"checksum crossbeam-deque 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f739f8c5363aca78cfb059edf753d8f0d36908c348f3d8d1503f03d8b75d9cf3"
|
||||
@ -844,7 +838,6 @@ dependencies = [
|
||||
"checksum owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cdf84f41639e037b484f93433aa3897863b561ed65c6e59c7073d7c561710f37"
|
||||
"checksum parking_lot 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d4d05f1349491390b1730afba60bb20d55761bef489a954546b58b4b34e1e2ac"
|
||||
"checksum parking_lot_core 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "4db1a8ccf734a7bce794cc19b3df06ed87ab2f3907036b693c68f56b4d4537fa"
|
||||
"checksum pkg-config 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)" = "110d5ee3593dbb73f56294327fe5668bcc997897097cbc76b51e7aed3f52452f"
|
||||
"checksum proc-macro2 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "1b06e2f335f48d24442b35a19df506a835fb3547bc3c06ef27340da9acf5cae7"
|
||||
"checksum proc-macro2 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "1fa93823f53cfd0f5ac117b189aed6cfdfb2cfc0a9d82e956dd7927595ed7d46"
|
||||
"checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0"
|
||||
|
@ -493,11 +493,18 @@ fn delim_token_to_str(
|
||||
delim_token: &DelimToken,
|
||||
shape: Shape,
|
||||
use_multiple_lines: bool,
|
||||
inner_is_empty: bool,
|
||||
) -> (String, String) {
|
||||
let (lhs, rhs) = match *delim_token {
|
||||
DelimToken::Paren => ("(", ")"),
|
||||
DelimToken::Bracket => ("[", "]"),
|
||||
DelimToken::Brace => ("{ ", " }"),
|
||||
DelimToken::Brace => {
|
||||
if inner_is_empty || use_multiple_lines {
|
||||
("{", "}")
|
||||
} else {
|
||||
("{ ", " }")
|
||||
}
|
||||
}
|
||||
DelimToken::NoDelim => ("", ""),
|
||||
};
|
||||
if use_multiple_lines {
|
||||
@ -553,13 +560,13 @@ impl MacroArgKind {
|
||||
use_multiple_lines: bool,
|
||||
) -> Option<String> {
|
||||
let rewrite_delimited_inner = |delim_tok, args| -> Option<(String, String, String)> {
|
||||
let (lhs, rhs) = delim_token_to_str(context, delim_tok, shape, false);
|
||||
let inner = wrap_macro_args(context, args, shape)?;
|
||||
let (lhs, rhs) = delim_token_to_str(context, delim_tok, shape, false, inner.is_empty());
|
||||
if lhs.len() + inner.len() + rhs.len() <= shape.width {
|
||||
return Some((lhs, inner, rhs));
|
||||
}
|
||||
|
||||
let (lhs, rhs) = delim_token_to_str(context, delim_tok, shape, true);
|
||||
let (lhs, rhs) = delim_token_to_str(context, delim_tok, shape, true, false);
|
||||
let nested_shape = shape
|
||||
.block_indent(context.config.tab_spaces())
|
||||
.with_max_width(context.config);
|
||||
@ -830,6 +837,7 @@ impl MacroArgParser {
|
||||
|
||||
if self.is_meta_var {
|
||||
self.add_repeat(delimited_arg, delimited.delim, &mut iter, *sp)?;
|
||||
self.is_meta_var = false;
|
||||
} else {
|
||||
self.add_delimited(delimited_arg, delimited.delim, *sp);
|
||||
}
|
||||
|
@ -194,3 +194,13 @@ macro_rules! m {
|
||||
($x:) => {};
|
||||
($($foo:expr)()?) => {};
|
||||
}
|
||||
|
||||
// #2749
|
||||
macro_rules! foo {
|
||||
($(x)* {}) => {};
|
||||
($(x)* ()) => {};
|
||||
($(x)* []) => {};
|
||||
}
|
||||
macro_rules! __wundergraph_expand_sqlite_mutation {
|
||||
( $mutation_name:ident $((context = $($context:tt)*))*{ $( $entity_name:ident( $(insert = $insert:ident,)* $(update = $update:ident,)* $(delete = $($delete:tt)+)* ), )* } ) => {};
|
||||
}
|
||||
|
@ -226,3 +226,23 @@ macro_rules! m {
|
||||
($x:) => {};
|
||||
($($foo:expr)()?) => {};
|
||||
}
|
||||
|
||||
// #2749
|
||||
macro_rules! foo {
|
||||
($(x)* {}) => {};
|
||||
($(x)*()) => {};
|
||||
($(x)*[]) => {};
|
||||
}
|
||||
macro_rules! __wundergraph_expand_sqlite_mutation {
|
||||
(
|
||||
$mutation_name:ident $((context = $($context:tt)*))* {
|
||||
$(
|
||||
$entity_name:ident(
|
||||
$(insert = $insert:ident,)*
|
||||
$(update = $update:ident,)*
|
||||
$(delete = $($delete:tt)+)*
|
||||
),
|
||||
)*
|
||||
}
|
||||
) => {};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user