Skip to content

Commit 98eb4dd

Browse files
committed
Fix parsing of extern paths in types and poly-traits
1 parent b1f8e6f commit 98eb4dd

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

src/libsyntax/parse/parser.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1321,7 +1321,7 @@ impl<'a> Parser<'a> {
13211321
pub fn token_is_bare_fn_keyword(&mut self) -> bool {
13221322
self.check_keyword(keywords::Fn) ||
13231323
self.check_keyword(keywords::Unsafe) ||
1324-
self.check_keyword(keywords::Extern)
1324+
self.check_keyword(keywords::Extern) && self.is_extern_non_path()
13251325
}
13261326

13271327
fn eat_label(&mut self) -> Option<Label> {

src/test/run-pass/rfc-2126-extern-absolute-paths/auxiliary/xcrate.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#[derive(Debug)]
11+
#[derive(Debug, PartialEq)]
1212
pub struct S;
1313

1414
#[derive(Debug)]
1515
pub struct Z;
16+
17+
pub trait Tr<'a> {}

src/test/run-pass/rfc-2126-extern-absolute-paths/extern.rs

+4
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414

1515
use extern::xcrate::Z;
1616

17+
type A = extern::xcrate::S;
18+
type B = for<'a> extern::xcrate::Tr<'a>;
19+
1720
fn f() {
1821
use extern::xcrate;
1922
use extern::xcrate as ycrate;
@@ -28,4 +31,5 @@ fn main() {
2831
assert_eq!(format!("{:?}", s), "S");
2932
let z = Z;
3033
assert_eq!(format!("{:?}", z), "Z");
34+
assert_eq!(A {}, extern::xcrate::S {});
3135
}

0 commit comments

Comments
 (0)