misc fixes

This commit is contained in:
DropDemBits 2024-09-02 22:53:54 -04:00
parent d929121f7b
commit 69e8393963
No known key found for this signature in database
GPG key ID: 7FE02A6C1EDFA075
3 changed files with 20 additions and 26 deletions

View file

@ -150,6 +150,12 @@ impl SyntaxAnnotation {
}
}
impl Default for SyntaxAnnotation {
fn default() -> Self {
Self::new()
}
}
/// Position describing where to insert elements
#[derive(Debug)]
pub struct Position {
@ -445,24 +451,6 @@ mod tests {
.all(|element| element.ancestors().any(|it| &it == edit.root())))
}
#[test]
#[should_panic = "some replace change ranges intersect: [Replace(Node(TUPLE_EXPR@5..7), Some(Node(NAME_REF@0..8))), Replace(Node(TUPLE_EXPR@5..7), Some(Node(NAME_REF@0..8)))]"]
fn fail_on_non_disjoint_single_replace() {
let root = make::match_arm([make::wildcard_pat().into()], None, make::expr_tuple([]));
let to_wrap = root.syntax().descendants().find_map(ast::TupleExpr::cast).unwrap();
let mut editor = SyntaxEditor::new(root.syntax().clone());
let name_ref = make::name_ref("var_name").clone_for_update();
// should die, ranges are not disjoint
editor.replace(to_wrap.syntax(), name_ref.syntax());
editor.replace(to_wrap.syntax(), name_ref.syntax());
let _ = editor.finish();
}
#[test]
fn test_insert_independent() {
let root = make::block_expr(