1
Fork 0

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.
This commit is contained in:
Jieyou Xu 2024-12-05 08:09:02 +00:00 committed by 许杰友 Jieyou Xu (Joe)
parent dd3b313b56
commit b5c7a55250
3 changed files with 35 additions and 8 deletions

View file

@ -1,8 +0,0 @@
//@ compile-flags: -Awarnings
//@ check-pass
#[derive()]
#[derive(Copy, Clone)]
pub struct Foo;
pub fn main() {}

View file

@ -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

View file

@ -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