Skip to content

Commit

Permalink
Merge branch 'alic/binding_lint' into 'master'
Browse files Browse the repository at this point in the history
chore: Enable linting error for `bindings_with_variant_name`

Reference for the lint: https://doc.rust-lang.org/beta/nightly-rustc/rustc_lint/builtin/static.BINDINGS_WITH_VARIANT_NAME.html

This lint is currently only a warning on our current Rust version. I recommend turning it into an error. The failure can be quite nasty. Consider this example:

```Rust
pub enum PayloadType { Summary, Data }

// ... later somewhere
let x = PayloadType::Data;
match x {
    Summary => println!("summary"),
    Data => println!("data"),
}
```
Now, in the ic repo, the above code will print "summary", because without the fully-qualified path, Summary is just a bound variable (instead of a sum type variant)

**This lint is deny-by-default since Rust 1.68.2 ([this MR](rust-lang/rust#104154)), but we're still on an older version. That's why I suggest we enable it pro-actively.** 

See merge request dfinity-lab/public/ic!12636
  • Loading branch information
dist1ll committed Jun 1, 2023
2 parents 93684ff + 5cbef72 commit f2b04ad
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ build --incompatible_strict_action_env # use an environment with a static value
# default to optimized and unstripped binaries.
build --compilation_mode=opt
build --@rules_rust//:extra_rustc_flags=-Cdebug-assertions=on
build --@rules_rust//:extra_rustc_flag=-Dbindings_with_variant_name
build --strip=never

build --strategy_regexp=ic-os/.*=local
Expand Down

0 comments on commit f2b04ad

Please sign in to comment.