From 9521deecc4992d31f761a3bd7e3b60479837cd1d Mon Sep 17 00:00:00 2001 From: flip1995 <9744647+flip1995@users.noreply.github.com> Date: Mon, 27 Aug 2018 23:22:47 +0200 Subject: [PATCH] Add tests for backward compat --- .../ui-fulldeps/auxiliary/lint_tool_test.rs | 7 ++- src/test/ui-fulldeps/lint_tool_test.rs | 16 +++++- src/test/ui-fulldeps/lint_tool_test.stderr | 56 +++++++++++++++++-- 3 files changed, 72 insertions(+), 7 deletions(-) diff --git a/src/test/ui-fulldeps/auxiliary/lint_tool_test.rs b/src/test/ui-fulldeps/auxiliary/lint_tool_test.rs index d7895bd8781..e184c0919d0 100644 --- a/src/test/ui-fulldeps/auxiliary/lint_tool_test.rs +++ b/src/test/ui-fulldeps/auxiliary/lint_tool_test.rs @@ -25,12 +25,13 @@ use rustc_plugin::Registry; use syntax::ast; declare_tool_lint!(pub clippy::TEST_LINT, Warn, "Warn about stuff"); +declare_tool_lint!(pub clippy::TEST_GROUP, Warn, "Warn about other stuff"); struct Pass; impl LintPass for Pass { fn get_lints(&self) -> LintArray { - lint_array!(TEST_LINT) + lint_array!(TEST_LINT, TEST_GROUP) } } @@ -39,10 +40,14 @@ fn check_item(&mut self, cx: &EarlyContext, it: &ast::Item) { if it.ident.name == "lintme" { cx.span_lint(TEST_LINT, it.span, "item is named 'lintme'"); } + if it.ident.name == "lintmetoo" { + cx.span_lint(TEST_GROUP, it.span, "item is named 'lintmetoo'"); + } } } #[plugin_registrar] pub fn plugin_registrar(reg: &mut Registry) { reg.register_early_lint_pass(box Pass); + reg.register_lint_group("clippy::group", Some("clippy_group"), vec![TEST_LINT, TEST_GROUP]); } diff --git a/src/test/ui-fulldeps/lint_tool_test.rs b/src/test/ui-fulldeps/lint_tool_test.rs index ccdcd2df31b..a132e1d5c6b 100644 --- a/src/test/ui-fulldeps/lint_tool_test.rs +++ b/src/test/ui-fulldeps/lint_tool_test.rs @@ -8,17 +8,29 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// run-pass // aux-build:lint_tool_test.rs // ignore-stage1 #![feature(plugin)] #![feature(tool_lints)] #![plugin(lint_tool_test)] #![allow(dead_code)] +#![deny(clippy_group)] +//~^ WARNING lint name `clippy_group` is deprecated and may not have an effect in the future -fn lintme() { } //~ WARNING item is named 'lintme' +fn lintme() { } //~ ERROR item is named 'lintme' + +#[allow(clippy::group)] +fn lintmetoo() {} #[allow(clippy::test_lint)] pub fn main() { fn lintme() { } + fn lintmetoo() { } //~ ERROR item is named 'lintmetoo' +} + +#[allow(test_group)] +//~^ WARNING lint name `test_group` is deprecated and may not have an effect in the future +#[deny(this_lint_does_not_exist)] //~ WARNING unknown lint: `this_lint_does_not_exist` +fn hello() { + fn lintmetoo() { } } diff --git a/src/test/ui-fulldeps/lint_tool_test.stderr b/src/test/ui-fulldeps/lint_tool_test.stderr index 22d0f458e7d..2b3c45439ca 100644 --- a/src/test/ui-fulldeps/lint_tool_test.stderr +++ b/src/test/ui-fulldeps/lint_tool_test.stderr @@ -1,8 +1,56 @@ -warning: item is named 'lintme' - --> $DIR/lint_tool_test.rs:19:1 +warning: lint name `clippy_group` is deprecated and may not have an effect in the future + --> $DIR/lint_tool_test.rs:17:9 | -LL | fn lintme() { } //~ WARNING item is named 'lintme' +LL | #![deny(clippy_group)] + | ^^^^^^^^^^^^ help: change it to: `clippy::group` + | + = note: #[warn(renamed_and_removed_lints)] on by default + +warning: lint name `test_group` is deprecated and may not have an effect in the future + --> $DIR/lint_tool_test.rs:31:9 + | +LL | #[allow(test_group)] + | ^^^^^^^^^^ help: change it to: `clippy::test_group` + +warning: unknown lint: `this_lint_does_not_exist` + --> $DIR/lint_tool_test.rs:33:8 + | +LL | #[deny(this_lint_does_not_exist)] //~ WARNING unknown lint: `this_lint_does_not_exist` + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: #[warn(unknown_lints)] on by default + +warning: lint name `clippy_group` is deprecated and may not have an effect in the future + --> $DIR/lint_tool_test.rs:17:9 + | +LL | #![deny(clippy_group)] + | ^^^^^^^^^^^^ help: change it to: `clippy::group` + +error: item is named 'lintme' + --> $DIR/lint_tool_test.rs:20:1 + | +LL | fn lintme() { } //~ ERROR item is named 'lintme' | ^^^^^^^^^^^^^^^ | - = note: #[warn(clippy::test_lint)] on by default +note: lint level defined here + --> $DIR/lint_tool_test.rs:17:9 + | +LL | #![deny(clippy_group)] + | ^^^^^^^^^^^^ + = note: #[deny(clippy::test_lint)] implied by #[deny(clippy::group)] + +error: item is named 'lintmetoo' + --> $DIR/lint_tool_test.rs:28:5 + | +LL | fn lintmetoo() { } //~ ERROR item is named 'lintmetoo' + | ^^^^^^^^^^^^^^^^^^ + | +note: lint level defined here + --> $DIR/lint_tool_test.rs:17:9 + | +LL | #![deny(clippy_group)] + | ^^^^^^^^^^^^ + = note: #[deny(clippy::test_group)] implied by #[deny(clippy::group)] + +error: aborting due to 2 previous errors -- 2.44.0