]> git.lizzy.rs Git - rust.git/commit
Make bytes!() return 'static
authorKevin Ballard <kevin@sb.org>
Sat, 18 Jan 2014 06:30:36 +0000 (22:30 -0800)
committerKevin Ballard <kevin@sb.org>
Sun, 18 May 2014 20:03:38 +0000 (13:03 -0700)
commitbcabcf53cfe2a86ebf02aa762b8ab7278060ce10
tree5a0ce4fec2100f41123572573abfde840bc1b2f3
parent134f797a6309e8f284372c745689bcde17829c30
Make bytes!() return 'static

Change `bytes!()` to return

    {
        static BYTES: &'static [u8] = &[...];
        BYTES
    }

This gives it the `'static` lifetime, whereas before it had an rvalue
lifetime. Until recently this would have prevented assigning `bytes!()`
to a static, as in

    static FOO: &'static [u8] = bytes!(1,2,3);

but #14183 fixed it so blocks are now allowed in constant expressions
(with restrictions).

Fixes #11641.
src/libsyntax/ext/bytes.rs
src/test/run-pass/bytes-macro-static.rs [new file with mode: 0644]