summaryrefslogtreecommitdiff
path: root/dhall
diff options
context:
space:
mode:
authorNadrieril2020-02-02 17:49:49 +0000
committerNadrieril2020-02-02 17:49:49 +0000
commitb6625eccbf3f2d1bcfe1a88f4d556439281e91de (patch)
tree5ce5357114855d828aad5a6ba394e2b75334c5d0 /dhall
parent4f98c23963e82eaf08c9d7291d0988d13571d337 (diff)
Use Spans consistently by value
Diffstat (limited to 'dhall')
-rw-r--r--dhall/src/error/builder.rs10
-rw-r--r--dhall/src/semantics/nze/value.rs6
-rw-r--r--dhall/src/semantics/tck/tyexpr.rs4
-rw-r--r--dhall/src/semantics/tck/typecheck.rs16
-rw-r--r--dhall/src/syntax/text/parser.rs6
5 files changed, 19 insertions, 23 deletions
diff --git a/dhall/src/error/builder.rs b/dhall/src/error/builder.rs
index 29d0d35..8c7eef3 100644
--- a/dhall/src/error/builder.rs
+++ b/dhall/src/error/builder.rs
@@ -63,7 +63,7 @@ impl ErrorBuilder {
consumed: false,
}
}
- pub fn new_span_err(span: &Span, message: impl ToString) -> Self {
+ pub fn new_span_err(span: Span, message: impl ToString) -> Self {
let message = message.to_string();
let mut builder = Self::new(message.clone());
builder.span_err(span, message);
@@ -72,7 +72,7 @@ impl ErrorBuilder {
pub fn span_annot(
&mut self,
- span: &Span,
+ span: Span,
message: impl ToString,
annotation_type: AnnotationType,
) -> &mut Self {
@@ -82,7 +82,7 @@ impl ErrorBuilder {
_ => return self,
};
self.annotations.push(SpannedAnnotation {
- span: span.clone(),
+ span,
message: message.to_string(),
annotation_type,
});
@@ -102,14 +102,14 @@ impl ErrorBuilder {
pub fn span_err(
&mut self,
- span: &Span,
+ span: Span,
message: impl ToString,
) -> &mut Self {
self.span_annot(span, message, AnnotationType::Error)
}
pub fn span_help(
&mut self,
- span: &Span,
+ span: Span,
message: impl ToString,
) -> &mut Self {
self.span_annot(span, message, AnnotationType::Help)
diff --git a/dhall/src/semantics/nze/value.rs b/dhall/src/semantics/nze/value.rs
index d97b8c4..1143781 100644
--- a/dhall/src/semantics/nze/value.rs
+++ b/dhall/src/semantics/nze/value.rs
@@ -174,9 +174,9 @@ impl Value {
_ => None,
}
}
- pub(crate) fn span(&self) -> Span {
- self.0.span.clone()
- }
+ // pub(crate) fn span(&self) -> Span {
+ // self.0.span.clone()
+ // }
/// This is what you want if you want to pattern-match on the value.
/// WARNING: drop this ref before normalizing the same value or you will run into BorrowMut
diff --git a/dhall/src/semantics/tck/tyexpr.rs b/dhall/src/semantics/tck/tyexpr.rs
index 1a048f9..1886646 100644
--- a/dhall/src/semantics/tck/tyexpr.rs
+++ b/dhall/src/semantics/tck/tyexpr.rs
@@ -48,8 +48,8 @@ impl TyExpr {
pub fn kind(&self) -> &TyExprKind {
&*self.kind
}
- pub fn span(&self) -> &Span {
- &self.span
+ pub fn span(&self) -> Span {
+ self.span.clone()
}
pub fn get_type(&self) -> Result<Type, TypeError> {
match &self.ty {
diff --git a/dhall/src/semantics/tck/typecheck.rs b/dhall/src/semantics/tck/typecheck.rs
index 48794a8..7518e90 100644
--- a/dhall/src/semantics/tck/typecheck.rs
+++ b/dhall/src/semantics/tck/typecheck.rs
@@ -76,7 +76,7 @@ fn type_one_layer(
annot.get_type()?.to_expr_tyenv(env),
))
.span_err(
- &annot.span(),
+ annot.span(),
format!(
"this has type: `{}`",
annot.get_type()?.to_expr_tyenv(env)
@@ -503,11 +503,11 @@ fn type_one_layer(
"Wrong handler input type"
))
.span_err(
- &span,
+ span,
format!("in this merge expression",),
)
.span_err(
- &record.span(),
+ record.span(),
format!(
"the handler `{}` expects a value \
of type: `{}`",
@@ -516,7 +516,7 @@ fn type_one_layer(
),
)
.span_err(
- &union.span(),
+ union.span(),
format!(
"but the corresponding variant \
has type: `{}`",
@@ -538,11 +538,11 @@ fn type_one_layer(
"Handler is not a function"
))
.span_err(
- &span,
+ span,
format!("in this merge expression",),
)
.span_err(
- &record.span(),
+ record.span(),
format!(
"the handler `{}` had type: `{}`",
x,
@@ -550,7 +550,7 @@ fn type_one_layer(
),
)
.span_help(
- &union.span(),
+ union.span(),
format!(
"the corresponding variant has type: \
`{}`",
@@ -647,7 +647,7 @@ pub(crate) fn type_with(
None => {
return mkerr(
ErrorBuilder::new(format!("unbound variable `{}`", var))
- .span_err(&expr.span(), "not found in this scope")
+ .span_err(expr.span(), "not found in this scope")
.format(),
)
}
diff --git a/dhall/src/syntax/text/parser.rs b/dhall/src/syntax/text/parser.rs
index ceae2cd..8d571c0 100644
--- a/dhall/src/syntax/text/parser.rs
+++ b/dhall/src/syntax/text/parser.rs
@@ -82,11 +82,7 @@ fn input_to_span(input: ParseInput) -> Span {
fn spanned(input: ParseInput, x: UnspannedExpr) -> Expr {
Expr::new(x, input_to_span(input))
}
-fn spanned_union(
- span1: Span,
- span2: Span,
- x: UnspannedExpr,
-) -> Expr {
+fn spanned_union(span1: Span, span2: Span, x: UnspannedExpr) -> Expr {
Expr::new(x, span1.union(&span2))
}