Skip to content

Commit 09f42dd

Browse files
committed
Add missing lifetime fragment specifier to error message.
A very minor issue, `lifetime` was missing from the error list. I left `literal` in the list, even though it is unstable. It looks like it may stabilize soon anyways.
1 parent 945372d commit 09f42dd

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed

src/libsyntax/ext/tt/macro_rules.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ use std::collections::hash_map::Entry;
3434
use rustc_data_structures::sync::Lrc;
3535
use errors::Applicability;
3636

37+
const VALID_FRAGMENT_NAMES_MSG: &str = "valid fragment specifiers are \
38+
`ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `lifetime`, `literal`, \
39+
`path`, `meta`, `tt`, `item` and `vis`";
40+
3741
pub struct ParserAnyMacro<'a> {
3842
parser: Parser<'a>,
3943

@@ -708,8 +712,7 @@ fn check_matcher_core(sess: &ParseSess,
708712
if let Err(bad_frag) = has_legal_fragment_specifier(sess, features, attrs, token) {
709713
let msg = format!("invalid fragment specifier `{}`", bad_frag);
710714
sess.span_diagnostic.struct_span_err(token.span(), &msg)
711-
.help("valid fragment specifiers are `ident`, `block`, `stmt`, `expr`, \
712-
`pat`, `ty`, `literal`, `path`, `meta`, `tt`, `item` and `vis`")
715+
.help(VALID_FRAGMENT_NAMES_MSG)
713716
.emit();
714717
// (This eliminates false positives and duplicates
715718
// from error messages.)
@@ -938,9 +941,7 @@ fn is_in_follow(tok: &quoted::TokenTree, frag: &str) -> Result<bool, (String, &'
938941
},
939942
"" => Ok(true), // keywords::Invalid
940943
_ => Err((format!("invalid fragment specifier `{}`", frag),
941-
"valid fragment specifiers are `ident`, `block`, \
942-
`stmt`, `expr`, `pat`, `ty`, `path`, `meta`, `tt`, \
943-
`literal`, `item` and `vis`"))
944+
VALID_FRAGMENT_NAMES_MSG))
944945
}
945946
}
946947
}

src/test/ui/issues/issue-21356.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error: invalid fragment specifier `t_ty`
44
LL | macro_rules! test { ($wrong:t_ty ..) => () }
55
| ^^^^^^^^^^^
66
|
7-
= help: valid fragment specifiers are `ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `literal`, `path`, `meta`, `tt`, `item` and `vis`
7+
= help: valid fragment specifiers are `ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `lifetime`, `literal`, `path`, `meta`, `tt`, `item` and `vis`
88

99
error: aborting due to previous error
1010

src/test/ui/macros/macro-invalid-fragment-spec.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error: invalid fragment specifier `foo`
44
LL | ($x:foo) => ()
55
| ^^^^^^
66
|
7-
= help: valid fragment specifiers are `ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `literal`, `path`, `meta`, `tt`, `item` and `vis`
7+
= help: valid fragment specifiers are `ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `lifetime`, `literal`, `path`, `meta`, `tt`, `item` and `vis`
88

99
error: aborting due to previous error
1010

src/test/ui/unused/unused-macro-with-bad-frag-spec.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error: invalid fragment specifier `t_ty`
44
LL | ($wrong:t_ty) => () //~ ERROR invalid fragment specifier `t_ty`
55
| ^^^^^^^^^^^
66
|
7-
= help: valid fragment specifiers are `ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `literal`, `path`, `meta`, `tt`, `item` and `vis`
7+
= help: valid fragment specifiers are `ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `lifetime`, `literal`, `path`, `meta`, `tt`, `item` and `vis`
88

99
error: aborting due to previous error
1010

0 commit comments

Comments
 (0)