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;
1111
1212/// **What it does:**
1313///
14- /// Suggests the use of `const` in functions and methods where possible
14+ /// Suggests the use of `const` in functions and methods where possible.
1515///
1616/// **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 .
1919///
2020/// **Known problems:**
2121///
Original file line number Diff line number Diff line change @@ -25,8 +25,8 @@ fn two() -> i32 {
2525 abc
2626}
2727
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.
3030fn string ( ) -> String {
3131 String :: new ( )
3232}
@@ -41,12 +41,14 @@ fn generic<T>(t: T) -> T {
4141 t
4242}
4343
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.
4546fn sub ( x : u32 ) -> usize {
4647 unsafe { transmute ( & x) }
4748}
4849
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.
5052fn generic_arr < T : Copy > ( t : [ T ; 1 ] ) -> T {
5153 t[ 0 ]
5254}
You can’t perform that action at this time.
0 commit comments