rust-clippy/tests/ui/upper_case_acronyms.fixed

71 lines
1.7 KiB
Rust
Raw Normal View History

2023-07-27 11:40:22 +00:00
#![warn(clippy::upper_case_acronyms)]
struct HTTPResponse; // not linted by default, but with cfg option
struct CString; // not linted
enum Flags {
NS, // not linted
Cwr,
//~^ ERROR: name `CWR` contains a capitalized acronym
//~| NOTE: `-D clippy::upper-case-acronyms` implied by `-D warnings`
2023-07-27 11:40:22 +00:00
Ece,
//~^ ERROR: name `ECE` contains a capitalized acronym
2023-07-27 11:40:22 +00:00
Urg,
//~^ ERROR: name `URG` contains a capitalized acronym
2023-07-27 11:40:22 +00:00
Ack,
//~^ ERROR: name `ACK` contains a capitalized acronym
2023-07-27 11:40:22 +00:00
Psh,
//~^ ERROR: name `PSH` contains a capitalized acronym
2023-07-27 11:40:22 +00:00
Rst,
//~^ ERROR: name `RST` contains a capitalized acronym
2023-07-27 11:40:22 +00:00
Syn,
//~^ ERROR: name `SYN` contains a capitalized acronym
2023-07-27 11:40:22 +00:00
Fin,
//~^ ERROR: name `FIN` contains a capitalized acronym
2023-07-27 11:40:22 +00:00
}
// linted with cfg option, beware that lint suggests `GccllvmSomething` instead of
// `GccLlvmSomething`
struct GCCLLVMSomething;
// public items must not be linted
pub struct NOWARNINGHERE;
pub struct ALSONoWarningHERE;
// enum variants should not be linted if the num is pub
pub enum ParseError<T> {
YDB(u8),
Utf8(std::string::FromUtf8Error),
Parse(T, String),
}
// private, do lint here
enum ParseErrorPrivate<T> {
Wasd(u8),
//~^ ERROR: name `WASD` contains a capitalized acronym
2023-07-27 11:40:22 +00:00
Utf8(std::string::FromUtf8Error),
Parse(T, String),
}
// do lint here
struct Json;
//~^ ERROR: name `JSON` contains a capitalized acronym
2023-07-27 11:40:22 +00:00
// do lint here
enum Yaml {
//~^ ERROR: name `YAML` contains a capitalized acronym
2023-07-27 11:40:22 +00:00
Num(u32),
Str(String),
}
// test for issue #7708
enum AllowOnField {
Disallow,
//~^ ERROR: name `DISALLOW` contains a capitalized acronym
#[allow(clippy::upper_case_acronyms)]
ALLOW,
}
2023-07-27 11:40:22 +00:00
fn main() {}