Skip to content

Commit 1b9e0e6

Browse files
committed
Make everything run on GHC 7.10
...and clean up loose language extensions. The main change: don't use records in the Syntax module (DuplicateRecordFields is only post 8.0 and not worth it). See #6.
1 parent d7f3d73 commit 1b9e0e6

File tree

15 files changed

+214
-263
lines changed

15 files changed

+214
-263
lines changed

bench/allocation-benchmarks/Main.hs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{-# LANGUAGE OverloadedStrings, TypeApplications #-}
1+
{-# LANGUAGE OverloadedStrings #-}
22

33
import Weigh
44

@@ -8,6 +8,7 @@ import Data.Foldable (for_)
88
import Data.Traversable (for)
99
import GHC.Exts (fromString)
1010

11+
import Language.Rust.Data.InputStream (InputStream)
1112
import Language.Rust.Syntax (SourceFile)
1213
import Language.Rust.Parser (readInputStream, Span, parse')
1314

@@ -47,7 +48,7 @@ main = do
4748
-- Run 'weigh' tests
4849
fileStreams <- for files $ \file -> do { is <- readInputStream file; pure (takeFileName file, is) }
4950
let weigh = do setColumns [ Case, Max, Allocated, GCs, Live ]
50-
for_ fileStreams $ \(file,is) -> func file (parse' @(SourceFile Span)) is
51+
for_ fileStreams $ \(file,is) -> func file (parse' :: InputStream -> SourceFile Span) is
5152
mainWith weigh
5253
(wr, _) <- weighResults weigh
5354
let results = object [ case maybeErr of

bench/timing-benchmarks/Main.hs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{-# LANGUAGE OverloadedStrings, TypeApplications #-}
1+
{-# LANGUAGE OverloadedStrings #-}
22

33
import Criterion
44
import Criterion.Main (defaultConfig)
@@ -11,6 +11,7 @@ import Data.Foldable (for_)
1111
import Data.Traversable (for)
1212
import GHC.Exts (fromString)
1313

14+
import Language.Rust.Data.InputStream (InputStream)
1415
import Language.Rust.Syntax (SourceFile)
1516
import Language.Rust.Parser (readInputStream, Span, parse')
1617

@@ -50,7 +51,7 @@ main = do
5051
let name = takeFileName f
5152
putStrLn name
5253
is <- readInputStream f
53-
bnch <- benchmarkWith' defaultConfig{ timeLimit = 20 } (nf (parse' @(SourceFile Span)) is)
54+
bnch <- benchmarkWith' defaultConfig{ timeLimit = 20 } (nf (parse' :: InputStream -> SourceFile Span) is)
5455
pure (name, bnch)
5556
let results = object [ fromString name .= object [ "mean" .= m
5657
, "lower bound" .= l

language-rust.cabal

Lines changed: 55 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ source-repository head
2020
location: https://github.com/harpocrates/language-rust.git
2121

2222
flag useByteStrings
23-
description: Use ByteString as InputStream datatype
23+
description: Use ByteString instead of String as InputStream datatype
2424
default: True
2525

2626
flag enableQuasiquotes
@@ -54,19 +54,28 @@ library
5454
Language.Rust.Syntax.Ident
5555
Language.Rust.Syntax.Token
5656

57-
other-extensions: OverloadedStrings
57+
other-extensions: FlexibleContexts
58+
, FlexibleInstances
59+
, OverloadedStrings
5860
, OverloadedLists
59-
, DuplicateRecordFields
61+
, StandaloneDeriving
62+
, DeriveFunctor
6063
, DeriveGeneric
64+
, DeriveAnyClass
6165
, DeriveDataTypeable
66+
, TypeFamilies
67+
, TypeOperators
68+
, Rank2Types
69+
, BangPatterns
6270
, CPP
63-
, DeriveFunctor
6471

65-
build-depends: base >=4.9 && <5.0
66-
, prettyprinter >=1.1
67-
, transformers >=0.5 && <0.6
72+
build-depends: base >=4.8 && <5.0
73+
, prettyprinter >=1.0
74+
, transformers >=0.4 && <0.6
6875
, array >=0.5 && <0.6
69-
, deepseq >=1.4.2.0
76+
, deepseq >=1.1
77+
if impl(ghc < 8)
78+
build-depends: semigroups >= 0.18
7079

7180
if flag(useByteStrings)
7281
build-depends: utf8-string >=1.0
@@ -86,11 +95,18 @@ test-suite unit-tests
8695
ParserTest
8796
PrettyTest
8897
CompleteTest
98+
99+
other-extensions: FlexibleContexts
100+
, OverloadedStrings
101+
, OverloadedLists
102+
, ScopedTypeVariables
103+
, UnicodeSyntax
104+
89105
type: exitcode-stdio-1.0
90106
default-language: Haskell2010
91-
build-depends: base >=4.9 && <5.0
92-
, HUnit >=1.5.0.0
93-
, prettyprinter >=1.1
107+
build-depends: base >=4.8 && <5.0
108+
, HUnit >=1.3.0.0
109+
, prettyprinter >=1.0
94110
, test-framework >=0.8.0
95111
, test-framework-hunit >= 0.3.0
96112
, language-rust
@@ -101,49 +117,65 @@ test-suite rustc-tests
101117
main-is: Main.hs
102118
other-modules: Diff
103119
DiffUtils
120+
121+
other-extensions: InstanceSigs
122+
, OverloadedStrings
123+
, OverloadedLists
124+
, MultiParamTypeClasses
125+
, UnicodeSyntax
126+
104127
type: exitcode-stdio-1.0
105128
default-language: Haskell2010
106-
build-depends: base >=4.9 && <5.0
107-
, process >= 1.3
129+
build-depends: base >=4.8 && <5.0
130+
, process >= 1.4.3
108131
, bytestring >=0.10
109-
, aeson >= 1.0.0.0
110-
, directory >= 1.3.0.0
132+
, aeson >= 0.11.0.0
133+
, directory >= 1.2.5.0
111134
, filepath >= 1.4.0.0
112135
, test-framework >=0.8.0
113136
, vector >=0.10.0
114137
, text >=1.2.0
115138
, unordered-containers >= 0.2.7
116139
, language-rust
117140
, time >=1.2.0.0
141+
if impl(ghc < 8)
142+
build-depends: semigroups >= 0.18
118143

119144
benchmark timing-benchmarks
120145
hs-source-dirs: bench/timing-benchmarks
121146
ghc-options: -Wall
122147
main-is: Main.hs
148+
149+
other-extensions: OverloadedStrings
150+
123151
type: exitcode-stdio-1.0
124152
default-language: Haskell2010
125-
build-depends: base >=4.9 && <5.0
126-
, process >= 1.3
153+
build-depends: base >=4.8 && <5.0
154+
, process >= 1.4.3
127155
, bytestring >=0.10
128-
, directory >= 1.3.0.0
156+
, directory >= 1.2.5.0
129157
, filepath >= 1.4.0.0
130158
, language-rust
131159
, criterion >=1.1.1.0
132160
, statistics
133-
, aeson >= 1.0.0.0
161+
, aeson >= 0.11.0.0
134162

135163
benchmark allocation-benchmarks
136164
hs-source-dirs: bench/allocation-benchmarks
137165
ghc-options: -Wall
138166
main-is: Main.hs
167+
168+
169+
other-extensions: OverloadedStrings
170+
139171
type: exitcode-stdio-1.0
140172
default-language: Haskell2010
141-
build-depends: base >=4.9 && <5.0
142-
, process >= 1.3
173+
build-depends: base >=4.8 && <5.0
174+
, process >= 1.4.3
143175
, bytestring >=0.10
144-
, directory >= 1.3.0.0
176+
, directory >= 1.2.5.0
145177
, filepath >= 1.4.0.0
146178
, language-rust
147179
, weigh >=0.0.4
148-
, aeson >= 1.0.0.0
180+
, aeson >= 0.11.0.0
149181

src/Language/Rust/Data/Position.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Portability : portable
99
1010
Everything to do with describing a position or a contiguous region in a file.
1111
-}
12-
{-# LANGUAGE DeriveDataTypeable, DeriveGeneric, CPP, UndecidableInstances, PolyKinds, DeriveAnyClass #-}
12+
{-# LANGUAGE CPP, DeriveDataTypeable, DeriveGeneric, DeriveAnyClass #-}
1313

1414
module Language.Rust.Data.Position (
1515
-- * Positions in files

src/Language/Rust/Parser/Internal.y

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -415,16 +415,16 @@ string :: { Lit Span }
415415
qual_path(segs) :: { Spanned (QSelf Span, Path Span) }
416416
: '<' qual_path_suf(segs) { let Spanned x _ = $2 in Spanned x ($1 # $2) }
417417
| lt_ty_qual_path as ty_path '>' '::' segs {
418-
let segs = segments $3 <> unspan $6
419-
in Spanned (QSelf (unspan $1) (length (segments $3)), $3{ segments = segs }) ($1 # $>)
418+
let Path g segsTy x = $3
419+
in Spanned (QSelf (unspan $1) (length segsTy), Path g (segsTy <> unspan $6) x) ($1 # $>)
420420
}
421421
422422
-- Basically a qualified path, but ignoring the very first '<' token
423423
qual_path_suf(segs) :: { Spanned (QSelf Span, Path Span) }
424424
: ty '>' '::' segs { Spanned (QSelf $1 0, Path False (unspan $4) (spanOf $4)) ($1 # $>) }
425425
| ty as ty_path '>' '::' segs {
426-
let segs = segments $3 <> unspan $6
427-
in Spanned (QSelf $1 (length (segments $3)), $3{ segments = segs }) ($1 # $>)
426+
let Path g segsTy x = $3
427+
in Spanned (QSelf $1 (length segsTy), Path g (segsTy <> unspan $6) x) ($1 # $>)
428428
}
429429
430430
-- Usually qual_path_suf is for... type paths! This consumes these but with a starting '<<' token.
@@ -507,9 +507,10 @@ mod_path :: { Path Span }
507507
: ntPath { $1 }
508508
| self_or_ident { Path False [(unspan $1, NoParameters mempty)] (spanOf $1) }
509509
| '::' self_or_ident { Path True [(unspan $2, NoParameters mempty)] ($1 # $>) }
510-
| mod_path '::' ident
511-
{ Path (global $1) (segments $1 |> (unspan $3, NoParameters mempty)) ($1 # $>) }
512-
510+
| mod_path '::' ident {
511+
let Path g segs _ = $1
512+
in Path g (segs |> (unspan $3, NoParameters mempty)) ($1 # $>)
513+
}
513514

514515
-----------
515516
-- Types --
@@ -1245,19 +1246,19 @@ gen_item(vis) :: { Item Span }
12451246
| many(outer_attribute) vis const ident ':' ty '=' expr ';'
12461247
{ ConstItem $1 (unspan $2) (unspan $4) $6 $8 ($1 # $2 # $3 # $>) }
12471248
| many(outer_attribute) vis type ident generics where_clause '=' ty ';'
1248-
{ TyAlias $1 (unspan $2) (unspan $4) $8 $5{ whereClause = $6 } ($1 # $2 # $3 # $>) }
1249+
{ TyAlias $1 (unspan $2) (unspan $4) $8 ($5 `withWhere` $6) ($1 # $2 # $3 # $>) }
12491250
| many(outer_attribute) vis use view_path ';'
12501251
{ Use $1 (unspan $2) $4 ($1 # $2 # $3 # $>) }
12511252
| many(outer_attribute) vis safety extern crate ident ';'
12521253
{% noSafety $3 (ExternCrate $1 (unspan $2) (unspan $6) Nothing ($1 # $2 # $4 # $>)) }
12531254
| many(outer_attribute) vis safety extern crate ident as ident ';'
12541255
{% noSafety $3 (ExternCrate $1 (unspan $2) (unspan $8) (Just (unspan $6)) ($1 # $2 # $4 # $>)) }
12551256
| many(outer_attribute) vis const safety fn ident generics fn_decl(arg_named) where_clause inner_attrs_block
1256-
{ Fn ($1 ++ fst $>) (unspan $2) (unspan $6) $8 (unspan $4) Const Rust $7{ whereClause = $9 } (snd $>) ($1 # $2 # $3 # snd $>) }
1257+
{ Fn ($1 ++ fst $>) (unspan $2) (unspan $6) $8 (unspan $4) Const Rust ($7 `withWhere` $9) (snd $>) ($1 # $2 # $3 # snd $>) }
12571258
| many(outer_attribute) vis safety extern abi fn ident generics fn_decl(arg_named) where_clause inner_attrs_block
1258-
{ Fn ($1 ++ fst $>) (unspan $2) (unspan $7) $9 (unspan $3) NotConst $5 $8{ whereClause = $10 } (snd $>) ($1 # $2 # $3 # $4 # snd $>) }
1259+
{ Fn ($1 ++ fst $>) (unspan $2) (unspan $7) $9 (unspan $3) NotConst $5 ($8 `withWhere` $10) (snd $>) ($1 # $2 # $3 # $4 # snd $>) }
12591260
| many(outer_attribute) vis safety fn ident generics fn_decl(arg_named) where_clause inner_attrs_block
1260-
{ Fn ($1 ++ fst $>) (unspan $2) (unspan $5) $7 (unspan $3) NotConst Rust $6{ whereClause = $8 } (snd $>) ($1 # $2 # $3 # $4 # snd $>) }
1261+
{ Fn ($1 ++ fst $>) (unspan $2) (unspan $5) $7 (unspan $3) NotConst Rust ($6 `withWhere` $8) (snd $>) ($1 # $2 # $3 # $4 # snd $>) }
12611262
| many(outer_attribute) vis mod ident ';'
12621263
{ Mod $1 (unspan $2) (unspan $4) Nothing ($1 # $2 # $3 # $>) }
12631264
| many(outer_attribute) vis mod ident '{' many(mod_item) '}'
@@ -1269,31 +1270,31 @@ gen_item(vis) :: { Item Span }
12691270
| many(outer_attribute) vis safety extern abi '{' inner_attrs many(foreign_item) '}'
12701271
{% noSafety $3 (ForeignMod ($1 ++ toList $7) (unspan $2) $5 $8 ($1 # $2 # $4 # $>)) }
12711272
| many(outer_attribute) vis struct ident generics struct_decl_args
1272-
{ StructItem $1 (unspan $2) (unspan $4) (snd $6) $5{ whereClause = fst $6 } ($1 # $2 # $3 # snd $>) }
1273+
{ StructItem $1 (unspan $2) (unspan $4) (snd $6) ($5 `withWhere` fst $6) ($1 # $2 # $3 # snd $>) }
12731274
| many(outer_attribute) vis union ident generics struct_decl_args
1274-
{ Union $1 (unspan $2) (unspan $4) (snd $6) $5{ whereClause = fst $6 } ($1 # $2 # $3 # snd $>) }
1275+
{ Union $1 (unspan $2) (unspan $4) (snd $6) ($5 `withWhere` fst $6) ($1 # $2 # $3 # snd $>) }
12751276
| many(outer_attribute) vis enum ident generics where_clause '{' sep_byT(enum_def,',') '}'
1276-
{ Enum $1 (unspan $2) (unspan $4) $8 $5{ whereClause = $6 } ($1 # $2 # $3 # $>) }
1277+
{ Enum $1 (unspan $2) (unspan $4) $8 ($5 `withWhere` $6) ($1 # $2 # $3 # $>) }
12771278
| many(outer_attribute) vis safety trait ident generics ':' sep_by1T(ty_param_bound,'+') where_clause '{' many(trait_item) '}'
1278-
{ Trait $1 (unspan $2) (unspan $5) (unspan $3) $6{ whereClause = $9 } (toList $8) $11 ($1 # $2 # $3 # $4 # $>) }
1279+
{ Trait $1 (unspan $2) (unspan $5) (unspan $3) ($6 `withWhere` $9) (toList $8) $11 ($1 # $2 # $3 # $4 # $>) }
12791280
| many(outer_attribute) vis safety trait ident generics where_clause '{' many(trait_item) '}'
1280-
{ Trait $1 (unspan $2) (unspan $5) (unspan $3) $6{ whereClause = $7 } [] $9 ($1 # $2 # $3 # $4 # $>) }
1281+
{ Trait $1 (unspan $2) (unspan $5) (unspan $3) ($6 `withWhere` $7) [] $9 ($1 # $2 # $3 # $4 # $>) }
12811282
| many(outer_attribute) vis safety impl generics ty_prim where_clause '{' impl_items '}'
1282-
{ Impl ($1 ++ fst $9) (unspan $2) Final (unspan $3) Positive $5{ whereClause = $7 } Nothing $6 (snd $9) ($1 # $2 # $3 # $4 # $5 # $>) }
1283+
{ Impl ($1 ++ fst $9) (unspan $2) Final (unspan $3) Positive ($5 `withWhere` $7) Nothing $6 (snd $9) ($1 # $2 # $3 # $4 # $5 # $>) }
12831284
| many(outer_attribute) vis default safety impl generics ty_prim where_clause '{' impl_items '}'
1284-
{ Impl ($1 ++ fst $10) (unspan $2) Default (unspan $4) Positive $6{ whereClause = $8 } Nothing $7 (snd $10) ($1 # $2 # $3 # $4 # $5 # $>) }
1285+
{ Impl ($1 ++ fst $10) (unspan $2) Default (unspan $4) Positive ($6 `withWhere` $8) Nothing $7 (snd $10) ($1 # $2 # $3 # $4 # $5 # $>) }
12851286
| many(outer_attribute) vis safety impl generics '(' ty_no_plus ')' where_clause '{' impl_items '}'
1286-
{ Impl ($1 ++ fst $11) (unspan $2) Final (unspan $3) Positive $5{ whereClause = $9 } Nothing (ParenTy $7 ($6 # $8)) (snd $11) ($1 # $2 # $3 # $4 # $5 # $>) }
1287+
{ Impl ($1 ++ fst $11) (unspan $2) Final (unspan $3) Positive ($5 `withWhere` $9) Nothing (ParenTy $7 ($6 # $8)) (snd $11) ($1 # $2 # $3 # $4 # $5 # $>) }
12871288
| many(outer_attribute) vis default safety impl generics '(' ty_no_plus ')' where_clause '{' impl_items '}'
1288-
{ Impl ($1 ++ fst $12) (unspan $2) Default (unspan $4) Positive $6{ whereClause = $10 } Nothing (ParenTy $8 ($7 # $9)) (snd $12) ($1 # $2 # $3 # $4 # $5 # $>) }
1289+
{ Impl ($1 ++ fst $12) (unspan $2) Default (unspan $4) Positive ($6 `withWhere` $10) Nothing (ParenTy $8 ($7 # $9)) (snd $12) ($1 # $2 # $3 # $4 # $5 # $>) }
12891290
| many(outer_attribute) vis safety impl generics '!' trait_ref for ty where_clause '{' impl_items '}'
1290-
{ Impl ($1 ++ fst $12) (unspan $2) Final (unspan $3) Negative $5{ whereClause = $10 } (Just $7) $9 (snd $12) ($1 # $2 # $3 # $4 # $5 # $>) }
1291+
{ Impl ($1 ++ fst $12) (unspan $2) Final (unspan $3) Negative ($5 `withWhere` $10) (Just $7) $9 (snd $12) ($1 # $2 # $3 # $4 # $5 # $>) }
12911292
| many(outer_attribute) vis default safety impl generics '!' trait_ref for ty where_clause '{' impl_items '}'
1292-
{ Impl ($1 ++ fst $13) (unspan $2) Default (unspan $4) Negative $6{ whereClause = $11 } (Just $8) $10 (snd $13) ($1 # $2 # $3 # $4 # $5 # $>) }
1293+
{ Impl ($1 ++ fst $13) (unspan $2) Default (unspan $4) Negative ($6 `withWhere` $11) (Just $8) $10 (snd $13) ($1 # $2 # $3 # $4 # $5 # $>) }
12931294
| many(outer_attribute) vis safety impl generics trait_ref for ty where_clause '{' impl_items '}'
1294-
{ Impl ($1 ++ fst $11) (unspan $2) Final (unspan $3) Positive $5{ whereClause = $9 } (Just $6) $8 (snd $11) ($1 # $2 # $3 # $4 # $5 # $>) }
1295+
{ Impl ($1 ++ fst $11) (unspan $2) Final (unspan $3) Positive ($5 `withWhere` $9) (Just $6) $8 (snd $11) ($1 # $2 # $3 # $4 # $5 # $>) }
12951296
| many(outer_attribute) vis default safety impl generics trait_ref for ty where_clause '{' impl_items '}'
1296-
{ Impl ($1 ++ fst $12) (unspan $2) Default (unspan $4) Positive $6{ whereClause = $10 } (Just $7) $9 (snd $12) ($1 # $2 # $3 # $4 # $5 # $>) }
1297+
{ Impl ($1 ++ fst $12) (unspan $2) Default (unspan $4) Positive ($6 `withWhere` $10) (Just $7) $9 (snd $12) ($1 # $2 # $3 # $4 # $5 # $>) }
12971298
| many(outer_attribute) vis safety impl generics trait_ref for '..' '{' '}'
12981299
{% case $5 of
12991300
Generics [] [] _ _ -> pure $ DefaultImpl $1 (unspan $2) (unspan $3) $6 ($1 # $2 # $3 # $4 # $>)
@@ -1323,7 +1324,7 @@ foreign_item :: { ForeignItem Span }
13231324
| many(outer_attribute) vis static mut ident ':' ty ';'
13241325
{ ForeignStatic $1 (unspan $2) (unspan $5) $7 Mutable ($1 # $2 # $>) }
13251326
| many(outer_attribute) vis fn ident generics fn_decl(arg_named) where_clause ';'
1326-
{ ForeignFn $1 (unspan $2) (unspan $4) $6 $5{ whereClause = $7 } ($1 # $2 # $>) }
1327+
{ ForeignFn $1 (unspan $2) (unspan $4) $6 ($5 `withWhere` $7) ($1 # $2 # $>) }
13271328
13281329
-- parse_generics
13291330
-- Leaves the WhereClause empty
@@ -1385,10 +1386,10 @@ impl_item :: { ImplItem Span }
13851386
| many(outer_attribute) vis def const ident ':' ty '=' expr ';' { ConstI $1 (unspan $2) (unspan $3) (unspan $5) $7 $9 ($1 # $2 # $3 # $4 # $>) }
13861387
| many(outer_attribute) def mod_mac { MacroI $1 (unspan $2) $3 ($1 # $2 # $>) }
13871388
| many(outer_attribute) vis def const safety fn ident generics fn_decl_with_self_named where_clause inner_attrs_block
1388-
{ let methodSig = MethodSig (unspan $5) Const Rust $9 $8{ whereClause = $10 }
1389+
{ let methodSig = MethodSig (unspan $5) Const Rust $9 ($8 `withWhere` $10)
13891390
in MethodI ($1 ++ fst $>) (unspan $2) (unspan $3) (unspan $7) methodSig (snd $>) ($1 # $2 # $3 # $4 # snd $>) }
13901391
| many(outer_attribute) vis def safety ext_abi fn ident generics fn_decl_with_self_named where_clause inner_attrs_block
1391-
{ let methodSig = MethodSig (unspan $4) NotConst (unspan $5) $9 $8{ whereClause = $10 }
1392+
{ let methodSig = MethodSig (unspan $4) NotConst (unspan $5) $9 ($8 `withWhere` $10)
13921393
in MethodI ($1 ++ fst $>) (unspan $2) (unspan $3) (unspan $7) methodSig (snd $>) ($1 # $2 # $3 # $4 # $5 # $6 # snd $>) }
13931394
13941395
trait_item :: { TraitItem Span }
@@ -1402,10 +1403,10 @@ trait_item :: { TraitItem Span }
14021403
| many(outer_attribute) type ident ':' sep_by1T(ty_param_bound_mod,'+') '=' ty ';'
14031404
{ TypeT $1 (unspan $3) (toList $5) (Just $7) ($1 # $2 # $>) }
14041405
| many(outer_attribute) safety ext_abi fn ident generics fn_decl_with_self_general where_clause ';'
1405-
{ let methodSig = MethodSig (unspan $2) NotConst (unspan $3) $7 $6{ whereClause = $8 }
1406+
{ let methodSig = MethodSig (unspan $2) NotConst (unspan $3) $7 ($6 `withWhere` $8)
14061407
in MethodT $1 (unspan $5) methodSig Nothing ($1 # $2 # $3 # $4 # $>) }
14071408
| many(outer_attribute) safety ext_abi fn ident generics fn_decl_with_self_general where_clause inner_attrs_block
1408-
{ let methodSig = MethodSig (unspan $2) NotConst (unspan $3) $7 $6{ whereClause = $8 }
1409+
{ let methodSig = MethodSig (unspan $2) NotConst (unspan $3) $7 ($6 `withWhere` $8)
14091410
in MethodT ($1 ++ fst $>) (unspan $5) methodSig (Just (snd $>)) ($1 # $2 # $3 # $4 # snd $>) }
14101411
14111412
safety :: { Spanned Unsafety }
@@ -1708,6 +1709,10 @@ noVis :: Spanned (Visibility Span) -> a -> P a
17081709
noVis (Spanned InheritedV _) x = pure x
17091710
noVis _ _ = fail "visibility is not allowed here"
17101711

1712+
-- | Fill in the where clause in a generic
1713+
withWhere :: Generics a -> WhereClause a -> Generics a
1714+
withWhere (Generics l t _ x) w = Generics l t w x
1715+
17111716
-- | Return the second argument, as long as the safety is 'Normal'
17121717
noSafety :: Spanned Unsafety -> a -> P a
17131718
noSafety (Spanned Normal _) x = pure x

src/Language/Rust/Parser/ParseMonad.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ instruction manual, the benefits of this are that:
1717
1818
In our case, this shared information is held in 'PState'.
1919
-}
20-
{-# LANGUAGE RankNTypes, BangPatterns #-}
20+
{-# LANGUAGE Rank2Types, BangPatterns #-}
2121

2222
module Language.Rust.Parser.ParseMonad (
2323
-- * Parsing monad

src/Language/Rust/Parser/Reversed.hs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ Portability : portable
1010
Datatypes wrapping lists and non-empty lists designed for fast append (as opposed to prepend)
1111
along with the usual class instances.
1212
-}
13+
{-# LANGUAGE CPP #-}
1314
{-# LANGUAGE FlexibleInstances, TypeFamilies #-}
15+
#if __GLASGOW_HASKELL__ < 800
16+
{-# LANGUAGE FlexibleContexts #-}
17+
#endif
1418

1519
module Language.Rust.Parser.Reversed (
1620
Reversed(..), toNonEmpty, unsnoc

0 commit comments

Comments
 (0)