diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:13 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:13 +0000 |
commit | 218caa410aa38c29984be31a5229b9fa717560ee (patch) | |
tree | c54bd55eeb6e4c508940a30e94c0032fbd45d677 /tests/ui/lint/force-warn | |
parent | Releasing progress-linux version 1.67.1+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-218caa410aa38c29984be31a5229b9fa717560ee.tar.xz rustc-218caa410aa38c29984be31a5229b9fa717560ee.zip |
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
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 000000000..0199381fc --- /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 000000000..4de68a079 --- /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 000000000..b24ab822d --- /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 000000000..ac98b5896 --- /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 000000000..257df13ef --- /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 000000000..6a1fc76e1 --- /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 000000000..0d4b468c2 --- /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 000000000..9ef53d47e --- /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 000000000..631a8cb2f --- /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 000000000..0f58953a5 --- /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 000000000..06b372867 --- /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 000000000..a6634e212 --- /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 000000000..fdba7f410 --- /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 000000000..03a32fa6f --- /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 000000000..e65f156bf --- /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 000000000..d1b764b34 --- /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 000000000..c2e9377e9 --- /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 000000000..c644d0fe7 --- /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 000000000..4b95f4d2d --- /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 000000000..dc7b1b7b9 --- /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 000000000..7ad7462dd --- /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 000000000..e17630fd3 --- /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 000000000..ee5a18c38 --- /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 000000000..72198541a --- /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 000000000..248aece6f --- /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 000000000..52c870ac2 --- /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 000000000..47a480ad7 --- /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 000000000..824bcccc0 --- /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 000000000..d1d4f5602 --- /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 000000000..1faeed337 --- /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`. |