mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-13 15:33:53 +00:00
libsyntax: no binary/hex float literals
This commit is contained in:
parent
801f3225b2
commit
01cc9ecafe
@ -431,6 +431,13 @@ fn scan_number(c: char, rdr: string_reader) -> token::Token {
|
|||||||
let dec_part = scan_digits(rdr, 10u);
|
let dec_part = scan_digits(rdr, 10u);
|
||||||
num_str += ~"." + dec_part;
|
num_str += ~"." + dec_part;
|
||||||
}
|
}
|
||||||
|
if is_float {
|
||||||
|
match base {
|
||||||
|
16u => rdr.fatal(~"hexadecimal float literal is not supported"),
|
||||||
|
2u => rdr.fatal(~"binary float literal is not supported"),
|
||||||
|
_ => ()
|
||||||
|
}
|
||||||
|
}
|
||||||
match scan_exponent(rdr) {
|
match scan_exponent(rdr) {
|
||||||
Some(ref s) => {
|
Some(ref s) => {
|
||||||
is_float = true;
|
is_float = true;
|
||||||
|
18
src/test/compile-fail/no-binary-float-literal.rs
Normal file
18
src/test/compile-fail/no-binary-float-literal.rs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
// Copyright 2013 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 <LICENSE-APACHE or
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||||
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||||
|
// option. This file may not be copied, modified, or distributed
|
||||||
|
// except according to those terms.
|
||||||
|
|
||||||
|
// error-pattern:binary float literal is not supported
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
0b101010f;
|
||||||
|
0b101.010;
|
||||||
|
0b101p4f;
|
||||||
|
}
|
||||||
|
|
18
src/test/compile-fail/no-hex-float-literal.rs
Normal file
18
src/test/compile-fail/no-hex-float-literal.rs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
// Copyright 2013 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 <LICENSE-APACHE or
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||||
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||||
|
// option. This file may not be copied, modified, or distributed
|
||||||
|
// except according to those terms.
|
||||||
|
|
||||||
|
// error-pattern:hexadecimal float literal is not supported
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
0xABC.Df;
|
||||||
|
0x567.89;
|
||||||
|
0xDEAD.BEEFp-2f;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user