Skip to content

Commit c957817

Browse files
committed
---
yaml --- r: 190162 b: refs/heads/tmp c: de67c3a h: refs/heads/master v: v3
1 parent 2ed6b34 commit c957817

File tree

8 files changed

+96
-11
lines changed

8 files changed

+96
-11
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,6 @@ refs/heads/building: 126db549b038c84269a1e4fe46f051b2c15d6970
3434
refs/heads/beta: 522d09dfecbeca1595f25ac58c6d0178bbd21d7d
3535
refs/heads/windistfix: 7608dbad651f02e837ed05eef3d74a6662a6e928
3636
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
37-
refs/heads/tmp: 425297a93035bc89663ff5f83d229f6c19341ffb
37+
refs/heads/tmp: de67c3a5bbfc8a9db2dc3d134700046dd6db05b3
3838
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3939
refs/tags/homu-tmp: d3c49d2140fc65e8bb7d7cf25bfe74dda6ce5ecf

branches/tmp/src/libcollections/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@ mod prelude {
175175
}
176176

177177
/// An endpoint of a range of keys.
178-
#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)]
179178
pub enum Bound<T> {
180179
/// An inclusive bound.
181180
Included(T),

branches/tmp/src/librustc_trans/trans/consts.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,8 +505,10 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
505505
// pass. Reporting here is a bit late.
506506
cx.sess().span_err(e.span,
507507
"const index-expr is out of bounds");
508+
C_undef(type_of::type_of(cx, bt).element_type())
509+
} else {
510+
const_get_elt(cx, arr, &[iv as c_uint])
508511
}
509-
const_get_elt(cx, arr, &[iv as c_uint])
510512
}
511513
ast::ExprCast(ref base, _) => {
512514
let llty = type_of::type_of(cx, ety);

branches/tmp/src/libsyntax/parse/obsolete.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ use ptr::P;
2424
pub enum ObsoleteSyntax {
2525
Sized,
2626
ForSized,
27+
ProcType,
28+
ProcExpr,
2729
ClosureType,
2830
ClosureKind,
2931
EmptyIndex,
@@ -55,6 +57,16 @@ impl<'a> ParserObsoleteMethods for parser::Parser<'a> {
5557
by default",
5658
true,
5759
),
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+
),
5870
ObsoleteSyntax::ClosureType => (
5971
"`|usize| -> bool` closure type",
6072
"use unboxed closures instead, no type annotation needed",

branches/tmp/src/libsyntax/parse/parser.rs

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1051,7 +1051,9 @@ 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.token_is_bare_fn_keyword() || self.token_is_closure_keyword() {
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() {
10551057
self.parse_ty_bare_fn_or_ty_closure(lifetime_defs)
10561058
} else if self.check(&token::ModSep) ||
10571059
self.token.is_ident() ||
@@ -1119,6 +1121,35 @@ impl<'a> Parser<'a> {
11191121
}))
11201122
}
11211123

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+
11221153
/// Parses an obsolete closure kind (`&:`, `&mut:`, or `:`).
11231154
pub fn parse_obsolete_closure_kind(&mut self) {
11241155
let lo = self.span.lo;
@@ -1491,6 +1522,8 @@ impl<'a> Parser<'a> {
14911522
let e = self.parse_expr();
14921523
self.expect(&token::CloseDelim(token::Paren));
14931524
TyTypeof(e)
1525+
} else if self.eat_keyword_noexpect(keywords::Proc) {
1526+
self.parse_proc_type(Vec::new())
14941527
} else if self.eat_lt() {
14951528
// QUALIFIED PATH `<TYPE as TRAIT_REF>::item`
14961529
let self_type = self.parse_ty_sum();
@@ -2252,6 +2285,12 @@ impl<'a> Parser<'a> {
22522285
if self.eat_keyword(keywords::Move) {
22532286
return self.parse_lambda_expr(CaptureByValue);
22542287
}
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+
}
22552294
if self.eat_keyword(keywords::If) {
22562295
return self.parse_if_expr();
22572296
}
@@ -4606,6 +4645,23 @@ impl<'a> Parser<'a> {
46064645
})
46074646
}
46084647

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+
46094665
/// Parse the name and optional generic types of a function header.
46104666
fn parse_fn_header(&mut self) -> (Ident, ast::Generics) {
46114667
let id = self.parse_ident();

branches/tmp/src/libsyntax/parse/token.rs

Lines changed: 4 additions & 4 deletions
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, Box, "box");
565-
(43, Const, "const");
566-
(44, Where, "where");
564+
(42, Proc, "proc");
565+
(43, Box, "box");
566+
(44, Const, "const");
567+
(45, Where, "where");
567568
'reserved:
568-
(45, Proc, "proc");
569569
(46, Alignof, "alignof");
570570
(47, Become, "become");
571571
(48, Offsetof, "offsetof");
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2015 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+
const FOO: [u32; 3] = [1, 2, 3];
12+
const BAR: u32 = FOO[5]; //~ ERROR const index-expr is out of bounds
13+
14+
fn main() {
15+
let _ = BAR;
16+
}

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

Lines changed: 3 additions & 3 deletions
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 `proc` is a reserved keyword
13+
fn foo(p: proc()) { } //~ ERROR obsolete syntax: the `proc` type
1414

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

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

0 commit comments

Comments
 (0)