diff options
| author | Nathan Stocks <cleancut@github.com> | 2022-09-22 10:15:51 -0600 |
|---|---|---|
| committer | Nathan Stocks <cleancut@github.com> | 2022-10-07 13:19:27 -0600 |
| commit | 3a748330af35ec9da4b07f55b78e8f08f2af0888 (patch) | |
| tree | 2f2758f32ae9e9ff765e540b298db6dd5075f0d2 | |
| parent | f8ebc72b4aa138772434039950126f2c7f07a3f4 (diff) | |
| download | rust-3a748330af35ec9da4b07f55b78e8f08f2af0888.tar.gz rust-3a748330af35ec9da4b07f55b78e8f08f2af0888.zip | |
use cherry-picked commit from #100754 to emit note without error
| -rw-r--r-- | compiler/rustc_error_messages/locales/en-US/passes.ftl | 6 | ||||
| -rw-r--r-- | compiler/rustc_passes/src/errors.rs | 5 | ||||
| -rw-r--r-- | compiler/rustc_passes/src/weak_lang_items.rs | 6 |
3 files changed, 12 insertions, 5 deletions
diff --git a/compiler/rustc_error_messages/locales/en-US/passes.ftl b/compiler/rustc_error_messages/locales/en-US/passes.ftl index 7dddc6e10b6..49cd2ee1758 100644 --- a/compiler/rustc_error_messages/locales/en-US/passes.ftl +++ b/compiler/rustc_error_messages/locales/en-US/passes.ftl @@ -364,9 +364,11 @@ passes_unknown_external_lang_item = passes_missing_panic_handler = `#[panic_handler]` function required, but not found -passes_missing_alloc_error_handler = +passes_alloc_func_required = `#[alloc_error_handler]` function required, but not found - .note = use `#![feature(default_alloc_error_handler)]` for a default error handler + +passes_missing_alloc_error_handler = + use `#![feature(default_alloc_error_handler)]` for a default error handler passes_missing_lang_item = language item required, but not found: `{$name}` diff --git a/compiler/rustc_passes/src/errors.rs b/compiler/rustc_passes/src/errors.rs index 0fabbb206cf..26190af0358 100644 --- a/compiler/rustc_passes/src/errors.rs +++ b/compiler/rustc_passes/src/errors.rs @@ -691,8 +691,11 @@ pub struct UnknownExternLangItem { pub struct MissingPanicHandler; #[derive(Diagnostic)] +#[diag(passes::alloc_func_required)] +pub struct AllocFuncRequired; + +#[derive(Diagnostic)] #[diag(passes::missing_alloc_error_handler)] -#[note] pub struct MissingAllocErrorHandler; #[derive(Diagnostic)] diff --git a/compiler/rustc_passes/src/weak_lang_items.rs b/compiler/rustc_passes/src/weak_lang_items.rs index 0d2745fb5f4..92024989a75 100644 --- a/compiler/rustc_passes/src/weak_lang_items.rs +++ b/compiler/rustc_passes/src/weak_lang_items.rs @@ -8,7 +8,8 @@ use rustc_middle::ty::TyCtxt; use rustc_session::config::CrateType; use crate::errors::{ - MissingAllocErrorHandler, MissingLangItem, MissingPanicHandler, UnknownExternLangItem, + AllocFuncRequired, MissingAllocErrorHandler, MissingLangItem, MissingPanicHandler, + UnknownExternLangItem, }; /// 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) { tcx.sess.emit_err(MissingPanicHandler); } else if item == LangItem::Oom { if !tcx.features().default_alloc_error_handler { - tcx.sess.emit_err(MissingAllocErrorHandler); + tcx.sess.emit_err(AllocFuncRequired); + tcx.sess.emit_note(MissingAllocErrorHandler); } } else { tcx.sess.emit_err(MissingLangItem { name: *name }); |
