-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"impractical" const fn #11192
Comments
Do you remember any specific examples? Would be good to see what we could reasonably suggest to do instead |
Here's a couple :) multiformats/rust-multihash#330 (addressing in multiformats/rust-multihash#331) In the first case, the solution is creating a new |
I'd say it's fine if it lints this as well, But this does contradict |
A const That is, const EMPTY: Vec<u8> = Vec::new();
let arr = [EMPTY; 10]; So if for some reason you can't use |
Related issue for the aforementioned lint: |
This is my current thinking for this lint - are there things I'm missing? |
What it does
A couple of times, I've seen library authors create
const fn
s that can't usefully be used inconst
contexts.This lint would catch these
Advantage
Catch API bugs
Drawbacks
It's not clear what
useful
means.A candidate is "is the return type const-droppable", but that would flag
Vec::new
. Maybe that's okay?Or maybe the first iteration is to catch
enum
s that can't be dropped in a const context? Or maybe even justResult
sExample
The text was updated successfully, but these errors were encountered: