Skip to content
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

Incorrect help message for bad tuple indexing on parenthesised array #56963

Closed
varkor opened this issue Dec 18, 2018 · 1 comment
Closed

Incorrect help message for bad tuple indexing on parenthesised array #56963

varkor opened this issue Dec 18, 2018 · 1 comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints

Comments

@varkor
Copy link
Member

varkor commented Dec 18, 2018

fn main() {
    let x = [0u32];
    (x as [u32; 1]).0
}

The help message suggests:

help: instead of using tuple indexing, use array indexing: `x as [u32; 1][0]`

The parentheses have gone missing.

This is related to #56714.

@varkor varkor added the A-diagnostics Area: Messages for errors, warnings, and lints label Dec 18, 2018
@zackmdavis
Copy link
Member

This kind of thing (compare to e.g. #55109) happens when we use the pretty printer to synthesize suggestions.

let base = self.tcx.hir().node_to_pretty_string(base.id);
let help = "instead of using tuple indexing, use array indexing";
let suggestion = format!("{}[{}]", base, field);

Centril added a commit to Centril/rust that referenced this issue Dec 23, 2018
…zackmdavis

Correct strings for raw pointer deref and array access suggestions

Fixes rust-lang#56714.
Fixes rust-lang#56963.

r? @zackmdavis
Centril added a commit to Centril/rust that referenced this issue Dec 23, 2018
…zackmdavis

Correct strings for raw pointer deref and array access suggestions

Fixes rust-lang#56714.
Fixes rust-lang#56963.

r? @zackmdavis
Centril added a commit to Centril/rust that referenced this issue Dec 23, 2018
…zackmdavis

Correct strings for raw pointer deref and array access suggestions

Fixes rust-lang#56714.
Fixes rust-lang#56963.

r? @zackmdavis
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints
Projects
None yet
Development

No branches or pull requests

2 participants