Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement RFC 2421, 'Keyword unreservations (pure, sizeof, alignof, offsetof) #51196

Merged
merged 2 commits into from
Jun 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 18 additions & 22 deletions src/libsyntax_pos/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -384,34 +384,30 @@ declare_keywords! {

// Keywords reserved for future use.
(40, Abstract, "abstract")
(41, Alignof, "alignof")
(42, Become, "become")
(43, Do, "do")
(44, Final, "final")
(45, Macro, "macro")
(46, Offsetof, "offsetof")
(47, Override, "override")
(48, Priv, "priv")
(49, Pure, "pure")
(50, Sizeof, "sizeof")
(51, Typeof, "typeof")
(52, Unsized, "unsized")
(53, Virtual, "virtual")
(54, Yield, "yield")
(41, Become, "become")
(42, Do, "do")
(43, Final, "final")
(44, Macro, "macro")
(45, Override, "override")
(46, Priv, "priv")
(47, Typeof, "typeof")
(48, Unsized, "unsized")
(49, Virtual, "virtual")
(50, Yield, "yield")

// Edition-specific keywords reserved for future use.
(55, Async, "async") // >= 2018 Edition Only
(51, Async, "async") // >= 2018 Edition Only

// Special lifetime names
(56, UnderscoreLifetime, "'_")
(57, StaticLifetime, "'static")
(52, UnderscoreLifetime, "'_")
(53, StaticLifetime, "'static")

// Weak keywords, have special meaning only in specific contexts.
(58, Auto, "auto")
(59, Catch, "catch")
(60, Default, "default")
(61, Dyn, "dyn")
(62, Union, "union")
(54, Auto, "auto")
(55, Catch, "catch")
(56, Default, "default")
(57, Dyn, "dyn")
(58, Union, "union")
}

impl Symbol {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
Expand All @@ -8,6 +8,15 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// compile-flags: -Z parse-only
// Test that removed keywords are allowed as identifiers.
fn main () {
let offsetof = ();
let alignof = ();
let sizeof = ();
let pure = ();
}

pure fn f() {} //~ ERROR expected item, found `pure`
fn offsetof() {}
fn alignof() {}
fn sizeof() {}
fn pure() {}