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