2023-07-27 08:23:04 -05:00
|
|
|
//@aux-build:proc_macro_derive.rs
|
2019-08-18 09:52:59 -05:00
|
|
|
|
|
|
|
#![warn(clippy::unseparated_literal_suffix)]
|
|
|
|
#![allow(dead_code)]
|
|
|
|
|
2019-09-06 22:53:34 -05:00
|
|
|
#[macro_use]
|
2021-05-27 11:03:13 -05:00
|
|
|
extern crate proc_macro_derive;
|
2019-09-06 22:53:34 -05:00
|
|
|
|
|
|
|
// Test for proc-macro attribute
|
|
|
|
#[derive(ClippyMiniMacroTest)]
|
|
|
|
struct Foo;
|
|
|
|
|
2019-08-26 04:11:43 -05:00
|
|
|
macro_rules! lit_from_macro {
|
|
|
|
() => {
|
|
|
|
42_usize
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2019-08-18 09:52:59 -05:00
|
|
|
fn main() {
|
|
|
|
let _ok1 = 1234_i32;
|
|
|
|
let _ok2 = 1234_isize;
|
|
|
|
let _ok3 = 0x123_isize;
|
|
|
|
let _fail1 = 1234_i32;
|
|
|
|
let _fail2 = 1234_u32;
|
|
|
|
let _fail3 = 1234_isize;
|
|
|
|
let _fail4 = 1234_usize;
|
|
|
|
let _fail5 = 0x123_isize;
|
|
|
|
|
|
|
|
let _okf1 = 1.5_f32;
|
|
|
|
let _okf2 = 1_f32;
|
|
|
|
let _failf1 = 1.5_f32;
|
|
|
|
let _failf2 = 1_f32;
|
2019-08-26 04:11:43 -05:00
|
|
|
|
|
|
|
// Test for macro
|
|
|
|
let _ = lit_from_macro!();
|
|
|
|
|
|
|
|
// Counter example
|
|
|
|
let _ = line!();
|
|
|
|
// Because `assert!` contains `line!()` macro.
|
|
|
|
assert_eq!(4897_u32, 32223);
|
2019-08-18 09:52:59 -05:00
|
|
|
}
|