Skip to content

Commit 95edb88

Browse files
committed
Inline and remove error_malformed_cfg_attr_missing.
It has a single call site. This also means `CFG_ATTR_{GRAMMAR_HELP,NOTE_REF}` can be moved into `parse_cfg_attr`, now that it's the only function that uses them. And the commit removes the line break in the URL.
1 parent 8fff47d commit 95edb88

File tree

1 file changed

+10
-10
lines changed
  • compiler/rustc_parse/src

1 file changed

+10
-10
lines changed

compiler/rustc_parse/src/lib.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,10 @@ pub fn parse_cfg_attr(
207207
attr: &Attribute,
208208
psess: &ParseSess,
209209
) -> Option<(MetaItem, Vec<(AttrItem, Span)>)> {
210+
const CFG_ATTR_GRAMMAR_HELP: &str = "#[cfg_attr(condition, attribute, other_attribute, ...)]";
211+
const CFG_ATTR_NOTE_REF: &str = "for more information, visit \
212+
<https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg_attr-attribute>";
213+
210214
match attr.get_normal_item().args {
211215
ast::AttrArgs::Delimited(ast::DelimArgs { dspan, delim, ref tokens })
212216
if !tokens.is_empty() =>
@@ -221,16 +225,12 @@ pub fn parse_cfg_attr(
221225
}
222226
}
223227
}
224-
_ => error_malformed_cfg_attr_missing(attr.span, psess),
228+
_ => {
229+
psess.dcx.emit_err(errors::MalformedCfgAttr {
230+
span: attr.span,
231+
sugg: CFG_ATTR_GRAMMAR_HELP,
232+
});
233+
}
225234
}
226235
None
227236
}
228-
229-
const CFG_ATTR_GRAMMAR_HELP: &str = "#[cfg_attr(condition, attribute, other_attribute, ...)]";
230-
const CFG_ATTR_NOTE_REF: &str = "for more information, visit \
231-
<https://doc.rust-lang.org/reference/conditional-compilation.html\
232-
#the-cfg_attr-attribute>";
233-
234-
fn error_malformed_cfg_attr_missing(span: Span, psess: &ParseSess) {
235-
psess.dcx.emit_err(errors::MalformedCfgAttr { span, sugg: CFG_ATTR_GRAMMAR_HELP });
236-
}

0 commit comments

Comments
 (0)