Skip to content

Commit 3a74833

Browse files
committed
use cherry-picked commit from rust-lang#100754 to emit note without error
1 parent f8ebc72 commit 3a74833

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

compiler/rustc_error_messages/locales/en-US/passes.ftl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,9 +364,11 @@ passes_unknown_external_lang_item =
364364
passes_missing_panic_handler =
365365
`#[panic_handler]` function required, but not found
366366
367-
passes_missing_alloc_error_handler =
367+
passes_alloc_func_required =
368368
`#[alloc_error_handler]` function required, but not found
369-
.note = use `#![feature(default_alloc_error_handler)]` for a default error handler
369+
370+
passes_missing_alloc_error_handler =
371+
use `#![feature(default_alloc_error_handler)]` for a default error handler
370372
371373
passes_missing_lang_item =
372374
language item required, but not found: `{$name}`

compiler/rustc_passes/src/errors.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -690,9 +690,12 @@ pub struct UnknownExternLangItem {
690690
#[diag(passes::missing_panic_handler)]
691691
pub struct MissingPanicHandler;
692692

693+
#[derive(Diagnostic)]
694+
#[diag(passes::alloc_func_required)]
695+
pub struct AllocFuncRequired;
696+
693697
#[derive(Diagnostic)]
694698
#[diag(passes::missing_alloc_error_handler)]
695-
#[note]
696699
pub struct MissingAllocErrorHandler;
697700

698701
#[derive(Diagnostic)]

compiler/rustc_passes/src/weak_lang_items.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ use rustc_middle::ty::TyCtxt;
88
use rustc_session::config::CrateType;
99

1010
use crate::errors::{
11-
MissingAllocErrorHandler, MissingLangItem, MissingPanicHandler, UnknownExternLangItem,
11+
AllocFuncRequired, MissingAllocErrorHandler, MissingLangItem, MissingPanicHandler,
12+
UnknownExternLangItem,
1213
};
1314

1415
/// Checks the crate for usage of weak lang items, returning a vector of all the
@@ -70,7 +71,8 @@ fn verify<'tcx>(tcx: TyCtxt<'tcx>, items: &lang_items::LanguageItems) {
7071
tcx.sess.emit_err(MissingPanicHandler);
7172
} else if item == LangItem::Oom {
7273
if !tcx.features().default_alloc_error_handler {
73-
tcx.sess.emit_err(MissingAllocErrorHandler);
74+
tcx.sess.emit_err(AllocFuncRequired);
75+
tcx.sess.emit_note(MissingAllocErrorHandler);
7476
}
7577
} else {
7678
tcx.sess.emit_err(MissingLangItem { name: *name });

0 commit comments

Comments
 (0)