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

Support turbo tasks inside of mod blocks #8530

Merged
merged 1 commit into from
Jun 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions crates/turbo-tasks-build/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
use std::{
collections::{HashMap, HashSet},
env::{
current_dir, {self},
},
env::{self, current_dir},
fmt::{Display, Write},
fs::read_dir,
path::{PathBuf, MAIN_SEPARATOR as PATH_SEP},
Expand Down Expand Up @@ -111,7 +109,7 @@ pub fn generate_register() {

file_path: &file_path,
prefix: &prefix,
mod_path: &mod_path,
mod_path,

register: &mut register_code,
values: &mut values,
Expand Down Expand Up @@ -191,7 +189,7 @@ struct RegisterContext<'a> {
queue: &'a mut Vec<(String, PathBuf)>,

file_path: &'a PathBuf,
mod_path: &'a str,
mod_path: String,
prefix: &'a str,

register: &'a mut String,
Expand Down Expand Up @@ -269,7 +267,15 @@ impl<'a> RegisterContext<'a> {
}

fn process_mod(&mut self, mod_item: ItemMod) -> Result<()> {
if mod_item.content.is_none() {
if let Some((_, items)) = mod_item.content {
let mod_name = mod_item.ident.to_string();
let child_mod_path = format!("{}::{}", self.mod_path, mod_name);
let parent_mod_path = std::mem::replace(&mut self.mod_path, child_mod_path);
for item in items {
self.process_item(item)?;
}
self.mod_path = parent_mod_path;
} else {
let name = mod_item.ident.to_string();
let parent_path = self.file_path.parent().unwrap();
let direct = parent_path.join(format!("{name}.rs"));
Expand Down Expand Up @@ -391,7 +397,7 @@ impl<'a> RegisterContext<'a> {
}

fn add_value(&mut self, ident: &Ident) {
let key: ValueKey = (self.mod_path.to_owned(), ident.clone());
let key: ValueKey = (self.mod_path.clone(), ident.clone());
let value: ValueEntry = (self.get_global_name(&[ident]), Vec::new());

assert!(
Expand Down Expand Up @@ -426,7 +432,7 @@ impl<'a> RegisterContext<'a> {
}

fn add_value_trait(&mut self, ident: &Ident, trait_ident: &Ident) {
let key: ValueKey = (self.mod_path.to_owned(), ident.clone());
let key: ValueKey = (self.mod_path.clone(), ident.clone());

let entry = self.values.get_mut(&key);
if entry.is_none() {
Expand Down
Loading