From 659b0a2fd94440c9429fff6ec9967990b219caf0 Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Sun, 12 Sep 2021 13:19:04 +0200 Subject: [PATCH] Bless tests. --- .../run-make-fulldeps/obtain-borrowck/driver.rs | 5 +---- .../ui-fulldeps/auxiliary/lint-for-crate-rpass.rs | 6 ++++-- src/test/ui-fulldeps/auxiliary/lint-for-crate.rs | 13 ++++++------- src/test/ui/privacy/privacy2.stderr | 8 +++++++- src/test/ui/privacy/privacy3.stderr | 8 +++++++- 5 files changed, 25 insertions(+), 15 deletions(-) diff --git a/src/test/run-make-fulldeps/obtain-borrowck/driver.rs b/src/test/run-make-fulldeps/obtain-borrowck/driver.rs index 961ea518c13..a288b90d792 100644 --- a/src/test/run-make-fulldeps/obtain-borrowck/driver.rs +++ b/src/test/run-make-fulldeps/obtain-borrowck/driver.rs @@ -48,7 +48,6 @@ fn main() { pub struct CompilerCalls; impl rustc_driver::Callbacks for CompilerCalls { - // In this callback we override the mir_borrowck query. fn config(&mut self, config: &mut Config) { assert!(config.override_queries.is_none()); @@ -64,12 +63,10 @@ impl rustc_driver::Callbacks for CompilerCalls { ) -> Compilation { compiler.session().abort_if_errors(); queries.global_ctxt().unwrap().peek_mut().enter(|tcx| { - // Collect definition ids of MIR bodies. let hir = tcx.hir(); - let krate = hir.krate(); let mut visitor = HirVisitor { bodies: Vec::new() }; - krate.visit_all_item_likes(&mut visitor); + hir.visit_all_item_likes(&mut visitor); // Trigger borrow checking of all bodies. for def_id in visitor.bodies { diff --git a/src/test/ui-fulldeps/auxiliary/lint-for-crate-rpass.rs b/src/test/ui-fulldeps/auxiliary/lint-for-crate-rpass.rs index fc57c14ec32..e726f8402ef 100644 --- a/src/test/ui-fulldeps/auxiliary/lint-for-crate-rpass.rs +++ b/src/test/ui-fulldeps/auxiliary/lint-for-crate-rpass.rs @@ -13,6 +13,7 @@ extern crate rustc_ast; use rustc_ast::attr; use rustc_driver::plugin::Registry; use rustc_lint::{LateContext, LateLintPass, LintContext, LintPass}; +use rustc_span::def_id::CRATE_DEF_ID; use rustc_span::symbol::Symbol; macro_rules! fake_lint_pass { @@ -26,13 +27,14 @@ macro_rules! fake_lint_pass { } impl LateLintPass<'_> for $struct { - fn check_crate(&mut self, cx: &LateContext, krate: &rustc_hir::Crate) { + fn check_crate(&mut self, cx: &LateContext) { let attrs = cx.tcx.hir().attrs(rustc_hir::CRATE_HIR_ID); + let span = cx.tcx.def_span(CRATE_DEF_ID); $( if !cx.sess().contains_name(attrs, $attr) { cx.lint(CRATE_NOT_OKAY, |lint| { let msg = format!("crate is not marked with #![{}]", $attr); - lint.build(&msg).set_span(krate.module().inner).emit() + lint.build(&msg).set_span(span).emit() }); } )* diff --git a/src/test/ui-fulldeps/auxiliary/lint-for-crate.rs b/src/test/ui-fulldeps/auxiliary/lint-for-crate.rs index 78c6c7ed887..4bbed502980 100644 --- a/src/test/ui-fulldeps/auxiliary/lint-for-crate.rs +++ b/src/test/ui-fulldeps/auxiliary/lint-for-crate.rs @@ -8,13 +8,13 @@ extern crate rustc_hir; extern crate rustc_lint; #[macro_use] extern crate rustc_session; -extern crate rustc_span; extern crate rustc_ast; +extern crate rustc_span; use rustc_driver::plugin::Registry; -use rustc_lint::{LateContext, LateLintPass, LintArray, LintContext, LintPass}; +use rustc_lint::{LateContext, LateLintPass, LintContext}; +use rustc_span::def_id::CRATE_DEF_ID; use rustc_span::symbol::Symbol; -use rustc_ast::attr; declare_lint! { CRATE_NOT_OKAY, @@ -25,13 +25,12 @@ declare_lint! { declare_lint_pass!(Pass => [CRATE_NOT_OKAY]); impl<'tcx> LateLintPass<'tcx> for Pass { - fn check_crate(&mut self, cx: &LateContext, krate: &rustc_hir::Crate) { + fn check_crate(&mut self, cx: &LateContext) { let attrs = cx.tcx.hir().attrs(rustc_hir::CRATE_HIR_ID); + let span = cx.tcx.def_span(CRATE_DEF_ID); if !cx.sess().contains_name(attrs, Symbol::intern("crate_okay")) { cx.lint(CRATE_NOT_OKAY, |lint| { - lint.build("crate is not marked with #![crate_okay]") - .set_span(krate.module().inner) - .emit() + lint.build("crate is not marked with #![crate_okay]").set_span(span).emit() }); } } diff --git a/src/test/ui/privacy/privacy2.stderr b/src/test/ui/privacy/privacy2.stderr index c2a33ce1f59..882f314655d 100644 --- a/src/test/ui/privacy/privacy2.stderr +++ b/src/test/ui/privacy/privacy2.stderr @@ -23,7 +23,13 @@ LL | pub fn foo() {} error: requires `sized` lang_item -error: aborting due to 3 previous errors +error: requires `sized` lang_item + +error: requires `sized` lang_item + +error: requires `sized` lang_item + +error: aborting due to 6 previous errors Some errors have detailed explanations: E0432, E0603. For more information about an error, try `rustc --explain E0432`. diff --git a/src/test/ui/privacy/privacy3.stderr b/src/test/ui/privacy/privacy3.stderr index 22c1e48b07d..42ce456d962 100644 --- a/src/test/ui/privacy/privacy3.stderr +++ b/src/test/ui/privacy/privacy3.stderr @@ -6,6 +6,12 @@ LL | use bar::gpriv; error: requires `sized` lang_item -error: aborting due to 2 previous errors +error: requires `sized` lang_item + +error: requires `sized` lang_item + +error: requires `sized` lang_item + +error: aborting due to 5 previous errors For more information about this error, try `rustc --explain E0432`.