Skip to content

Commit

Permalink
[rust] Check if __END__ exists by is_null()
Browse files Browse the repository at this point in the history
  • Loading branch information
ryym authored and kddnewton committed Jun 3, 2024
1 parent 1acec15 commit 99b2303
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions rust/ruby-prism/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,12 +201,11 @@ impl<'pr> ParseResult<'pr> {
/// Returns an optional location of the __END__ marker and the rest of the content of the file.
#[must_use]
pub fn data_loc(&self) -> Option<Location<'_>> {
let root = self.source.as_ptr();
let location = unsafe { &(*self.parser.as_ptr()).data_loc };
if location.start >= root {
Some(Location::new(self.parser, location))
} else {
if location.start.is_null() {
None
} else {
Some(Location::new(self.parser, location))
}
}

Expand Down

0 comments on commit 99b2303

Please sign in to comment.