Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the crate language #4035

Merged
merged 4 commits into from
Nov 28, 2012
Merged

Remove the crate language #4035

merged 4 commits into from
Nov 28, 2012

Conversation

brson
Copy link
Contributor

@brson brson commented Nov 25, 2012

r? @graydon, @nikomatsakis

Working towards #2176

This series completely removes the special language for .rc files. It uses several hacks required until the next snapshot.

After this is completed .rc files will be parsed exactly the same as .rs files and companion mods will no longer exist, either at the crate level or directory level.

There's not a whole lot to review here, as it's just rewriting the crate files to use features compatible with the new model, but it is a big change.

There are two notable side-effects of this change:

  1. The int-template and iter-trait hacks used a latent property of our directory companion mods to 'merge' the contents of two different files into a single module. In lieu of item macros this will be supported by a new parser hack that uses a #[merge = "path/to/file.rs"] attribute.

  2. There will no longer be any in-language notion of directory structure. Through ongoing discussions it's not obvious what the right solution to this is. In the meantime, crates can use #[path = "path/to/file.rs"] to impose any directory structure they want. I think this itself is a decent compromise, gives us room to experiment with the correct patterns here.

In the medium-term, the rust repo itself will prefer the following pattern to create directory structure:

rustc.rc:

#[path = "front/mod.rs"]
mod front;
#[path = "middle/mod.rs"]
mod middle;
#[path = "back/mod.rs"]
mod back;

front/mod.rs:

mod core_inject;
mod test;

Modules that are stored in directories will use a mod.rs file inside the directory (vs. today's code where the mod file is outside the directory).

Transitional ugliness:

  • core, std, syntax, and rustc are all using a massive hack to force stage0 to use one crate file and the others to use a different one. Files that begin with // DIVERT are automatically parsed from a different file called alternate_crate.rc. This allows stage0 to continue using it's directory modules while stage1+ use the above described strategy.
  • There's a lot of usage of the new #[merge] attribute, but these are transitional except for the ones in core that implement iter-trait, etc.

@graydon
Copy link
Contributor

graydon commented Nov 27, 2012

r+ assuming the remaining steps are "remove the transitionary hacks" and, presumably, "remove .rc files as a handled file extension". Though I imagine this will take quite a while, several snapshots, and possibly updating everything registered in cargo-central in order to complete :)

@graydon
Copy link
Contributor

graydon commented Nov 27, 2012

Also: this is excellent, patient, tedious work. Thank you.

@brson
Copy link
Contributor Author

brson commented Nov 27, 2012

Thanks for the review.

Yes, I am planning to remove the 'DIVERT' hack completely and most uses of the 'merge' hack. I was intending to leave .rc files in (by convention - the parser no longer cares) so cargo can continue searching for them.

I had not considered updating cargo-central, but I will at least send a message to the mailing list.

@brson brson merged commit 8179e26 into rust-lang:incoming Nov 28, 2012
RalfJung added a commit to RalfJung/rust that referenced this pull request Nov 21, 2024
refactor: refine thread variant for windows
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.

2 participants