File tree Expand file tree Collapse file tree 2 files changed +9
-7
lines changed
tests/ui/missing_const_for_fn Expand file tree Collapse file tree 2 files changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -11,11 +11,11 @@ use syntax_pos::Span;
11
11
12
12
/// **What it does:**
13
13
///
14
- /// Suggests the use of `const` in functions and methods where possible
14
+ /// Suggests the use of `const` in functions and methods where possible.
15
15
///
16
16
/// **Why is this bad?**
17
- /// Not using `const` is a missed optimization. Instead of having the function execute at runtime,
18
- /// when using ` const`, it's evaluated at compiletime .
17
+ ///
18
+ /// Not having the function const prevents callers of the function from being const as well .
19
19
///
20
20
/// **Known problems:**
21
21
///
Original file line number Diff line number Diff line change @@ -25,8 +25,8 @@ fn two() -> i32 {
25
25
abc
26
26
}
27
27
28
- // TODO: Why can this be const? because it's a zero sized type?
29
- // There is the `const_string_new` feature, but it seems that this already works in const fns?
28
+ // FIXME: This is a false positive in the `is_min_const_fn` function.
29
+ // At least until the `const_string_new` feature is stabilzed.
30
30
fn string ( ) -> String {
31
31
String :: new ( )
32
32
}
@@ -41,12 +41,14 @@ fn generic<T>(t: T) -> T {
41
41
t
42
42
}
43
43
44
- // FIXME: This could be const but is currently not linted
44
+ // FIXME: Depends on the `const_transmute` and `const_fn` feature gates.
45
+ // In the future Clippy should be able to suggest this as const, too.
45
46
fn sub ( x : u32 ) -> usize {
46
47
unsafe { transmute ( & x) }
47
48
}
48
49
49
- // FIXME: This could be const but is currently not linted
50
+ // NOTE: This is currently not yet allowed to be const
51
+ // Once implemented, Clippy should be able to suggest this as const, too.
50
52
fn generic_arr < T : Copy > ( t : [ T ; 1 ] ) -> T {
51
53
t[ 0 ]
52
54
}
You can’t perform that action at this time.
0 commit comments