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

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

Closed
strangeglyph opened this issue Oct 18, 2012 · 6 comments
Closed

Comments

@strangeglyph
Copy link
Contributor

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

@brson
Copy link
Contributor

brson commented Oct 22, 2012

--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.

@catamorphism
Copy link
Contributor

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

@Ghoughpteighbteau
Copy link

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.

@pnkfelix
Copy link
Member

@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.

capdevc added a commit to capdevc/flycheck that referenced this issue Jan 22, 2014
per rust-lang/rust#3808

Currently `rustc --parse-only` only catches syntax errors. `--no-trans` ensures the code will compile. Unfortunately, this is slow. But, at the moment parse-only doesn't do much. Syntastic for vim is using --no-trans as of a39b397e6ae3b32d2a0497d0f4ddfec0479ad2bb, for example.
capdevc added a commit to capdevc/flycheck that referenced this issue Jan 22, 2014
per rust-lang/rust#3808

Currently `rustc --parse-only` only catches syntax errors. `--no-trans` ensures the code will compile. Unfortunately, this is slow. But, at the moment parse-only doesn't do much. Syntastic for vim is using --no-trans as of a39b397e6ae3b32d2a0497d0f4ddfec0479ad2bb, for example.
Also switched rustc invocation to `source-inplace` since it looks in the source direcory for modules
capdevc added a commit to capdevc/flycheck that referenced this issue Jan 22, 2014
Switch to --no-trans per rust-lang/rust#3808
Switch source to source-inplace since rustc looks for modules in the
source directory.
Add a pattern for rustc warnings and add a unit test.
Update the rust syntax error unit test.
@Hi-Angel
Copy link

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'

@jonas-schievink
Copy link
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.

bors pushed a commit to rust-lang-ci/rust that referenced this issue May 15, 2021
RalfJung pushed a commit to RalfJung/rust that referenced this issue Sep 17, 2024
Renamed variable and fixed comments referring to renamed FileDescriptor

Fixes rust-lang#3808, does not change any functionality
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants