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.
This commit is contained in:
Philipp Hansch 2019-01-22 07:59:09 +01:00
parent 0c6bdda562
commit aed001b8d4
No known key found for this signature in database
GPG key ID: B6FA06A6E0E2665B
2 changed files with 9 additions and 7 deletions

View file

@ -11,11 +11,11 @@ use syntax_pos::Span;
/// **What it does:**
///
/// Suggests the use of `const` in functions and methods where possible
/// Suggests the use of `const` in functions and methods where possible.
///
/// **Why is this bad?**
/// Not using `const` is a missed optimization. Instead of having the function execute at runtime,
/// when using `const`, it's evaluated at compiletime.
///
/// Not having the function const prevents callers of the function from being const as well.
///
/// **Known problems:**
///

View file

@ -25,8 +25,8 @@ fn two() -> i32 {
abc
}
// TODO: Why can this be const? because it's a zero sized type?
// There is the `const_string_new` feature, but it seems that this already works in const fns?
// FIXME: This is a false positive in the `is_min_const_fn` function.
// At least until the `const_string_new` feature is stabilzed.
fn string() -> String {
String::new()
}
@ -41,12 +41,14 @@ fn generic<T>(t: T) -> T {
t
}
// FIXME: This could be const but is currently not linted
// FIXME: Depends on the `const_transmute` and `const_fn` feature gates.
// In the future Clippy should be able to suggest this as const, too.
fn sub(x: u32) -> usize {
unsafe { transmute(&x) }
}
// FIXME: This could be const but is currently not linted
// NOTE: This is currently not yet allowed to be const
// Once implemented, Clippy should be able to suggest this as const, too.
fn generic_arr<T: Copy>(t: [T; 1]) -> T {
t[0]
}