Skip to content

Commit 0a23ffe

Browse files
committed
Bump to Rust 1.22
No changes in the parser. One small bugfix to let `|_||x, y| x+y` be parsed as a valid closure returning a closure.
1 parent c265c31 commit 0a23ffe

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

sample-sources/expressions.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ fn main() {
2323
loop { break; }
2424
'l: loop { break 'l 1; }
2525
match x { _ => () }
26-
let x = move |a,b,c| { a + b + c };
26+
let x = move |a,b,c| { a + b + c };
27+
let f = |_||x, y| x+y;
2728
let x = { 1 };
2829
let x = unsafe { 1 };
2930
a = 1;

src/Language/Rust/Parser/Internal.y

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,16 @@ gt :: { () }
348348
_ -> pushToken (Spanned tok s)
349349
}
350350

351+
-- This should precede any '|' token which could be absorbed in a '||' token. This works in the same
352+
-- way as 'gt'.
353+
pipe :: { () }
354+
: {- empty -} {%% \(Spanned tok s) ->
355+
let s' = nudge 1 0 s; s'' = nudge 0 (-1) s
356+
in case tok of
357+
PipePipe -> pushToken (Spanned Pipe s') *> pushToken (Spanned Pipe s'')
358+
_ -> pushToken (Spanned tok s)
359+
}
360+
351361
-------------
352362
-- Utility --
353363
-------------
@@ -1133,7 +1143,7 @@ lambda_expr_block :: { Expr Span }
11331143
-- Lambda expression arguments block
11341144
lambda_args :: { Spanned [Arg Span] }
11351145
: '||' { Spanned [] (spanOf $1) }
1136-
| '|' sep_byT(lambda_arg,',') '|' { Spanned $2 ($1 # $3) }
1146+
| '|' sep_byT(lambda_arg,',') pipe '|' { Spanned $2 ($1 # $4) }
11371147

11381148

11391149
-- Struct expression literal

test/rustc-tests/Main.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import Test.Framework.Providers.API
3333
main :: IO ()
3434
main = do
3535
-- Check last time `rustc` version was bumped
36-
let lastDay = fromGregorian 2017 8 21
36+
let lastDay = fromGregorian 2017 9 25
3737
today <- utctDay <$> getCurrentTime
3838
when (diffDays today lastDay > 32) $
3939
putStrLn $ "\x1b[33m" ++ "\nThe version of `rustc' the tests will try to use is older than 1 month" ++ "\x1b[0m"

0 commit comments

Comments
 (0)