Skip to content

Commit

Permalink
Fix parsing of extern paths in types and poly-traits
Browse files Browse the repository at this point in the history
  • Loading branch information
petrochenkov committed Feb 22, 2018
1 parent b1f8e6f commit 98eb4dd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/libsyntax/parse/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1321,7 +1321,7 @@ impl<'a> Parser<'a> {
pub fn token_is_bare_fn_keyword(&mut self) -> bool {
self.check_keyword(keywords::Fn) ||
self.check_keyword(keywords::Unsafe) ||
self.check_keyword(keywords::Extern)
self.check_keyword(keywords::Extern) && self.is_extern_non_path()
}

fn eat_label(&mut self) -> Option<Label> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#[derive(Debug)]
#[derive(Debug, PartialEq)]
pub struct S;

#[derive(Debug)]
pub struct Z;

pub trait Tr<'a> {}
4 changes: 4 additions & 0 deletions src/test/run-pass/rfc-2126-extern-absolute-paths/extern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@

use extern::xcrate::Z;

type A = extern::xcrate::S;
type B = for<'a> extern::xcrate::Tr<'a>;

fn f() {
use extern::xcrate;
use extern::xcrate as ycrate;
Expand All @@ -28,4 +31,5 @@ fn main() {
assert_eq!(format!("{:?}", s), "S");
let z = Z;
assert_eq!(format!("{:?}", z), "Z");
assert_eq!(A {}, extern::xcrate::S {});
}

0 comments on commit 98eb4dd

Please sign in to comment.