Repository navigation
Point at array length instead of whole array type - #165516
Merged
Merged
Conversation
Collaborator
|
changes to the core type system cc @lcnr |
Collaborator
|
r? @nnethercote rustbot has assigned @nnethercote. Use Why was this reviewer chosen?The reviewer was selected based on:
|
Contributor
Author
|
Will have merge conflicts with #164775. |
This comment has been minimized.
This comment has been minimized.
estebank
force-pushed
the
point-at-arr-len
branch
from
November 7, 2026 23:22
6812404 to
2768aea
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
estebank
force-pushed
the
point-at-arr-len
branch
from
November 8, 2026 21:30
2768aea to
4cd3375
Compare
Collaborator
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
This comment has been minimized.
This comment has been minimized.
```
error: the constant `N` is not of type `usize`
--> $DIR/bad-subst-const-kind.rs:8:31
|
LL | impl<const N: u64> Q for [u8; N] {
| ------------ ^ array length expected `usize`, found `u64`
| |
| `N` defined here
|
= note: the length of array `[u8; N]` must be type `usize`
```
When evaluating an array type's length we don't have accurate spans for that hir node, because evaluation happens on types. Keep the Span for the whole array type that we can use later to try and find the hir node and extract the right span to use in the diagnostic.
estebank
force-pushed
the
point-at-arr-len
branch
from
November 9, 2026 05:10
4cd3375 to
93e596a
Compare
Contributor
|
@bors r+ rollup |
Contributor
rust-bors Bot
pushed a commit
that referenced
this pull request
Nov 9, 2026
…uwer Rollup of 9 pull requests Successful merges: - #165161 (`rustc_builtin_macros` cleanup, part 9) - #165663 (Avoid repeated gated spans snapshots during macro matching) - #165637 (library: std: process: Make Command::status platform specific) - #163571 ([rustdoc] Render `Deref` methods on aliased items) - #164712 (Reject unexpanded attributes in attributes) - #165516 (Point at array length instead of whole array type) - #165674 (Add regression test for issue 118449) - #165676 (Make `Proxy` weak reference as it seems that it is not dropped at all) - #165695 (Add regression test for unsafe diagnostic attributes)
rust-bors Bot
pushed a commit
that referenced
this pull request
Nov 9, 2026
Rollup merge of #165516 - estebank:point-at-arr-len, r=nnethercote Point at array length instead of whole array type ``` error: the constant `N` is not of type `usize` --> $DIR/bad-subst-const-kind.rs:8:31 | LL | impl<const N: u64> Q for [u8; N] { | ^ array length expected `usize`, found `u64` | = note: the length of array `[u8; N]` must be type `usize` ``` When evaluating an array type's length we don't have accurate spans for that hir node, because evaluation happens on types. Keep the Span for the whole array type that we can use later to try and find the hir node and extract the right span to use in the diagnostic.
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.
When evaluating an array type's length we don't have accurate spans for that hir node, because evaluation happens on types. Keep the Span for the whole array type that we can use later to try and find the hir node and extract the right span to use in the diagnostic.