Stabilize const for integer {to,from}_{be,le,ne}_bytes methods by tspiteri · Pull Request #69373 · rust-lang/rust (original) (raw)

Conversation

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})

tspiteri

@jonas-schievink jonas-schievink added relnotes

Marks issues that should be documented in the release notes of the next release.

T-libs-api

Relevant to the library API team, which will review and decide on the PR/issue.

labels

Feb 22, 2020

@tspiteri

All of these functions can be implemented simply and naturally as const functions, e.g. u32::from_le_bytes can be implemented as

(bytes[0] as u32)
    | (bytes[1] as u32) << 8
    | (bytes[2] as u32) << 16
    | (bytes[3] as u32) << 24

So stabilizing the constness will not expose that internally they are implemented using transmute which is not const in stable.

@kennytm kennytm added the needs-fcp

This change is insta-stable, so needs a completed FCP to proceed.

label

Feb 23, 2020

@rfcbot rfcbot added the final-comment-period

In the final comment period and will be merged soon unless new substantive objections are raised.

label

Feb 23, 2020

@bors bors added S-waiting-on-bors

Status: Waiting on bors to run and complete tests. Bors will change the label on completion.

and removed S-waiting-on-review

Status: Awaiting review from the assignee but also interested parties.

labels

Mar 10, 2020

Centril added a commit to Centril/rust that referenced this pull request

Mar 11, 2020

@Centril

…i-obk

Stabilize const for integer {to,from}_{be,le,ne}_bytes methods

All of these functions can be implemented simply and naturally as const functions, e.g. u32::from_le_bytes can be implemented as

(bytes[0] as u32)
    | (bytes[1] as u32) << 8
    | (bytes[2] as u32) << 16
    | (bytes[3] as u32) << 24

So stabilizing the constness will not expose that internally they are implemented using transmute which is not const in stable.

bors added a commit that referenced this pull request

Mar 11, 2020

@bors

Rollup of 10 pull requests

Successful merges:

Failed merges:

r? @ghost

JohnTitor added a commit to JohnTitor/rust that referenced this pull request

Mar 13, 2020

@JohnTitor

…, r=dtolnay

Update stable-since version for const_int_conversion

Since rust-lang#69373 was not merged in time for 1.43.0 beta, update to since = "1.44.0".

netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this pull request

Jun 8, 2020

@he32

Pkgsrc changes:

Upstream changes:

Version 1.44.0 (2020-06-04)

Language

Syntax-only changes

#[cfg(FALSE)]
mod foo {
    mod bar {
        mod baz; // `foo/bar/baz.rs` doesn't exist, but no error!
    }
}

These are still rejected semantically, so you will likely receive an error but these changes can be seen and parsed by macros and conditional compilation.

Compiler

Libraries

Stabilized APIs

Cargo

Misc

Compatibility Notes

Internal Only

These changes provide no direct user facing benefits, but represent significant improvements to the internals and overall performance of rustc and related tools.

netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this pull request

Jun 9, 2020

@alarixnia

Version 1.44.0 (2020-06-04)

Language

Syntax-only changes

#[cfg(FALSE)]
mod foo {
    mod bar {
        mod baz; // `foo/bar/baz.rs` doesn't exist, but no error!
    }
}

These are still rejected semantically, so you will likely receive an error but these changes can be seen and parsed by macros and conditional compilation.

Compiler

Libraries

Stabilized APIs

Cargo

Misc

Compatibility Notes

Internal Only

These changes provide no direct user facing benefits, but represent significant improvements to the internals and overall performance of rustc and related tools.

netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this pull request

Jul 6, 2020

@he32

Pkgsrc changes:

Upstream changes:

Version 1.44.0 (2020-06-04)

Language

Syntax-only changes

#[cfg(FALSE)]
mod foo {
    mod bar {
        mod baz; // `foo/bar/baz.rs` doesn't exist, but no error!
    }
}

These are still rejected semantically, so you will likely receive an error but these changes can be seen and parsed by macros and conditional compilation.

Compiler

Libraries

Stabilized APIs

Cargo

Misc

Compatibility Notes

Internal Only

These changes provide no direct user facing benefits, but represent significant improvements to the internals and overall performance of rustc and related tools.

JohnTitor added a commit to JohnTitor/rust that referenced this pull request

Aug 8, 2020

@JohnTitor

clean up const-hacks in int endianess conversion functions

Cleans up the const hacks added in rust-lang#69373.

r? @oli-obk