Remove deprecated usage in benches/bench.rs - #611
Merged
Conversation
alejandro-vaz
approved these changes
Sep 14, 2026
Collaborator
|
makes a lot of sense, didn't realize we still had use of the macro thanks for contributing |
Collaborator
|
by the way, feel free at any time to open PRs without any issue being required |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
As #589 removes the usage of the deprecated
smallvecmacro, I took the liberty to write this small PR to also replace it in the benchmark and rid it of its#![allow(deprecated)].This refactor revealed an underlying problem:
vec!is not deprecated, and allows the notationvec![T; N].smallvec!IS deprecated, and there's no equivalent in this regard;smallvec::from_elem(val, n), what I use (internally) in this PR, is hidden from documentation and isn't meant to be consumed by the public. Its doc comment literally states "It is recommended to use the macro instead of using thís function." (which isn't the case anymore as we know, since the macro got deprecated). Thestddoes this as well, but the difference is that thestdgives thevec!macro as the recommendation and didn't deprecate it.SmallVec::from, the suggested counterpart, obviously doesn't fit because a) InSmallVec::from([val; n]);,[val; n]won't compile ifnisn't known at compile-time, and b)SmallVec::from(vec![val; n]);is obviously self-defeating and is fundamentally a different case, as we're transforming aVecinto aSmallVec, not constructing aSmallVecfrom a value and a length.To summarise, this gives us the question: What is a consumer supposed to do if they want to make a
SmallVecout ofnelements ofval, not beingna constant, and without using a deprecated macro?I believe we might want to answer this question. Perhaps de-deprecating the macro, giving a specific function or something else.