1 #![warn(clippy::missing_const_for_fn)]
2 #![allow(incomplete_features, clippy::let_and_return)]
3 #![feature(custom_inner_attributes)]
5 use std::mem::transmute;
13 pub fn new() -> Self {
17 fn const_generic_params<'a, T, const N: usize>(&self, b: &'a [T; N]) -> &'a [T; N] {
27 // Could also be const
33 // Could be const (since Rust 1.39)
34 fn string() -> String {
39 unsafe fn four() -> i32 {
43 // Could also be const
44 fn generic<T>(t: T) -> T {
48 fn sub(x: u32) -> usize {
49 unsafe { transmute(&x) }
52 // NOTE: This is currently not yet allowed to be const
53 // Once implemented, Clippy should be able to suggest this as const, too.
54 fn generic_arr<T: Copy>(t: [T; 1]) -> T {
66 // This can be const, because `a` is passed by reference
67 pub fn b(self, a: &A) -> B {
73 mod const_fn_stabilized_before_msrv {
74 #![clippy::msrv = "1.47.0"]
76 // This could be const because `u8::is_ascii_digit` is a stable const function in 1.47.
77 fn const_fn_stabilized_before_msrv(byte: u8) {
78 byte.is_ascii_digit();
82 // Should not be const