/src/librustc/lint/builtin.rs

https://gitlab.com/pranith/rust · Rust · 140 lines · 105 code · 19 blank · 16 comment · 1 complexity · 76700b84cfd804228b6809657ed3f424 MD5 · raw file

  1. // Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
  2. // file at the top-level directory of this distribution and at
  3. // http://rust-lang.org/COPYRIGHT.
  4. //
  5. // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
  6. // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
  7. // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
  8. // option. This file may not be copied, modified, or distributed
  9. // except according to those terms.
  10. //! Some lints that are built in to the compiler.
  11. //!
  12. //! These are the built-in lints that are emitted direct in the main
  13. //! compiler code, rather than using their own custom pass. Those
  14. //! lints are all available in `rustc_lint::builtin`.
  15. use lint::{LintPass, LintArray};
  16. declare_lint! {
  17. pub UNUSED_IMPORTS,
  18. Warn,
  19. "imports that are never used"
  20. }
  21. declare_lint! {
  22. pub UNUSED_EXTERN_CRATES,
  23. Allow,
  24. "extern crates that are never used"
  25. }
  26. declare_lint! {
  27. pub UNUSED_QUALIFICATIONS,
  28. Allow,
  29. "detects unnecessarily qualified names"
  30. }
  31. declare_lint! {
  32. pub UNKNOWN_LINTS,
  33. Warn,
  34. "unrecognized lint attribute"
  35. }
  36. declare_lint! {
  37. pub UNUSED_VARIABLES,
  38. Warn,
  39. "detect variables which are not used in any way"
  40. }
  41. declare_lint! {
  42. pub UNUSED_ASSIGNMENTS,
  43. Warn,
  44. "detect assignments that will never be read"
  45. }
  46. declare_lint! {
  47. pub DEAD_CODE,
  48. Warn,
  49. "detect unused, unexported items"
  50. }
  51. declare_lint! {
  52. pub UNREACHABLE_CODE,
  53. Warn,
  54. "detects unreachable code paths"
  55. }
  56. declare_lint! {
  57. pub WARNINGS,
  58. Warn,
  59. "mass-change the level for lints which produce warnings"
  60. }
  61. declare_lint! {
  62. pub UNUSED_FEATURES,
  63. Warn,
  64. "unused or unknown features found in crate-level #[feature] directives"
  65. }
  66. declare_lint! {
  67. pub STABLE_FEATURES,
  68. Warn,
  69. "stable features found in #[feature] directive"
  70. }
  71. declare_lint! {
  72. pub UNKNOWN_CRATE_TYPES,
  73. Deny,
  74. "unknown crate type found in #[crate_type] directive"
  75. }
  76. declare_lint! {
  77. pub VARIANT_SIZE_DIFFERENCES,
  78. Allow,
  79. "detects enums with widely varying variant sizes"
  80. }
  81. declare_lint! {
  82. pub FAT_PTR_TRANSMUTES,
  83. Allow,
  84. "detects transmutes of fat pointers"
  85. }
  86. declare_lint! {
  87. pub TRIVIAL_CASTS,
  88. Allow,
  89. "detects trivial casts which could be removed"
  90. }
  91. declare_lint! {
  92. pub TRIVIAL_NUMERIC_CASTS,
  93. Allow,
  94. "detects trivial casts of numeric types which could be removed"
  95. }
  96. /// Does nothing as a lint pass, but registers some `Lint`s
  97. /// which are used by other parts of the compiler.
  98. #[derive(Copy, Clone)]
  99. pub struct HardwiredLints;
  100. impl LintPass for HardwiredLints {
  101. fn get_lints(&self) -> LintArray {
  102. lint_array!(
  103. UNUSED_IMPORTS,
  104. UNUSED_EXTERN_CRATES,
  105. UNUSED_QUALIFICATIONS,
  106. UNKNOWN_LINTS,
  107. UNUSED_VARIABLES,
  108. UNUSED_ASSIGNMENTS,
  109. DEAD_CODE,
  110. UNREACHABLE_CODE,
  111. WARNINGS,
  112. UNUSED_FEATURES,
  113. STABLE_FEATURES,
  114. UNKNOWN_CRATE_TYPES,
  115. VARIANT_SIZE_DIFFERENCES,
  116. FAT_PTR_TRANSMUTES,
  117. TRIVIAL_CASTS,
  118. TRIVIAL_NUMERIC_CASTS
  119. )
  120. }
  121. }