/src/test/ui/lint/unused/unused-attr-duplicate.rs

https://gitlab.com/rust-lang/rust · Rust · 105 lines · 70 code · 12 blank · 23 comment · 0 complexity · af3c526e70a7d09b19f167177cda6bbc MD5 · raw file

  1. // Tests for repeating attribute warnings.
  2. // aux-build:lint_unused_extern_crate.rs
  3. // compile-flags:--test
  4. // Not tested due to extra requirements:
  5. // - panic_handler: needs extra setup
  6. // - target_feature: platform-specific
  7. // - link_section: platform-specific
  8. // - proc_macro, proc_macro_derive, proc_macro_attribute: needs to be a
  9. // proc-macro, and have special handling for mixing.
  10. // - unstable attributes (not going to bother)
  11. // - no_main: extra setup
  12. #![deny(unused_attributes)]
  13. #![crate_name = "unused_attr_duplicate"]
  14. #![crate_name = "unused_attr_duplicate2"] //~ ERROR unused attribute
  15. //~^ WARN this was previously accepted
  16. #![recursion_limit = "128"]
  17. #![recursion_limit = "256"] //~ ERROR unused attribute
  18. //~^ WARN this was previously accepted
  19. #![type_length_limit = "1048576"]
  20. #![type_length_limit = "1"] //~ ERROR unused attribute
  21. //~^ WARN this was previously accepted
  22. #![no_std]
  23. #![no_std] //~ ERROR unused attribute
  24. #![no_implicit_prelude]
  25. #![no_implicit_prelude] //~ ERROR unused attribute
  26. #![windows_subsystem = "console"]
  27. #![windows_subsystem = "windows"] //~ ERROR unused attribute
  28. //~^ WARN this was previously accepted
  29. #![no_builtins]
  30. #![no_builtins] //~ ERROR unused attribute
  31. #[no_link]
  32. #[no_link] //~ ERROR unused attribute
  33. extern crate lint_unused_extern_crate;
  34. #[macro_use]
  35. #[macro_use] //~ ERROR unused attribute
  36. pub mod m {
  37. #[macro_export]
  38. #[macro_export] //~ ERROR unused attribute
  39. macro_rules! foo {
  40. () => {};
  41. }
  42. }
  43. #[path = "auxiliary/lint_unused_extern_crate.rs"]
  44. #[path = "bar.rs"] //~ ERROR unused attribute
  45. //~^ WARN this was previously accepted
  46. pub mod from_path;
  47. #[test]
  48. #[ignore]
  49. #[ignore = "some text"] //~ ERROR unused attribute
  50. #[should_panic]
  51. #[should_panic(expected = "values don't match")] //~ ERROR unused attribute
  52. //~^ WARN this was previously accepted
  53. fn t1() {}
  54. #[must_use]
  55. #[must_use = "some message"] //~ ERROR unused attribute
  56. //~^ WARN this was previously accepted
  57. // No warnings for #[repr], would require more logic.
  58. #[repr(C)]
  59. #[repr(C)]
  60. #[non_exhaustive]
  61. #[non_exhaustive] //~ ERROR unused attribute
  62. pub struct X;
  63. #[automatically_derived]
  64. #[automatically_derived] //~ ERROR unused attribute
  65. impl X {}
  66. #[inline(always)]
  67. #[inline(never)] //~ ERROR unused attribute
  68. //~^ WARN this was previously accepted
  69. #[cold]
  70. #[cold] //~ ERROR unused attribute
  71. #[track_caller]
  72. #[track_caller] //~ ERROR unused attribute
  73. pub fn xyz() {}
  74. // No warnings for #[link], would require more logic.
  75. #[link(name = "rust_test_helpers", kind = "static")]
  76. #[link(name = "rust_test_helpers", kind = "static")]
  77. extern "C" {
  78. #[link_name = "this_does_not_exist"] //~ ERROR unused attribute
  79. //~^ WARN this was previously accepted
  80. #[link_name = "rust_dbg_extern_identity_u32"]
  81. pub fn name_in_rust(v: u32) -> u32;
  82. }
  83. #[export_name = "exported_symbol_name"] //~ ERROR unused attribute
  84. //~^ WARN this was previously accepted
  85. #[export_name = "exported_symbol_name2"]
  86. pub fn export_test() {}
  87. #[no_mangle]
  88. #[no_mangle] //~ ERROR unused attribute
  89. pub fn no_mangle_test() {}
  90. #[used]
  91. #[used] //~ ERROR unused attribute
  92. static FOO: u32 = 0;
  93. fn main() {}