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