From e6e58e43f8f9507474fdf35544b6b0c0fc6cef39 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Tue, 11 Nov 2014 10:45:59 -0800 Subject: libsyntax: Forbid type parameters in field expressions. This breaks code like: struct Foo { x: int, } let f: Foo = ...; ... f.x:: ... 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] --- src/libsyntax/parse/parser.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/libsyntax') diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 6873c015fd5..90ada8a687c 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -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); } } } -- cgit 1.4.1-3-g733a5