Actually just three programming languages in a trenchcoat
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

we can use if let chains now!

+47 -48
+7 -7
trilogy-ir/src/ir/assignment.rs
··· 21 21 22 22 let op = match ast.strategy { 23 23 Direct(..) => { 24 - if let expression::Value::Reference(id) = &lhs.value { 25 - if !id.is_mutable { 26 - converter.error(Error::AssignedImmutableBinding { 27 - name: *id.clone(), 28 - assignment: span, 29 - }); 30 - } 24 + if let expression::Value::Reference(id) = &lhs.value 25 + && !id.is_mutable 26 + { 27 + converter.error(Error::AssignedImmutableBinding { 28 + name: *id.clone(), 29 + assignment: span, 30 + }); 31 31 } 32 32 return Expression::assignment(span, Assignment { lhs, rhs }); 33 33 }
+4 -4
trilogy-ir/src/scope.rs
··· 27 27 } 28 28 29 29 pub fn declare(&mut self, name: String, is_mutable: bool, span: Span) -> Id { 30 - if self.pseudo { 31 - if let Some(declared) = self.declared_pseudo(&name) { 32 - return declared.clone(); 33 - } 30 + if self.pseudo 31 + && let Some(declared) = self.declared_pseudo(&name) 32 + { 33 + return declared.clone(); 34 34 } 35 35 self.symbols.reusable(name, is_mutable, span).clone() 36 36 }
+10 -11
trilogy-llvm/src/expression/mod.rs
··· 471 471 name: &str, 472 472 ) -> Option<PointerValue<'ctx>> { 473 473 // Possibly a static module reference, which we can support very easily and efficiently 474 - if let Value::Reference(module) = &module_ref.value { 475 - if let Some(module) = 474 + if let Value::Reference(module) = &module_ref.value 475 + && let Some(module) = 476 476 self.globals 477 477 .get(&module.id) 478 478 .and_then(|global| match &global.head { ··· 486 486 Head::ExternalModule(path) => Some(path.to_owned()), 487 487 _ => None, 488 488 }) 489 - { 490 - let target = self.allocate_value(name); 491 - let declared = self 492 - .module 493 - .get_function(&format!("{module}::{}", ident.as_ref())) 494 - .unwrap(); 495 - self.call_internal(target, declared, &[]); 496 - return Some(target); 497 - } 489 + { 490 + let target = self.allocate_value(name); 491 + let declared = self 492 + .module 493 + .get_function(&format!("{module}::{}", ident.as_ref())) 494 + .unwrap(); 495 + self.call_internal(target, declared, &[]); 496 + return Some(target); 498 497 } 499 498 500 499 let module_value = self.compile_expression(module_ref, "")?;
+4 -4
trilogy-parser/src/syntax/array_literal.rs
··· 97 97 parser: &mut Parser, 98 98 ) -> SyntaxResult<Result<Self, (Option<Token>, Pattern)>> { 99 99 let spread = parser.expect(OpDotDot).ok(); 100 - if let Some(spread) = &spread { 101 - if let Ok(dot) = parser.expect(OpDot) { 102 - parser.error(ErrorKind::TripleDot { dot: dot.span }.at(spread.span)); 103 - } 100 + if let Some(spread) = &spread 101 + && let Ok(dot) = parser.expect(OpDot) 102 + { 103 + parser.error(ErrorKind::TripleDot { dot: dot.span }.at(spread.span)); 104 104 } 105 105 let expression = Expression::parse_parameter_list(parser)?; 106 106 match expression {
+4 -4
trilogy-parser/src/syntax/set_literal.rs
··· 97 97 parser: &mut Parser, 98 98 ) -> SyntaxResult<Result<Self, (Option<Token>, Pattern)>> { 99 99 let spread = parser.expect(OpDotDot).ok(); 100 - if let Some(spread) = &spread { 101 - if let Ok(dot) = parser.expect(OpDot) { 102 - parser.error(ErrorKind::TripleDot { dot: dot.span }.at(spread.span)); 103 - } 100 + if let Some(spread) = &spread 101 + && let Ok(dot) = parser.expect(OpDot) 102 + { 103 + parser.error(ErrorKind::TripleDot { dot: dot.span }.at(spread.span)); 104 104 } 105 105 let expression = Expression::parse_parameter_list(parser)?; 106 106 match expression {
+5 -4
trilogy-scanner/src/scanner.rs
··· 269 269 if ch == '"' { 270 270 return self.make_token(on_end).with_value(content); 271 271 } 272 - if let Some(on_continue) = on_continue { 273 - if ch == '$' && self.expect(|ch| ch == '{').is_some() { 274 - return self.make_token(on_continue).with_value(content); 275 - } 272 + if let Some(on_continue) = on_continue 273 + && ch == '$' 274 + && self.expect(|ch| ch == '{').is_some() 275 + { 276 + return self.make_token(on_continue).with_value(content); 276 277 } 277 278 if ch == '\\' { 278 279 ch = match self.escape_sequence() {
+13 -14
trilogy/src/runtime/runtime_error.rs
··· 103 103 eprintln!("{frame}"); 104 104 105 105 if report.is_none() { 106 - if let Some((_, loc)) = &frame.expr { 107 - if let Some(local) = loc 106 + if let Some((_, loc)) = &frame.expr 107 + && let Some(local) = loc 108 108 .file 109 109 .parse::<Url>() 110 110 .ok() 111 111 .and_then(|url| url.to_file_path().ok()) 112 112 .map(|path| path.display().to_string()) 113 + { 113 114 // Ariadne hates us 114 - { 115 - let span = cache.span(&local, loc.span); 116 - report = Some( 117 - ariadne::Report::build(ReportKind::Error, &loc.file, span.1.start) 118 - .with_message(format!("{}", self.error)) 119 - .with_label( 120 - Label::new(span) 121 - .with_color(primary) 122 - .with_message("in this expression"), 123 - ), 124 - ); 125 - } 115 + let span = cache.span(&local, loc.span); 116 + report = Some( 117 + ariadne::Report::build(ReportKind::Error, &loc.file, span.1.start) 118 + .with_message(format!("{}", self.error)) 119 + .with_label( 120 + Label::new(span) 121 + .with_color(primary) 122 + .with_message("in this expression"), 123 + ), 124 + ); 126 125 } 127 126 } 128 127 }