Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions compiler/rustc_codegen_llvm/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@ pub(crate) struct ParseTargetMachineConfig<'a>(pub LlvmError<'a>);

impl<G: EmissionGuarantee> Diagnostic<'_, G> for ParseTargetMachineConfig<'_> {
fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_, G> {
let diag: Diag<'_, G> = self.0.into_diag(dcx, level);
// Reuse the formatted primary message from `LlvmError` without emitting it.
let diag: Diag<'_, ()> = self.0.into_diag(dcx, level);
let (message, _) = diag.messages.first().expect("`LlvmError` with no message");
let message = format_diag_message(message, &diag.args);
let message = format_diag_message(message, &diag.args).into_owned();
diag.cancel();

Diag::new(
dcx,
level,
Expand Down
1 change: 1 addition & 0 deletions src/tools/tidy/src/ui_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ fn check_unexpected_extension(check: &mut RunningCheck, file_path: &Path, ext: &
"tests/ui/asm/named-asm-labels.s", // loading an external asm file to test named labels lint
"tests/ui/asm/normalize-offsets-for-crlf.s", // loading an external asm file to test CRLF normalization
"tests/ui/codegen/mismatched-data-layout.json", // testing mismatched data layout w/ custom targets
"tests/ui/codegen/custom-target-invalid-llvm-target.json", // testing invalid custom targets
"tests/ui/check-cfg/my-awesome-platform.json", // testing custom targets with cfgs
"tests/ui/argfile/commandline-argfile-badutf8.args", // passing args via a file
"tests/ui/argfile/commandline-argfile.args", // passing args via a file
Expand Down
6 changes: 6 additions & 0 deletions tests/ui/codegen/custom-target-invalid-llvm-target.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"llvm-target": "not-a-real-target",
"data-layout": "e",
"arch": "x86_64",
"target-pointer-width": 64
}
10 changes: 10 additions & 0 deletions tests/ui/codegen/custom-target-invalid-llvm-target.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Regression test for https://github.com/rust-lang/rust/issues/157401

// ignore-tidy-target-specific-tests
//@ check-fail
//@ compile-flags: --target={{src-base}}/codegen/custom-target-invalid-llvm-target.json -Z unstable-options
//@ ignore-backends: gcc

fn main() {}

//~? ERROR failed to parse target machine config to target machine
2 changes: 2 additions & 0 deletions tests/ui/codegen/custom-target-invalid-llvm-target.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
error: failed to parse target machine config to target machine: could not create LLVM TargetMachine for triple: not-a-real-target

Loading