Skip to content

Commit

Permalink
Reserve the alignof, offsetof, and sizeof keywords
Browse files Browse the repository at this point in the history
Closes #9333.
  • Loading branch information
poiru committed Sep 22, 2013
1 parent eabcb39 commit 2ab278f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/etc/vim/syntax/rust.vim
Expand Up @@ -34,7 +34,7 @@ syn match rustIdentifier contains=rustIdentifierPrime "\%([^[:cntrl:][:spac
syn match rustFuncName "\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*" display contained

" Reserved (but not yet used) keywords {{{2
syn keyword rustKeyword be yield typeof
syn keyword rustKeyword alignof be offsetof pure sizeof typeof yield

" Built-in types {{{2
syn keyword rustType int uint float char bool u8 u16 u32 u64 f32
Expand Down
18 changes: 14 additions & 4 deletions src/libsyntax/parse/token.rs
Expand Up @@ -482,6 +482,9 @@ fn mk_fresh_ident_interner() -> @ident_interner {
"pure", // 65
"yield", // 66
"typeof", // 67
"alignof", // 68
"offsetof", // 69
"sizeof", // 70
];

@interner::StrInterner::prefill(init_vec)
Expand Down Expand Up @@ -622,14 +625,17 @@ pub mod keywords {
True,
Trait,
Type,
Typeof,
Unsafe,
Use,
While,

// Reserved keywords
Alignof,
Be,
Offsetof,
Pure,
Sizeof,
Typeof,
Yield,
}

Expand Down Expand Up @@ -667,12 +673,16 @@ pub mod keywords {
True => Ident { name: 57, ctxt: 0 },
Trait => Ident { name: 58, ctxt: 0 },
Type => Ident { name: 59, ctxt: 0 },
Typeof => Ident { name: 67, ctxt: 0 },
Unsafe => Ident { name: 60, ctxt: 0 },
Use => Ident { name: 61, ctxt: 0 },
While => Ident { name: 62, ctxt: 0 },

Alignof => Ident { name: 68, ctxt: 0 },
Be => Ident { name: 64, ctxt: 0 },
Offsetof => Ident { name: 69, ctxt: 0 },
Pure => Ident { name: 65, ctxt: 0 },
Sizeof => Ident { name: 70, ctxt: 0 },
Typeof => Ident { name: 67, ctxt: 0 },
Yield => Ident { name: 66, ctxt: 0 },
}
}
Expand All @@ -689,7 +699,7 @@ pub fn is_keyword(kw: keywords::Keyword, tok: &Token) -> bool {
pub fn is_any_keyword(tok: &Token) -> bool {
match *tok {
token::IDENT(sid, false) => match sid.name {
8 | 27 | 32 .. 67 => true,
8 | 27 | 32 .. 70 => true,
_ => false,
},
_ => false
Expand All @@ -709,7 +719,7 @@ pub fn is_strict_keyword(tok: &Token) -> bool {
pub fn is_reserved_keyword(tok: &Token) -> bool {
match *tok {
token::IDENT(sid, false) => match sid.name {
64 .. 67 => true,
64 .. 70 => true,
_ => false,
},
_ => false,
Expand Down

5 comments on commit 2ab278f

@bors
Copy link
Contributor

@bors bors commented on 2ab278f Sep 22, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from alexcrichton
at poiru@2ab278f

@bors
Copy link
Contributor

@bors bors commented on 2ab278f Sep 22, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging poiru/rust/issue-9333 = 2ab278f into auto

@bors
Copy link
Contributor

@bors bors commented on 2ab278f Sep 22, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

poiru/rust/issue-9333 = 2ab278f merged ok, testing candidate = cd2da7d

@bors
Copy link
Contributor

@bors bors commented on 2ab278f Sep 22, 2013

@bors
Copy link
Contributor

@bors bors commented on 2ab278f Sep 22, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = cd2da7d

Please sign in to comment.