1
Fork 0

libsyntax: Forbid type parameters in field expressions.

This breaks code like:

    struct Foo {
        x: int,
    }

    let f: Foo = ...;
    ... f.x::<int> ...

Change this code to not contain an unused type parameter. For example:

    struct Foo {
        x: int,
    }

    let f: Foo = ...;
    ... f.x ...

Closes #18680.

[breaking-change]
This commit is contained in:
Patrick Walton 2014-11-11 10:45:59 -08:00
parent 5d29209bda
commit e6e58e43f8
2 changed files with 32 additions and 1 deletions

View file

@ -2415,9 +2415,16 @@ impl<'a> Parser<'a> {
e = self.mk_expr(lo, hi, nd);
}
_ => {
if !tys.is_empty() {
let last_span = self.last_span;
self.span_err(last_span,
"field expressions may not \
have type parameters");
}
let id = spanned(dot, hi, i);
let field = self.mk_field(e, id, tys);
e = self.mk_expr(lo, hi, field)
e = self.mk_expr(lo, hi, field);
}
}
}