2023-07-27 13:23:04 +00:00
|
|
|
//@aux-build:proc_macros.rs
|
2023-06-10 09:00:59 +00:00
|
|
|
#![allow(irrefutable_let_patterns, nonstandard_style, unused)]
|
2023-10-17 16:34:27 +00:00
|
|
|
#![allow(clippy::struct_field_names)]
|
2023-06-09 22:49:35 +00:00
|
|
|
#![warn(clippy::min_ident_chars)]
|
2023-06-09 18:33:30 +00:00
|
|
|
|
|
|
|
extern crate proc_macros;
|
2023-07-03 17:42:48 +00:00
|
|
|
use proc_macros::{external, with_span};
|
2023-06-09 18:33:30 +00:00
|
|
|
|
|
|
|
struct A {
|
|
|
|
a: u32,
|
|
|
|
i: u32,
|
|
|
|
A: u32,
|
|
|
|
I: u32,
|
|
|
|
}
|
|
|
|
|
|
|
|
struct B(u32);
|
|
|
|
|
2023-06-10 09:00:59 +00:00
|
|
|
struct O {
|
|
|
|
o: u32,
|
|
|
|
}
|
|
|
|
|
2023-06-09 18:33:30 +00:00
|
|
|
struct i;
|
|
|
|
|
|
|
|
enum C {
|
|
|
|
D,
|
|
|
|
E,
|
|
|
|
F,
|
|
|
|
j,
|
|
|
|
}
|
|
|
|
|
|
|
|
struct Vec4 {
|
|
|
|
x: u32,
|
|
|
|
y: u32,
|
|
|
|
z: u32,
|
|
|
|
w: u32,
|
|
|
|
}
|
|
|
|
|
|
|
|
struct AA<T, E>(T, E);
|
|
|
|
|
2024-02-14 21:22:15 +00:00
|
|
|
trait Trait {
|
|
|
|
const A: u32 = 0;
|
|
|
|
type A;
|
|
|
|
fn a() {}
|
|
|
|
}
|
|
|
|
|
2023-06-09 18:33:30 +00:00
|
|
|
fn main() {
|
|
|
|
// Allowed idents
|
|
|
|
let w = 1;
|
|
|
|
// Ok, not this one
|
|
|
|
// let i = 1;
|
2023-06-10 09:00:59 +00:00
|
|
|
let j = 1;
|
|
|
|
let n = 1;
|
|
|
|
let z = 1;
|
|
|
|
let y = 1;
|
|
|
|
let z = 1;
|
|
|
|
// Implicitly disallowed idents
|
|
|
|
let h = 1;
|
|
|
|
let e = 2;
|
|
|
|
let l = 3;
|
|
|
|
let l = 4;
|
|
|
|
let o = 6;
|
|
|
|
// 2 len does not lint
|
|
|
|
let hi = 0;
|
|
|
|
// Lint
|
|
|
|
let (h, o, w) = (1, 2, 3);
|
|
|
|
for (a, (r, e)) in (0..1000).enumerate().enumerate() {}
|
|
|
|
let you = Vec4 { x: 1, y: 2, z: 3, w: 4 };
|
|
|
|
while let (d, o, _i, n, g) = (true, true, false, false, true) {}
|
|
|
|
let today = true;
|
|
|
|
// Ideally this wouldn't lint, but this would (likely) require global analysis, outta scope
|
|
|
|
// of this lint regardless
|
|
|
|
let o = 1;
|
|
|
|
let o = O { o };
|
2023-06-09 18:33:30 +00:00
|
|
|
|
|
|
|
for j in 0..1000 {}
|
2023-06-10 14:13:04 +00:00
|
|
|
for _ in 0..10 {}
|
2023-06-09 18:33:30 +00:00
|
|
|
|
|
|
|
// Do not lint code from external macros
|
|
|
|
external! { for j in 0..1000 {} }
|
|
|
|
// Do not lint code from procedural macros
|
|
|
|
with_span! {
|
|
|
|
span
|
|
|
|
for j in 0..1000 {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn b() {}
|
2023-06-10 14:13:04 +00:00
|
|
|
fn wrong_pythagoras(a: f32, b: f32) -> f32 {
|
|
|
|
a * a + a * b
|
|
|
|
}
|
2023-07-24 12:54:55 +00:00
|
|
|
|
|
|
|
mod issue_11163 {
|
|
|
|
struct Array<T, const N: usize>([T; N]);
|
|
|
|
}
|