summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNadrieril2019-02-27 15:45:09 +0100
committerNadrieril2019-02-27 18:53:08 +0100
commitd8b88c1a5da7218011fca2bccc525907aa439335 (patch)
tree7a93645a8209d640bb8dd32e36468d544f732f11
parent8a1012be323459440032813c2b21b62174924c6c (diff)
Switch to Rust 2018 edition
Diffstat (limited to '')
-rw-r--r--Cargo.toml1
-rw-r--r--build.rs2
-rw-r--r--src/core.rs22
-rw-r--r--src/grammar_util.rs4
-rw-r--r--src/lexer.rs14
-rw-r--r--src/main.rs12
-rw-r--r--src/parser.rs8
-rw-r--r--src/typecheck.rs16
8 files changed, 39 insertions, 40 deletions
diff --git a/Cargo.toml b/Cargo.toml
index f781e03..06d978a 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -2,6 +2,7 @@
name = "dhall"
version = "0.1.0"
authors = ["NanoTech <nanotech@nanotechcorp.net>"]
+edition = "2018"
build = "build.rs"
[build-dependencies]
diff --git a/build.rs b/build.rs
index ce7e591..946841a 100644
--- a/build.rs
+++ b/build.rs
@@ -1,4 +1,4 @@
-extern crate lalrpop;
+use lalrpop;
fn main() {
lalrpop::process_root().unwrap();
diff --git a/src/core.rs b/src/core.rs
index a9de523..67a7492 100644
--- a/src/core.rs
+++ b/src/core.rs
@@ -290,7 +290,7 @@ impl<'i, S, A> Expr<'i, S, A> {
impl<'i, S, A: Display> Display for Expr<'i, S, A> {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { // buildExprA
- use Expr::*;
+ use crate::Expr::*;
match self {
&Annot(ref a, ref b) => { a.fmt_b(f)?; write!(f, " : ")?; b.fmt(f) }
&Note(_, ref b) => b.fmt(f),
@@ -301,7 +301,7 @@ impl<'i, S, A: Display> Display for Expr<'i, S, A> {
impl<'i, S, A: Display> Expr<'i, S, A> {
fn fmt_b(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
- use Expr::*;
+ use crate::Expr::*;
match self {
&Lam(a, ref b, ref c) => {
write!(f, "λ({} : ", a)?;
@@ -364,7 +364,7 @@ impl<'i, S, A: Display> Expr<'i, S, A> {
}
fn fmt_c(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
- use Expr::*;
+ use crate::Expr::*;
match self {
// FIXME precedence
&BoolOr(ref a, ref b) => { a.fmt_d(f)?; f.write_str(" || ")?; b.fmt_c(f) }
@@ -381,7 +381,7 @@ impl<'i, S, A: Display> Expr<'i, S, A> {
}
fn fmt_d(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
- use Expr::*;
+ use crate::Expr::*;
match self {
&App(ref a, ref b) => { a.fmt_d(f)?; f.write_str(" ")?; b.fmt_e(f) }
&Note(_, ref b) => b.fmt_d(f),
@@ -390,7 +390,7 @@ impl<'i, S, A: Display> Expr<'i, S, A> {
}
fn fmt_e(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
- use Expr::*;
+ use crate::Expr::*;
match self {
&Field(ref a, b) => { a.fmt_e(f)?; write!(f, ".{}", b) }
&Note(_, ref b) => b.fmt_e(f),
@@ -399,7 +399,7 @@ impl<'i, S, A: Display> Expr<'i, S, A> {
}
fn fmt_f(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
- use Expr::*;
+ use crate::Expr::*;
match self {
&Var(a) => a.fmt(f),
&Const(k) => k.fmt(f),
@@ -464,7 +464,7 @@ impl Display for BuiltinType {
impl Display for BuiltinValue {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
- use BuiltinValue::*;
+ use crate::BuiltinValue::*;
f.write_str(match *self {
ListBuild => "List/build",
ListFold => "List/fold",
@@ -625,7 +625,7 @@ fn map_op2<T, U, V, F, G>(f: F, g: G, a: T, b: T) -> V
/// name in order to avoid shifting the bound variables by mistake.
///
pub fn shift<'i, S, T, A: Clone>(d: isize, v: V, e: &Expr<'i, S, A>) -> Expr<'i, T, A> {
- use Expr::*;
+ use crate::Expr::*;
let V(x, n) = v;
match *e {
Const(a) => Const(a),
@@ -721,7 +721,7 @@ pub fn subst<'i, S, T, A>(v: V<'i>, e: &Expr<'i, S, A>, b: &Expr<'i, T, A>) -> E
where S: Clone,
A: Clone
{
- use Expr::*;
+ use crate::Expr::*;
let V(x, n) = v;
match *b {
Const(a) => Const(a),
@@ -823,8 +823,8 @@ pub fn normalize<'i, S, T, A>(e: &Expr<'i, S, A>) -> Expr<'i, T, A>
T: Clone + fmt::Debug,
A: Clone + fmt::Debug,
{
- use BuiltinValue::*;
- use Expr::*;
+ use crate::BuiltinValue::*;
+ use crate::Expr::*;
match *e {
Const(k) => Const(k),
Var(v) => Var(v),
diff --git a/src/grammar_util.rs b/src/grammar_util.rs
index 49b7fb8..c546a13 100644
--- a/src/grammar_util.rs
+++ b/src/grammar_util.rs
@@ -1,5 +1,5 @@
-use core::{Expr, X};
-use lexer::Builtin;
+use crate::core::{Expr, X};
+use crate::lexer::Builtin;
pub type ParsedExpr<'i> = Expr<'i, X, X>; // FIXME Parse paths and replace the second X with Path
pub type BoxExpr<'i> = Box<ParsedExpr<'i>>;
diff --git a/src/lexer.rs b/src/lexer.rs
index 0b58293..d396951 100644
--- a/src/lexer.rs
+++ b/src/lexer.rs
@@ -1,10 +1,10 @@
-use nom;
+use nom::*;
-use core::Const;
-use core::BuiltinType;
-use core::BuiltinType::*;
-use core::BuiltinValue;
-use core::BuiltinValue::*;
+use crate::core::Const;
+use crate::core::BuiltinType;
+use crate::core::BuiltinType::*;
+use crate::core::BuiltinValue;
+use crate::core::BuiltinValue::*;
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Keyword {
@@ -359,7 +359,7 @@ fn test_lex() {
ParenL,
Identifier("b"),
Ascription,
- Builtin(self::Builtin::Type(::core::BuiltinType::Bool)),
+ Builtin(self::Builtin::Type(crate::core::BuiltinType::Bool)),
ParenR,
Arrow,
Identifier("b"),
diff --git a/src/main.rs b/src/main.rs
index fde3978..22a4c3b 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,15 +1,13 @@
#![feature(box_patterns)]
-extern crate bytecount;
-#[macro_use]
-extern crate lalrpop_util;
-#[macro_use]
-extern crate nom;
-extern crate term_painter;
+use bytecount;
+use lalrpop_util;
+use lalrpop_util::lalrpop_mod;
+use term_painter;
pub mod context;
mod core;
-pub use core::*;
+pub use crate::core::*;
lalrpop_mod!(pub grammar); // synthesized by LALRPOP
mod grammar_util;
pub mod lexer;
diff --git a/src/parser.rs b/src/parser.rs
index 3ad7ffc..2e252b1 100644
--- a/src/parser.rs
+++ b/src/parser.rs
@@ -1,8 +1,8 @@
use lalrpop_util;
-use grammar;
-use grammar_util::BoxExpr;
-use lexer::{Lexer, LexicalError, Tok};
+use crate::grammar;
+use crate::grammar_util::BoxExpr;
+use crate::lexer::{Lexer, LexicalError, Tok};
pub type ParseError<'i> = lalrpop_util::ParseError<usize, Tok<'i>, LexicalError>;
@@ -12,7 +12,7 @@ pub fn parse_expr(s: &str) -> Result<BoxExpr, ParseError> {
#[test]
fn test_parse() {
- use core::Expr::*;
+ use crate::core::Expr::*;
println!("test {:?}", parse_expr("+3 + +5 * +10"));
assert!(parse_expr("22").is_ok());
assert!(parse_expr("(22)").is_ok());
diff --git a/src/typecheck.rs b/src/typecheck.rs
index 576b059..62ff7d2 100644
--- a/src/typecheck.rs
+++ b/src/typecheck.rs
@@ -3,14 +3,14 @@ use std::collections::BTreeMap;
use std::collections::HashSet;
use std::fmt;
-use context::Context;
-use core;
-use core::{Expr, V, X, bx, normalize, shift, subst};
-use core::{pi, app};
-use core::BuiltinType::*;
-use core::BuiltinValue::*;
-use core::Const::*;
-use core::Expr::*;
+use crate::context::Context;
+use crate::core;
+use crate::core::{Expr, V, X, bx, normalize, shift, subst};
+use crate::core::{pi, app};
+use crate::core::BuiltinType::*;
+use crate::core::BuiltinValue::*;
+use crate::core::Const::*;
+use crate::core::Expr::*;
use self::TypeMessage::*;