Skip to content

Commit 1a14348

Browse files
Merge #1035
1035: Handle -fsyntax-only r=CohenArthur a=CohenArthur 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: Arthur Cohen <[email protected]>
2 parents b7baee8 + e30d07d commit 1a14348

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)