diff options
| author | Laurenz <laurmaedje@gmail.com> | 2022-09-20 19:49:47 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2022-09-20 19:49:47 +0200 |
| commit | 3760748fddd3b793c79c370398a9d4a3fc5afc04 (patch) | |
| tree | b1a615e510aa231cfe9757a9c0a35a375e32e3ba /src/source.rs | |
| parent | 757a701c1aa2a6fb80033c7e75666661818da6f9 (diff) | |
Refactor error handling
Diffstat (limited to 'src/source.rs')
| -rw-r--r-- | src/source.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/source.rs b/src/source.rs index c3648e11..b78d9052 100644 --- a/src/source.rs +++ b/src/source.rs @@ -5,13 +5,13 @@ use std::path::{Path, PathBuf}; use unscanny::Scanner; -use crate::diag::TypResult; +use crate::diag::SourceResult; use crate::parse::{is_newline, parse, reparse}; use crate::syntax::ast::Markup; use crate::syntax::{Span, SyntaxNode}; use crate::util::{PathExt, StrExt}; -/// A single source file. +/// A source file. /// /// _Note_: All line and column indices start at zero, just like byte indices. /// Only for user-facing display, you should add 1 to them. @@ -63,10 +63,10 @@ impl Source { } /// The root node of the file's typed abstract syntax tree. - pub fn ast(&self) -> TypResult<Markup> { + pub fn ast(&self) -> SourceResult<Markup> { let errors = self.root.errors(); if errors.is_empty() { - Ok(self.root.cast().unwrap()) + Ok(self.root.cast().expect("root node must be markup")) } else { Err(Box::new(errors)) } |
