title: How can a Rust module have the same name as a const in the same namespace?
body: <p>I came across some code in a piece of published code that had something like the following structure (which compiles and runs fine):</p>
  
  <pre class="lang-rust prettyprint-override"><code>pub mod foo {
      pub const BAR: u32 = 53;
  
      #[allow(non_snake_case)]
      pub mod BAR {
          pub fn eep() {
              println!("This is attached to BAR");
          }
      }
  }
  
  fn main() {
      println!("Hello, world!, {}", foo::BAR);
      foo::BAR::eep();
  }
  </code></pre>
  
  <p>This seems strange and interesting to me. The strange bit being <code>BAR</code> being defined as both a <code>const</code> and a <code>mod</code>.</p>
  
  <p>Is this idiomatic Rust?</p>
  
  <p>What is going on here? Should I be able to find out about this in the docs? When is such a pattern valid?</p>
  
  <p>I can see that this might be useful, but is there some really compelling use case?</p>