-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
const eval Vec::new() the same as vec![] #54475
Copy link
Copy link
Closed
Labels
A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.I-slowIssue: Problems and improvements with respect to performance of generated code.Issue: Problems and improvements with respect to performance of generated code.
Metadata
Metadata
Assignees
Labels
A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.I-slowIssue: Problems and improvements with respect to performance of generated code.Issue: Problems and improvements with respect to performance of generated code.
Type
Fields
Give feedbackNo fields configured for issues without a type.
For some reason, it seems that rustc can deduce
.len() == 0better forvec![]than forVec::new().https://rust.godbolt.org/z/xEhPhI
surprisingly, when I replaced one
Vec::new()withvec![], rustc was able to const-eval the return value to0.https://rust.godbolt.org/z/cdbEGU
Apparently
and
generate the same code tough.