summaryrefslogtreecommitdiff
path: root/dhall/src/syntax/ast/span.rs
diff options
context:
space:
mode:
authorNadrieril2020-02-19 17:24:41 +0000
committerNadrieril2020-02-19 17:24:41 +0000
commit26ed5a1d4d43573ac8ad2f8de9e4dd411650aa9a (patch)
tree39c7a0dbc2ae2c0448591f2d91f612d324ae6393 /dhall/src/syntax/ast/span.rs
parentce4665bdfcbcb4e34e760acef83bd4de3fbef530 (diff)
Expose fewer pub things
Diffstat (limited to '')
-rw-r--r--dhall/src/syntax/ast/span.rs31
1 files changed, 3 insertions, 28 deletions
diff --git a/dhall/src/syntax/ast/span.rs b/dhall/src/syntax/ast/span.rs
index fba6a2d..e75ea53 100644
--- a/dhall/src/syntax/ast/span.rs
+++ b/dhall/src/syntax/ast/span.rs
@@ -2,7 +2,7 @@ use std::rc::Rc;
/// A location in the source text
#[derive(Debug, Clone)]
-pub struct ParsedSpan {
+pub(crate) struct ParsedSpan {
input: Rc<str>,
/// # Safety
///
@@ -15,7 +15,7 @@ pub struct ParsedSpan {
}
#[derive(Debug, Clone)]
-pub enum Span {
+pub(crate) enum Span {
/// A location in the source text
Parsed(ParsedSpan),
/// For expressions obtained from decoding binary
@@ -50,7 +50,7 @@ impl Span {
/// Takes the union of the two spans, i.e. the range of input covered by the two spans plus any
/// input between them. Assumes that the spans come from the same input. Fails if one of the
/// spans does not point to an input location.
- pub fn union(&self, other: &Span) -> Self {
+ pub(crate) fn union(&self, other: &Span) -> Self {
use std::cmp::{max, min};
use Span::*;
match (self, other) {
@@ -67,31 +67,6 @@ impl Span {
),
}
}
-
- /// Merges two spans assumed to point to a similar thing. If only one of them points to an
- /// input location, use that one.
- pub fn merge(&self, other: &Span) -> Self {
- use Span::*;
- match (self, other) {
- (Parsed(x), _) | (_, Parsed(x)) => Parsed(x.clone()),
- (Artificial, _) | (_, Artificial) => Artificial,
- (Decoded, Decoded) => Decoded,
- }
- }
-
- pub fn error(&self, message: impl Into<String>) -> String {
- use pest::error::{Error, ErrorVariant};
- use pest::Span;
- let message: String = message.into();
- let span = match self {
- self::Span::Parsed(span) => span,
- _ => return format!("[unknown location] {}", message),
- };
- let span = Span::new(&*span.input, span.start, span.end).unwrap();
- let err: ErrorVariant<!> = ErrorVariant::CustomError { message };
- let err = Error::new_from_span(err, span);
- format!("{}", err)
- }
}
/// Convert a byte idx into a string into a char idx for consumption by annotate_snippets.