Skip to content

Commit

Permalink
Fix everything
Browse files Browse the repository at this point in the history
  • Loading branch information
bjorn3 committed Mar 8, 2024
1 parent b0ddd96 commit 9c5667a
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 14 deletions.
1 change: 1 addition & 0 deletions compiler/rustc_codegen_cranelift/build_system/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,7 @@ impl<'a> TestRunner<'a> {
cmd.arg("-Zunstable-options");
cmd.arg("--check-cfg=cfg(no_unstable_features)");
cmd.arg("--check-cfg=cfg(jit)");
cmd.arg("--emit=metadata,link");
cmd.args(args);
cmd
}
Expand Down
6 changes: 5 additions & 1 deletion compiler/rustc_metadata/src/rmeta/encoder.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::errors::{FailCreateFileEncoder, FailWriteFile};
use crate::errors::{FailCreateFileEncoder, FailWriteFile, FailedCreateFile};
use crate::rmeta::*;

use rustc_ast::Attribute;
Expand Down Expand Up @@ -2274,6 +2274,10 @@ pub fn encode_metadata(tcx: TyCtxt<'_>, path: &Path, ref_path: &Path) {
});
header.position.get()
});
} else {
std::fs::File::create(&ref_path).unwrap_or_else(|err| {
tcx.dcx().emit_fatal(FailedCreateFile { filename: &ref_path, err });
});
}
}

Expand Down
10 changes: 8 additions & 2 deletions src/bootstrap/src/core/build_steps/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1989,7 +1989,12 @@ pub fn run_cargo(
let file_stem = parts.next().unwrap().to_owned();
let extension = parts.next().unwrap().to_owned();

toplevel.push((file_stem, extension, expected_len));
if extension == "so" || extension == "dylib" {
// FIXME workaround for the fact that cargo doesn't understand `-Zsplit-metadata`
toplevel.push((file_stem.clone(), "rmeta".to_owned(), None));
}

toplevel.push((file_stem, extension, Some(expected_len)));
}
});

Expand All @@ -2010,7 +2015,7 @@ pub fn run_cargo(
.collect::<Vec<_>>();
for (prefix, extension, expected_len) in toplevel {
let candidates = contents.iter().filter(|&(_, filename, meta)| {
meta.len() == expected_len
expected_len.map_or(true, |expected_len| meta.len() == expected_len)
&& filename
.strip_prefix(&prefix[..])
.map(|s| s.starts_with('-') && s.ends_with(&extension[..]))
Expand All @@ -2021,6 +2026,7 @@ pub fn run_cargo(
});
let path_to_add = match max {
Some(triple) => triple.0.to_str().unwrap(),
None if extension == "rmeta" => continue, // cfg(not(bootstrap)) remove this once -Zsplit-metadata is passed for all stages
None => panic!("no output generated for {prefix:?} {extension:?}"),
};
if is_dylib(path_to_add) {
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/duplicate_entry_error.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@ normalize-stderr-test "loaded from .*libstd-.*.rlib" -> "loaded from SYSROOT/libstd-*.rlib"
//@ normalize-stderr-test "loaded from .*libstd-.*.rmeta" -> "loaded from SYSROOT/libstd-*.rmeta"
// note-pattern: first defined in crate `std`.

// Test for issue #31788 and E0152
Expand All @@ -9,7 +9,7 @@ use std::panic::PanicInfo;

#[lang = "panic_impl"]
fn panic_impl(info: &PanicInfo) -> ! {
//~^ ERROR: found duplicate lang item `panic_impl`
//~^ ERROR: found duplicate lang item `panic_impl`
loop {}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/duplicate_entry_error.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ LL | | }
| |_^
|
= note: the lang item is first defined in crate `std` (which `duplicate_entry_error` depends on)
= note: first definition in `std` loaded from SYSROOT/libstd-*.rlib
= note: first definition in `std` loaded from SYSROOT/libstd-*.rmeta
= note: second definition in the local crate (`duplicate_entry_error`)

error: aborting due to 1 previous error
Expand Down
5 changes: 2 additions & 3 deletions tests/ui/error-codes/E0152.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
//@ normalize-stderr-test "loaded from .*liballoc-.*.rlib" -> "loaded from SYSROOT/liballoc-*.rlib"
//@ normalize-stderr-test "loaded from .*liballoc-.*.rmeta" -> "loaded from SYSROOT/liballoc-*.rmeta"
#![feature(lang_items)]

#[lang = "owned_box"]
struct Foo<T>(T); //~ ERROR E0152

fn main() {
}
fn main() {}
2 changes: 1 addition & 1 deletion tests/ui/error-codes/E0152.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LL | struct Foo<T>(T);
| ^^^^^^^^^^^^^^^^^
|
= note: the lang item is first defined in crate `alloc` (which `std` depends on)
= note: first definition in `alloc` loaded from SYSROOT/liballoc-*.rlib
= note: first definition in `alloc` loaded from SYSROOT/liballoc-*.rmeta
= note: second definition in the local crate (`E0152`)

error: aborting due to 1 previous error
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/lang-items/duplicate.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@ normalize-stderr-test "loaded from .*libcore-.*.rlib" -> "loaded from SYSROOT/libcore-*.rlib"
//@ normalize-stderr-test "loaded from .*libcore-.*.rmeta" -> "loaded from SYSROOT/libcore-*.rmeta"
#![feature(lang_items)]

#[lang = "sized"]
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/lang-items/duplicate.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LL | trait Sized {}
| ^^^^^^^^^^^^^^
|
= note: the lang item is first defined in crate `core` (which `std` depends on)
= note: first definition in `core` loaded from SYSROOT/libcore-*.rlib
= note: first definition in `core` loaded from SYSROOT/libcore-*.rmeta
= note: second definition in the local crate (`duplicate`)

error: aborting due to 1 previous error
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/panic-handler/panic-handler-std.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@ normalize-stderr-test "loaded from .*libstd-.*.rlib" -> "loaded from SYSROOT/libstd-*.rlib"
//@ normalize-stderr-test "loaded from .*libstd-.*.rmeta" -> "loaded from SYSROOT/libstd-*.rmeta"
//@ error-pattern: found duplicate lang item `panic_impl`


Expand Down
2 changes: 1 addition & 1 deletion tests/ui/panic-handler/panic-handler-std.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ LL | | }
| |_^
|
= note: the lang item is first defined in crate `std` (which `panic_handler_std` depends on)
= note: first definition in `std` loaded from SYSROOT/libstd-*.rlib
= note: first definition in `std` loaded from SYSROOT/libstd-*.rmeta
= note: second definition in the local crate (`panic_handler_std`)

error: aborting due to 1 previous error
Expand Down

0 comments on commit 9c5667a

Please sign in to comment.