From b6625eccbf3f2d1bcfe1a88f4d556439281e91de Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Sun, 2 Feb 2020 17:49:49 +0000 Subject: Use Spans consistently by value --- dhall/src/semantics/nze/value.rs | 6 +++--- dhall/src/semantics/tck/tyexpr.rs | 4 ++-- dhall/src/semantics/tck/typecheck.rs | 16 ++++++++-------- 3 files changed, 13 insertions(+), 13 deletions(-) (limited to 'dhall/src/semantics') 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 { 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(), ) } -- cgit v1.2.3