Add help for the error message when missing rustc_driver
This commit is contained in:
parent
5c84f76f57
commit
7837058073
@ -4,6 +4,11 @@ metadata_rlib_required =
|
||||
metadata_lib_required =
|
||||
crate `{$crate_name}` required to be available in {$kind} format, but was not found in this form
|
||||
|
||||
metadata_rustc_lib_required =
|
||||
crate `{$crate_name}` required to be available in {$kind} format, but was not found in this form
|
||||
.note = only .rmeta files are distributed for `rustc_private` crates other than `rustc_driver`
|
||||
.help = try adding `extern crate rustc_driver;` at the top level of this crate
|
||||
|
||||
metadata_crate_dep_multiple =
|
||||
cannot satisfy dependencies so `{$crate_name}` only shows up once
|
||||
.help = having upstream crates all available in one format will likely make this go away
|
||||
|
@ -54,7 +54,7 @@
|
||||
use crate::creader::CStore;
|
||||
use crate::errors::{
|
||||
BadPanicStrategy, CrateDepMultiple, IncompatiblePanicInDropStrategy, LibRequired,
|
||||
RequiredPanicStrategy, RlibRequired, TwoPanicRuntimes,
|
||||
RequiredPanicStrategy, RlibRequired, RustcLibRequired, TwoPanicRuntimes,
|
||||
};
|
||||
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
@ -224,7 +224,12 @@ fn calculate_type(tcx: TyCtxt<'_>, ty: CrateType) -> DependencyList {
|
||||
Linkage::Static => "rlib",
|
||||
_ => "dylib",
|
||||
};
|
||||
sess.emit_err(LibRequired { crate_name: tcx.crate_name(cnum), kind: kind });
|
||||
let crate_name = tcx.crate_name(cnum);
|
||||
if crate_name.as_str().starts_with("rustc_") {
|
||||
sess.emit_err(RustcLibRequired { crate_name, kind });
|
||||
} else {
|
||||
sess.emit_err(LibRequired { crate_name, kind });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +24,14 @@ pub struct LibRequired<'a> {
|
||||
pub kind: &'a str,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(metadata_rustc_lib_required)]
|
||||
#[help]
|
||||
pub struct RustcLibRequired<'a> {
|
||||
pub crate_name: Symbol,
|
||||
pub kind: &'a str,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(metadata_crate_dep_multiple)]
|
||||
#[help]
|
||||
|
9
src/test/ui-fulldeps/missing-rustc-driver-error.rs
Normal file
9
src/test/ui-fulldeps/missing-rustc-driver-error.rs
Normal file
@ -0,0 +1,9 @@
|
||||
// Test that we get the following hint when trying to use a compiler crate without rustc_driver.
|
||||
// error-pattern: try adding `extern crate rustc_driver;` at the top level of this crate
|
||||
// compile-flags: --emit link
|
||||
|
||||
#![feature(rustc_private)]
|
||||
|
||||
extern crate rustc_serialize;
|
||||
|
||||
fn main() {}
|
24
src/test/ui-fulldeps/missing-rustc-driver-error.stderr
Normal file
24
src/test/ui-fulldeps/missing-rustc-driver-error.stderr
Normal file
@ -0,0 +1,24 @@
|
||||
error: crate `rustc_serialize` required to be available in rlib format, but was not found in this form
|
||||
|
|
||||
= help: try adding `extern crate rustc_driver;` at the top level of this crate
|
||||
|
||||
error: crate `smallvec` required to be available in rlib format, but was not found in this form
|
||||
|
||||
error: crate `thin_vec` required to be available in rlib format, but was not found in this form
|
||||
|
||||
error: crate `indexmap` required to be available in rlib format, but was not found in this form
|
||||
|
||||
error: crate `hashbrown` required to be available in rlib format, but was not found in this form
|
||||
|
||||
error: crate `ahash` required to be available in rlib format, but was not found in this form
|
||||
|
||||
error: crate `once_cell` required to be available in rlib format, but was not found in this form
|
||||
|
||||
error: crate `getrandom` required to be available in rlib format, but was not found in this form
|
||||
|
||||
error: crate `cfg_if` required to be available in rlib format, but was not found in this form
|
||||
|
||||
error: crate `libc` required to be available in rlib format, but was not found in this form
|
||||
|
||||
error: aborting due to 10 previous errors
|
||||
|
Loading…
x
Reference in New Issue
Block a user