Improve force-warn tests

This commit is contained in:
Ryan Levick 2021-08-18 11:05:59 +02:00
parent cbe3afece5
commit 0d2fd70dab
28 changed files with 114 additions and 11 deletions

View file

@ -1,3 +1,5 @@
// --force-warn $LINT causes $LINT (which is warn-by-default) to warn
// despite allowing all warnings in module
// compile-flags: --force-warn dead_code -Zunstable-options
// check-pass

View file

@ -1,5 +1,5 @@
warning: function is never used: `dead_function`
--> $DIR/force-allowed-warning.rs:6:4
--> $DIR/allow-warnings.rs:8:4
|
LL | fn dead_function() {}
| ^^^^^^^^^^^^^

View file

@ -1,3 +1,4 @@
// --force-warn $LINT causes $LINT (which is allow-by-default) to warn
// compile-flags: --force-warn elided_lifetimes_in_paths -Zunstable-options
// check-pass

View file

@ -1,5 +1,5 @@
warning: hidden lifetime parameters in types are deprecated
--> $DIR/force-allowed-by-default-lint.rs:8:12
--> $DIR/allowed-by-default-lint.rs:9:12
|
LL | fn foo(x: &Foo) {}
| ^^^- help: indicate the anonymous lifetime: `<'_>`

View file

@ -0,0 +1,10 @@
// --force-warn $LINT causes $LINT (which is deny-by-default) to warn
// despite $LINT being allowed on command line
// compile-flags: -A const_err --force-warn const_err -Zunstable-options
// check-pass
const C: i32 = 1 / 0;
//~^ WARN any use of this value will cause an error
//~| WARN this was previously accepted by the compiler
fn main() {}

View file

@ -1,5 +1,5 @@
warning: any use of this value will cause an error
--> $DIR/force-allowed-deny-by-default-lint.rs:5:16
--> $DIR/allowed-cli-deny-by-default-lint.rs:6:16
|
LL | const C: i32 = 1 / 0;
| ---------------^^^^^-

View file

@ -1,3 +1,5 @@
// --force-warn $LINT causes $LINT (which is deny-by-default) to warn
// despite $LINT being allowed in module
// compile-flags: --force-warn const_err -Zunstable-options
// check-pass

View file

@ -0,0 +1,14 @@
warning: any use of this value will cause an error
--> $DIR/allowed-deny-by-default-lint.rs:7:16
|
LL | const C: i32 = 1 / 0;
| ---------------^^^^^-
| |
| attempt to divide `1_i32` by zero
|
= note: requested on the command line with `--force-warn const-err`
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
warning: 1 warning emitted

View file

@ -1,3 +1,5 @@
// --force-warn $LINT causes $LINT (which is warn-by-default) to warn
// despite $LINT_GROUP (which contains $LINT) being allowed
// compile-flags: --force-warn bare_trait_objects -Zunstable-options
// check-pass

View file

@ -1,5 +1,5 @@
warning: trait objects without an explicit `dyn` are deprecated
--> $DIR/force-lint-in-allowed-group.rs:8:25
--> $DIR/allowed-group-warn-by-default-lint.rs:10:25
|
LL | pub fn function(_x: Box<SomeTrait>) {}
| ^^^^^^^^^ help: use `dyn`: `dyn SomeTrait`

View file

@ -1,3 +1,5 @@
// --force-warn $LINT causes $LINT (which is warn-by-default) to warn
// despite $LINT being allowed in module
// compile-flags: --force-warn dead_code -Zunstable-options
// check-pass

View file

@ -1,5 +1,5 @@
warning: function is never used: `dead_function`
--> $DIR/force-lint-allow-all-warnings.rs:6:4
--> $DIR/allowed-warn-by-default-lint.rs:8:4
|
LL | fn dead_function() {}
| ^^^^^^^^^^^^^

View file

@ -1,3 +1,5 @@
// --force-warn $LINT casuses $LINT to warn despite --cap-lints
// set to allow
// compile-flags: --cap-lints allow --force-warn bare_trait_objects -Zunstable-options
// check-pass

View file

@ -1,5 +1,5 @@
warning: trait objects without an explicit `dyn` are deprecated
--> $DIR/force-warn-cap-lints-allow.rs:6:25
--> $DIR/cap-lints-allow.rs:8:25
|
LL | pub fn function(_x: Box<SomeTrait>) {}
| ^^^^^^^^^ help: use `dyn`: `dyn SomeTrait`

View file

@ -1,3 +1,5 @@
// --force-warn $LINT_GROUP causes $LINT to warn despite $LINT being
// allowed in module and cap-lints set to warn
// compile-flags: --cap-lints warn --force-warn rust-2021-compatibility -Zunstable-options
// check-pass
#![allow(ellipsis_inclusive_range_patterns)]

