submit_post_lto_module_to_llvm, submit_pre_lto_module_to_llvm, ComputedLtoType, OngoingCodegen,
};
use crate::common::{IntPredicate, RealPredicate, TypeKind};
+use crate::errors;
use crate::meth;
use crate::mir;
use crate::mir::operand::OperandValue;
let Some(llfn) = cx.declare_c_main(llfty) else {
// FIXME: We should be smart and show a better diagnostic here.
let span = cx.tcx().def_span(rust_main_def_id);
- cx.sess()
- .struct_span_err(span, "entry symbol `main` declared multiple times")
- .help("did you use `#[no_mangle]` on `fn main`? Use `#[start]` instead")
- .emit();
+ cx.sess().emit_err(errors::MultipleMainFunctions { span });
cx.sess().abort_if_errors();
bug!();
};
&metadata,
&exported_symbols::metadata_symbol_name(tcx),
);
- if let Err(err) = std::fs::write(&file_name, data) {
- tcx.sess.fatal(&format!("error writing metadata object file: {}", err));
+ if let Err(error) = std::fs::write(&file_name, data) {
+ tcx.sess.emit_fatal(errors::MetadataObjectFileWrite { error });
}
Some(CompiledModule {
name: metadata_cgu_name,
let subsystem = tcx.sess.first_attr_value_str_by_name(crate_attrs, sym::windows_subsystem);
let windows_subsystem = subsystem.map(|subsystem| {
if subsystem != sym::windows && subsystem != sym::console {
- tcx.sess.fatal(&format!(
- "invalid windows subsystem `{}`, only \
- `windows` and `console` are allowed",
- subsystem
- ));
+ tcx.sess.emit_fatal(errors::InvalidWindowsSubsystem { subsystem });
}
subsystem.to_string()
});
#[primary_span]
pub span: Span,
}
+
+#[derive(Diagnostic)]
+#[diag(codegen_ssa_multiple_main_functions)]
+#[help]
+pub struct MultipleMainFunctions {
+ #[primary_span]
+ pub span: Span,
+}
+
+#[derive(Diagnostic)]
+#[diag(codegen_ssa_metadata_object_file_write)]
+pub struct MetadataObjectFileWrite {
+ pub error: Error,
+}
+
+#[derive(Diagnostic)]
+#[diag(codegen_ssa_invalid_windows_subsystem)]
+pub struct InvalidWindowsSubsystem {
+ pub subsystem: Symbol,
+}
Don't know how to build archive of type: {$kind}
codegen_ssa_expected_used_symbol = expected `used`, `used(compiler)` or `used(linker)`
+
+codegen_ssa_multiple_main_functions = entry symbol `main` declared multiple times
+ .help = did you use `#[no_mangle]` on `fn main`? Use `#[start]` instead
+
+codegen_ssa_metadata_object_file_write = error writing metadata object file: {$error}
+
+codegen_ssa_invalid_windows_subsystem = invalid windows subsystem `{$subsystem}`, only `windows` and `console` are allowed