resolve: suggest usize for array-length consts - #160155
resolve: suggest usize for array-length consts#160155AayushMainali-Github wants to merge 1 commit into
Conversation
|
r? @mati865 rustbot has assigned @mati865. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
Hi, for the last few months we have been receiving an increased amount of LLM generated contributions. We have no way to distinguish your PR from other generated ones, therefore need to put some additional barriers for contributions. This PR show some LLM usage which under our current policy is not allowed nor it's missing a disclosure about LLM use. We are a community of contributors, not just a code repository. We focus on contributors who desire to stay around and put in the work to produce high quality contributions or learn to do so. Please also get familiar with our contributions guidelines and contribution standards. Therefore we are closing this PR. If you're unsure about how to proceed, please feel free to join our Zulip mentoring channel and ask for a mentor to learn how best to use (or not use) LLMs. -- the Rust mod team |
Suggest usize instead of placeholder type for array length constants Fixes rust-lang#159487 This PR makes the type suggestion for a anonymous constant used as an array length or repeat expression less generic: usize instead of placeholder type. I divided the work in several commits so I could track my own progress and test my understanding. I could squash them all into one if needed. Some ideas were pulled from rust-lang#160155 , which is why the PR might look similar. That said I only used it as reference when I got stuck, because I was prioritizing my own learning instead of just quickly pushing the changes (hence, many commits).
Suggest usize instead of placeholder type for array length constants Fixes rust-lang#159487 This PR makes the type suggestion for a anonymous constant used as an array length or repeat expression less generic: usize instead of placeholder type. I divided the work in several commits so I could track my own progress and test my understanding. I could squash them all into one if needed. Some ideas were pulled from rust-lang#160155 , which is why the PR might look similar. That said I only used it as reference when I got stuck, because I was prioritizing my own learning instead of just quickly pushing the changes (hence, many commits).
Suggest usize instead of placeholder type for array length constants Fixes rust-lang#159487 This PR makes the type suggestion for a anonymous constant used as an array length or repeat expression less generic: usize instead of placeholder type. I divided the work in several commits so I could track my own progress and test my understanding. I could squash them all into one if needed. Some ideas were pulled from rust-lang#160155 , which is why the PR might look similar. That said I only used it as reference when I got stuck, because I was prioritizing my own learning instead of just quickly pushing the changes (hence, many commits).
Suggest usize instead of placeholder type for array length constants Fixes rust-lang#159487 This PR makes the type suggestion for a anonymous constant used as an array length or repeat expression less generic: usize instead of placeholder type. I divided the work in several commits so I could track my own progress and test my understanding. I could squash them all into one if needed. Some ideas were pulled from rust-lang#160155 , which is why the PR might look similar. That said I only used it as reference when I got stuck, because I was prioritizing my own learning instead of just quickly pushing the changes (hence, many commits).
Suggest usize instead of placeholder type for array length constants Fixes rust-lang#159487 This PR makes the type suggestion for a anonymous constant used as an array length or repeat expression less generic: usize instead of placeholder type. I divided the work in several commits so I could track my own progress and test my understanding. I could squash them all into one if needed. Some ideas were pulled from rust-lang#160155 , which is why the PR might look similar. That said I only used it as reference when I got stuck, because I was prioritizing my own learning instead of just quickly pushing the changes (hence, many commits).
Suggest usize instead of placeholder type for array length constants Fixes rust-lang#159487 This PR makes the type suggestion for a anonymous constant used as an array length or repeat expression less generic: usize instead of placeholder type. I divided the work in several commits so I could track my own progress and test my understanding. I could squash them all into one if needed. Some ideas were pulled from rust-lang#160155 , which is why the PR might look similar. That said I only used it as reference when I got stuck, because I was prioritizing my own learning instead of just quickly pushing the changes (hence, many commits).
Suggest usize instead of placeholder type for array length constants Fixes rust-lang#159487 This PR makes the type suggestion for a anonymous constant used as an array length or repeat expression less generic: usize instead of placeholder type. I divided the work in several commits so I could track my own progress and test my understanding. I could squash them all into one if needed. Some ideas were pulled from rust-lang#160155 , which is why the PR might look similar. That said I only used it as reference when I got stuck, because I was prioritizing my own learning instead of just quickly pushing the changes (hence, many commits).
Rollup merge of #160906 - lsunsi:push-ysqvmnlvvzwr, r=davidtwco Suggest usize instead of placeholder type for array length constants Fixes #159487 This PR makes the type suggestion for a anonymous constant used as an array length or repeat expression less generic: usize instead of placeholder type. I divided the work in several commits so I could track my own progress and test my understanding. I could squash them all into one if needed. Some ideas were pulled from #160155 , which is why the PR might look similar. That said I only used it as reference when I got stuck, because I was prioritizing my own learning instead of just quickly pushing the changes (hence, many commits).
Suggest usize instead of placeholder type for array length constants Fixes rust-lang/rust#159487 This PR makes the type suggestion for a anonymous constant used as an array length or repeat expression less generic: usize instead of placeholder type. I divided the work in several commits so I could track my own progress and test my understanding. I could squash them all into one if needed. Some ideas were pulled from rust-lang/rust#160155 , which is why the PR might look similar. That said I only used it as reference when I got stuck, because I was prioritizing my own learning instead of just quickly pushing the changes (hence, many commits).
Suggest usize instead of placeholder type for array length constants Fixes rust-lang/rust#159487 This PR makes the type suggestion for a anonymous constant used as an array length or repeat expression less generic: usize instead of placeholder type. I divided the work in several commits so I could track my own progress and test my understanding. I could squash them all into one if needed. Some ideas were pulled from rust-lang/rust#160155 , which is why the PR might look similar. That said I only used it as reference when I got stuck, because I was prioritizing my own learning instead of just quickly pushing the changes (hence, many commits).
Fixes #159487.
Summary
letinto aconstbecause the binding was used as an array length ([T; n]) or repeat count ([x; n]), suggestusizeinstead of/* Type */./* Type */placeholder.Reason for the change
Array lengths are always
usize, so the placeholder type in the suggestion was unhelpful for the common case shown in the issue.Testing performed
./x test tests/ui/consts/suggest-usize-for-array-length.rs --stage 1— passed (new regression test)./x test tests/ui/consts/non-const-value-in-const.rs tests/ui/repeat-expr/repeat_count.rs tests/ui/error-codes/E0435.rs tests/ui/parser/recover/array-type-no-semi.rs tests/ui/const-generics/legacy-const-generics-bad.rs --stage 1 --force-rerun— passedrustfmt --edition 2024 --checkon changedrustc_resolvesources — clean