Skip to content

Conversation

@longfangsong
Copy link
Contributor

@longfangsong longfangsong commented Sep 11, 2021

Close part of #10143.

This PR adds a assist to promote module to directory, which means make a .rs file module into a directory style module with the same name.

未命名(1)

@flodiebold
Copy link
Member

I'd call this something like "Turn a.rs into a/mod.rs" to make clearer what it does. It's IMO not a "promotion" in any sense, and a mostly unnecessary transformation nowadays.

@longfangsong
Copy link
Contributor Author

I'd call this something like "Turn a.rs into a/mod.rs" to make clearer what it does. It's IMO not a "promotion" in any sense

Intellij Rust and emacs uses the word "promote". Though I'm not sure whether it is a good name either, maybe we should keepace with them?

@flodiebold
Copy link
Member

I assume both IntelliJ and Emacs had this function before the 2018 edition. At that time, you could view it as a 'promotion' since it wasn't possible to have submodules without it. Plus, I don't think reusing the terminology from them really helps anyone -- it's not like someone used to "promote" wouldn't understand "Turn a.rs into a/mod.rs".

@matklad
Copy link
Contributor

matklad commented Sep 13, 2021

I do think we need something like this, but I don't think it's a good idea to make it available anywhere in a module -- this adds a 💡 entry everywhere, which is unhelpful every time you don't invoke this assist.

Let's re-use @vsrs's brilliant insight in #9735 and make the assist avialable only when the whole file is selected (ctrl+a).

I've documented this and other tricks in matklad@46cdde7

@longfangsong
Copy link
Contributor Author

Now this assist is avialable only when the whole file is selected.
/cc @bjorn3 @matklad

@jonas-schievink
Copy link
Contributor

Thanks, looks great now!

bors r+

@bors
Copy link
Contributor

bors bot commented Sep 25, 2021

@bors bors bot merged commit d401f2a into rust-lang:master Sep 25, 2021
@lnicola
Copy link
Member

lnicola commented Sep 26, 2021

changelog feature (first contribution) add assist to convert file module to directory

@lnicola
Copy link
Member

lnicola commented Sep 26, 2021

mod-to-folder

bors bot added a commit that referenced this pull request Sep 28, 2021
10362: feat: Convert a/mod.rs into a.rs r=Veykril a=longfangsong

This is the reverse operation of #10211.

![demo](https://user-images.githubusercontent.com/13777628/134837717-074c23e9-1ca2-4207-b780-8443b2241272.gif)

Close #10143.



Co-authored-by: longfangsong <longfangsong@icloud.com>
Co-authored-by: 龙方淞 <longfangsong@icloud.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants