diff options
| author | Laurenz <laurmaedje@gmail.com> | 2021-07-10 20:42:28 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2021-07-10 23:14:46 +0200 |
| commit | 891e0c5fa6cd9200c24011c33b6f2115d84d4d74 (patch) | |
| tree | 3ea29dff87350d3d2020cdbb48b7acd01a33a1a2 /src/parse | |
| parent | 982ce85976913463eed6c95d3599868c5e1a79dd (diff) | |
Remove warnings from parsing and casting
Diffstat (limited to 'src/parse')
| -rw-r--r-- | src/parse/mod.rs | 3 | ||||
| -rw-r--r-- | src/parse/parser.rs | 5 |
2 files changed, 6 insertions, 2 deletions
diff --git a/src/parse/mod.rs b/src/parse/mod.rs index ecce0138..6724c559 100644 --- a/src/parse/mod.rs +++ b/src/parse/mod.rs @@ -193,8 +193,7 @@ fn heading(p: &mut Parser) -> SyntaxNode { } if level > 6 { - p.diag(warning!(start .. p.prev_end(), "should not exceed depth 6")); - level = 6; + return SyntaxNode::Text(p.eaten_from(start).into()); } let body = tree_indented(p); diff --git a/src/parse/parser.rs b/src/parse/parser.rs index 1e0f2f5d..d4192b50 100644 --- a/src/parse/parser.rs +++ b/src/parse/parser.rs @@ -322,6 +322,11 @@ impl<'s> Parser<'s> { Span::new(start, self.prev_end()) } + /// Return the source string from `start` to the end of the previous token. + pub fn eaten_from(&self, start: usize) -> &'s str { + self.tokens.scanner().get(start .. self.prev_end()) + } + /// Jump to an index in the string. /// /// You need to know the correct column. |
