Skip to content

Commit ae4fdd2

Browse files
committed
Formatting changes
1 parent be19420 commit ae4fdd2

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

src/libsyntax/ext/tt/macro_rules.rs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -775,6 +775,8 @@ fn check_matcher_core(sess: &ParseSess,
775775
new.add_one_maybe(TokenTree::Token(delim_sp.entire(), u.clone()));
776776
&new
777777
} else {
778+
// Verify that a fragment isn't followed by an invalid fragment type through
779+
// repetition.
778780
if let (
779781
Some(tok),
780782
Some(TokenTree::MetaVarDecl(sp, name, frag_spec)),
@@ -786,7 +788,7 @@ fn check_matcher_core(sess: &ParseSess,
786788
let next = if *sp == tok_sp {
787789
"itself".to_owned()
788790
} else {
789-
format!("`{}`", quoted_tt_to_string(tok))
791+
quoted_tt_to_string(tok)
790792
};
791793
let mut err = sess.span_diagnostic.struct_span_warn(
792794
*sp,
@@ -817,8 +819,8 @@ fn check_matcher_core(sess: &ParseSess,
817819
}
818820
let sugg_span = sess.source_map().next_point(delim_sp.close);
819821
let msg = "allowed there are: ";
820-
let sugg_msg = "add a valid separator for the repetition to be \
821-
unambiguous";
822+
let sugg_msg =
823+
"add a valid separator for the repetition to be unambiguous";
822824
match &possible[..] {
823825
&[] => {}
824826
&[t] => {
@@ -914,7 +916,7 @@ fn check_matcher_core(sess: &ParseSess,
914916
let sp = next_token.span();
915917
let mut err = sess.span_diagnostic.struct_span_err(
916918
sp,
917-
&format!("`${name}:{frag}` {may_be} followed by `{next}`, which \
919+
&format!("`${name}:{frag}` {may_be} followed by {next}, which \
918920
is not allowed for `{frag}` fragments",
919921
name=name,
920922
frag=frag_spec,
@@ -1140,9 +1142,13 @@ fn is_legal_fragment_specifier(sess: &ParseSess,
11401142

11411143
fn quoted_tt_to_string(tt: &quoted::TokenTree) -> String {
11421144
match *tt {
1143-
quoted::TokenTree::Token(_, ref tok) => ::print::pprust::token_to_string(tok),
1144-
quoted::TokenTree::MetaVar(_, name) => format!("${}", name),
1145-
quoted::TokenTree::MetaVarDecl(_, name, kind) => format!("${}:{}", name, kind),
1146-
ref tt => panic!("unexpected {:?} in follow set checker", tt),
1145+
quoted::TokenTree::Token(_, ref tok) => format!(
1146+
"`{}`",
1147+
::print::pprust::token_to_string(tok),
1148+
),
1149+
quoted::TokenTree::MetaVar(_, name) => format!("`${}`", name),
1150+
quoted::TokenTree::MetaVarDecl(_, name, kind) => format!("`${}:{}`", name, kind),
1151+
quoted::TokenTree::Delimited(..) => "a delimited token tree".to_owned(),
1152+
quoted::TokenTree::Sequence(..) => "a sequence".to_owned(),
11471153
}
11481154
}

0 commit comments

Comments
 (0)