Skip to content

Commit f8aa3f1

Browse files
committed
Fix #20616
1 parent abf0548 commit f8aa3f1

File tree

12 files changed

+439
-2
lines changed

12 files changed

+439
-2
lines changed

src/librustc_typeck/check/method/suggest.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ pub fn all_traits<'a>(ccx: &'a CrateCtxt) -> AllTraits<'a> {
364364
}
365365

366366
pub struct AllTraits<'a> {
367-
borrow: cell::Ref<'a Option<AllTraitsVec>>,
367+
borrow: cell::Ref<'a, Option<AllTraitsVec>>,
368368
idx: usize
369369
}
370370

src/libsyntax/parse/parser.rs

+18-1
Original file line numberDiff line numberDiff line change
@@ -896,7 +896,9 @@ impl<'a> Parser<'a> {
896896
pub fn bump(&mut self) -> PResult<()> {
897897
self.last_span = self.span;
898898
// Stash token for error recovery (sometimes; clone is not necessarily cheap).
899-
self.last_token = if self.token.is_ident() || self.token.is_path() {
899+
self.last_token = if self.token.is_ident() ||
900+
self.token.is_path() ||
901+
self.token == token::Comma {
900902
Some(box self.token.clone())
901903
} else {
902904
None
@@ -3798,6 +3800,21 @@ impl<'a> Parser<'a> {
37983800
Vec<P<TypeBinding>>)> {
37993801
let lifetimes = try!(self.parse_lifetimes(token::Comma));
38003802

3803+
// Fix #20616
3804+
if !lifetimes.is_empty() && self.last_token != Some(box token::Comma) {
3805+
match self.token {
3806+
token::Gt | token::Ge |
3807+
token::BinOpEq(token::Shr) | token::BinOp(token::Shr) => {}
3808+
_ => {
3809+
let this_token_str = self.this_token_to_string();
3810+
let msg = format!("expected `,` or `>` after lifetime \
3811+
name, found `{}`",
3812+
this_token_str);
3813+
return Err(self.fatal(&msg));
3814+
}
3815+
}
3816+
}
3817+
38013818
// First parse types.
38023819
let (types, returned) = try!(self.parse_seq_to_gt_or_return(
38033820
Some(token::Comma),
+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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+
type Type_1_<'a, T> = &'a T;
12+
13+
14+
type Type_1<'a T> = &'a T; //~ error: expected `,` or `>` after lifetime name, found `T`
15+
16+
17+
//type Type_2 = Type_1_<'static ()>; // error: expected `,` or `>` after lifetime name, found `(`
18+
19+
20+
//type Type_3<T> = Box<T,,>; // error: expected type, found `,`
21+
22+
23+
//type Type_4<T> = Type_1_<'static,, T>; // error: expected type, found `,`
24+
25+
26+
type Type_5_<'a> = Type_1_<'a, ()>;
27+
28+
29+
//type Type_5<'a> = Type_1_<'a, (),,>; // error: expected type, found `,`
30+
31+
32+
//type Type_6 = Type_5_<'a,,>; // error: expected type, found `,`
33+
34+
35+
//type Type_7 = Box<(),,>; // error: expected type, found `,`
36+
37+
38+
//type Type_8<'a,,> = &'a (); // error: expected ident, found `,`
39+
40+
41+
//type Type_9<T,,> = Box<T>; // error: expected ident, found `,`
+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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+
type Type_1_<'a, T> = &'a T;
12+
13+
14+
//type Type_1<'a T> = &'a T; // error: expected `,` or `>` after lifetime name, found `T`
15+
16+
17+
type Type_2 = Type_1_<'static ()>; //~ error: expected `,` or `>` after lifetime name, found `(`
18+
19+
20+
//type Type_3<T> = Box<T,,>; // error: expected type, found `,`
21+
22+
23+
//type Type_4<T> = Type_1_<'static,, T>; // error: expected type, found `,`
24+
25+
26+
type Type_5_<'a> = Type_1_<'a, ()>;
27+
28+
29+
//type Type_5<'a> = Type_1_<'a, (),,>; // error: expected type, found `,`
30+
31+
32+
//type Type_6 = Type_5_<'a,,>; // error: expected type, found `,`
33+
34+
35+
//type Type_7 = Box<(),,>; // error: expected type, found `,`
36+
37+
38+
//type Type_8<'a,,> = &'a (); // error: expected ident, found `,`
39+
40+
41+
//type Type_9<T,,> = Box<T>; // error: expected ident, found `,`
+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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+
type Type_1_<'a, T> = &'a T;
12+
13+
14+
//type Type_1<'a T> = &'a T; // error: expected `,` or `>` after lifetime name, found `T`
15+
16+
17+
//type Type_2 = Type_1_<'static ()>; // error: expected `,` or `>` after lifetime name, found `(`
18+
19+
20+
type Type_3<T> = Box<T,,>; //~ error: expected type, found `,`
21+
22+
23+
//type Type_4<T> = Type_1_<'static,, T>; // error: expected type, found `,`
24+
25+
26+
type Type_5_<'a> = Type_1_<'a, ()>;
27+
28+
29+
//type Type_5<'a> = Type_1_<'a, (),,>; // error: expected type, found `,`
30+
31+
32+
//type Type_6 = Type_5_<'a,,>; // error: expected type, found `,`
33+
34+
35+
//type Type_7 = Box<(),,>; // error: expected type, found `,`
36+
37+
38+
//type Type_8<'a,,> = &'a (); // error: expected ident, found `,`
39+
40+
41+
//type Type_9<T,,> = Box<T>; // error: expected ident, found `,`
+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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+
type Type_1_<'a, T> = &'a T;
12+
13+
14+
//type Type_1<'a T> = &'a T; // error: expected `,` or `>` after lifetime name, found `T`
15+
16+
17+
//type Type_2 = Type_1_<'static ()>; // error: expected `,` or `>` after lifetime name, found `(`
18+
19+
20+
//type Type_3<T> = Box<T,,>; // error: expected type, found `,`
21+
22+
23+
type Type_4<T> = Type_1_<'static,, T>; //~ error: expected type, found `,`
24+
25+
26+
type Type_5_<'a> = Type_1_<'a, ()>;
27+
28+
29+
//type Type_5<'a> = Type_1_<'a, (),,>; // error: expected type, found `,`
30+
31+
32+
//type Type_6 = Type_5_<'a,,>; // error: expected type, found `,`
33+
34+
35+
//type Type_7 = Box<(),,>; // error: expected type, found `,`
36+
37+
38+
//type Type_8<'a,,> = &'a (); // error: expected ident, found `,`
39+
40+
41+
//type Type_9<T,,> = Box<T>; // error: expected ident, found `,`
+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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+
type Type_1_<'a, T> = &'a T;
12+
13+
14+
//type Type_1<'a T> = &'a T; // error: expected `,` or `>` after lifetime name, found `T`
15+
16+
17+
//type Type_2 = Type_1_<'static ()>; // error: expected `,` or `>` after lifetime name, found `(`
18+
19+
20+
//type Type_3<T> = Box<T,,>; // error: expected type, found `,`
21+
22+
23+
//type Type_4<T> = Type_1_<'static,, T>; // error: expected type, found `,`
24+
25+
26+
type Type_5_<'a> = Type_1_<'a, ()>;
27+
28+
29+
type Type_5<'a> = Type_1_<'a, (),,>; //~ error: expected type, found `,`
30+
31+
32+
//type Type_6 = Type_5_<'a,,>; // error: expected type, found `,`
33+
34+
35+
//type Type_7 = Box<(),,>; // error: expected type, found `,`
36+
37+
38+
//type Type_8<'a,,> = &'a (); // error: expected ident, found `,`
39+
40+
41+
//type Type_9<T,,> = Box<T>; // error: expected ident, found `,`
+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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+
type Type_1_<'a, T> = &'a T;
12+
13+
14+
//type Type_1<'a T> = &'a T; // error: expected `,` or `>` after lifetime name, found `T`
15+
16+
17+
//type Type_2 = Type_1_<'static ()>; // error: expected `,` or `>` after lifetime name, found `(`
18+
19+
20+
//type Type_3<T> = Box<T,,>; // error: expected type, found `,`
21+
22+
23+
//type Type_4<T> = Type_1_<'static,, T>; // error: expected type, found `,`
24+
25+
26+
type Type_5_<'a> = Type_1_<'a, ()>;
27+
28+
29+
//type Type_5<'a> = Type_1_<'a, (),,>; // error: expected type, found `,`
30+
31+
32+
type Type_6 = Type_5_<'a,,>; //~ error: expected type, found `,`
33+
34+
35+
//type Type_7 = Box<(),,>; // error: expected type, found `,`
36+
37+
38+
//type Type_8<'a,,> = &'a (); // error: expected ident, found `,`
39+
40+
41+
//type Type_9<T,,> = Box<T>; // error: expected ident, found `,`
+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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+
type Type_1_<'a, T> = &'a T;
12+
13+
14+
//type Type_1<'a T> = &'a T; // error: expected `,` or `>` after lifetime name, found `T`
15+
16+
17+
//type Type_2 = Type_1_<'static ()>; // error: expected `,` or `>` after lifetime name, found `(`
18+
19+
20+
//type Type_3<T> = Box<T,,>; // error: expected type, found `,`
21+
22+
23+
//type Type_4<T> = Type_1_<'static,, T>; // error: expected type, found `,`
24+
25+
26+
type Type_5_<'a> = Type_1_<'a, ()>;
27+
28+
29+
//type Type_5<'a> = Type_1_<'a, (),,>; // error: expected type, found `,`
30+
31+
32+
//type Type_6 = Type_5_<'a,,>; // error: expected type, found `,`
33+
34+
35+
type Type_7 = Box<(),,>; //~ error: expected type, found `,`
36+
37+
38+
//type Type_8<'a,,> = &'a (); // error: expected ident, found `,`
39+
40+
41+
//type Type_9<T,,> = Box<T>; // error: expected ident, found `,`
+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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+
type Type_1_<'a, T> = &'a T;
12+
13+
14+
//type Type_1<'a T> = &'a T; // error: expected `,` or `>` after lifetime name, found `T`
15+
16+
17+
//type Type_2 = Type_1_<'static ()>; // error: expected `,` or `>` after lifetime name, found `(`
18+
19+
20+
//type Type_3<T> = Box<T,,>; // error: expected type, found `,`
21+
22+
23+
//type Type_4<T> = Type_1_<'static,, T>; // error: expected type, found `,`
24+
25+
26+
type Type_5_<'a> = Type_1_<'a, ()>;
27+
28+
29+
//type Type_5<'a> = Type_1_<'a, (),,>; // error: expected type, found `,`
30+
31+
32+
//type Type_6 = Type_5_<'a,,>; // error: expected type, found `,`
33+
34+
35+
//type Type_7 = Box<(),,>; // error: expected type, found `,`
36+
37+
38+
type Type_8<'a,,> = &'a (); //~ error: expected ident, found `,`
39+
40+
41+
//type Type_9<T,,> = Box<T>; // error: expected ident, found `,`

0 commit comments

Comments
 (0)