Skip to content

Commit 0af4824

Browse files
committed
Unified: Use infallible yeast translation
1 parent 07877db commit 0af4824

1 file changed

Lines changed: 13 additions & 9 deletions

File tree

  • unified/extractor/src/languages/swift

‎unified/extractor/src/languages/swift/swift.rs‎

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ fn translation_rules() -> Vec<Rule<SwiftContext>> {
375375
let val = ctx.scoped(|ctx| {
376376
ctx.reset();
377377
ctx.translate(val)
378-
})?;
378+
});
379379
result.push(tree!(
380380
(variable_declaration
381381
modifier: {ctx.outer_modifiers.clone()}
@@ -386,7 +386,7 @@ fn translation_rules() -> Vec<Rule<SwiftContext>> {
386386
}
387387
for acc in accessors.into_iter() {
388388
ctx.is_chained = !result.is_empty();
389-
result.extend(ctx.translate(acc)?);
389+
result.extend(ctx.translate(acc));
390390
}
391391
result
392392
}
@@ -421,7 +421,7 @@ fn translation_rules() -> Vec<Rule<SwiftContext>> {
421421
let modifiers = ctx.outer_modifiers.clone();
422422
let name = ctx
423423
.property_name_node
424-
.ok_or("accessor outside property context")?;
424+
.expect("accessor outside property context");
425425
let return_ty = if spec_text == "get" {
426426
ctx.property_type
427427
} else {
@@ -431,7 +431,7 @@ fn translation_rules() -> Vec<Rule<SwiftContext>> {
431431
Some(block) => ctx.scoped(|ctx| {
432432
ctx.reset();
433433
ctx.translate(block)
434-
})?.into_iter().next(),
434+
}).into_iter().next(),
435435
None => None,
436436
};
437437
tree!((accessor_declaration
@@ -496,7 +496,7 @@ fn translation_rules() -> Vec<Rule<SwiftContext>> {
496496
let mut result = Vec::new();
497497
for (i, b) in bindings.into_iter().enumerate() {
498498
ctx.is_chained = i > 0;
499-
result.extend(ctx.translate(b)?);
499+
result.extend(ctx.translate(b));
500500
}
501501
result
502502
}
@@ -569,7 +569,7 @@ fn translation_rules() -> Vec<Rule<SwiftContext>> {
569569
let mut result = Vec::new();
570570
for (i, case) in cases.into_iter().enumerate() {
571571
ctx.is_chained = i > 0;
572-
result.extend(ctx.translate(case)?);
572+
result.extend(ctx.translate(case));
573573
}
574574
result
575575
}
@@ -741,7 +741,7 @@ fn translation_rules() -> Vec<Rule<SwiftContext>> {
741741
let callee = ctx.scoped(|ctx| {
742742
ctx.in_pattern = false;
743743
ctx.translate(rawCallee)
744-
})?;
744+
});
745745
tree!((call_expr
746746
callee: {callee}
747747
argument: {args}
@@ -1063,7 +1063,11 @@ fn translation_rules() -> Vec<Rule<SwiftContext>> {
10631063
// ---- Optionals and errors ----
10641064
// Optional chaining — unwrap the marker
10651065
rule!((optionalChainingExpr expression: @@inner) => expr {
1066-
let inner = ctx.translate(inner)?.into_iter().next().ok_or("optional chaining expression has no child")?;
1066+
let inner = ctx
1067+
.translate(inner)
1068+
.into_iter()
1069+
.next()
1070+
.expect("optional chaining expression has no child");
10671071
if ctx.in_pattern {
10681072
tree!((call_expr
10691073
callee: (member_access_expr
@@ -1160,7 +1164,7 @@ fn translation_rules() -> Vec<Rule<SwiftContext>> {
11601164
path: (importPathComponent name: @@parts)*) @@decl
11611165
=>
11621166
import_declaration {
1163-
let last = *parts.last().ok_or("import has no path")?;
1167+
let last = *parts.last().expect("import has no path");
11641168
tree!((import_declaration
11651169
modifier: [(modifier #{kind})]
11661170
modifier: {attrs}

0 commit comments

Comments
 (0)