Migrate builtin-macros-expected-one-cfg-pattern
to SessionDiagnostic
This commit is contained in:
parent
6264ffbfef
commit
be5337cde5
2 changed files with 10 additions and 1 deletions
|
@ -43,6 +43,13 @@ struct RequiresCfgPattern {
|
||||||
span: Span,
|
span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(SessionDiagnostic)]
|
||||||
|
#[error(slug = "builtin-macros-expected-one-cfg-pattern")]
|
||||||
|
struct OneCfgPattern {
|
||||||
|
#[primary_span]
|
||||||
|
span: Span,
|
||||||
|
}
|
||||||
|
|
||||||
fn parse_cfg<'a>(cx: &mut ExtCtxt<'a>, span: Span, tts: TokenStream) -> PResult<'a, ast::MetaItem> {
|
fn parse_cfg<'a>(cx: &mut ExtCtxt<'a>, span: Span, tts: TokenStream) -> PResult<'a, ast::MetaItem> {
|
||||||
let mut p = cx.new_parser_from_tts(tts);
|
let mut p = cx.new_parser_from_tts(tts);
|
||||||
|
|
||||||
|
@ -55,7 +62,7 @@ fn parse_cfg<'a>(cx: &mut ExtCtxt<'a>, span: Span, tts: TokenStream) -> PResult<
|
||||||
let _ = p.eat(&token::Comma);
|
let _ = p.eat(&token::Comma);
|
||||||
|
|
||||||
if !p.eat(&token::Eof) {
|
if !p.eat(&token::Eof) {
|
||||||
return Err(cx.struct_span_err(span, "expected 1 cfg-pattern"));
|
return Err(cx.create_err(OneCfgPattern { span }));
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(cfg)
|
Ok(cfg)
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
builtin-macros-requires-cfg-pattern =
|
builtin-macros-requires-cfg-pattern =
|
||||||
macro requires a cfg-pattern as an argument
|
macro requires a cfg-pattern as an argument
|
||||||
.label = cfg-pattern required
|
.label = cfg-pattern required
|
||||||
|
|
||||||
|
builtin-macros-expected-one-cfg-pattern = expected 1 cfg-pattern
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue