Skip to content

Commit 1b4f093

Browse files
committed
Update various docs
* `const_transmute` currently also seems to depend on the `const_fn` feature. * Only `Sized` is currently allowed as a bound, not Copy.
1 parent 5dab1c7 commit 1b4f093

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

clippy_lints/src/missing_const_for_fn.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff 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
///

tests/ui/missing_const_for_fn/could_be_const.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff 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.
3030
fn 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.
4546
fn 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.
5052
fn generic_arr<T: Copy>(t: [T; 1]) -> T {
5153
t[0]
5254
}

0 commit comments

Comments
 (0)