Skip to content

Improve diagnostics for incorrect double pointer type #102261

Closed
@Rageking8

Description

@Rageking8

Given the following code: link

fn main() {
    let x: i32 = 5;
    let ptr: *const i32 = &x;
    let dptr: **const i32 = &ptr;
}

The current output is:

   Compiling playground v0.0.1 (/playground)
error: expected mut or const in raw pointer type
 --> src/main.rs:4:15
  |
4 |     let dptr: **const i32 = &ptr;
  |               ^ expected mut or const in raw pointer type
  |
  = help: use `*mut T` or `*const T` as appropriate

error: could not compile `playground` due to previous error

Ideally the output should suggest correct ways to specify a double pointer type (e.g. *const *const T)(May be able to extend for more levels of indirection if wanted), instead of a generic single pointer suggestion, which may not be what the user wants.

Metadata

Metadata

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions