Skip to content

Commit e30d07d

Browse files
parser: Handle -fsyntax-only properly
Handle the -fsyntax-only properly from the rust frontend. This flag allows checking for syntax and stopping after that, skipping further passes of the pipeline. The flag was accepted by the frontend, but was not used anywhere. Co-authored-by: philberty <philip.herron@embecosm.com>
1 parent 2dfc196 commit e30d07d

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

gcc/rust/rust-session-manager.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,11 @@ Session::parse_file (const char *filename)
542542

543543
rust_debug ("\033[0;31mSUCCESSFULLY PARSED CRATE \033[0m");
544544

545+
// If -fsyntax-only was passed, we can just skip the remaining passes.
546+
// Parsing errors are already emitted in `parse_crate()`
547+
if (flag_syntax_only)
548+
return;
549+
545550
// register plugins pipeline stage
546551
register_plugins (parsed_crate);
547552
rust_debug ("\033[0;31mSUCCESSFULLY REGISTERED PLUGINS \033[0m");
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// { dg-additional-options "-fsyntax-only" }
2+
3+
fn main() {
4+
let mut a = 15;
5+
a = true;
6+
}

0 commit comments

Comments
 (0)