View file

@ -1,5 +1,5 @@
warning: `...` range patterns are deprecated
--> $DIR/force-warn-cap-lints-warn.rs:8:10
--> $DIR/cap-lints-warn-allowed-warn-by-default-lint.rs:10:10
|
LL | 0...100 => true,
| ^^^ help: use `..=` for an inclusive range

View file

@ -1,3 +1,4 @@
// --force-warn $LINT causes $LINT (which is deny-by-default) to warn
// compile-flags: --force-warn const_err -Zunstable-options
// check-pass

View file

@ -1,5 +1,5 @@
warning: any use of this value will cause an error
--> $DIR/force-deny-by-default-lint.rs:4:16
--> $DIR/deny-by-default-lint.rs:5:16
|
LL | const C: i32 = 1 / 0;
| ---------------^^^^^-

View file

@ -1,3 +1,6 @@
// --force-warn $LINT_GROUP causes $LINT in $LINT_GROUP to warn
// despite all warnings being allowed in module
// warn-by-default lint to warn
// compile-flags: --force-warn nonstandard_style -Zunstable-options
// check-pass

View file

@ -1,5 +1,5 @@
warning: function `FUNCTION` should have a snake case name
--> $DIR/force-lint-group-allow-all-warnings.rs:6:8
--> $DIR/lint-group-allow-warnings.rs:9:8
|
LL | pub fn FUNCTION() {}
| ^^^^^^^^ help: convert the identifier to snake case: `function`

View file

@ -0,0 +1,12 @@
// --force-warn $LINT_GROUP causes $LINT (which is warn-by-default) to warn
// despite $LINT being allowed on command line
// compile-flags: -A bare-trait-objects --force-warn rust-2018-idioms -Zunstable-options
// check-pass
pub trait SomeTrait {}
pub fn function(_x: Box<SomeTrait>) {}
//~^ WARN trait objects without an explicit `dyn` are deprecated
//~| WARN this is accepted in the current edition
fn main() {}

View file

@ -0,0 +1,12 @@
warning: trait objects without an explicit `dyn` are deprecated
--> $DIR/lint-group-allowed-cli-warn-by-default-lint.rs:8:25
|
LL | pub fn function(_x: Box<SomeTrait>) {}
| ^^^^^^^^^ help: use `dyn`: `dyn SomeTrait`
|
= note: `--force-warn bare-trait-objects` implied by `--force-warn rust-2018-idioms`
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
warning: 1 warning emitted

View file

@ -1,3 +1,5 @@
// --force-warn $LINT_GROUP causes $LINT to warn despite
// $LINT_GROUP being allowed in module
// compile-flags: --force-warn rust_2018_idioms -Zunstable-options
// check-pass

View file

@ -1,5 +1,5 @@
warning: trait objects without an explicit `dyn` are deprecated
--> $DIR/force-warn-group.rs:8:25
--> $DIR/lint-group-allowed-lint-group.rs:10:25
|
LL | pub fn function(_x: Box<SomeTrait>) {}
| ^^^^^^^^^ help: use `dyn`: `dyn SomeTrait`

View file

@ -1,3 +1,5 @@
// --force-warn $LINT_GROUP causes $LINT (which is warn-by-default) to warn
// despite $LINT being allowed in module
// compile-flags: --force-warn rust-2018-idioms -Zunstable-options
// check-pass

View file

@ -1,5 +1,5 @@
warning: trait objects without an explicit `dyn` are deprecated
--> $DIR/force-warn-group-allow-warning.rs:8:25
--> $DIR/lint-group-allowed-warn-by-default-lint.rs:10:25
|
LL | pub fn function(_x: Box<SomeTrait>) {}
| ^^^^^^^^^ help: use `dyn`: `dyn SomeTrait`

View file

@ -0,0 +1,18 @@
// --force-warn $LINT causes $LINT (which is warn-by-default) to warn
// despite being allowed in one submodule (but not the other)
// compile-flags: --force-warn dead_code -Zunstable-options
// check-pass
mod one {
#![allow(dead_code)]
fn dead_function() {}
//~^ WARN function is never used
}
mod two {
fn dead_function() {}
//~^ WARN function is never used
}
fn main() {}

View file

@ -0,0 +1,16 @@
warning: function is never used: `dead_function`
--> $DIR/warn-by-default-lint-two-modules.rs:9:8
|
LL | fn dead_function() {}
| ^^^^^^^^^^^^^
|
= note: requested on the command line with `--force-warn dead-code`
warning: function is never used: `dead_function`
--> $DIR/warn-by-default-lint-two-modules.rs:14:8
|
LL | fn dead_function() {}
| ^^^^^^^^^^^^^
warning: 2 warnings emitted