summaryrefslogtreecommitdiff
path: root/rust/compiler.go
diff options
context:
space:
mode:
authorThiƩbaud Weksteen <tweek@google.com>2020-06-30 21:43:35 +0200
committerThiƩbaud Weksteen <tweek@google.com>2020-07-01 17:11:58 +0200
commit8e46efac71a025bc71840c4ea1a4293233fc0958 (patch)
treed93436d0c86d1510d72944b3dae280a6f3402c9e /rust/compiler.go
parentcfc2df847ca22645993926b1f0c21bd11c5aa918 (diff)
Explicitly define Rust default lints
Add documentation on how lints are defined and used in Android. Merge the deny_warnings attribute with a new attribute (no_lint) which can be used to disable the default linting parameters. Explicitly allow all lints for external/ and prebuilts/, which remove any warning when building sysroot for the devices. Test: cd external/rust/crates; mma Test: add dummy internal Rust module; mma Change-Id: I62be1c41aeda4068fb9e288038727c1de5ffe547
Diffstat (limited to 'rust/compiler.go')
-rw-r--r--rust/compiler.go12
1 files changed, 4 insertions, 8 deletions
diff --git a/rust/compiler.go b/rust/compiler.go
index efc1ce4ca..363fe5e39 100644
--- a/rust/compiler.go
+++ b/rust/compiler.go
@@ -28,10 +28,6 @@ func getEdition(compiler *baseCompiler) string {
return proptools.StringDefault(compiler.Properties.Edition, config.DefaultEdition)
}
-func getDenyWarnings(compiler *baseCompiler) bool {
- return BoolDefault(compiler.Properties.Deny_warnings, config.DefaultDenyWarnings)
-}
-
func (compiler *baseCompiler) setNoStdlibs() {
compiler.Properties.No_stdlibs = proptools.BoolPtr(true)
}
@@ -56,8 +52,8 @@ type BaseCompilerProperties struct {
// path to the source file that is the main entry point of the program (e.g. main.rs or lib.rs)
Srcs []string `android:"path,arch_variant"`
- // whether to pass "-D warnings" to rustc. Defaults to true.
- Deny_warnings *bool
+ // whether to suppress the standard lint flags - default to false
+ No_lint *bool
// flags to pass to rustc
Flags []string `android:"path,arch_variant"`
@@ -145,8 +141,8 @@ func (compiler *baseCompiler) featuresToFlags(features []string) []string {
func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags) Flags {
- if getDenyWarnings(compiler) {
- flags.RustFlags = append(flags.RustFlags, "-D warnings")
+ if !Bool(compiler.Properties.No_lint) {
+ flags.RustFlags = append(flags.RustFlags, config.RustcLintsForDir(ctx.ModuleDir()))
}
flags.RustFlags = append(flags.RustFlags, compiler.Properties.Flags...)
flags.RustFlags = append(flags.RustFlags, compiler.featuresToFlags(compiler.Properties.Features)...)