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

--cfg parse failures produces hard to understand errors #31496

Closed
brson opened this issue Feb 8, 2016 · 1 comment · Fixed by #64467
Closed

--cfg parse failures produces hard to understand errors #31496

brson opened this issue Feb 8, 2016 · 1 comment · Fixed by #64467
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-parser Area: The parsing of Rust source code to an AST C-enhancement Category: An issue proposing an enhancement or a PR with one.

Comments

@brson
Copy link
Contributor

brson commented Feb 8, 2016

rustc --cfg "a{" ../src/test/run-pass/hello.rs

produces:

cfgspec:1:3: 1:3 error: this file contains an un-closed delimiter
cfgspec:1 a{
            ^
cfgspec:1:2: 1:3 help: did you mean to close this delimiter?
cfgspec:1 a{
           ^

It's clear that the way this is parsed is by constructing a fake source file and running it through the main parser. This is a confusing and ugly way to report these errors. Instead the errors should be converted to display in a way that makes it clear that what isn't parsing is the cfg provided on the command line. Perhaps like

error: invalid cfg spec passed on the command line: `a{`

Translating all possible parse errors to something that makes sense in a non-file context may be tricky, so this example does lose information about what the error was.

cc @nrc since you've done some parser refactoring recently.

@brson brson added the A-parser Area: The parsing of Rust source code to an AST label Feb 8, 2016
@brson brson changed the title --print cfg parse failures produces hard to understand errors --cfg parse failures produces hard to understand errors Feb 8, 2016
@brson brson added the A-diagnostics Area: Messages for errors, warnings, and lints label Feb 8, 2016
@birkenfeld
Copy link
Contributor

Current compiler (after fix for #31497) says (last line is new):

cfgspec:1:3: 1:3 error: this file contains an un-closed delimiter
cfgspec:1 a{
            ^
cfgspec:1:2: 1:3 help: did you mean to close this delimiter?
cfgspec:1 a{
           ^
error: invalid --cfg argument: a{

@steveklabnik steveklabnik removed the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Mar 9, 2017
@Mark-Simulacrum Mark-Simulacrum added the C-enhancement Category: An issue proposing an enhancement or a PR with one. label Jul 24, 2017
@bors bors closed this as completed in 75db571 Sep 16, 2019
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 A-parser Area: The parsing of Rust source code to an AST C-enhancement Category: An issue proposing an enhancement or a PR with one.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants