From afa905fcf59580ac76b3e3677b5d9c82b4a19169 Mon Sep 17 00:00:00 2001 From: christopherdumas Date: Wed, 2 Sep 2015 15:48:21 -0700 Subject: [PATCH] Fix tuple float bug. --- src/libsyntax/parse/parser.rs | 2 +- src/test/parse-fail/tuple-float-index.rs | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 src/test/parse-fail/tuple-float-index.rs diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 0772d124db8..265f435978c 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -2363,7 +2363,7 @@ pub fn parse_dot_or_call_expr_with(&mut self, e0: P) -> PResult> { self.fileline_help(last_span, &format!("try parenthesizing the first index; e.g., `(foo.{}){}`", float.trunc() as usize, - &float.fract().to_string()[1..])); + format!(".{}", fstr.splitn(2, ".").last().unwrap()))); } self.abort_if_errors(); diff --git a/src/test/parse-fail/tuple-float-index.rs b/src/test/parse-fail/tuple-float-index.rs new file mode 100644 index 00000000000..f3f5e356346 --- /dev/null +++ b/src/test/parse-fail/tuple-float-index.rs @@ -0,0 +1,16 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn main () { + (1, (2, 3)).1.1; //~ ERROR unexpected token + //~^ HELP try parenthesizing the first index; e.g., `(foo.1).1` +} -- 2.44.0