Fix stage2 test failures from call to span_lint.
span_lint was removed. Callers should use the `lint` method now, and call `set_span` within the closure passed to this method.
This commit is contained in:
parent
e450996193
commit
b959da2f4c
@ -4,17 +4,19 @@
|
||||
extern crate rustc_ast_pretty;
|
||||
extern crate rustc_driver;
|
||||
extern crate rustc_hir;
|
||||
#[macro_use] extern crate rustc_lint;
|
||||
#[macro_use] extern crate rustc_session;
|
||||
#[macro_use]
|
||||
extern crate rustc_lint;
|
||||
#[macro_use]
|
||||
extern crate rustc_session;
|
||||
extern crate rustc_span;
|
||||
extern crate syntax;
|
||||
|
||||
use rustc_ast_pretty::pprust;
|
||||
use rustc_hir::intravisit;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::Node;
|
||||
use rustc_lint::{LateContext, LintPass, LintArray, LateLintPass, LintContext};
|
||||
use rustc_driver::plugin::Registry;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::intravisit;
|
||||
use rustc_hir::Node;
|
||||
use rustc_lint::{LateContext, LateLintPass, LintArray, LintContext, LintPass};
|
||||
use rustc_span::source_map;
|
||||
|
||||
#[plugin_registrar]
|
||||
@ -32,14 +34,15 @@ declare_lint! {
|
||||
declare_lint_pass!(MissingWhitelistedAttrPass => [MISSING_WHITELISTED_ATTR]);
|
||||
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingWhitelistedAttrPass {
|
||||
fn check_fn(&mut self,
|
||||
cx: &LateContext<'a, 'tcx>,
|
||||
_: intravisit::FnKind<'tcx>,
|
||||
_: &'tcx hir::FnDecl,
|
||||
_: &'tcx hir::Body,
|
||||
span: source_map::Span,
|
||||
id: hir::HirId) {
|
||||
|
||||
fn check_fn(
|
||||
&mut self,
|
||||
cx: &LateContext<'a, 'tcx>,
|
||||
_: intravisit::FnKind<'tcx>,
|
||||
_: &'tcx hir::FnDecl,
|
||||
_: &'tcx hir::Body,
|
||||
span: source_map::Span,
|
||||
id: hir::HirId,
|
||||
) {
|
||||
let item = match cx.tcx.hir().get(id) {
|
||||
Node::Item(item) => item,
|
||||
_ => cx.tcx.hir().expect_item(cx.tcx.hir().get_parent_item(id)),
|
||||
@ -47,8 +50,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingWhitelistedAttrPass {
|
||||
|
||||
let whitelisted = |attr| pprust::attribute_to_string(attr).contains("whitelisted_attr");
|
||||
if !item.attrs.iter().any(whitelisted) {
|
||||
cx.span_lint(MISSING_WHITELISTED_ATTR, span,
|
||||
"Missing 'whitelisted_attr' attribute");
|
||||
cx.lint(MISSING_WHITELISTED_ATTR, |lint| {
|
||||
lint.build("Missing 'whitelisted_attr' attribute").set_span(span).emit()
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,12 +5,14 @@
|
||||
extern crate rustc_driver;
|
||||
extern crate rustc_hir;
|
||||
extern crate rustc_span;
|
||||
#[macro_use] extern crate rustc_lint;
|
||||
#[macro_use] extern crate rustc_session;
|
||||
#[macro_use]
|
||||
extern crate rustc_lint;
|
||||
#[macro_use]
|
||||
extern crate rustc_session;
|
||||
extern crate syntax;
|
||||
|
||||
use rustc_lint::{LateContext, LintContext, LintPass, LateLintPass};
|
||||
use rustc_driver::plugin::Registry;
|
||||
use rustc_lint::{LateContext, LateLintPass, LintContext, LintPass};
|
||||
use rustc_span::symbol::Symbol;
|
||||
use syntax::attr;
|
||||
|
||||
@ -28,8 +30,10 @@ macro_rules! fake_lint_pass {
|
||||
fn check_crate(&mut self, cx: &LateContext, krate: &rustc_hir::Crate) {
|
||||
$(
|
||||
if !attr::contains_name(&krate.attrs, $attr) {
|
||||
cx.span_lint(CRATE_NOT_OKAY, krate.span,
|
||||
&format!("crate is not marked with #![{}]", $attr));
|
||||
cx.lint(CRATE_NOT_OKAY, |lint| {
|
||||
let msg = format!("crate is not marked with #![{}]", $attr);
|
||||
lint.build(&msg).set_span(krate.span).emit()
|
||||
});
|
||||
}
|
||||
)*
|
||||
}
|
||||
|
@ -5,13 +5,15 @@
|
||||
|
||||
extern crate rustc_driver;
|
||||
extern crate rustc_hir;
|
||||
#[macro_use] extern crate rustc_lint;
|
||||
#[macro_use] extern crate rustc_session;
|
||||
#[macro_use]
|
||||
extern crate rustc_lint;
|
||||
#[macro_use]
|
||||
extern crate rustc_session;
|
||||
extern crate rustc_span;
|
||||
extern crate syntax;
|
||||
|
||||
use rustc_lint::{LateContext, LintContext, LintPass, LateLintPass, LintArray};
|
||||
use rustc_driver::plugin::Registry;
|
||||
use rustc_lint::{LateContext, LateLintPass, LintArray, LintContext, LintPass};
|
||||
use rustc_span::symbol::Symbol;
|
||||
use syntax::attr;
|
||||
|
||||
@ -26,8 +28,11 @@ declare_lint_pass!(Pass => [CRATE_NOT_OKAY]);
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
|
||||
fn check_crate(&mut self, cx: &LateContext, krate: &rustc_hir::Crate) {
|
||||
if !attr::contains_name(&krate.attrs, Symbol::intern("crate_okay")) {
|
||||
cx.span_lint(CRATE_NOT_OKAY, krate.span,
|
||||
"crate is not marked with #![crate_okay]");
|
||||
cx.lint(CRATE_NOT_OKAY, |lint| {
|
||||
lint.build("crate is not marked with #![crate_okay]")
|
||||
.set_span(krate.span)
|
||||
.emit()
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,11 +6,13 @@
|
||||
// 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;
|
||||
#[macro_use]
|
||||
extern crate rustc_lint;
|
||||
#[macro_use]
|
||||
extern crate rustc_session;
|
||||
|
||||
use rustc_lint::{LateContext, LintContext, LintPass, LateLintPass, LintArray, LintId};
|
||||
use rustc_driver::plugin::Registry;
|
||||
use rustc_lint::{LateContext, LateLintPass, LintArray, LintContext, LintId, LintPass};
|
||||
|
||||
declare_lint!(TEST_LINT, Warn, "Warn about items named 'lintme'");
|
||||
|
||||
@ -21,8 +23,12 @@ declare_lint_pass!(Pass => [TEST_LINT, PLEASE_LINT]);
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
|
||||
fn check_item(&mut self, cx: &LateContext, it: &rustc_hir::Item) {
|
||||
match &*it.ident.as_str() {
|
||||
"lintme" => cx.span_lint(TEST_LINT, it.span, "item is named 'lintme'"),
|
||||
"pleaselintme" => cx.span_lint(PLEASE_LINT, it.span, "item is named 'pleaselintme'"),
|
||||
"lintme" => cx.lint(TEST_LINT, |lint| {
|
||||
lint.build("item is named 'lintme'").set_span(it.span).emit()
|
||||
}),
|
||||
"pleaselintme" => cx.lint(PLEASE_LINT, |lint| {
|
||||
lint.build("item is named 'pleaselintme'").set_span(it.span).emit()
|
||||
}),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
@ -32,6 +38,10 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
|
||||
pub fn plugin_registrar(reg: &mut Registry) {
|
||||
reg.lint_store.register_lints(&[&TEST_LINT, &PLEASE_LINT]);
|
||||
reg.lint_store.register_late_pass(|| box Pass);
|
||||
reg.lint_store.register_group(true, "lint_me", None,
|
||||
vec![LintId::of(&TEST_LINT), LintId::of(&PLEASE_LINT)]);
|
||||
reg.lint_store.register_group(
|
||||
true,
|
||||
"lint_me",
|
||||
None,
|
||||
vec![LintId::of(&TEST_LINT), LintId::of(&PLEASE_LINT)],
|
||||
);
|
||||
}
|
||||
|
@ -7,11 +7,13 @@ extern crate syntax;
|
||||
|
||||
// Load rustc as a plugin to get macros
|
||||
extern crate rustc_driver;
|
||||
#[macro_use] extern crate rustc_lint;
|
||||
#[macro_use] extern crate rustc_session;
|
||||
#[macro_use]
|
||||
extern crate rustc_lint;
|
||||
#[macro_use]
|
||||
extern crate rustc_session;
|
||||
|
||||
use rustc_lint::{EarlyContext, LintContext, LintPass, EarlyLintPass, LintArray};
|
||||
use rustc_driver::plugin::Registry;
|
||||
use rustc_lint::{EarlyContext, EarlyLintPass, LintArray, LintContext, LintPass};
|
||||
use syntax::ast;
|
||||
declare_lint!(TEST_LINT, Warn, "Warn about items named 'lintme'");
|
||||
|
||||
@ -20,7 +22,9 @@ declare_lint_pass!(Pass => [TEST_LINT]);
|
||||
impl EarlyLintPass for Pass {
|
||||
fn check_item(&mut self, cx: &EarlyContext, it: &ast::Item) {
|
||||
if it.ident.name.as_str() == "lintme" {
|
||||
cx.span_lint(TEST_LINT, it.span, "item is named 'lintme'");
|
||||
cx.lint(TEST_LINT, |lint| {
|
||||
lint.build("item is named 'lintme'").set_span(it.span).emit()
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,11 +5,13 @@ extern crate syntax;
|
||||
|
||||
// Load rustc as a plugin to get macros
|
||||
extern crate rustc_driver;
|
||||
#[macro_use] extern crate rustc_lint;
|
||||
#[macro_use] extern crate rustc_session;
|
||||
#[macro_use]
|
||||
extern crate rustc_lint;
|
||||
#[macro_use]
|
||||
extern crate rustc_session;
|
||||
|
||||
use rustc_lint::{EarlyContext, EarlyLintPass, LintArray, LintContext, LintPass, LintId};
|
||||
use rustc_driver::plugin::Registry;
|
||||
use rustc_lint::{EarlyContext, EarlyLintPass, LintArray, LintContext, LintId, LintPass};
|
||||
use syntax::ast;
|
||||
declare_tool_lint!(pub clippy::TEST_LINT, Warn, "Warn about stuff");
|
||||
declare_tool_lint!(
|
||||
@ -30,10 +32,14 @@ declare_lint_pass!(Pass => [TEST_LINT, TEST_GROUP, TEST_RUSTC_TOOL_LINT]);
|
||||
impl EarlyLintPass for Pass {
|
||||
fn check_item(&mut self, cx: &EarlyContext, it: &ast::Item) {
|
||||
if it.ident.name.as_str() == "lintme" {
|
||||
cx.span_lint(TEST_LINT, it.span, "item is named 'lintme'");
|
||||
cx.lint(TEST_LINT, |lint| {
|
||||
lint.build("item is named 'lintme'").set_span(it.span).emit()
|
||||
});
|
||||
}
|
||||
if it.ident.name.as_str() == "lintmetoo" {
|
||||
cx.span_lint(TEST_GROUP, it.span, "item is named 'lintmetoo'");
|
||||
cx.lint(TEST_GROUP, |lint| {
|
||||
lint.build("item is named 'lintmetoo'").set_span(it.span).emit()
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -42,6 +48,10 @@ impl EarlyLintPass for Pass {
|
||||
pub fn plugin_registrar(reg: &mut Registry) {
|
||||
reg.lint_store.register_lints(&[&TEST_RUSTC_TOOL_LINT, &TEST_LINT, &TEST_GROUP]);
|
||||
reg.lint_store.register_early_pass(|| box Pass);
|
||||
reg.lint_store.register_group(true, "clippy::group", Some("clippy_group"),
|
||||
vec![LintId::of(&TEST_LINT), LintId::of(&TEST_GROUP)]);
|
||||
reg.lint_store.register_group(
|
||||
true,
|
||||
"clippy::group",
|
||||
Some("clippy_group"),
|
||||
vec![LintId::of(&TEST_LINT), LintId::of(&TEST_GROUP)],
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user