Rfcs: Multiple Module Declaration

Created on 16 Mar 2020  路  4Comments  路  Source: rust-lang/rfcs

It would be great if we could declare multiple modules simultaneously:

pub mod x, y, z;

One major limitation is that doc comments couldn't go above the declaration since it makes little sense for the same documentation to apply to multiple modules.

I recently made mods to address the lack of this feature:

mods::mods! {
    pub x, y, z;
}

I'm not a fan of tiny, single-purpose crates so it'd be great if the language obsoleted it.

A-modules A-syntax T-lang

Most helpful comment

Agreed. This seems like a simple, worthwhile change to me. At the very least, it's worth discussing.

We don't normally do discussions in issues on the rfcs repository anymore, but if you'd like to start a discussion on internals with an eye towards an RFC, I'd be interested to see one.

All 4 comments

I don't think we should do this. As you mention, it has the major limitation wrt. doc comments. Moreover, this has no precedent in the language. For example, we do not allow let x, y, z = ...;. Another problem would be wrt. interactions with future proposals re. generic modules. I also don't see us prioritizing this anytime soon (nor do I think it is a problem deserving of priority).

If you want to discuss this further, raise the issue at internals.rust-lang.org/.

We do however allow let (x, y, z) =. I agree with your other points.

I've essentially never seen module docs on the outside of the module in the first place.

There could be other concerns, but that specific concern seems to be of no weight.

Agreed. This seems like a simple, worthwhile change to me. At the very least, it's worth discussing.

We don't normally do discussions in issues on the rfcs repository anymore, but if you'd like to start a discussion on internals with an eye towards an RFC, I'd be interested to see one.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

3442853561 picture 3442853561  路  4Comments

yongqli picture yongqli  路  3Comments

rudolfschmidt picture rudolfschmidt  路  3Comments

steveklabnik picture steveklabnik  路  4Comments

clarfonthey picture clarfonthey  路  3Comments