diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2013-05-10 18:19:58 -0700 |
|---|---|---|
| committer | Patrick Walton <pcwalton@mimiga.net> | 2013-05-12 16:35:19 -0700 |
| commit | db0693ac8d06202a289f451c223eb6f514819ffe (patch) | |
| tree | 62a37a5077065acb55755dd0a8a5b35dd258fcef /src/libcore | |
| parent | 5d3559e6455757c5508bba5b5add69477ebac53e (diff) | |
| download | rust-db0693ac8d06202a289f451c223eb6f514819ffe.tar.gz rust-db0693ac8d06202a289f451c223eb6f514819ffe.zip | |
libsyntax: Tighten up expressions in patterns to only allow identifiers or literals (possibly with a minus).
This had very minimal fallout.
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/num/strconv.rs | 10 | ||||
| -rw-r--r-- | src/libcore/unstable/extfmt.rs | 36 |
2 files changed, 23 insertions, 23 deletions
diff --git a/src/libcore/num/strconv.rs b/src/libcore/num/strconv.rs index c16a29f8295..052246a7744 100644 --- a/src/libcore/num/strconv.rs +++ b/src/libcore/num/strconv.rs @@ -486,11 +486,11 @@ pub fn from_str_bytes_common<T:NumCast+Zero+One+Eq+Ord+Copy+Div<T,T>+ } } - let (start, accum_positive) = match buf[0] { - '-' as u8 if !negative => return None, - '-' as u8 => (1u, false), - '+' as u8 => (1u, true), - _ => (0u, true) + let (start, accum_positive) = match buf[0] as char { + '-' if !negative => return None, + '-' => (1u, false), + '+' => (1u, true), + _ => (0u, true) }; // Initialize accumulator with signed zero for floating point parsing to diff --git a/src/libcore/unstable/extfmt.rs b/src/libcore/unstable/extfmt.rs index 258da9ff383..11ac8c14fe4 100644 --- a/src/libcore/unstable/extfmt.rs +++ b/src/libcore/unstable/extfmt.rs @@ -257,12 +257,12 @@ pub mod ct { let mut flags = ~[]; while i < lim { - let f = match s[i] { - '-' as u8 => FlagLeftJustify, - '0' as u8 => FlagLeftZeroPad, - ' ' as u8 => FlagSpaceForSign, - '+' as u8 => FlagSignAlways, - '#' as u8 => FlagAlternate, + let f = match s[i] as char { + '-' => FlagLeftJustify, + '0' => FlagLeftZeroPad, + ' ' => FlagSpaceForSign, + '+' => FlagSignAlways, + '#' => FlagAlternate, _ => break }; @@ -313,18 +313,18 @@ pub mod ct { // FIXME (#2249): Do we really want two signed types here? // How important is it to be printf compatible? - let t = match s[i] { - 'b' as u8 => TyBool, - 's' as u8 => TyStr, - 'c' as u8 => TyChar, - 'd' as u8 | 'i' as u8 => TyInt(Signed), - 'u' as u8 => TyInt(Unsigned), - 'x' as u8 => TyHex(CaseLower), - 'X' as u8 => TyHex(CaseUpper), - 't' as u8 => TyBits, - 'o' as u8 => TyOctal, - 'f' as u8 => TyFloat, - '?' as u8 => TyPoly, + let t = match s[i] as char { + 'b' => TyBool, + 's' => TyStr, + 'c' => TyChar, + 'd' | 'i' => TyInt(Signed), + 'u' => TyInt(Unsigned), + 'x' => TyHex(CaseLower), + 'X' => TyHex(CaseUpper), + 't' => TyBits, + 'o' => TyOctal, + 'f' => TyFloat, + '?' => TyPoly, _ => err(~"unknown type in conversion: " + s.substr(i, 1)) }; |
