-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Closed
Copy link
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
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.
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.