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:
parent
461e807801
commit
bb8d4307eb
104 changed files with 705 additions and 550 deletions
|
|
@ -50,7 +50,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingAllowedAttrPass {
|
|||
let allowed = |attr| pprust::attribute_to_string(attr).contains("allowed_attr");
|
||||
if !cx.tcx.hir().attrs(item.hir_id()).iter().any(allowed) {
|
||||
cx.lint(MISSING_ALLOWED_ATTR, |lint| {
|
||||
lint.build("Missing 'allowed_attr' attribute").set_span(span).emit()
|
||||
lint.build("Missing 'allowed_attr' attribute").set_span(span).emit();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ macro_rules! fake_lint_pass {
|
|||
if !cx.sess().contains_name(attrs, $attr) {
|
||||
cx.lint(CRATE_NOT_OKAY, |lint| {
|
||||
let msg = format!("crate is not marked with #![{}]", $attr);
|
||||
lint.build(&msg).set_span(span).emit()
|
||||
lint.build(&msg).set_span(span).emit();
|
||||
});
|
||||
}
|
||||
)*
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ impl<'tcx> LateLintPass<'tcx> for Pass {
|
|||
let span = cx.tcx.def_span(CRATE_DEF_ID);
|
||||
if !cx.sess().contains_name(attrs, Symbol::intern("crate_okay")) {
|
||||
cx.lint(CRATE_NOT_OKAY, |lint| {
|
||||
lint.build("crate is not marked with #![crate_okay]").set_span(span).emit()
|
||||
lint.build("crate is not marked with #![crate_okay]").set_span(span).emit();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,10 +23,10 @@ impl<'tcx> LateLintPass<'tcx> for Pass {
|
|||
fn check_item(&mut self, cx: &LateContext, it: &rustc_hir::Item) {
|
||||
match it.ident.as_str() {
|
||||
"lintme" => cx.lint(TEST_LINT, |lint| {
|
||||
lint.build("item is named 'lintme'").set_span(it.span).emit()
|
||||
lint.build("item is named 'lintme'").set_span(it.span).emit();
|
||||
}),
|
||||
"pleaselintme" => cx.lint(PLEASE_LINT, |lint| {
|
||||
lint.build("item is named 'pleaselintme'").set_span(it.span).emit()
|
||||
lint.build("item is named 'pleaselintme'").set_span(it.span).emit();
|
||||
}),
|
||||
_ => {}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ impl EarlyLintPass for Pass {
|
|||
fn check_item(&mut self, cx: &EarlyContext, it: &ast::Item) {
|
||||
if it.ident.name.as_str() == "lintme" {
|
||||
cx.lint(TEST_LINT, |lint| {
|
||||
lint.build("item is named 'lintme'").set_span(it.span).emit()
|
||||
lint.build("item is named 'lintme'").set_span(it.span).emit();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,12 +32,12 @@ impl EarlyLintPass for Pass {
|
|||
fn check_item(&mut self, cx: &EarlyContext, it: &ast::Item) {
|
||||
if it.ident.name.as_str() == "lintme" {
|
||||
cx.lint(TEST_LINT, |lint| {
|
||||
lint.build("item is named 'lintme'").set_span(it.span).emit()
|
||||
lint.build("item is named 'lintme'").set_span(it.span).emit();
|
||||
});
|
||||
}
|
||||
if it.ident.name.as_str() == "lintmetoo" {
|
||||
cx.lint(TEST_GROUP, |lint| {
|
||||
lint.build("item is named 'lintmetoo'").set_span(it.span).emit()
|
||||
lint.build("item is named 'lintmetoo'").set_span(it.span).emit();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue