From 1426f5834c96234bc1998921e889cfc5ca4893c8 Mon Sep 17 00:00:00 2001 From: John Gallagher Date: Tue, 7 Oct 2014 22:17:54 -0400 Subject: [PATCH 1/4] Add `abstract`, `final`, and `override` to reserved keywords --- src/libsyntax/parse/token.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index a8c827439cc60..7cc78891d91d1 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -520,6 +520,9 @@ declare_special_idents_and_keywords! { (54, Unsized, "unsized"); (55, Yield, "yield"); (56, Do, "do"); + (57, Abstract, "abstract"); + (58, Final, "final"); + (59, Override, "override"); } } From 7091fe39720b6a41b1eb08044fccd23d37d3166f Mon Sep 17 00:00:00 2001 From: John Gallagher Date: Tue, 7 Oct 2014 22:18:12 -0400 Subject: [PATCH 2/4] Remove use of `final` and `override` (now reserved) --- src/librustc/middle/trans/reflect.rs | 8 ++++---- src/libstd/io/timer.rs | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/librustc/middle/trans/reflect.rs b/src/librustc/middle/trans/reflect.rs index bff1a0400a9d1..ebdd2eb6354b1 100644 --- a/src/librustc/middle/trans/reflect.rs +++ b/src/librustc/middle/trans/reflect.rs @@ -436,20 +436,20 @@ pub fn emit_calls_to_trait_visit_ty<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, visitor_trait_id: DefId) -> Block<'blk, 'tcx> { let fcx = bcx.fcx; - let final = fcx.new_temp_block("final"); + let final_bcx = fcx.new_temp_block("final"); let tydesc_ty = ty::get_tydesc_ty(bcx.tcx()).unwrap(); let tydesc_ty = type_of(bcx.ccx(), tydesc_ty); let visitor_items = ty::trait_items(bcx.tcx(), visitor_trait_id); let mut r = Reflector { visitor_val: visitor_val, visitor_items: visitor_items.as_slice(), - final_bcx: final, + final_bcx: final_bcx, tydesc_ty: tydesc_ty, bcx: bcx }; r.visit_ty(t); - Br(r.bcx, final.llbb); - return final; + Br(r.bcx, final_bcx.llbb); + return final_bcx; } pub fn ast_fn_style_constant(fn_style: ast::FnStyle) -> uint { diff --git a/src/libstd/io/timer.rs b/src/libstd/io/timer.rs index 55d4073154eea..e7df02855406a 100644 --- a/src/libstd/io/timer.rs +++ b/src/libstd/io/timer.rs @@ -308,7 +308,7 @@ mod test { } #[test] - fn override() { + fn test_override() { let mut timer = Timer::new().unwrap(); let orx = timer.oneshot(Duration::milliseconds(100)); let prx = timer.periodic(Duration::milliseconds(100)); From 4d190b12350a921c1940393ede51c81c5cdf3075 Mon Sep 17 00:00:00 2001 From: John Gallagher Date: Tue, 7 Oct 2014 22:18:36 -0400 Subject: [PATCH 3/4] Add `abstract`, `final`, and `override` to rust.vim keyword list --- src/etc/vim/syntax/rust.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/etc/vim/syntax/rust.vim b/src/etc/vim/syntax/rust.vim index 93931246a0240..407742b9c346e 100644 --- a/src/etc/vim/syntax/rust.vim +++ b/src/etc/vim/syntax/rust.vim @@ -54,7 +54,7 @@ syn match rustMacroRepeatCount ".\?[*+]" contained syn match rustMacroVariable "$\w\+" " Reserved (but not yet used) keywords {{{2 -syn keyword rustReservedKeyword alignof be do offsetof priv pure sizeof typeof unsized yield +syn keyword rustReservedKeyword alignof be do offsetof priv pure sizeof typeof unsized yield abstract final override " Built-in types {{{2 syn keyword rustType int uint float char bool u8 u16 u32 u64 f32 From 3db9070e9c2a88cf88766d277ffc03ab65e72dec Mon Sep 17 00:00:00 2001 From: John Gallagher Date: Tue, 7 Oct 2014 22:19:02 -0400 Subject: [PATCH 4/4] Add tests for new reserved keywords `abstract`,`final`,`override` --- src/test/compile-fail/keyword-abstract.rs | 13 +++++++++++++ src/test/compile-fail/keyword-final.rs | 13 +++++++++++++ src/test/compile-fail/keyword-override.rs | 13 +++++++++++++ 3 files changed, 39 insertions(+) create mode 100644 src/test/compile-fail/keyword-abstract.rs create mode 100644 src/test/compile-fail/keyword-final.rs create mode 100644 src/test/compile-fail/keyword-override.rs diff --git a/src/test/compile-fail/keyword-abstract.rs b/src/test/compile-fail/keyword-abstract.rs new file mode 100644 index 0000000000000..1f1360eac0078 --- /dev/null +++ b/src/test/compile-fail/keyword-abstract.rs @@ -0,0 +1,13 @@ +// 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. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + let abstract = (); //~ ERROR `abstract` is a reserved keyword +} diff --git a/src/test/compile-fail/keyword-final.rs b/src/test/compile-fail/keyword-final.rs new file mode 100644 index 0000000000000..305ef0ef075f7 --- /dev/null +++ b/src/test/compile-fail/keyword-final.rs @@ -0,0 +1,13 @@ +// 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. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + let final = (); //~ ERROR `final` is a reserved keyword +} diff --git a/src/test/compile-fail/keyword-override.rs b/src/test/compile-fail/keyword-override.rs new file mode 100644 index 0000000000000..f70e6b9261053 --- /dev/null +++ b/src/test/compile-fail/keyword-override.rs @@ -0,0 +1,13 @@ +// 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. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + let override = (); //~ ERROR `override` is a reserved keyword +}