From 48368c5a078cacaa554c80af1649b6be96c95227 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Fri, 27 Apr 2012 15:03:30 -0700 Subject: [PATCH] test: Add test for two restricted keyword cases --- src/librustsyntax/parse/parser.rs | 4 ++-- src/test/compile-fail/restricted-keyword1.rs | 7 +++++++ src/test/compile-fail/restricted-keyword2.rs | 5 +++++ 3 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 src/test/compile-fail/restricted-keyword1.rs create mode 100644 src/test/compile-fail/restricted-keyword2.rs diff --git a/src/librustsyntax/parse/parser.rs b/src/librustsyntax/parse/parser.rs index 8731af4ca60b..7e9a38604544 100644 --- a/src/librustsyntax/parse/parser.rs +++ b/src/librustsyntax/parse/parser.rs @@ -1395,7 +1395,7 @@ fn parse_pat(p: parser) -> @ast::pat { subpat = parse_pat(p); } else { if is_restricted_keyword(p, fieldname) { - p.fatal("found " + fieldname + " in binding position"); + p.fatal("found `" + fieldname + "` in binding position"); } subpat = @{id: p.get_id(), node: ast::pat_ident(fieldpath, none), @@ -2149,7 +2149,7 @@ fn parse_item_enum(p: parser, attrs: [ast::attribute]) -> @ast::item { // Newtype syntax if p.token == token::EQ { if is_restricted_keyword(p, id) { - p.fatal("found " + id + " in enum constructor position"); + p.fatal("found `" + id + "` in enum constructor position"); } p.bump(); let ty = parse_ty(p, false); diff --git a/src/test/compile-fail/restricted-keyword1.rs b/src/test/compile-fail/restricted-keyword1.rs new file mode 100644 index 000000000000..238e2404c9e0 --- /dev/null +++ b/src/test/compile-fail/restricted-keyword1.rs @@ -0,0 +1,7 @@ +// error-pattern:found `let` in binding position + +fn main() { + alt true { + {let} { } + } +} diff --git a/src/test/compile-fail/restricted-keyword2.rs b/src/test/compile-fail/restricted-keyword2.rs new file mode 100644 index 000000000000..30f755c6016c --- /dev/null +++ b/src/test/compile-fail/restricted-keyword2.rs @@ -0,0 +1,5 @@ +// error-pattern:found `let` in enum constructor position + +fn main() { + enum let = int; +}