compilers/rust: Implement warning levels

Currently this implements 3 warning levels, 1 and 2 are just the
"default" set by rustc, 3, is "everything is a warning", and 0 is
"nothign is a warning".
pull/8773/head
Dylan Baker 4 years ago
parent e2260650a0
commit d32fc0563d
  1. 1
      docs/markdown/snippets/rustc-improvements.md
  2. 14
      mesonbuild/compilers/rust.py

@ -2,3 +2,4 @@
- Werror now works, this set's `-D warnings`, which will cause rustc to error
for every warning not explicitly disabled
- warning levels have been implemented

@ -45,6 +45,13 @@ class RustCompiler(Compiler):
# rustc doesn't invoke the compiler itself, it doesn't need a LINKER_PREFIX
language = 'rust'
_WARNING_LEVELS: T.Dict[str, T.List[str]] = {
'0': ['-A', 'warnings'],
'1': [],
'2': [],
'3': ['-W', 'warnings'],
}
def __init__(self, exelist: T.List[str], version: str, for_machine: MachineChoice,
is_cross: bool, info: 'MachineInfo',
exe_wrapper: T.Optional['ExternalProgram'] = None,
@ -173,3 +180,10 @@ class RustCompiler(Compiler):
# Use -D warnings, which makes every warning not explicitly allowed an
# error
return ['-D', 'warnings']
def get_warn_args(self, level: str) -> T.List[str]:
# TODO: I'm not really sure what to put here, Rustc doesn't have warning
return self._WARNING_LEVELS[level]
def get_no_warn_args(self) -> T.List[str]:
return self._WARNING_LEVELS["0"]

Loading…
Cancel
Save