Today I’ve discovered this apparently valid program:
pub mod a {
pub use super::*;
pub fn a() {}
}
fn main() { a::a::a::a::a::a::a::a(); }
Are such “infinite” paths valid?
Today I’ve discovered this apparently valid program:
pub mod a {
pub use super::*;
pub fn a() {}
}
fn main() { a::a::a::a::a::a::a::a(); }
Are such “infinite” paths valid?
The paths are not infinite. You’d need an infinite source file to make it so.
Apart from that, I could see a clippy lint against this. What do you think?
Challenge accepted!
$ (echo "pub mod a { use super::*; pub fn a() {} } fn main() {"; yes "a::"; echo "a(); }") | rustc -
But memory is not infinite, sadly… (Don’t OOM yourself trying this!)
Yep, this is valid. More generally, module paths are allowed to be cyclic.
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.