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

Suggestion to wrap inner types using 'allocator_api' in tuple #90856

Merged
merged 1 commit into from
Nov 23, 2021
Merged

Suggestion to wrap inner types using 'allocator_api' in tuple #90856

merged 1 commit into from
Nov 23, 2021

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
Collaborator

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

compiler/rustc_middle/src/middle/stability.rs Outdated Show resolved Hide resolved
compiler/rustc_middle/src/middle/stability.rs Outdated Show resolved Hide resolved
compiler/rustc_middle/src/middle/stability.rs Outdated Show resolved Hide resolved
@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.

compiler/rustc_middle/src/middle/stability.rs Outdated Show resolved Hide resolved
compiler/rustc_middle/src/middle/stability.rs Show resolved Hide resolved
compiler/rustc_middle/src/middle/stability.rs Outdated Show resolved Hide resolved
@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
Contributor

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