rust/tests/ui/upper_case_acronyms.rs

63 lines
1.5 KiB
Rust
Raw Normal View History

2020-12-19 07:50:45 -06:00
#![warn(clippy::upper_case_acronyms)]
struct HTTPResponse; // not linted by default, but with cfg option
2020-12-19 07:50:45 -06:00
struct CString; // not linted
enum Flags {
NS, // not linted
2020-12-19 07:50:45 -06:00
CWR,
//~^ ERROR: name `CWR` contains a capitalized acronym
//~| NOTE: `-D clippy::upper-case-acronyms` implied by `-D warnings`
2020-12-19 07:50:45 -06:00
ECE,
//~^ ERROR: name `ECE` contains a capitalized acronym
2020-12-19 07:50:45 -06:00
URG,
//~^ ERROR: name `URG` contains a capitalized acronym
2020-12-19 07:50:45 -06:00
ACK,
//~^ ERROR: name `ACK` contains a capitalized acronym
2020-12-19 07:50:45 -06:00
PSH,
//~^ ERROR: name `PSH` contains a capitalized acronym
2020-12-19 07:50:45 -06:00
RST,
//~^ ERROR: name `RST` contains a capitalized acronym
2020-12-19 07:50:45 -06:00
SYN,
//~^ ERROR: name `SYN` contains a capitalized acronym
2020-12-19 07:50:45 -06:00
FIN,
//~^ ERROR: name `FIN` contains a capitalized acronym
2020-12-19 07:50:45 -06:00
}
// linted with cfg option, beware that lint suggests `GccllvmSomething` instead of
// `GccLlvmSomething`
struct GCCLLVMSomething;
2020-12-19 07:50:45 -06:00
// 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
Utf8(std::string::FromUtf8Error),
Parse(T, String),
}
// do lint here
struct JSON;
//~^ ERROR: name `JSON` contains a capitalized acronym
// do lint here
enum YAML {
//~^ ERROR: name `YAML` contains a capitalized acronym
Num(u32),
Str(String),
}
2020-12-19 07:50:45 -06:00
fn main() {}