Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make bytes!() return 'static #14275

Merged
merged 1 commit into from
May 18, 2014
Merged

Conversation

lilyball
Copy link
Contributor

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.

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 rust-lang#14183 fixed it so blocks are now allowed in constant expressions
(with restrictions).

Fixes rust-lang#11641.
bors added a commit that referenced this pull request May 18, 2014
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.
@bors bors closed this May 18, 2014
@bors bors merged commit bcabcf5 into rust-lang:master May 18, 2014
@lilyball lilyball deleted the bytes-return-static branch May 18, 2014 23:15
lnicola pushed a commit to lnicola/rust that referenced this pull request Mar 13, 2023
bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 5, 2023
MIR episode 4

In lowering, it now supports overloaded and arith assignment binary operators, statics. and constants in patterns. There is now 252 functions that we fail to emit mir for them, and the majority of them are due type mismatches or other deep and unrelated issues (but it isn't done yet, for example slice patterns and destructing assignment is not implemented yet).

In evaluating, it now can evaluate associated constants in traits (so now typenum's `U5::ToConst` should work), allocator functions, atomic intrinsics, and some more things. It also provides a (hacky) basis for making progress in rust-lang#14275. I also added a `Interpret` code lens to `Run` and `Debug` when the experimental `interpret tests` is enabled (previously it showed result in hover, which was unusable even for debugging)

Changes in unrelated files are:
* Changes substitutions of closures, now it includes parent substs ~~before~~ after `sig_ty`.
* ~~A salsa input for retrieving the path of a file id, used in emitting stack trace for interpret result.~~
* Normalizing associated types in layout computing
bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 5, 2023
Lazy evaluate consts in `path_to_const`

fix rust-lang#14275
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bytes!() is now hard to use in a lot of cases due to lifetime issues
2 participants