Skip to content

Commit 40f5bc6

Browse files
committed
Add warnings_are_errors and show_warnings to the cache info.
Rewrite the cache info variable accessors to be more fragile. When done in the `let Self{ ... } = self;` style, this code should now cause errors and lints as new fields get added.
1 parent f0230cb commit 40f5bc6

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

lrpar/src/lib/ctbuilder.rs

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -811,14 +811,27 @@ where
811811
// Record the time that this version of lrpar was built. If the source code changes and
812812
// rustc forces a recompile, this will change this value, causing anything which depends on
813813
// this build of lrpar to be recompiled too.
814+
let Self {
815+
// All variables except for `output_path` and `phantom` should
816+
// be written into the cache.
817+
grammar_path,
818+
mod_name,
819+
recoverer,
820+
yacckind,
821+
output_path: _,
822+
error_on_conflicts,
823+
warnings_are_errors,
824+
show_warnings,
825+
visibility,
826+
rust_edition,
827+
phantom:_,
828+
} = self;
814829
let build_time = env!("VERGEN_BUILD_TIMESTAMP");
815-
let grammar_path = self.grammar_path.as_ref().unwrap().to_string_lossy();
816-
let mod_name = QuoteOption(self.mod_name);
817-
let recoverer = self.recoverer;
818-
let yacckind = self.yacckind;
819-
let visibility = self.visibility.to_variant_tokens();
820-
let rust_edition = self.rust_edition.to_variant_tokens();
821-
let error_on_conflicts = self.error_on_conflicts;
830+
let grammar_path = grammar_path.as_ref().unwrap().to_string_lossy();
831+
let mod_name = QuoteOption(mod_name.as_deref());
832+
let visibility = visibility.to_variant_tokens();
833+
let rust_edition = rust_edition.to_variant_tokens();
834+
let yacckind = yacckind.expect("is_some() by this point");
822835
let rule_map = grm
823836
.iter_tidxs()
824837
.map(|tidx| {
@@ -841,6 +854,8 @@ where
841854
const RECOVERER: RecoveryKind = #recoverer;
842855
const YACC_KIND: YaccKind = #yacckind;
843856
const ERROR_ON_CONFLICTS: bool = #error_on_conflicts;
857+
const SHOW_WARNINGS: bool = #show_warnings;
858+
const WARNINGS_ARE_ERRORS: bool = #warnings_are_errors;
844859
const RUST_EDITION: RustEdition = #rust_edition;
845860
const RULE_IDS_MAP: [(usize, &str); #rule_map_len] = [#(#rule_map,)*];
846861
fn visibility() -> Visibility {

0 commit comments

Comments
 (0)