Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
11 changes: 11 additions & 0 deletions compiler/rustc_metadata/src/creader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ pub struct CStore {
unused_externs: Vec<Symbol>,

used_extern_options: FxHashSet<Symbol>,
/// Whether there was a failure in resolving crate,
/// it's used to suppress some diagnostics that would otherwise too noisey.
has_crate_resolve_with_fail: bool,
}

impl std::fmt::Debug for CStore {
Expand Down Expand Up @@ -328,6 +331,10 @@ impl CStore {
self.has_alloc_error_handler
}

pub fn had_extern_crate_load_failure(&self) -> bool {
self.has_crate_resolve_with_fail
}

pub fn report_unused_deps(&self, tcx: TyCtxt<'_>) {
let json_unused_externs = tcx.sess.opts.json_unused_externs;

Expand Down Expand Up @@ -514,6 +521,7 @@ impl CStore {
resolved_externs: UnordMap::default(),
unused_externs: Vec::new(),
used_extern_options: Default::default(),
has_crate_resolve_with_fail: false,
}
}

Expand Down Expand Up @@ -723,6 +731,9 @@ impl CStore {
}
Err(err) => {
debug!("failed to resolve crate {} {:?}", name, dep_kind);
if !tcx.sess.dcx().has_errors().is_some() {
self.has_crate_resolve_with_fail = true;
}
let missing_core = self
.maybe_resolve_crate(
tcx,
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_resolve/src/imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,10 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
}
}

if self.cstore().had_extern_crate_load_failure() {
self.tcx.sess.dcx().abort_if_errors();
}

if !errors.is_empty() {
self.throw_unresolved_import_error(errors, glob_error);
return;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//@ edition: 2024

extern crate missing_154096;
//~^ ERROR can't find crate for `missing_154096`

mod defs {
pub use missing_154096::Thing;
}

pub use defs::Thing;

mod first {
use crate::Thing;

pub fn take(_: Thing) {}
}

mod second {
use crate::Thing;

pub fn take(_: Thing) {}
}

fn main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
error[E0463]: can't find crate for `missing_154096`
--> $DIR/missing-extern-crate-cascade-issue-154096.rs:3:1
|
LL | extern crate missing_154096;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0463`.
3 changes: 0 additions & 3 deletions tests/ui/extern-flag/empty-extern-arg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,3 @@
//@ 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
9 changes: 1 addition & 8 deletions tests/ui/extern-flag/empty-extern-arg.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,5 @@ error: extern location for std does not exist:

error: cannot resolve a prelude import

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
error: aborting due to 2 previous errors

1 change: 0 additions & 1 deletion tests/ui/rust-2018/uniform-paths/deadlock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@

use bar::foo; //~ ERROR can't find crate for `bar`
use foo::bar;
//~^^ ERROR unresolved imports `bar::foo`, `foo::bar`

fn main() {}
13 changes: 2 additions & 11 deletions tests/ui/rust-2018/uniform-paths/deadlock.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,6 @@ error[E0463]: can't find crate for `bar`
LL | use bar::foo;
| ^^^ can't find crate

error[E0432]: unresolved imports `bar::foo`, `foo::bar`
--> $DIR/deadlock.rs:4:5
|
LL | use bar::foo;
| ^^^^^^^^
LL | use foo::bar;
| ^^^^^^^^

error: aborting due to 2 previous errors
error: aborting due to 1 previous error

Some errors have detailed explanations: E0432, E0463.
For more information about an error, try `rustc --explain E0432`.
For more information about this error, try `rustc --explain E0463`.
Loading