about summary refs log tree commit diff
path: root/tests/ui/diagnostic-flags
diff options
context:
space:
mode:
authorJieyou Xu <jieyouxu@outlook.com>2024-12-05 08:09:02 +0000
committer许杰友 Jieyou Xu (Joe) <39484203+jieyouxu@users.noreply.github.com>2024-12-10 11:29:43 +0800
commitb5c7a552502e6d27f96a1b7edf1b86d703dbad8a (patch)
treec1f70ecb8666b2191c5d1da10de1af3c61185a37 /tests/ui/diagnostic-flags
parentdd3b313b56f34e21cd79d610cdf4e501a4bb8c4e (diff)
downloadrust-b5c7a552502e6d27f96a1b7edf1b86d703dbad8a.tar.gz
rust-b5c7a552502e6d27f96a1b7edf1b86d703dbad8a.zip
Adjust `allow-non-lint-warnings.rs`
- Document `allow-non-lint-warnings.rs`
- Move `allow-non-lint-warnings.rs` under `tests/ui/diagnostic-flags/`
- Improve the test to use two *differential* revisions:
    1. One revision checks that without `-A warnings` the code sample
       actually emits a warning.
    2. The other revision checks that `-A warnings` suppresses the
       warning.
  This makes sure that if the code sample no longer warns, the test
  doesn't silently pass but fail to check its intended purpose.
Diffstat (limited to 'tests/ui/diagnostic-flags')
-rw-r--r--tests/ui/diagnostic-flags/allow-non-lint-warnings.rs27
-rw-r--r--tests/ui/diagnostic-flags/allow-non-lint-warnings.without_flag.stderr8
2 files changed, 35 insertions, 0 deletions
diff --git a/tests/ui/diagnostic-flags/allow-non-lint-warnings.rs b/tests/ui/diagnostic-flags/allow-non-lint-warnings.rs
new file mode 100644
index 00000000000..40b9e6536f5
--- /dev/null
+++ b/tests/ui/diagnostic-flags/allow-non-lint-warnings.rs
@@ -0,0 +1,27 @@
+// ignore-tidy-linelength
+//! Check that `-A warnings` cli flag applies to non-lint warnings as well.
+//!
+//! This test tries to exercise that by checking that the "relaxing a default bound only does
+//! something for `?Sized`; all other traits are not bound by default" non-lint warning (normally
+//! warn-by-default) is suppressed if the `-A warnings` cli flag is passed.
+//!
+//! Take special note that `warnings` is a special pseudo lint group in relationship to non-lint
+//! warnings, which is somewhat special. This test does not exercise other `-A <other_lint_group>`
+//! that check that they are working in the same way, only `warnings` specifically.
+//!
+//! # Relevant context
+//!
+//! - Original impl PR: <https://github.com/rust-lang/rust/pull/21248>.
+//! - RFC 507 "Release channels":
+//!   <https://github.com/rust-lang/rfcs/blob/c017755b9bfa0421570d92ba38082302e0f3ad4f/text/0507-release-channels.md>.
+#![crate_type = "lib"]
+
+//@ revisions: without_flag with_flag
+
+//@[with_flag] compile-flags: -Awarnings
+
+//@ check-pass
+
+pub trait Trait {}
+pub fn f<T: ?Trait>() {}
+//[without_flag]~^ WARN relaxing a default bound only does something for `?Sized`; all other traits are not bound by default
diff --git a/tests/ui/diagnostic-flags/allow-non-lint-warnings.without_flag.stderr b/tests/ui/diagnostic-flags/allow-non-lint-warnings.without_flag.stderr
new file mode 100644
index 00000000000..b037847c70f
--- /dev/null
+++ b/tests/ui/diagnostic-flags/allow-non-lint-warnings.without_flag.stderr
@@ -0,0 +1,8 @@
+warning: relaxing a default bound only does something for `?Sized`; all other traits are not bound by default
+  --> $DIR/allow-non-lint-warnings.rs:26:13
+   |
+LL | pub fn f<T: ?Trait>() {}
+   |             ^^^^^^
+
+warning: 1 warning emitted
+