Skip to content

Commit 2e33a55

Browse files
committed
Allow declaring existential types inside blocks
1 parent 3900bf8 commit 2e33a55

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

Diff for: src/libsyntax/parse/parser.rs

+6
Original file line numberDiff line numberDiff line change
@@ -4391,6 +4391,11 @@ impl<'a> Parser<'a> {
43914391
self.token.is_keyword(keywords::Extern) && self.look_ahead(1, |t| t != &token::ModSep)
43924392
}
43934393

4394+
fn is_existential_type_decl(&self) -> bool {
4395+
self.token.is_keyword(keywords::Existential) &&
4396+
self.look_ahead(1, |t| t.is_keyword(keywords::Type))
4397+
}
4398+
43944399
fn is_auto_trait_item(&mut self) -> bool {
43954400
// auto trait
43964401
(self.token.is_keyword(keywords::Auto)
@@ -4495,6 +4500,7 @@ impl<'a> Parser<'a> {
44954500
!self.is_union_item() &&
44964501
!self.is_crate_vis() &&
44974502
!self.is_extern_non_path() &&
4503+
!self.is_existential_type_decl() &&
44984504
!self.is_auto_trait_item() {
44994505
let pth = self.parse_path(PathStyle::Expr)?;
45004506

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright 2018 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+
// compile-pass
12+
13+
#![feature(existential_type)]
14+
15+
use std::fmt::Debug;
16+
17+
fn main() {
18+
existential type Existential: Debug;
19+
20+
fn f() -> Existential {}
21+
println!("{:?}", f());
22+
}

0 commit comments

Comments
 (0)