Closed
Description
Given the following code: (playground)
const fn f(a: &u8, b: &u8) -> bool {
a == b
}
The current output is:
error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants
--> src/lib.rs:2:5
|
2 | a == b
| ^^^^^^
Ideally the output should look like:
error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants
--> src/lib.rs:2:5
|
2 | a == b
| ^^^^^^
note: `a` has type `&u8`, `b` has type `&u8`
help: consider dereferencing `a` and `b`
|
2 | *a == *b
| + +
I've encountered this "in the wild" while trying to implement const
version of str::strip_prefix
: (playground). Another, a bit simpler example (const fn
&[u8]
eq): (playground). In both cases references were created implicitly by matching on a slice.