Skip to content

Conversation

ken-matsui
Copy link
Contributor

@ken-matsui ken-matsui commented Nov 13, 2021

This PR provides a suggestion to wrap the inner types in tuple when being along with 'allocator_api'.

Closes #83250

fn main() {
    let _vec: Vec<u8, _> = vec![]; //~ ERROR use of unstable library feature 'allocator_api'
}
 error[E0658]: use of unstable library feature 'allocator_api'
   --> $DIR/suggest-vec-allocator-api.rs:2:23
    |
 LL |     let _vec: Vec<u8, _> = vec![];
-   |                       ^
+   |                   ----^
+   |                   |
+   |                   help: consider wrapping the inner types in tuple: `(u8, _)`
    |
    = note: see issue #32838 <https://github.com/rust-lang/rust/issues/32838> for more information
    = help: add `#![feature(allocator_api)]` to the crate attributes to enable

@rust-highfive
Copy link
Contributor

r? @davidtwco

(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 Nov 13, 2021
@leonardo-m
Copy link

leonardo-m commented Nov 13, 2021

I don't understand what it's suggesting. Perhaps to replace Vec<u8, _> with Vec<u8, (_, _)> ?

@fbstj
Copy link
Contributor

fbstj commented Nov 13, 2021

I don't understand what it's suggesting. Perhaps to replace Vec<u8, _> with Vec<u8, (_, _)> ?

looking at #83250 makes it more obvious that it is suggesting Vec<(u8, _)>; ie not passing anything as the second (allocator) type to avoid the alocator_api entirely. maybe the generated help: should attempt to represent the expected output rather than the <(_,_)> which is confusing

@davidtwco davidtwco added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 15, 2021
Copy link
Member

@davidtwco davidtwco left a comment

Choose a reason for hiding this comment

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

This is looking much better, thanks for addressing those comments, a few more changes.

@rust-log-analyzer

This comment has been minimized.

@ken-matsui ken-matsui changed the title Suggestion to wrap Vec using 'allocator_api' in tuple Suggestion to wrap inner types using 'allocator_api' in tuple Nov 16, 2021
@apiraino apiraino added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Nov 18, 2021
Copy link
Member

@davidtwco davidtwco left a comment

Choose a reason for hiding this comment

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

Looks good, thanks for your work on this.

@davidtwco
Copy link
Member

@bors r+

@bors
Copy link
Collaborator

bors commented Nov 23, 2021

📌 Commit 57494f7 has been approved by davidtwco

@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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 23, 2021
bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 23, 2021
…askrgr

Rollup of 6 pull requests

Successful merges:

 - rust-lang#90856 (Suggestion to wrap inner types using 'allocator_api' in tuple)
 - rust-lang#91103 (Inhibit clicks on summary's children)
 - rust-lang#91137 (Give people a single link they can click in the contributing guide)
 - rust-lang#91140 (Split inline const to two feature gates and mark expression position inline const complete)
 - rust-lang#91148 (Use `derive_default_enum` in the compiler)
 - rust-lang#91153 (kernel_copy: avoid panic on unexpected OS error)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 68a44c8 into rust-lang:master Nov 23, 2021
@rustbot rustbot added this to the 1.58.0 milestone Nov 23, 2021
@ken-matsui ken-matsui deleted the suggestion-to-wrap-vec-allocator-api-in-tuple branch November 24, 2021 03:56
@damccull
Copy link

Awesome. Thanks for getting to this even before I found out lol. Rust team is awesome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Hint for Vec<String, String>
10 participants