d6af60266e
Nils had an excellent idea the other day: the same way that rustdoc is able to load `rustc_driver` from the sysroot, ui-fulldeps tests should also be able to load it from the sysroot. That allows us to run fulldeps tests with stage1, without having to fully rebuild the compiler twice. It does unfortunately have the downside that we're running the tests on the *bootstrap* compiler, not the in-tree sources, but since most of the fulldeps tests are for the *API* of the compiler, that seems ok. I think it's possible to extend this to `run-make-fulldeps`, but I've run out of energy for tonight. - Move `plugin` tests into a subdirectory. Plugins are loaded at runtime with `dlopen` and so require the ABI of the running compile to match the ABI of the compiler linked with `rustc_driver`. As a result they can't be supported in stage 1 and have to use `// ignore-stage1`. - Remove `ignore-stage1` from most non-plugin tests - Ignore diagnostic tests in stage 1. Even though this requires a stage 2 build to load rustc_driver, it's primarily testing the error message that the *running* compiler emits when the diagnostic struct is malformed. - Pass `-Zforce-unstable-if-unmarked` in stage1, not just stage2. That allows running `hash-stable-is-unstable` in stage1, since it now suggests adding `rustc_private` to enable loading the crates. - Add libLLVM.so to the stage0 target sysroot, to allow fulldeps tests that act as custom drivers to load it at runtime. - Pass `--sysroot stage0-sysroot` in compiletest so that we use the correct version of std.
45 lines
1.3 KiB
Rust
45 lines
1.3 KiB
Rust
// force-host
|
|
|
|
#![feature(rustc_private)]
|
|
|
|
// Load rustc as a plugin to get macros.
|
|
extern crate rustc_driver;
|
|
extern crate rustc_hir;
|
|
#[macro_use]
|
|
extern crate rustc_lint;
|
|
#[macro_use]
|
|
extern crate rustc_session;
|
|
|
|
use rustc_driver::plugin::Registry;
|
|
use rustc_lint::{LateContext, LateLintPass, LintArray, LintContext, LintId, LintPass};
|
|
|
|
declare_lint!(TEST_LINT, Warn, "Warn about items named 'lintme'");
|
|
|
|
declare_lint!(PLEASE_LINT, Warn, "Warn about items named 'pleaselintme'");
|
|
|
|
declare_lint_pass!(Pass => [TEST_LINT, PLEASE_LINT]);
|
|
|
|
impl<'tcx> LateLintPass<'tcx> for Pass {
|
|
fn check_item(&mut self, cx: &LateContext, it: &rustc_hir::Item) {
|
|
match it.ident.as_str() {
|
|
"lintme" => cx.lint(TEST_LINT, "item is named 'lintme'", |lint| lint.set_span(it.span)),
|
|
"pleaselintme" => {
|
|
cx.lint(PLEASE_LINT, "item is named 'pleaselintme'", |lint| lint.set_span(it.span))
|
|
}
|
|
_ => {}
|
|
}
|
|
}
|
|
}
|
|
|
|
#[no_mangle]
|
|
fn __rustc_plugin_registrar(reg: &mut Registry) {
|
|
reg.lint_store.register_lints(&[&TEST_LINT, &PLEASE_LINT]);
|
|
reg.lint_store.register_late_pass(|_| Box::new(Pass));
|
|
reg.lint_store.register_group(
|
|
true,
|
|
"lint_me",
|
|
None,
|
|
vec![LintId::of(&TEST_LINT), LintId::of(&PLEASE_LINT)],
|
|
);
|
|
}
|