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.
const
-ants are defined to be inline rvalues and this definition sometimes leads to quite non-intuitive behavior.For example, in this code the array
ARR
is (correctly) copied to the stack 3 times (see the unoptimized IR/asm http://is.gd/UMQz1B):The lint prevents such mistakes by checking the size of a
const
-ant and warning if it's larger thanMAX_CONST_SIZE
.In this PR the value of
MAX_CONST_SIZE
is selected to be 64 bytes, so nothing in Rust itself breaks (except for one place in libstd/thread_local), but it can (should?) be smaller.Obviously, the value should be larger than size of fat reference, because the code like
shouldn't warn.
Any ideas on what should the value of
MAX_CONST_SIZE
ideally be?