better self-types

This commit is contained in:
Aleksey Kladov 2018-08-24 01:19:38 +03:00
parent cf7d4a2a24
commit dc40f1298a
8 changed files with 67 additions and 45 deletions

View file

@ -208,7 +208,7 @@ fn extern_crate_item(p: &mut Parser) {
assert!(p.at(CRATE_KW));
p.bump();
name(p);
alias(p);
opt_alias(p);
p.expect(SEMI);
}

View file

@ -26,7 +26,7 @@ fn use_tree(p: &mut Parser) {
paths::use_path(p);
match p.current() {
AS_KW => {
alias(p);
opt_alias(p);
}
COLONCOLON => {
p.bump();

View file

@ -92,14 +92,14 @@ fn opt_visibility(p: &mut Parser) {
_ => (),
}
}
fn alias(p: &mut Parser) -> bool {
fn opt_alias(p: &mut Parser) {
if p.at(AS_KW) {
let alias = p.start();
let m = p.start();
p.bump();
name(p);
alias.complete(p, ALIAS);
m.complete(p, ALIAS);
}
true //FIXME: return false if three are errors
}
fn abi(p: &mut Parser) {

View file

@ -92,16 +92,18 @@ fn value_parameter(p: &mut Parser, flavor: Flavor) {
// fn b(&self,) {}
// fn c(&'a self,) {}
// fn d(&'a mut self, x: i32) {}
// fn e(mut self) {}
// }
fn self_param(p: &mut Parser) {
let m;
if p.at(SELF_KW) {
if p.at(SELF_KW) || p.at(MUT_KW) && p.nth(1) == SELF_KW {
m = p.start();
p.bump();
p.eat(MUT_KW);
p.eat(SELF_KW);
// test arb_self_types
// impl S {
// fn a(self: &Self) {}
// fn b(self: Box<Self>) {}
// fn b(mut self: Box<Self>) {}
// }
if p.at(COLON) {
types::ascription(p);