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 size_of_val and align_of_val const fns #50559

Closed
wants to merge 2 commits into from

Conversation

Gankra
Copy link
Contributor

@Gankra Gankra commented May 9, 2018

Closes #46571

@rust-highfive
Copy link
Collaborator

r? @Mark-Simulacrum

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 9, 2018
@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-3.9 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.

[00:04:50] travis_fold:start:tidy
travis_time:start:tidy
tidy check
[00:04:51] tidy error: /checkout/src/librustc_mir/transform/qualify_consts.rs:872: trailing whitespace
[00:04:51] tidy error: /checkout/src/librustc_mir/transform/qualify_consts.rs:873: trailing whitespace
[00:04:51] tidy error: /checkout/src/librustc_mir/transform/qualify_consts.rs:874: trailing whitespace
[00:04:52] some tidy checks failed
[00:04:52] 
[00:04:52] 
[00:04:52] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/tidy" "/checkout/src" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "--no-vendor" "--quiet"
[00:04:52] 
[00:04:52] 
[00:04:52] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/tools/tidy
[00:04:52] Build completed unsuccessfully in 0:01:59
[00:04:52] Build completed unsuccessfully in 0:01:59
[00:04:52] make: *** [tidy] Error 1
[00:04:52] Makefile:79: recipe for target 'tidy' failed

The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:1e0be218
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@@ -338,6 +338,34 @@ pub const fn size_of<T>() -> usize {
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
#[cfg(not(stage0))]
pub const fn size_of_val<T: ?Sized>(val: &T) -> usize {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want this PR to go through fast, you should be marking the function with #[rustc_const_unstable(feature = "const_size_of_val")] (and create a tracking issue)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@oli-obk const fn features have no tracking issues for now, unfortunately. See #44644.

assert_eq!(&EMPTY, b"");

// ~ one day ~
// static SIZE_OF_OWO_SLICE: usize = size_of_val(&OWO[..]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should be able to write

static FOO: &[u8] = &OWO;
static BAR: usize = size_of_val(FOO);

because coercions don't need method calls like slice indexing does

@kennytm
Copy link
Member

kennytm commented May 9, 2018

I've 👎'ed this PR due to #46571 (comment)

@oli-obk oli-obk added the T-lang Relevant to the language team, which will review and decide on the PR/issue. label May 9, 2018
@oli-obk
Copy link
Contributor

oli-obk commented May 9, 2018

tagging @rust-lang/lang because making this const fn would complicate future language changes.

@Gankra
Copy link
Contributor Author

Gankra commented May 9, 2018

Closing in favour of #50579 which I will use to make slice.len() const.

@Gankra Gankra closed this May 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-lang Relevant to the language team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants