[fine] Lifetime garbage, big refactor
So it turns out that I can't hold `&str` in token because it makes it impossible to encapsulate a source file in the larger context- self referential structure problems again. Everything gets rebuilt so that the source can be passed through. While we're at it, more things become Rc<> because, man..... life it too short. Semantics in particular has become a giant hub of the module state: we can basically just hold an Rc<Semantics> and have everything we could possibly want to know about a source file, computed lazily if necessary.
This commit is contained in:
parent
d5059dd450
commit
2dbdbb3957
7 changed files with 502 additions and 329 deletions
|
|
@ -57,7 +57,7 @@ fn generate_test_for_file(path: PathBuf) -> String {
|
|||
}
|
||||
|
||||
assertions.push(quote! {
|
||||
crate::assert_concrete(&_tree, #concrete, #display_path);
|
||||
crate::assert_concrete(source.clone(), _tree.clone(), #concrete, #display_path);
|
||||
});
|
||||
} else if line == "@compiles-to:" {
|
||||
let mut compiled = String::new();
|
||||
|
|
@ -72,7 +72,7 @@ fn generate_test_for_file(path: PathBuf) -> String {
|
|||
}
|
||||
|
||||
assertions.push(quote! {
|
||||
crate::assert_compiles_to(&_tree, &_lines, #compiled, #display_path);
|
||||
crate::assert_compiles_to(source.clone(), _tree.clone(), _lines.clone(), #compiled, #display_path);
|
||||
});
|
||||
} else if let Some(line) = line.strip_prefix("@type:") {
|
||||
let (pos, expected) = line
|
||||
|
|
@ -85,7 +85,7 @@ fn generate_test_for_file(path: PathBuf) -> String {
|
|||
.expect(&format!("Unable to parse position '{pos}'"));
|
||||
let expected = expected.trim();
|
||||
assertions.push(quote! {
|
||||
crate::assert_type_at(&_tree, &_lines, #pos, #expected, #display_path);
|
||||
crate::assert_type_at(source.clone(), _tree.clone(), _lines.clone(), #pos, #expected, #display_path);
|
||||
});
|
||||
} else if let Some(line) = line.strip_prefix("@type-error:") {
|
||||
let (pos, expected) = line
|
||||
|
|
@ -98,21 +98,21 @@ fn generate_test_for_file(path: PathBuf) -> String {
|
|||
.expect(&format!("Unable to parse position '{pos}'"));
|
||||
let expected = expected.trim();
|
||||
assertions.push(quote! {
|
||||
crate::assert_type_error_at(&_tree, &_lines, #pos, #expected, #display_path);
|
||||
crate::assert_type_error_at(source.clone(), _tree.clone(), _lines.clone(), #pos, #expected, #display_path);
|
||||
});
|
||||
} else if line == "@no-errors" {
|
||||
assertions.push(quote! {
|
||||
crate::assert_no_errors(&_tree, &_lines);
|
||||
crate::assert_no_errors(source.clone(), _tree.clone(), _lines.clone());
|
||||
});
|
||||
} else if let Some(line) = line.strip_prefix("@eval:") {
|
||||
let expected = line.trim();
|
||||
assertions.push(quote! {
|
||||
crate::assert_eval_ok(&_tree, &_lines, #expected);
|
||||
crate::assert_eval_ok(source.clone(), _tree.clone(), _lines.clone(), #expected);
|
||||
});
|
||||
} else if let Some(line) = line.strip_prefix("@check-error:") {
|
||||
let expected = line.trim();
|
||||
assertions.push(quote! {
|
||||
crate::assert_check_error(&_tree, &_lines, #expected);
|
||||
crate::assert_check_error(source.clone(), _tree.clone(), _lines.clone(), #expected);
|
||||
});
|
||||
} else if line == "@expect-errors:" {
|
||||
let mut errors = Vec::new();
|
||||
|
|
@ -127,7 +127,7 @@ fn generate_test_for_file(path: PathBuf) -> String {
|
|||
|
||||
let errors = ExpectedErrors(errors);
|
||||
assertions.push(quote! {
|
||||
crate::assert_errors(&_tree, &_lines, #errors);
|
||||
crate::assert_errors(source.clone(), _tree.clone(), _lines.clone(), #errors);
|
||||
});
|
||||
} else if line.starts_with("@") {
|
||||
panic!("Test file {display_path} has unknown directive: {line}");
|
||||
|
|
@ -138,7 +138,8 @@ fn generate_test_for_file(path: PathBuf) -> String {
|
|||
let test_method = quote! {
|
||||
#disabled
|
||||
fn #name() {
|
||||
let (_tree, _lines) = fine::parser::parse(#contents);
|
||||
let source : std::rc::Rc<str> = #contents.into();
|
||||
let (_tree, _lines) = fine::parser::parse(&source);
|
||||
#(#assertions)*
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue