Skip to content

Remove proc keyword #23156

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

Merged
merged 3 commits into from
Mar 12, 2015
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
12 changes: 0 additions & 12 deletions src/libsyntax/parse/obsolete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ use ptr::P;
pub enum ObsoleteSyntax {
Sized,
ForSized,
ProcType,
ProcExpr,
ClosureType,
ClosureKind,
EmptyIndex,
Expand Down Expand Up @@ -57,16 +55,6 @@ impl<'a> ParserObsoleteMethods for parser::Parser<'a> {
by default",
true,
),
ObsoleteSyntax::ProcType => (
"the `proc` type",
"use unboxed closures instead",
true,
),
ObsoleteSyntax::ProcExpr => (
"`proc` expression",
"use a `move ||` expression instead",
true,
),
ObsoleteSyntax::ClosureType => (
"`|usize| -> bool` closure type",
"use unboxed closures instead, no type annotation needed",
Expand Down
58 changes: 1 addition & 57 deletions src/libsyntax/parse/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1051,9 +1051,7 @@ impl<'a> Parser<'a> {
let lifetime_defs = self.parse_late_bound_lifetime_defs();

// examine next token to decide to do
if self.eat_keyword_noexpect(keywords::Proc) {
self.parse_proc_type(lifetime_defs)
} else if self.token_is_bare_fn_keyword() || self.token_is_closure_keyword() {
if self.token_is_bare_fn_keyword() || self.token_is_closure_keyword() {
self.parse_ty_bare_fn_or_ty_closure(lifetime_defs)
} else if self.check(&token::ModSep) ||
self.token.is_ident() ||
Expand Down Expand Up @@ -1121,35 +1119,6 @@ impl<'a> Parser<'a> {
}))
}

/// Parses a procedure type (`proc`). The initial `proc` keyword must
/// already have been parsed.
pub fn parse_proc_type(&mut self, lifetime_defs: Vec<ast::LifetimeDef>) -> Ty_ {
/*

proc <'lt> (S) [:Bounds] -> T
^~~^ ^~~~^ ^ ^~~~~~~~^ ^
| | | | |
| | | | Return type
| | | Bounds
| | Argument types
| Legacy lifetimes
the `proc` keyword (already consumed)

*/

let proc_span = self.last_span;

// To be helpful, parse the proc as ever
let _ = self.parse_legacy_lifetime_defs(lifetime_defs);
let _ = self.parse_fn_args(false, false);
let _ = self.parse_colon_then_ty_param_bounds(BoundParsingMode::Bare);
let _ = self.parse_ret_ty();

self.obsolete(proc_span, ObsoleteSyntax::ProcType);

TyInfer
}

/// Parses an obsolete closure kind (`&:`, `&mut:`, or `:`).
pub fn parse_obsolete_closure_kind(&mut self) {
let lo = self.span.lo;
Expand Down Expand Up @@ -1522,8 +1491,6 @@ impl<'a> Parser<'a> {
let e = self.parse_expr();
self.expect(&token::CloseDelim(token::Paren));
TyTypeof(e)
} else if self.eat_keyword_noexpect(keywords::Proc) {
self.parse_proc_type(Vec::new())
} else if self.eat_lt() {
// QUALIFIED PATH `<TYPE as TRAIT_REF>::item`
let self_type = self.parse_ty_sum();
Expand Down Expand Up @@ -2285,12 +2252,6 @@ impl<'a> Parser<'a> {
if self.eat_keyword(keywords::Move) {
return self.parse_lambda_expr(CaptureByValue);
}
if self.eat_keyword_noexpect(keywords::Proc) {
let span = self.last_span;
let _ = self.parse_proc_decl();
let _ = self.parse_expr();
return self.obsolete_expr(span, ObsoleteSyntax::ProcExpr);
}
if self.eat_keyword(keywords::If) {
return self.parse_if_expr();
}
Expand Down Expand Up @@ -4645,23 +4606,6 @@ impl<'a> Parser<'a> {
})
}

/// Parses the `(arg, arg) -> return_type` header on a procedure.
fn parse_proc_decl(&mut self) -> P<FnDecl> {
let inputs =
self.parse_unspanned_seq(&token::OpenDelim(token::Paren),
&token::CloseDelim(token::Paren),
seq_sep_trailing_allowed(token::Comma),
|p| p.parse_fn_block_arg());

let output = self.parse_ret_ty();

P(FnDecl {
inputs: inputs,
output: output,
variadic: false
})
}

/// Parse the name and optional generic types of a function header.
fn parse_fn_header(&mut self) -> (Ident, ast::Generics) {
let id = self.parse_ident();
Expand Down
8 changes: 4 additions & 4 deletions src/libsyntax/parse/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -561,11 +561,11 @@ declare_special_idents_and_keywords! {
(39, Virtual, "virtual");
(40, While, "while");
(41, Continue, "continue");
(42, Proc, "proc");
(43, Box, "box");
(44, Const, "const");
(45, Where, "where");
(42, Box, "box");
(43, Const, "const");
(44, Where, "where");
'reserved:
(45, Proc, "proc");
(46, Alignof, "alignof");
(47, Become, "become");
(48, Offsetof, "offsetof");
Expand Down
6 changes: 3 additions & 3 deletions src/test/parse-fail/obsolete-proc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

// Test that we generate obsolete syntax errors around usages of `proc`.

fn foo(p: proc()) { } //~ ERROR obsolete syntax: the `proc` type
fn foo(p: proc()) { } //~ ERROR `proc` is a reserved keyword

fn bar() { proc() 1; } //~ ERROR obsolete syntax: `proc` expression
fn bar() { proc() 1; }

fn main() { }
fn main() { }