Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

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

Closed

Description

@brson

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.

Activity

  1. added
    A-parser
    on Feb 8, 2016
  2. changed the title [-]--print cfg parse failures produces hard to understand errors[/-] [+]--cfg parse failures produces hard to understand errors[/+] on Feb 8, 2016
  3. added
    A-diagnostics
    on Feb 8, 2016
  4. birkenfeld commented on May 1, 2016

    @birkenfeld
    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{
    
  5. removed
    T-compiler
    on Mar 9, 2017
  6. added
    C-enhancement
    on Jul 24, 2017
  7. added a commit that references this issue on Sep 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsA-parserC-enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions