1
Fork 0

allow non-monomorphize modules to access hard-coded error message through new struct, use fluent message in monomorphize

This commit is contained in:
Nathan Stocks 2022-08-24 16:28:56 -06:00
parent e9142473df
commit 30c7506655
8 changed files with 29 additions and 13 deletions

View file

@ -207,7 +207,7 @@ use std::iter;
use std::ops::Range;
use std::path::PathBuf;
use crate::errors::{FatalError, LargeAssignmentsLint, RecursionLimit, TypeLengthLimit};
use crate::errors::{LargeAssignmentsLint, RecursionLimit, RequiresLangItem, TypeLengthLimit};
#[derive(PartialEq)]
pub enum MonoItemCollectionMode {
@ -1328,8 +1328,10 @@ impl<'v> RootCollector<'_, 'v> {
let start_def_id = match self.tcx.lang_items().require(LangItem::Start) {
Ok(s) => s,
Err(error_message) => {
self.tcx.sess.emit_fatal(FatalError { error_message: error_message.clone() });
Err(lang_item_err) => {
self.tcx
.sess
.emit_fatal(RequiresLangItem { lang_item: lang_item_err.0.name().to_string() });
}
};
let main_ret_ty = self.tcx.fn_sig(main_def_id).output();

View file

@ -33,9 +33,9 @@ pub struct TypeLengthLimit {
}
#[derive(SessionDiagnostic)]
#[diag(monomorphize::fatal_error)]
pub struct FatalError {
pub error_message: String,
#[diag(monomorphize::requires_lang_item)]
pub struct RequiresLangItem {
pub lang_item: String,
}
pub struct UnusedGenericParams {