Skip to content

Add an option to emit compiler warnings when using 'rustc --parse-only' #3808

Closed

Description

@strangeglyph

Right now, when using rustc to only parse an input file, only errors are displayed. There should be an option to also display warnings (and notes) without having to fully compile the program.

Trying again with a recent build of rustc, it appears that not even errors are displayed with rustc 0.5

Activity

  1. brson commented on Oct 22, 2012

    @brson
    Contributor

    --parse-only results in no analysis being performed, so only syntax errors can be emitted. When I run rustc --parse-only over a file with invalid syntax I see the error. The parser doesn't appear to contain any warnings and only one 'note' (for duplicate drop blocks in structs), but I do see that emitted.

  2. catamorphism commented on Oct 25, 2012

    @catamorphism
    Contributor

    Closing because this isn't really feasible (linting comes after many other passes that get skipped with --parse-only.)

  3. Ghoughpteighbteau commented on Jan 20, 2014

    @Ghoughpteighbteau

    can we get a recommendation from one of the devs as to what arguments we should use if we are checking the syntax of a file for correctness? For error and warning highlighting.

  4. pnkfelix commented on Jan 21, 2014

    @pnkfelix
    Contributor

    @Ghoughpteighbteau I'm guessing that since the lints use much info from the analysis passes, you still need those, so --no-analysis is not good enough.

    Thus I suspect --no-trans is the best you can do.

  5. Hi-Angel commented on Apr 21, 2019

    @Hi-Angel

    Neither option works for me.

    $ rustc main.rs --no-trans
    error: Unrecognized option: 'no-trans'
    
    $ rustc main.rs --parse-only
    error: Unrecognized option: 'parse-only'
    
  6. jonas-schievink commented on Apr 21, 2019

    @jonas-schievink
    Contributor

    @Hi-Angel you probably want to use cargo check, which uses rustc --emit=metadata internally. This thread is extremely old, things have changed a lot since then.

  7. added a commit that references this issue on Sep 17, 2024
    e6604ea
  8. added a commit that references this issue on Aug 21, 2026
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions