-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Suggest the correct array length on mismatch #107173
Conversation
r? @estebank (rustbot has picked a reviewer for you, use r? to override) |
83eda70
to
ec9399a
Compare
Actually, looking at the changes in tests, it might not be best to do this so generally 🤔 . It only really applies when the array is being bound and the type doesn't match. I'm not sure if the information is available here to only lint on those cases. |
Hmmm... yeah, I would look at @rustbot author |
cff21bb
to
804c4a0
Compare
Reusing some code from the original array length suggestion mentioned https://github.com/rust-lang/rust/blob/master/compiler/rustc_hir_typeck/src/expr.rs#L1339, this now suggests the correct type for constants. It would be nice to have this also work for |
804c4a0
to
903ca87
Compare
This now handles
'expected due to this' is emitted much further along the line and overlaps which isn't hugely readable, but IDEs should handle it fine which is the requested use case. for
(also, I notice that the @rustbot ready |
Hmmm... I guess this is fine. Maybe we should add an @bors r+ |
…compiler-errors Suggest the correct array length on mismatch Fixes rust-lang#107156 I wasn't able to find a way to get the `Span` for the actual array size unfortunately, so this suggestion can't be applied automatically. `@rustbot` label +A-diagnostics
Rollup of 7 pull requests Successful merges: - rust-lang#105300 (rework min_choice algorithm of member constraints) - rust-lang#107163 (Remove some superfluous type parameters from layout.rs.) - rust-lang#107173 (Suggest the correct array length on mismatch) - rust-lang#107411 (Handle discriminant in DataflowConstProp) - rust-lang#107968 (Enable `#[thread_local]` on armv6k-nintendo-3ds) - rust-lang#108032 (Un📦ing the Resolver) - rust-lang#108060 (Revert to using `RtlGenRandom` as a fallback) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Fixes #107156
I wasn't able to find a way to get the
Span
for the actual array size unfortunately, so this suggestion can't be applied automatically.@rustbot label +A-diagnostics