Skip to content

Commit cd95593

Browse files
committed
ignore compiler injected crate loading failure
1 parent f1fbfd4 commit cd95593

3 files changed

Lines changed: 16 additions & 2 deletions

File tree

compiler/rustc_metadata/src/creader.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -731,7 +731,11 @@ impl CStore {
731731
}
732732
Err(err) => {
733733
debug!("failed to resolve crate {} {:?}", name, dep_kind);
734-
if !tcx.sess.dcx().has_errors().is_some() {
734+
// crate maybe injrected with `standard_library_imports::inject`, their span is dummy.
735+
// we ignore compiler-injected prelude/sysroot loads here so they don't suppress
736+
// unrelated diagnostics, such as `unsupported targets for std library` etc,
737+
// these maybe helpful for users to resolve crate loading failure.
738+
if !tcx.sess.dcx().has_errors().is_some() && !span.is_dummy() {
735739
self.has_crate_resolve_with_fail = true;
736740
}
737741
let missing_core = self

tests/ui/extern-flag/empty-extern-arg.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@
55
//@ ignore-emscripten missing eh_catch_typeinfo lang item
66

77
fn main() {}
8+
9+
//~? ERROR `#[panic_handler]` function required, but not found
10+
//~? ERROR unwinding panics are not supported without std

tests/ui/extern-flag/empty-extern-arg.stderr

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,12 @@ error: extern location for std does not exist:
22

33
error: cannot resolve a prelude import
44

5-
error: aborting due to 2 previous errors
5+
error: `#[panic_handler]` function required, but not found
6+
7+
error: unwinding panics are not supported without std
8+
|
9+
= help: using nightly cargo, use -Zbuild-std with panic="abort" to avoid unwinding
10+
= note: since the core library is usually precompiled with panic="unwind", rebuilding your crate with panic="abort" may not be enough to fix the problem
11+
12+
error: aborting due to 4 previous errors
613

0 commit comments

Comments
 (0)