diff options
| author | Albert Larsan <74931857+albertlarsan68@users.noreply.github.com> | 2023-01-05 09:13:28 +0100 |
|---|---|---|
| committer | Albert Larsan <74931857+albertlarsan68@users.noreply.github.com> | 2023-01-11 09:32:08 +0000 |
| commit | cf2dff2b1e3fa55fa5415d524200070d0d7aacfe (patch) | |
| tree | 40a88d9a46aaf3e8870676eb2538378b75a263eb /tests/ui/lint/force-warn | |
| parent | ca855e6e42787ecd062d81d53336fe6788ef51a9 (diff) | |
| download | rust-cf2dff2b1e3fa55fa5415d524200070d0d7aacfe.tar.gz rust-cf2dff2b1e3fa55fa5415d524200070d0d7aacfe.zip | |
Move /src/test to /tests
Diffstat (limited to 'tests/ui/lint/force-warn')
30 files changed, 521 insertions, 0 deletions
diff --git a/tests/ui/lint/force-warn/allow-warnings.rs b/tests/ui/lint/force-warn/allow-warnings.rs new file mode 100644 index 00000000000..0199381fcbb --- /dev/null +++ b/tests/ui/lint/force-warn/allow-warnings.rs @@ -0,0 +1,11 @@ +// --force-warn $LINT causes $LINT (which is warn-by-default) to warn +// despite allowing all warnings in module +// compile-flags: --force-warn dead_code +// check-pass + +#![allow(warnings)] + +fn dead_function() {} +//~^ WARN function `dead_function` is never used + +fn main() {} diff --git a/tests/ui/lint/force-warn/allow-warnings.stderr b/tests/ui/lint/force-warn/allow-warnings.stderr new file mode 100644 index 00000000000..4de68a079e5 --- /dev/null +++ b/tests/ui/lint/force-warn/allow-warnings.stderr @@ -0,0 +1,10 @@ +warning: function `dead_function` is never used + --> $DIR/allow-warnings.rs:8:4 + | +LL | fn dead_function() {} + | ^^^^^^^^^^^^^ + | + = note: requested on the command line with `--force-warn dead-code` + +warning: 1 warning emitted + diff --git a/tests/ui/lint/force-warn/allowed-by-default-lint.rs b/tests/ui/lint/force-warn/allowed-by-default-lint.rs new file mode 100644 index 00000000000..b24ab822d93 --- /dev/null +++ b/tests/ui/lint/force-warn/allowed-by-default-lint.rs @@ -0,0 +1,12 @@ +// --force-warn $LINT causes $LINT (which is allow-by-default) to warn +// compile-flags: --force-warn elided_lifetimes_in_paths +// check-pass + +struct Foo<'a> { + x: &'a u32, +} + +fn foo(x: &Foo) {} +//~^ WARN hidden lifetime parameters in types are deprecated + +fn main() {} diff --git a/tests/ui/lint/force-warn/allowed-by-default-lint.stderr b/tests/ui/lint/force-warn/allowed-by-default-lint.stderr new file mode 100644 index 00000000000..ac98b5896ca --- /dev/null +++ b/tests/ui/lint/force-warn/allowed-by-default-lint.stderr @@ -0,0 +1,14 @@ +warning: hidden lifetime parameters in types are deprecated + --> $DIR/allowed-by-default-lint.rs:9:12 + | +LL | fn foo(x: &Foo) {} + | ^^^ expected lifetime parameter + | + = note: requested on the command line with `--force-warn elided-lifetimes-in-paths` +help: indicate the anonymous lifetime + | +LL | fn foo(x: &Foo<'_>) {} + | ++++ + +warning: 1 warning emitted + diff --git a/tests/ui/lint/force-warn/allowed-cli-deny-by-default-lint.rs b/tests/ui/lint/force-warn/allowed-cli-deny-by-default-lint.rs new file mode 100644 index 00000000000..257df13efe0 --- /dev/null +++ b/tests/ui/lint/force-warn/allowed-cli-deny-by-default-lint.rs @@ -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 mutable_transmutes --force-warn mutable_transmutes +// check-pass + +fn main() { + unsafe { + let y = std::mem::transmute::<&i32, &mut i32>(&5); //~WARN: undefined behavior + } +} diff --git a/tests/ui/lint/force-warn/allowed-cli-deny-by-default-lint.stderr b/tests/ui/lint/force-warn/allowed-cli-deny-by-default-lint.stderr new file mode 100644 index 00000000000..6a1fc76e18a --- /dev/null +++ b/tests/ui/lint/force-warn/allowed-cli-deny-by-default-lint.stderr @@ -0,0 +1,10 @@ +warning: transmuting &T to &mut T is undefined behavior, even if the reference is unused, consider instead using an UnsafeCell + --> $DIR/allowed-cli-deny-by-default-lint.rs:8:17 + | +LL | let y = std::mem::transmute::<&i32, &mut i32>(&5); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: requested on the command line with `--force-warn mutable-transmutes` + +warning: 1 warning emitted + diff --git a/tests/ui/lint/force-warn/allowed-deny-by-default-lint.rs b/tests/ui/lint/force-warn/allowed-deny-by-default-lint.rs new file mode 100644 index 00000000000..0d4b468c2b3 --- /dev/null +++ b/tests/ui/lint/force-warn/allowed-deny-by-default-lint.rs @@ -0,0 +1,11 @@ +// --force-warn $LINT causes $LINT (which is deny-by-default) to warn +// despite $LINT being allowed in module +// compile-flags: --force-warn mutable_transmutes +// check-pass + +#![allow(mutable_transmutes)] +fn main() { + unsafe { + let y = std::mem::transmute::<&i32, &mut i32>(&5); //~WARN: undefined behavior + } +} diff --git a/tests/ui/lint/force-warn/allowed-deny-by-default-lint.stderr b/tests/ui/lint/force-warn/allowed-deny-by-default-lint.stderr new file mode 100644 index 00000000000..9ef53d47eb9 --- /dev/null +++ b/tests/ui/lint/force-warn/allowed-deny-by-default-lint.stderr @@ -0,0 +1,10 @@ +warning: transmuting &T to &mut T is undefined behavior, even if the reference is unused, consider instead using an UnsafeCell + --> $DIR/allowed-deny-by-default-lint.rs:9:17 + | +LL | let y = std::mem::transmute::<&i32, &mut i32>(&5); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: requested on the command line with `--force-warn mutable-transmutes` + +warning: 1 warning emitted + diff --git a/tests/ui/lint/force-warn/allowed-group-warn-by-default-lint.rs b/tests/ui/lint/force-warn/allowed-group-warn-by-default-lint.rs new file mode 100644 index 00000000000..631a8cb2f08 --- /dev/null +++ b/tests/ui/lint/force-warn/allowed-group-warn-by-default-lint.rs @@ -0,0 +1,18 @@ +// --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 +// check-pass + +#![allow(rust_2018_idioms)] + +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 +//~| WARN trait objects without an explicit `dyn` are deprecated +//~| WARN this is accepted in the current edition +//~| WARN trait objects without an explicit `dyn` are deprecated +//~| WARN this is accepted in the current edition + +fn main() {} diff --git a/tests/ui/lint/force-warn/allowed-group-warn-by-default-lint.stderr b/tests/ui/lint/force-warn/allowed-group-warn-by-default-lint.stderr new file mode 100644 index 00000000000..0f58953a54b --- /dev/null +++ b/tests/ui/lint/force-warn/allowed-group-warn-by-default-lint.stderr @@ -0,0 +1,42 @@ +warning: trait objects without an explicit `dyn` are deprecated + --> $DIR/allowed-group-warn-by-default-lint.rs:10:25 + | +LL | pub fn function(_x: Box<SomeTrait>) {} + | ^^^^^^^^^ + | + = 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> + = note: requested on the command line with `--force-warn bare-trait-objects` +help: use `dyn` + | +LL | pub fn function(_x: Box<dyn SomeTrait>) {} + | +++ + +warning: trait objects without an explicit `dyn` are deprecated + --> $DIR/allowed-group-warn-by-default-lint.rs:10:25 + | +LL | pub fn function(_x: Box<SomeTrait>) {} + | ^^^^^^^^^ + | + = 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> +help: use `dyn` + | +LL | pub fn function(_x: Box<dyn SomeTrait>) {} + | +++ + +warning: trait objects without an explicit `dyn` are deprecated + --> $DIR/allowed-group-warn-by-default-lint.rs:10:25 + | +LL | pub fn function(_x: Box<SomeTrait>) {} + | ^^^^^^^^^ + | + = 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> +help: use `dyn` + | +LL | pub fn function(_x: Box<dyn SomeTrait>) {} + | +++ + +warning: 3 warnings emitted + diff --git a/tests/ui/lint/force-warn/allowed-warn-by-default-lint.rs b/tests/ui/lint/force-warn/allowed-warn-by-default-lint.rs new file mode 100644 index 00000000000..06b37286776 --- /dev/null +++ b/tests/ui/lint/force-warn/allowed-warn-by-default-lint.rs @@ -0,0 +1,11 @@ +// --force-warn $LINT causes $LINT (which is warn-by-default) to warn +// despite $LINT being allowed in module +// compile-flags: --force-warn dead_code +// check-pass + +#![allow(dead_code)] + +fn dead_function() {} +//~^ WARN function `dead_function` is never used + +fn main() {} diff --git a/tests/ui/lint/force-warn/allowed-warn-by-default-lint.stderr b/tests/ui/lint/force-warn/allowed-warn-by-default-lint.stderr new file mode 100644 index 00000000000..a6634e212bd --- /dev/null +++ b/tests/ui/lint/force-warn/allowed-warn-by-default-lint.stderr @@ -0,0 +1,10 @@ +warning: function `dead_function` is never used + --> $DIR/allowed-warn-by-default-lint.rs:8:4 + | +LL | fn dead_function() {} + | ^^^^^^^^^^^^^ + | + = note: requested on the command line with `--force-warn dead-code` + +warning: 1 warning emitted + diff --git a/tests/ui/lint/force-warn/cap-lints-allow.rs b/tests/ui/lint/force-warn/cap-lints-allow.rs new file mode 100644 index 00000000000..fdba7f4105e --- /dev/null +++ b/tests/ui/lint/force-warn/cap-lints-allow.rs @@ -0,0 +1,16 @@ +// --force-warn $LINT casuses $LINT to warn despite --cap-lints +// set to allow +// compile-flags: --cap-lints allow --force-warn bare_trait_objects +// 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 +//~| WARN trait objects without an explicit `dyn` are deprecated +//~| WARN this is accepted in the current edition +//~| WARN trait objects without an explicit `dyn` are deprecated +//~| WARN this is accepted in the current edition + +fn main() {} diff --git a/tests/ui/lint/force-warn/cap-lints-allow.stderr b/tests/ui/lint/force-warn/cap-lints-allow.stderr new file mode 100644 index 00000000000..03a32fa6f08 --- /dev/null +++ b/tests/ui/lint/force-warn/cap-lints-allow.stderr @@ -0,0 +1,42 @@ +warning: trait objects without an explicit `dyn` are deprecated + --> $DIR/cap-lints-allow.rs:8:25 + | +LL | pub fn function(_x: Box<SomeTrait>) {} + | ^^^^^^^^^ + | + = 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> + = note: requested on the command line with `--force-warn bare-trait-objects` +help: use `dyn` + | +LL | pub fn function(_x: Box<dyn SomeTrait>) {} + | +++ + +warning: trait objects without an explicit `dyn` are deprecated + --> $DIR/cap-lints-allow.rs:8:25 + | +LL | pub fn function(_x: Box<SomeTrait>) {} + | ^^^^^^^^^ + | + = 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> +help: use `dyn` + | +LL | pub fn function(_x: Box<dyn SomeTrait>) {} + | +++ + +warning: trait objects without an explicit `dyn` are deprecated + --> $DIR/cap-lints-allow.rs:8:25 + | +LL | pub fn function(_x: Box<SomeTrait>) {} + | ^^^^^^^^^ + | + = 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> +help: use `dyn` + | +LL | pub fn function(_x: Box<dyn SomeTrait>) {} + | +++ + +warning: 3 warnings emitted + diff --git a/tests/ui/lint/force-warn/cap-lints-warn-allowed-warn-by-default-lint.rs b/tests/ui/lint/force-warn/cap-lints-warn-allowed-warn-by-default-lint.rs new file mode 100644 index 00000000000..e65f156bfdc --- /dev/null +++ b/tests/ui/lint/force-warn/cap-lints-warn-allowed-warn-by-default-lint.rs @@ -0,0 +1,17 @@ +// --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 +// check-pass +#![allow(ellipsis_inclusive_range_patterns)] + +pub fn f() -> bool { + let x = 123; + match x { + 0...100 => true, + //~^ WARN range patterns are deprecated + //~| WARN this is accepted in the current edition + _ => false, + } +} + +fn main() {} diff --git a/tests/ui/lint/force-warn/cap-lints-warn-allowed-warn-by-default-lint.stderr b/tests/ui/lint/force-warn/cap-lints-warn-allowed-warn-by-default-lint.stderr new file mode 100644 index 00000000000..d1b764b3414 --- /dev/null +++ b/tests/ui/lint/force-warn/cap-lints-warn-allowed-warn-by-default-lint.stderr @@ -0,0 +1,12 @@ +warning: `...` range patterns are deprecated + --> $DIR/cap-lints-warn-allowed-warn-by-default-lint.rs:10:10 + | +LL | 0...100 => true, + | ^^^ help: use `..=` for an inclusive range + | + = 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> + = note: `--force-warn ellipsis-inclusive-range-patterns` implied by `--force-warn rust-2021-compatibility` + +warning: 1 warning emitted + diff --git a/tests/ui/lint/force-warn/deny-by-default-lint.rs b/tests/ui/lint/force-warn/deny-by-default-lint.rs new file mode 100644 index 00000000000..c2e9377e908 --- /dev/null +++ b/tests/ui/lint/force-warn/deny-by-default-lint.rs @@ -0,0 +1,9 @@ +// --force-warn $LINT causes $LINT (which is deny-by-default) to warn +// compile-flags: --force-warn mutable_transmutes +// check-pass + +fn main() { + unsafe { + let y = std::mem::transmute::<&i32, &mut i32>(&5); //~WARN: undefined behavior + } +} diff --git a/tests/ui/lint/force-warn/deny-by-default-lint.stderr b/tests/ui/lint/force-warn/deny-by-default-lint.stderr new file mode 100644 index 00000000000..c644d0fe741 --- /dev/null +++ b/tests/ui/lint/force-warn/deny-by-default-lint.stderr @@ -0,0 +1,10 @@ +warning: transmuting &T to &mut T is undefined behavior, even if the reference is unused, consider instead using an UnsafeCell + --> $DIR/deny-by-default-lint.rs:7:17 + | +LL | let y = std::mem::transmute::<&i32, &mut i32>(&5); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: requested on the command line with `--force-warn mutable-transmutes` + +warning: 1 warning emitted + diff --git a/tests/ui/lint/force-warn/lint-group-allow-warnings.rs b/tests/ui/lint/force-warn/lint-group-allow-warnings.rs new file mode 100644 index 00000000000..4b95f4d2dfb --- /dev/null +++ b/tests/ui/lint/force-warn/lint-group-allow-warnings.rs @@ -0,0 +1,12 @@ +// --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 +// check-pass + +#![allow(warnings)] + +pub fn FUNCTION() {} +//~^ WARN function `FUNCTION` should have a snake case name + +fn main() {} diff --git a/tests/ui/lint/force-warn/lint-group-allow-warnings.stderr b/tests/ui/lint/force-warn/lint-group-allow-warnings.stderr new file mode 100644 index 00000000000..dc7b1b7b98d --- /dev/null +++ b/tests/ui/lint/force-warn/lint-group-allow-warnings.stderr @@ -0,0 +1,10 @@ +warning: function `FUNCTION` should have a snake case name + --> $DIR/lint-group-allow-warnings.rs:9:8 + | +LL | pub fn FUNCTION() {} + | ^^^^^^^^ help: convert the identifier to snake case: `function` + | + = note: `--force-warn non-snake-case` implied by `--force-warn nonstandard-style` + +warning: 1 warning emitted + diff --git a/tests/ui/lint/force-warn/lint-group-allowed-cli-warn-by-default-lint.rs b/tests/ui/lint/force-warn/lint-group-allowed-cli-warn-by-default-lint.rs new file mode 100644 index 00000000000..7ad7462ddc5 --- /dev/null +++ b/tests/ui/lint/force-warn/lint-group-allowed-cli-warn-by-default-lint.rs @@ -0,0 +1,16 @@ +// --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 +// 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 +//~| WARN trait objects without an explicit `dyn` are deprecated +//~| WARN this is accepted in the current edition +//~| WARN trait objects without an explicit `dyn` are deprecated +//~| WARN this is accepted in the current edition + +fn main() {} diff --git a/tests/ui/lint/force-warn/lint-group-allowed-cli-warn-by-default-lint.stderr b/tests/ui/lint/force-warn/lint-group-allowed-cli-warn-by-default-lint.stderr new file mode 100644 index 00000000000..e17630fd358 --- /dev/null +++ b/tests/ui/lint/force-warn/lint-group-allowed-cli-warn-by-default-lint.stderr @@ -0,0 +1,42 @@ +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>) {} + | ^^^^^^^^^ + | + = 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> + = note: `--force-warn bare-trait-objects` implied by `--force-warn rust-2018-idioms` +help: use `dyn` + | +LL | pub fn function(_x: Box<dyn SomeTrait>) {} + | +++ + +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>) {} + | ^^^^^^^^^ + | + = 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> +help: use `dyn` + | +LL | pub fn function(_x: Box<dyn SomeTrait>) {} + | +++ + +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>) {} + | ^^^^^^^^^ + | + = 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> +help: use `dyn` + | +LL | pub fn function(_x: Box<dyn SomeTrait>) {} + | +++ + +warning: 3 warnings emitted + diff --git a/tests/ui/lint/force-warn/lint-group-allowed-lint-group.rs b/tests/ui/lint/force-warn/lint-group-allowed-lint-group.rs new file mode 100644 index 00000000000..ee5a18c3829 --- /dev/null +++ b/tests/ui/lint/force-warn/lint-group-allowed-lint-group.rs @@ -0,0 +1,18 @@ +// --force-warn $LINT_GROUP causes $LINT to warn despite +// $LINT_GROUP being allowed in module +// compile-flags: --force-warn rust_2018_idioms +// check-pass + +#![allow(rust_2018_idioms)] + +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 +//~| WARN trait objects without an explicit `dyn` are deprecated +//~| WARN this is accepted in the current edition +//~| WARN trait objects without an explicit `dyn` are deprecated +//~| WARN this is accepted in the current edition + +fn main() {} diff --git a/tests/ui/lint/force-warn/lint-group-allowed-lint-group.stderr b/tests/ui/lint/force-warn/lint-group-allowed-lint-group.stderr new file mode 100644 index 00000000000..72198541a70 --- /dev/null +++ b/tests/ui/lint/force-warn/lint-group-allowed-lint-group.stderr @@ -0,0 +1,42 @@ +warning: trait objects without an explicit `dyn` are deprecated + --> $DIR/lint-group-allowed-lint-group.rs:10:25 + | +LL | pub fn function(_x: Box<SomeTrait>) {} + | ^^^^^^^^^ + | + = 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> + = note: `--force-warn bare-trait-objects` implied by `--force-warn rust-2018-idioms` +help: use `dyn` + | +LL | pub fn function(_x: Box<dyn SomeTrait>) {} + | +++ + +warning: trait objects without an explicit `dyn` are deprecated + --> $DIR/lint-group-allowed-lint-group.rs:10:25 + | +LL | pub fn function(_x: Box<SomeTrait>) {} + | ^^^^^^^^^ + | + = 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> +help: use `dyn` + | +LL | pub fn function(_x: Box<dyn SomeTrait>) {} + | +++ + +warning: trait objects without an explicit `dyn` are deprecated + --> $DIR/lint-group-allowed-lint-group.rs:10:25 + | +LL | pub fn function(_x: Box<SomeTrait>) {} + | ^^^^^^^^^ + | + = 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> +help: use `dyn` + | +LL | pub fn function(_x: Box<dyn SomeTrait>) {} + | +++ + +warning: 3 warnings emitted + diff --git a/tests/ui/lint/force-warn/lint-group-allowed-warn-by-default-lint.rs b/tests/ui/lint/force-warn/lint-group-allowed-warn-by-default-lint.rs new file mode 100644 index 00000000000..248aece6fe7 --- /dev/null +++ b/tests/ui/lint/force-warn/lint-group-allowed-warn-by-default-lint.rs @@ -0,0 +1,18 @@ +// --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 +// check-pass + +#![allow(bare_trait_objects)] + +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 +//~| WARN trait objects without an explicit `dyn` are deprecated +//~| WARN this is accepted in the current edition +//~| WARN trait objects without an explicit `dyn` are deprecated +//~| WARN this is accepted in the current edition + +fn main() {} diff --git a/tests/ui/lint/force-warn/lint-group-allowed-warn-by-default-lint.stderr b/tests/ui/lint/force-warn/lint-group-allowed-warn-by-default-lint.stderr new file mode 100644 index 00000000000..52c870ac28a --- /dev/null +++ b/tests/ui/lint/force-warn/lint-group-allowed-warn-by-default-lint.stderr @@ -0,0 +1,42 @@ +warning: trait objects without an explicit `dyn` are deprecated + --> $DIR/lint-group-allowed-warn-by-default-lint.rs:10:25 + | +LL | pub fn function(_x: Box<SomeTrait>) {} + | ^^^^^^^^^ + | + = 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> + = note: `--force-warn bare-trait-objects` implied by `--force-warn rust-2018-idioms` +help: use `dyn` + | +LL | pub fn function(_x: Box<dyn SomeTrait>) {} + | +++ + +warning: trait objects without an explicit `dyn` are deprecated + --> $DIR/lint-group-allowed-warn-by-default-lint.rs:10:25 + | +LL | pub fn function(_x: Box<SomeTrait>) {} + | ^^^^^^^^^ + | + = 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> +help: use `dyn` + | +LL | pub fn function(_x: Box<dyn SomeTrait>) {} + | +++ + +warning: trait objects without an explicit `dyn` are deprecated + --> $DIR/lint-group-allowed-warn-by-default-lint.rs:10:25 + | +LL | pub fn function(_x: Box<SomeTrait>) {} + | ^^^^^^^^^ + | + = 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> +help: use `dyn` + | +LL | pub fn function(_x: Box<dyn SomeTrait>) {} + | +++ + +warning: 3 warnings emitted + diff --git a/tests/ui/lint/force-warn/warn-by-default-lint-two-modules.rs b/tests/ui/lint/force-warn/warn-by-default-lint-two-modules.rs new file mode 100644 index 00000000000..47a480ad708 --- /dev/null +++ b/tests/ui/lint/force-warn/warn-by-default-lint-two-modules.rs @@ -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 +// check-pass + +mod one { + #![allow(dead_code)] + + fn dead_function() {} + //~^ WARN function `dead_function` is never used +} + +mod two { + fn dead_function() {} + //~^ WARN function `dead_function` is never used +} + +fn main() {} diff --git a/tests/ui/lint/force-warn/warn-by-default-lint-two-modules.stderr b/tests/ui/lint/force-warn/warn-by-default-lint-two-modules.stderr new file mode 100644 index 00000000000..824bcccc05f --- /dev/null +++ b/tests/ui/lint/force-warn/warn-by-default-lint-two-modules.stderr @@ -0,0 +1,16 @@ +warning: function `dead_function` is never used + --> $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 `dead_function` is never used + --> $DIR/warn-by-default-lint-two-modules.rs:14:8 + | +LL | fn dead_function() {} + | ^^^^^^^^^^^^^ + +warning: 2 warnings emitted + diff --git a/tests/ui/lint/force-warn/warnings-lint-group.rs b/tests/ui/lint/force-warn/warnings-lint-group.rs new file mode 100644 index 00000000000..d1d4f5602f2 --- /dev/null +++ b/tests/ui/lint/force-warn/warnings-lint-group.rs @@ -0,0 +1,5 @@ +// --force-warn warnings is an error +// compile-flags: --force-warn warnings +// error-pattern: `warnings` lint group is not supported + +fn main() {} diff --git a/tests/ui/lint/force-warn/warnings-lint-group.stderr b/tests/ui/lint/force-warn/warnings-lint-group.stderr new file mode 100644 index 00000000000..1faeed33704 --- /dev/null +++ b/tests/ui/lint/force-warn/warnings-lint-group.stderr @@ -0,0 +1,7 @@ +error[E0602]: `warnings` lint group is not supported with ´--force-warn´ + +error[E0602]: `warnings` lint group is not supported with ´--force-warn´ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0602`. |
