/src/test/rustdoc/macro_pub_in_module.rs

https://gitlab.com/rust-lang/rust · Rust · 82 lines · 42 code · 12 blank · 28 comment · 0 complexity · 97c243c777399fbcd8166bd71df8cea4 MD5 · raw file

  1. // aux-build:macro_pub_in_module.rs
  2. // edition:2018
  3. // build-aux-docs
  4. //! See issue #74355
  5. #![feature(decl_macro, no_core, rustc_attrs)]
  6. #![crate_name = "krate"]
  7. #![no_core]
  8. // @has external_crate/some_module/macro.external_macro.html
  9. // @!has external_crate/macro.external_macro.html
  10. extern crate external_crate;
  11. pub mod inner {
  12. // @has krate/inner/macro.raw_const.html
  13. // @!has krate/macro.raw_const.html
  14. pub macro raw_const() {}
  15. // @has krate/inner/macro.test.html
  16. // @!has krate/macro.test.html
  17. #[rustc_builtin_macro]
  18. pub macro test($item:item) {}
  19. // @has krate/inner/macro.Clone.html
  20. // @!has krate/macro.Clone.html
  21. #[rustc_builtin_macro]
  22. pub macro Clone($item:item) {}
  23. // Make sure the logic is not affected by re-exports.
  24. mod unrenamed {
  25. // @!has krate/macro.unrenamed.html
  26. #[rustc_macro_transparency = "semitransparent"]
  27. pub macro unrenamed() {}
  28. }
  29. // @has krate/inner/macro.unrenamed.html
  30. pub use unrenamed::unrenamed;
  31. mod private {
  32. // @!has krate/macro.m.html
  33. pub macro m() {}
  34. }
  35. // @has krate/inner/macro.renamed.html
  36. // @!has krate/macro.renamed.html
  37. pub use private::m as renamed;
  38. mod private2 {
  39. // @!has krate/macro.m2.html
  40. pub macro m2() {}
  41. }
  42. use private2 as renamed_mod;
  43. // @has krate/inner/macro.m2.html
  44. pub use renamed_mod::m2;
  45. // @has krate/inner/macro.external_macro.html
  46. // @!has krate/macro.external_macro.html
  47. pub use ::external_crate::some_module::external_macro;
  48. }
  49. // Namespaces: Make sure the logic does not mix up a function name with a module name…
  50. fn both_fn_and_mod() {
  51. // @!has krate/macro.in_both_fn_and_mod.html
  52. pub macro in_both_fn_and_mod() {}
  53. }
  54. pub mod both_fn_and_mod {
  55. // @!has krate/both_fn_and_mod/macro.in_both_fn_and_mod.html
  56. }
  57. const __: () = {
  58. // @!has krate/macro.in_both_const_and_mod.html
  59. pub macro in_both_const_and_mod() {}
  60. };
  61. pub mod __ {
  62. // @!has krate/__/macro.in_both_const_and_mod.html
  63. }
  64. enum Enum {
  65. Crazy = {
  66. // @!has krate/macro.this_is_getting_weird.html;
  67. pub macro this_is_getting_weird() {}
  68. 42
  69. },
  70. }