ignore compiler injected crate loading failure

This commit is contained in:
yukang
2026-04-03 09:16:26 +08:00
parent f1fbfd4c11
commit cd95593755
3 changed files with 16 additions and 2 deletions
+5 -1
View File
@@ -731,7 +731,11 @@ fn resolve_crate<'tcx>(
}
Err(err) => {
debug!("failed to resolve crate {} {:?}", name, dep_kind);
if !tcx.sess.dcx().has_errors().is_some() {
// crate maybe injrected with `standard_library_imports::inject`, their span is dummy.
// we ignore compiler-injected prelude/sysroot loads here so they don't suppress
// unrelated diagnostics, such as `unsupported targets for std library` etc,
// these maybe helpful for users to resolve crate loading failure.
if !tcx.sess.dcx().has_errors().is_some() && !span.is_dummy() {
self.has_crate_resolve_with_fail = true;
}
let missing_core = self
+3
View File
@@ -5,3 +5,6 @@
//@ ignore-emscripten missing eh_catch_typeinfo lang item
fn main() {}
//~? ERROR `#[panic_handler]` function required, but not found
//~? ERROR unwinding panics are not supported without std
+8 -1
View File
@@ -2,5 +2,12 @@ error: extern location for std does not exist:
error: cannot resolve a prelude import
error: aborting due to 2 previous errors
error: `#[panic_handler]` function required, but not found
error: unwinding panics are not supported without std
|
= help: using nightly cargo, use -Zbuild-std with panic="abort" to avoid unwinding
= 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
error: aborting due to 4 previous errors