Not planned
Description
Code
pub type ChunkBlocks = GenericChunkBlocks<123>;
pub struct GenericChunkBlocks<const SIZE: usize> {
blocks: [u16; SIZE],
}
impl<const BLOCK_COUNT: usize> Default for GenericChunkBlocks<BLOCK_COUNT> {
fn default() -> Self {
ChunkBlocks { // Note how I accidentally used ChunkBlocks instead of Self.
blocks: [0; BLOCK_COUNT],
}
}
}
Current output
Compiling compiler-error v0.1.0 (/home/notyou/devel/compiler-error)
error[E0308]: mismatched types
--> src/lib.rs:10:21
|
10 | blocks: [0; BLOCK_COUNT],
| ^^^^^^^^^^^^^^^^ expected `123`, found `BLOCK_COUNT`
|
= note: expected array `[u16; 123]`
found array `[u16; BLOCK_COUNT]`
error[E0308]: mismatched types
--> src/lib.rs:9:9
|
8 | fn default() -> Self {
| ---- expected `GenericChunkBlocks<BLOCK_COUNT>` because of return type
9 | / ChunkBlocks {
10 | | blocks: [0; BLOCK_COUNT],
11 | | }
| |_________^ expected `BLOCK_COUNT`, found `123`
|
= note: expected struct `GenericChunkBlocks<BLOCK_COUNT>`
found struct `GenericChunkBlocks<123>`
For more information about this error, try `rustc --explain E0308`.
error: could not compile `compiler-error` (lib) due to 2 previous errors
warning: build failed, waiting for other jobs to finish...
error: could not compile `compiler-error` (lib test) due to 2 previous errors
Desired output
error[E0308]: mismatched types
--> src/lib.rs:9:9
|
8 | fn default() -> Self {
| ---- expected `GenericChunkBlocks<BLOCK_COUNT>` because of return type
9 | / ChunkBlocks {
10 | | blocks: [0; BLOCK_COUNT],
11 | | }
| |_________^ expected `BLOCK_COUNT`, found `123`
|
= note: expected struct `GenericChunkBlocks<BLOCK_COUNT>`
found struct `ChunkBlocks`
or
= note: GenericChunkBlocks<123> is a type alias: `ChunkBlocks`
Rationale and extra context
No response
Other cases
No response
Rust Version
rustc 1.82.0-nightly (13a52890d 2024-08-14)
binary: rustc
commit-hash: 13a52890dde8cfeb95069d77c223ac37c0cf3a46
commit-date: 2024-08-14
host: x86_64-unknown-linux-gnu
release: 1.82.0-nightly
LLVM version: 19.1.0
Anything else?
No response
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
fmease commentedon Aug 24, 2024
Duplicate of #17164