test: Add test for two restricted keyword cases
This commit is contained in:
parent
bde5a842ce
commit
48368c5a07
3 changed files with 14 additions and 2 deletions
|
@ -1395,7 +1395,7 @@ fn parse_pat(p: parser) -> @ast::pat {
|
||||||
subpat = parse_pat(p);
|
subpat = parse_pat(p);
|
||||||
} else {
|
} else {
|
||||||
if is_restricted_keyword(p, fieldname) {
|
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(),
|
subpat = @{id: p.get_id(),
|
||||||
node: ast::pat_ident(fieldpath, none),
|
node: ast::pat_ident(fieldpath, none),
|
||||||
|
@ -2149,7 +2149,7 @@ fn parse_item_enum(p: parser, attrs: [ast::attribute]) -> @ast::item {
|
||||||
// Newtype syntax
|
// Newtype syntax
|
||||||
if p.token == token::EQ {
|
if p.token == token::EQ {
|
||||||
if is_restricted_keyword(p, id) {
|
if is_restricted_keyword(p, id) {
|
||||||
p.fatal("found " + id + " in enum constructor position");
|
p.fatal("found `" + id + "` in enum constructor position");
|
||||||
}
|
}
|
||||||
p.bump();
|
p.bump();
|
||||||
let ty = parse_ty(p, false);
|
let ty = parse_ty(p, false);
|
||||||
|
|
7
src/test/compile-fail/restricted-keyword1.rs
Normal file
7
src/test/compile-fail/restricted-keyword1.rs
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
// error-pattern:found `let` in binding position
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
alt true {
|
||||||
|
{let} { }
|
||||||
|
}
|
||||||
|
}
|
5
src/test/compile-fail/restricted-keyword2.rs
Normal file
5
src/test/compile-fail/restricted-keyword2.rs
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
// error-pattern:found `let` in enum constructor position
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
enum let = int;
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue