impl From<[T; N]> for Vec by jyn514 · Pull Request #68692 · rust-lang/rust (original) (raw)

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 andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation41 Commits9 Checks0 Files changed

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 }})

jyn514

ebkalderon, emmatyping, GrayJack, CGMossa, Kobzol, and JarvisCraft reacted with hooray emoji panaman67, slanterns, Aaron1011, lperlaki, betseg, DianaNites, emmatyping, jonhoo, CGMossa, IsakSundeSingh, and JarvisCraft reacted with heart emoji

@rust-highfive

r? @withoutboats

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

Centril

@Centril Centril added needs-fcp

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

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

Jan 31, 2020

@rust-highfive

This comment has been minimized.

tesuji

@rust-highfive

This comment has been minimized.

@jyn514

This is blocked on me getting stage1 to compile locally so I can mess with the test suite. It might be a couple days, I have a slow laptop and my fast computer runs alpine which doesn't work with proc-macros.

@jyn514

Didn't take as long as I thought, only an hour 😉 This is ready for review.

@rust-highfive

This comment has been minimized.

@jyn514

This comment has been minimized.

@jyn514

Is there anything I need to change? This has been sitting around for a little while...

Mark-Simulacrum

@Mark-Simulacrum

@withoutboats will need to take a look at this and decide whether to FCP merge it.

I think this is plausibly useful for a generic "takes impl Into<Vec<T>> type API, though mostly only because we lack impl IntoIterator<Item=T> on arrays. If we had that, it would be the "likely better" variant of this, I think, since APIs written to take iterators are much more flexible.

@jyn514

APIs written to take iterators are much more flexible.

In this case I did need an owned buffer, not just an Iterator. impl IntoIterator for arrays would definitely be useful, it just wouldn't have solved this particular problem: #67963

@Mark-Simulacrum

IntoIterator would let you collect into a vector, which in theory should be equally performant if you're starting out with a vector or array etc. Thought that may not be true today.

@jyn514

@withoutboats do you know when you will get a chance to look at this?

@Centril

LukasKalbertodt

Choose a reason for hiding this comment

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

Looks fine to me (apart from the two inline comments) and seems like a useful addition.

@rust-highfive

The job x86_64-gnu-llvm-7 of your PR failed (pretty log, 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.

2020-03-10T23:16:15.0738544Z ========================== Starting Command Output ===========================
2020-03-10T23:16:15.0743677Z [command]/bin/bash --noprofile --norc /home/vsts/work/_temp/ba6fa79a-18ca-446f-bb7d-1b8e88e4dbeb.sh
2020-03-10T23:16:15.0744207Z 
2020-03-10T23:16:15.0749598Z ##[section]Finishing: Disable git automatic line ending conversion
2020-03-10T23:16:15.0770358Z ##[section]Starting: Checkout rust-lang/rust@refs/pull/68692/merge to s
2020-03-10T23:16:15.0774055Z Task         : Get sources
2020-03-10T23:16:15.0774403Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
2020-03-10T23:16:15.0774717Z Version      : 1.0.0
2020-03-10T23:16:15.0774932Z Author       : Microsoft
---
2020-03-10T23:16:16.0619286Z ##[command]git remote add origin https://github.com/rust-lang/rust
2020-03-10T23:16:16.0624218Z ##[command]git config gc.auto 0
2020-03-10T23:16:16.0627657Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2020-03-10T23:16:16.0630834Z ##[command]git config --get-all http.proxy
2020-03-10T23:16:16.0637640Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/68692/merge:refs/remotes/pull/68692/merge
---
2020-03-10T23:22:35.6959411Z    Compiling serde_json v1.0.40
2020-03-10T23:22:37.3355995Z    Compiling tidy v0.1.0 (/checkout/src/tools/tidy)
2020-03-10T23:22:46.9968289Z     Finished release [optimized] target(s) in 1m 18s
2020-03-10T23:22:47.0078440Z tidy check
2020-03-10T23:22:47.9989104Z tidy error: /checkout/src/liballoc/vec.rs: too many lines (3003) (add `// ignore-tidy-filelength` to the file to suppress this error)
2020-03-10T23:22:49.6691518Z Found 489 error codes
2020-03-10T23:22:49.6691839Z Found 0 error codes with no tests
2020-03-10T23:22:49.6692061Z Done!
2020-03-10T23:22:49.6692302Z some tidy checks failed
2020-03-10T23:22:49.6692302Z some tidy checks failed
2020-03-10T23:22:49.6692466Z 
2020-03-10T23:22:49.6692579Z 
2020-03-10T23:22:49.6697696Z 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"
2020-03-10T23:22:49.6698601Z 
2020-03-10T23:22:49.6755551Z 
2020-03-10T23:22:49.6756002Z failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/tools/tidy
2020-03-10T23:22:49.6756418Z Build completed unsuccessfully in 0:01:30
2020-03-10T23:22:49.6756418Z Build completed unsuccessfully in 0:01:30
2020-03-10T23:22:49.6761819Z == clock drift check ==
2020-03-10T23:22:49.6771363Z   local time: Tue Mar 10 23:22:49 UTC 2020
2020-03-10T23:22:49.9651667Z   network time: Tue, 10 Mar 2020 23:22:49 GMT
2020-03-10T23:22:49.9654536Z == end clock drift check ==
2020-03-10T23:22:50.7935838Z 
2020-03-10T23:22:50.8026693Z ##[error]Bash exited with code '1'.
2020-03-10T23:22:50.8042965Z ##[section]Finishing: Run build
2020-03-10T23:22:50.8090972Z ##[section]Starting: Checkout rust-lang/rust@refs/pull/68692/merge to s
2020-03-10T23:22:50.8096311Z Task         : Get sources
2020-03-10T23:22:50.8096710Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
2020-03-10T23:22:50.8097077Z Version      : 1.0.0
2020-03-10T23:22:50.8097354Z Author       : Microsoft
2020-03-10T23:22:50.8097354Z Author       : Microsoft
2020-03-10T23:22:50.8097762Z Help         : [More Information](https://go.microsoft.com/fwlink/?LinkId=798199)
2020-03-10T23:22:50.8098231Z ==============================================================================
2020-03-10T23:22:51.1597397Z Cleaning any cached credential from repository: rust-lang/rust (GitHub)
2020-03-10T23:22:51.1655185Z ##[section]Finishing: Checkout rust-lang/rust@refs/pull/68692/merge to s
2020-03-10T23:22:51.1765133Z Cleaning up task key
2020-03-10T23:22:51.1766569Z Start cleaning up orphan processes.
2020-03-10T23:22:51.1975749Z Terminate orphan process: pid (4707) (python)
2020-03-10T23:22:51.2147267Z ##[section]Finishing: Finalize Job

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 @rust-lang/infra. (Feature Requests)

@jyn514

bors added a commit to rust-lang-ci/rust that referenced this pull request

Mar 29, 2020

@bors

Rollup of 3 pull requests

Successful merges:

Failed merges:

r? @ghost

@jyn514 jyn514 deleted the vec-from-array branch

March 29, 2020 12:59

pickfire

impl<T, const N: usize> From<[T; N]> for Vec
where
[T; N]: LengthAtMost32,
{

Choose a reason for hiding this comment

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

Any docs for this?

Choose a reason for hiding this comment

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

Does it need documentation? It looks pretty self-explanatory to me.

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

May 20, 2020

@pickfire

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

May 28, 2020

@JohnTitor

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

May 29, 2020

@RalfJung

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

May 29, 2020

@RalfJung

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

May 29, 2020

@RalfJung

Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request

May 29, 2020

@Dylan-DPC

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

May 29, 2020

@RalfJung

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.

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

Jul 28, 2020

@jyn514

x.py build/test: stage 1

I've seen very few people who actually use full stage 2 builds on purpose. These compile rustc and libstd twice and don't give you much more information than a stage 1 build (except in rare cases like rust-lang#68692 (comment)). For new contributors, this makes the build process even more daunting than it already is. As long as CI is changed to use --stage 2 I see no downside here.

x.py bench/dist/install: stage 2

These commands have to do with a finished, optimized version of rustc. It seems very rare to want to use these with a stage 1 build.

x.py doc: stage 0

Normally when you document things you're just fixing a typo. In this case there is no need to build the whole rust compiler, since the documentation will usually be the same when generated with the beta compiler or with stage 1.

Note that for this release cycle only there will be a significant different between stage0 and stage1 docs: rust-lang#73101. However most of the time this will not be the case.

branlwyd added a commit to divviup/janus that referenced this pull request

Oct 7, 2022

@branlwyd

Opinionated change: since Rust 1.44 [1], it has been possible to use Vec::from to write vector literals. On the idea that a method call is a simpler tool than a macro, prefer a method call. (Vec::new is also used, if the vector being created is empty.)

[1] rust-lang/rust#68692

branlwyd added a commit to divviup/janus that referenced this pull request

Oct 7, 2022

@branlwyd

Opinionated change: since Rust 1.44 [1], it has been possible to use Vec::from to write vector literals. On the idea that a method call is a simpler tool than a macro, prefer a method call. (Vec::new is also used, if the vector being created is empty.)

[1] rust-lang/rust#68692

Labels

disposition-merge

This issue / PR is in PFCP or FCP with a disposition to merge it.

finished-final-comment-period

The final comment period is finished for this PR / Issue.

relnotes

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

S-waiting-on-bors

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

T-libs-api

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