Skip to content

Commit f657624

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 d1215da commit f657624

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

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

0 commit comments

Comments
 (0)