Skip to content

Commit 425297a

Browse files
committed
Auto merge of #23156 - GuillaumeGomez:remove-proc, r=alexcrichton
This is the implementation of the [RFC 584](rust-lang/rfcs#584).
2 parents ae4812b + db726fa commit 425297a

File tree

4 files changed

+8
-76
lines changed

4 files changed

+8
-76
lines changed

src/libsyntax/parse/obsolete.rs

-12
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ use ptr::P;
2424
pub enum ObsoleteSyntax {
2525
Sized,
2626
ForSized,
27-
ProcType,
28-
ProcExpr,
2927
ClosureType,
3028
ClosureKind,
3129
EmptyIndex,
@@ -57,16 +55,6 @@ impl<'a> ParserObsoleteMethods for parser::Parser<'a> {
5755
by default",
5856
true,
5957
),
60-
ObsoleteSyntax::ProcType => (
61-
"the `proc` type",
62-
"use unboxed closures instead",
63-
true,
64-
),
65-
ObsoleteSyntax::ProcExpr => (
66-
"`proc` expression",
67-
"use a `move ||` expression instead",
68-
true,
69-
),
7058
ObsoleteSyntax::ClosureType => (
7159
"`|usize| -> bool` closure type",
7260
"use unboxed closures instead, no type annotation needed",

src/libsyntax/parse/parser.rs

+1-57
Original file line numberDiff line numberDiff line change
@@ -1051,9 +1051,7 @@ impl<'a> Parser<'a> {
10511051
let lifetime_defs = self.parse_late_bound_lifetime_defs();
10521052

10531053
// examine next token to decide to do
1054-
if self.eat_keyword_noexpect(keywords::Proc) {
1055-
self.parse_proc_type(lifetime_defs)
1056-
} else if self.token_is_bare_fn_keyword() || self.token_is_closure_keyword() {
1054+
if self.token_is_bare_fn_keyword() || self.token_is_closure_keyword() {
10571055
self.parse_ty_bare_fn_or_ty_closure(lifetime_defs)
10581056
} else if self.check(&token::ModSep) ||
10591057
self.token.is_ident() ||
@@ -1121,35 +1119,6 @@ impl<'a> Parser<'a> {
11211119
}))
11221120
}
11231121

1124-
/// Parses a procedure type (`proc`). The initial `proc` keyword must
1125-
/// already have been parsed.
1126-
pub fn parse_proc_type(&mut self, lifetime_defs: Vec<ast::LifetimeDef>) -> Ty_ {
1127-
/*
1128-
1129-
proc <'lt> (S) [:Bounds] -> T
1130-
^~~^ ^~~~^ ^ ^~~~~~~~^ ^
1131-
| | | | |
1132-
| | | | Return type
1133-
| | | Bounds
1134-
| | Argument types
1135-
| Legacy lifetimes
1136-
the `proc` keyword (already consumed)
1137-
1138-
*/
1139-
1140-
let proc_span = self.last_span;
1141-
1142-
// To be helpful, parse the proc as ever
1143-
let _ = self.parse_legacy_lifetime_defs(lifetime_defs);
1144-
let _ = self.parse_fn_args(false, false);
1145-
let _ = self.parse_colon_then_ty_param_bounds(BoundParsingMode::Bare);
1146-
let _ = self.parse_ret_ty();
1147-
1148-
self.obsolete(proc_span, ObsoleteSyntax::ProcType);
1149-
1150-
TyInfer
1151-
}
1152-
11531122
/// Parses an obsolete closure kind (`&:`, `&mut:`, or `:`).
11541123
pub fn parse_obsolete_closure_kind(&mut self) {
11551124
let lo = self.span.lo;
@@ -1522,8 +1491,6 @@ impl<'a> Parser<'a> {
15221491
let e = self.parse_expr();
15231492
self.expect(&token::CloseDelim(token::Paren));
15241493
TyTypeof(e)
1525-
} else if self.eat_keyword_noexpect(keywords::Proc) {
1526-
self.parse_proc_type(Vec::new())
15271494
} else if self.eat_lt() {
15281495
// QUALIFIED PATH `<TYPE as TRAIT_REF>::item`
15291496
let self_type = self.parse_ty_sum();
@@ -2285,12 +2252,6 @@ impl<'a> Parser<'a> {
22852252
if self.eat_keyword(keywords::Move) {
22862253
return self.parse_lambda_expr(CaptureByValue);
22872254
}
2288-
if self.eat_keyword_noexpect(keywords::Proc) {
2289-
let span = self.last_span;
2290-
let _ = self.parse_proc_decl();
2291-
let _ = self.parse_expr();
2292-
return self.obsolete_expr(span, ObsoleteSyntax::ProcExpr);
2293-
}
22942255
if self.eat_keyword(keywords::If) {
22952256
return self.parse_if_expr();
22962257
}
@@ -4645,23 +4606,6 @@ impl<'a> Parser<'a> {
46454606
})
46464607
}
46474608

4648-
/// Parses the `(arg, arg) -> return_type` header on a procedure.
4649-
fn parse_proc_decl(&mut self) -> P<FnDecl> {
4650-
let inputs =
4651-
self.parse_unspanned_seq(&token::OpenDelim(token::Paren),
4652-
&token::CloseDelim(token::Paren),
4653-
seq_sep_trailing_allowed(token::Comma),
4654-
|p| p.parse_fn_block_arg());
4655-
4656-
let output = self.parse_ret_ty();
4657-
4658-
P(FnDecl {
4659-
inputs: inputs,
4660-
output: output,
4661-
variadic: false
4662-
})
4663-
}
4664-
46654609
/// Parse the name and optional generic types of a function header.
46664610
fn parse_fn_header(&mut self) -> (Ident, ast::Generics) {
46674611
let id = self.parse_ident();

src/libsyntax/parse/token.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -561,11 +561,11 @@ declare_special_idents_and_keywords! {
561561
(39, Virtual, "virtual");
562562
(40, While, "while");
563563
(41, Continue, "continue");
564-
(42, Proc, "proc");
565-
(43, Box, "box");
566-
(44, Const, "const");
567-
(45, Where, "where");
564+
(42, Box, "box");
565+
(43, Const, "const");
566+
(44, Where, "where");
568567
'reserved:
568+
(45, Proc, "proc");
569569
(46, Alignof, "alignof");
570570
(47, Become, "become");
571571
(48, Offsetof, "offsetof");

src/test/parse-fail/obsolete-proc.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010

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

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

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

17-
fn main() { }
17+
fn main() { }

0 commit comments

Comments
 (0)