1
Fork 0

rustc_error: make ErrorReported impossible to construct

There are a few places were we have to construct it, though, and a few
places that are more invasive to change. To do this, we create a
constructor with a long obvious name.
This commit is contained in:
mark 2022-01-22 18:49:12 -06:00
parent 461e807801
commit bb8d4307eb
104 changed files with 705 additions and 550 deletions

View file

@ -1330,7 +1330,7 @@ pub fn parse_macro_name_and_helper_attrs(
let attributes_attr = list.get(1);
let proc_attrs: Vec<_> = if let Some(attr) = attributes_attr {
if !attr.has_name(sym::attributes) {
diag.span_err(attr.span(), "second argument must be `attributes`")
diag.span_err(attr.span(), "second argument must be `attributes`");
}
attr.meta_item_list()
.unwrap_or_else(|| {

View file

@ -534,10 +534,10 @@ pub fn compile_declarative_macro(
let (transparency, transparency_error) = attr::find_transparency(&def.attrs, macro_rules);
match transparency_error {
Some(TransparencyError::UnknownTransparency(value, span)) => {
diag.span_err(span, &format!("unknown macro transparency: `{}`", value))
diag.span_err(span, &format!("unknown macro transparency: `{}`", value));
}
Some(TransparencyError::MultipleTransparencyAttrs(old_span, new_span)) => {
diag.span_err(vec![old_span, new_span], "multiple macro transparency attributes")
diag.span_err(vec![old_span, new_span], "multiple macro transparency attributes");
}
None => {}
}
@ -617,7 +617,9 @@ fn check_lhs_no_empty_seq(sess: &ParseSess, tts: &[mbe::TokenTree]) -> bool {
fn check_rhs(sess: &ParseSess, rhs: &mbe::TokenTree) -> bool {
match *rhs {
mbe::TokenTree::Delimited(..) => return true,
_ => sess.span_diagnostic.span_err(rhs.span(), "macro rhs must be delimited"),
_ => {
sess.span_diagnostic.span_err(rhs.span(), "macro rhs must be delimited");
}
}
false
}

View file

@ -31,8 +31,7 @@ impl base::ProcMacro for BangProcMacro {
if let Some(s) = e.as_str() {
err.help(&format!("message: {}", s));
}
err.emit();
ErrorGuaranteed
err.emit()
})
}
}
@ -58,8 +57,7 @@ impl base::AttrProcMacro for AttrProcMacro {
if let Some(s) = e.as_str() {
err.help(&format!("message: {}", s));
}
err.emit();
ErrorGuaranteed
err.emit()
})
}
}