Skip to content

Commit a2fab45

Browse files
committed
Reserve do as a keyword
Resolves issue #12157. `do` is hereby reinstated as a keyword; no syntax is associated with it though. Along the way, a unit test had to be adapted, since it was using `do` as a method identifier. Breaking changes: - Any code using `do` as an identifier will no longer work.
1 parent cf9164f commit a2fab45

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

src/libsyntax/parse/token.rs

+1
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,7 @@ declare_special_idents_and_keywords! {
492492
(53, Typeof, "typeof");
493493
(54, Unsized, "unsized");
494494
(55, Yield, "yield");
495+
(56, Do, "do");
495496
}
496497
}
497498

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
fn main() {
12+
let do = "bar"; //~ error: ident
13+
}

src/test/run-pass/temporary-lifetime-for-conditions.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ impl Drop for Temporary {
2323
}
2424

2525
impl Temporary {
26-
fn do(&self) -> bool {true}
26+
fn do_stuff(&self) -> bool {true}
2727
}
2828

2929
fn borrow() -> ~Temporary { ~Temporary }
@@ -35,7 +35,7 @@ pub fn main() {
3535
// This loop's condition
3636
// should call `Temporary`'s
3737
// `drop` 6 times.
38-
while borrow().do() {
38+
while borrow().do_stuff() {
3939
i += 1;
4040
if i > 5 {
4141
break;
@@ -44,7 +44,7 @@ pub fn main() {
4444

4545
// This if condition should
4646
// call it 1 time
47-
if borrow().do() {
47+
if borrow().do_stuff() {
4848
unsafe { assert_eq!(DROPPED, 7) }
4949
}
5050
}

0 commit comments

Comments
 (0)