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

Poor error message when indexing result of dbg!() #68876

Open
JustAPerson opened this issue Feb 6, 2020 · 1 comment
Open

Poor error message when indexing result of dbg!() #68876

JustAPerson opened this issue Feb 6, 2020 · 1 comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@JustAPerson
Copy link
Contributor

Consider:

fn main() {
  dbg!(1, 3)[1];
}

On nightly (2020-02-05) this yields the error:

error[E0608]: cannot index into a value of type `({integer}, {integer})`
 --> src/main.rs:2:3
  |
2 |   dbg!(1, 3)[1];
  |   ^^^^^^^^^^^^^ help: to access tuple elements, use: `($ ($ crate :: dbg ! ($ val)), +,).1`

Maybe the help: to access tuple elements, use part should either avoid printing the left-hand side of the dot operator, or use the span of the source file like help: to access tuple elements, use: 'dbg!(1, 3).1'

@jonas-schievink jonas-schievink added A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 6, 2020
@euclio
Copy link
Contributor

euclio commented May 15, 2020

Message is different now:

error[E0608]: cannot index into a value of type `({integer}, {integer})`
 --> src/main.rs:2:3
  |
2 |   dbg!(1, 3)[1];
  |   ^^^^^^^^^^^^^
  |
  = help: to access tuple elements, use tuple indexing syntax (e.g., `tuple.0`)

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 C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants