Auto merge of #118470 - nnethercote:cleanup-error-handlers, r=compiler-errors

Cleanup error handlers

Mostly by making function naming more consistent. More to do after this, but this is enough for one PR.

r? compiler-errors
This commit is contained in:
bors 2023-12-02 02:48:34 +00:00
commit 2da59b8676
170 changed files with 495 additions and 517 deletions

View file

@ -31,10 +31,7 @@ pub fn expand(
{
(item, true, ecx.with_def_site_ctxt(fn_kind.sig.span))
} else {
ecx.sess
.parse_sess
.span_diagnostic
.emit_err(errors::AllocErrorMustBeFn { span: item.span() });
ecx.sess.diagnostic().emit_err(errors::AllocErrorMustBeFn { span: item.span() });
return vec![orig_item];
};

View file

@ -34,10 +34,7 @@ pub fn expand(
{
(item, true, ecx.with_def_site_ctxt(ty.span))
} else {
ecx.sess
.parse_sess
.span_diagnostic
.emit_err(errors::AllocMustStatics { span: item.span() });
ecx.sess.diagnostic().emit_err(errors::AllocMustStatics { span: item.span() });
return vec![orig_item];
};

View file

@ -389,7 +389,7 @@ pub fn expand_test_or_bench(
}
fn not_testable_error(cx: &ExtCtxt<'_>, attr_sp: Span, item: Option<&ast::Item>) {
let diag = &cx.sess.parse_sess.span_diagnostic;
let diag = cx.sess.diagnostic();
let msg = "the `#[test]` attribute may only be used on a non-associated function";
let mut err = match item.map(|i| &i.kind) {
// These were a warning before #92959 and need to continue being that to avoid breaking
@ -466,7 +466,7 @@ fn should_ignore_message(i: &ast::Item) -> Option<Symbol> {
fn should_panic(cx: &ExtCtxt<'_>, i: &ast::Item) -> ShouldPanic {
match attr::find_by_name(&i.attrs, sym::should_panic) {
Some(attr) => {
let sd = &cx.sess.parse_sess.span_diagnostic;
let sd = cx.sess.diagnostic();
match attr.meta_item_list() {
// Handle #[should_panic(expected = "foo")]
@ -535,7 +535,7 @@ fn check_test_signature(
f: &ast::Fn,
) -> Result<(), ErrorGuaranteed> {
let has_should_panic_attr = attr::contains_name(&i.attrs, sym::should_panic);
let sd = &cx.sess.parse_sess.span_diagnostic;
let sd = cx.sess.diagnostic();
if let ast::Unsafe::Yes(span) = f.sig.header.unsafety {
return Err(sd.emit_err(errors::TestBadFn { span: i.span, cause: span, kind: "unsafe" }));
@ -579,7 +579,7 @@ fn check_bench_signature(
// N.B., inadequate check, but we're running
// well before resolve, can't get too deep.
if f.sig.decl.inputs.len() != 1 {
return Err(cx.sess.parse_sess.span_diagnostic.emit_err(errors::BenchSig { span: i.span }));
return Err(cx.sess.diagnostic().emit_err(errors::BenchSig { span: i.span }));
}
Ok(())
}