Skip to content

Commit 52bc7ce

Browse files
committed
Make not finding core a fatal error
1 parent da02fff commit 52bc7ce

File tree

5 files changed

+21
-23
lines changed

5 files changed

+21
-23
lines changed

compiler/rustc_metadata/src/locator.rs

+18-4
Original file line numberDiff line numberDiff line change
@@ -1077,7 +1077,7 @@ impl CrateError {
10771077
crate_rejections,
10781078
});
10791079
} else {
1080-
dcx.emit_err(errors::CannotFindCrate {
1080+
let error = errors::CannotFindCrate {
10811081
span,
10821082
crate_name,
10831083
add_info,
@@ -1091,11 +1091,18 @@ impl CrateError {
10911091
profiler_runtime: Symbol::intern(&sess.opts.unstable_opts.profiler_runtime),
10921092
locator_triple: locator.triple,
10931093
is_ui_testing: sess.opts.unstable_opts.ui_testing,
1094-
});
1094+
};
1095+
// The diagnostic for missing core is very good, but it is followed by a lot of
1096+
// other diagnostics that do not add information.
1097+
if missing_core {
1098+
dcx.emit_fatal(error);
1099+
} else {
1100+
dcx.emit_err(error);
1101+
}
10951102
}
10961103
}
10971104
CrateError::NotFound(crate_name) => {
1098-
dcx.emit_err(errors::CannotFindCrate {
1105+
let error = errors::CannotFindCrate {
10991106
span,
11001107
crate_name,
11011108
add_info: String::new(),
@@ -1105,7 +1112,14 @@ impl CrateError {
11051112
profiler_runtime: Symbol::intern(&sess.opts.unstable_opts.profiler_runtime),
11061113
locator_triple: sess.opts.target_triple.clone(),
11071114
is_ui_testing: sess.opts.unstable_opts.ui_testing,
1108-
});
1115+
};
1116+
// The diagnostic for missing core is very good, but it is followed by a lot of
1117+
// other diagnostics that do not add information.
1118+
if missing_core {
1119+
dcx.emit_fatal(error);
1120+
} else {
1121+
dcx.emit_err(error);
1122+
}
11091123
}
11101124
}
11111125
}

tests/ui/crate-loading/missing-std.stderr

+1-3
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ LL | extern crate core;
88
= help: consider downloading the target with `rustup target add x86_64-unknown-uefi`
99
= help: consider building the standard library from source with `cargo build -Zbuild-std`
1010

11-
error: requires `sized` lang_item
12-
13-
error: aborting due to 2 previous errors
11+
error: aborting due to 1 previous error
1412

1513
For more information about this error, try `rustc --explain E0463`.

tests/ui/issues/issue-37131.stderr

+1-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ error[E0463]: can't find crate for `std`
44
= help: consider downloading the target with `rustup target add thumbv6m-none-eabi`
55
= help: consider building the standard library from source with `cargo build -Zbuild-std`
66

7-
error: requires `sized` lang_item
8-
9-
error: aborting due to 2 previous errors
7+
error: aborting due to 1 previous error
108

119
For more information about this error, try `rustc --explain E0463`.
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//~ ERROR can't find crate for `core`
2-
//~^ ERROR can't find crate for `compiler_builtins`
32

43
//@ compile-flags: --target thumbv7em-none-eabihf
54
//@ needs-llvm-components: arm
@@ -8,6 +7,5 @@
87
#![no_std]
98

109
extern crate cortex_m;
11-
//~^ ERROR can't find crate for `cortex_m`
1210

1311
fn main() {}

tests/ui/issues/issue-49851/compiler-builtins-error.stderr

+1-11
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,6 @@ error[E0463]: can't find crate for `core`
44
= help: consider downloading the target with `rustup target add thumbv7em-none-eabihf`
55
= help: consider building the standard library from source with `cargo build -Zbuild-std`
66

7-
error[E0463]: can't find crate for `compiler_builtins`
8-
9-
error[E0463]: can't find crate for `cortex_m`
10-
--> $DIR/compiler-builtins-error.rs:10:1
11-
|
12-
LL | extern crate cortex_m;
13-
| ^^^^^^^^^^^^^^^^^^^^^^ can't find crate
14-
15-
error: requires `sized` lang_item
16-
17-
error: aborting due to 4 previous errors
7+
error: aborting due to 1 previous error
188

199
For more information about this error, try `rustc --explain E0463`.

0 commit comments

Comments
 (0)