about summary refs log tree commit diff
path: root/src/libsyntax/ext
diff options
context:
space:
mode:
authorAndrew Cann <shum@canndrew.org>2014-11-17 17:35:18 +0800
committerAndrew Cann <shum@canndrew.org>2014-11-17 17:35:18 +0800
commit197a0ac481ae6d154c0966b21849432f1b32c28f (patch)
tree05eaeb29b0d0a3dcff43b96f869d13a5b7fc9094 /src/libsyntax/ext
parent803aacd5aef78f90fdd06ae7653fc20eec224992 (diff)
downloadrust-197a0ac481ae6d154c0966b21849432f1b32c28f.tar.gz
rust-197a0ac481ae6d154c0966b21849432f1b32c28f.zip
change return type of slice_shift_char
`slice_shift_char` splits a `str` into it's leading `char` and the remainder
of the `str`. Currently, it returns a `(Option<char>, &str)` such that:

    "bar".slice_shift_char() => (Some('b'), "ar")
    "ar".slice_shift_char()  => (Some('a'), "r")
    "r".slice_shift_char()   => (Some('r'), "")
    "".slice_shift_char()    => (None,      "")

This is a little odd. Either a `str` can be split into both a head and a
tail or it cannot. So the return type should be `Option<(char, &str)>`.
With the current behaviour, in the case of the empty string, the `str`
returned is meaningless - it is always the empty string.

This commit changes slice_shift_char so that:

    "bar".slice_shift_char() => Some(('b', "ar"))
    "ar".slice_shift_char()  => Some(('a', "r"))
    "r".slice_shift_char()   => Some(('r', ""))
    "".slice_shift_char()    => None

[breaking-change]
Diffstat (limited to 'src/libsyntax/ext')
-rw-r--r--src/libsyntax/ext/asm.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/libsyntax/ext/asm.rs b/src/libsyntax/ext/asm.rs
index d57d6e52d7f..dc9e62cabff 100644
--- a/src/libsyntax/ext/asm.rs
+++ b/src/libsyntax/ext/asm.rs
@@ -96,8 +96,8 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
                     // cannot be shared with any other operand (usually when
                     // a register is clobbered early.)
                     let output = match constraint.get().slice_shift_char() {
-                        (Some('='), _) => None,
-                        (Some('+'), operand) => {
+                        Some(('=', _)) => None,
+                        Some(('+', operand)) => {
                             Some(token::intern_and_get_ident(format!(
                                         "={}",
                                         operand).as_slice()))