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

Turn alloc's force_expr macro into a regular macro_rules. #81241

Merged
merged 2 commits into from
Jan 22, 2021

Conversation

m-ou-se
Copy link
Member

@m-ou-se m-ou-se commented Jan 21, 2021

This turns alloc's force_expr macro into a regular macro_rules.

Otherwise rust-analyzer doesn't understand vec![]. See rust-lang/rust-analyzer#7349 and #81080 (comment)

Edit: See #81241 (comment) for a discussion of alternatives.

@m-ou-se m-ou-se added T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. S-experimental Status: Ongoing experiment that does not require reviewing and won't be merged in its current state. labels Jan 21, 2021
@jonas-schievink
Copy link
Contributor

Why not give it a more complicated name, like __rustc_force_expr?

@m-ou-se
Copy link
Member Author

m-ou-se commented Jan 21, 2021

Sure, that makes a collision less likely, but we don't have any identifiers guaranteed to be reserved for the language/library implementation like C and C++ have. But yeah, if we can't find a better way, we should probably do that.

@estebank
Copy link
Contributor

Sure, that makes a collision less likely, but we don't have any identifiers guaranteed to be reserved for the language/library implementation

That's not something that we can do anything about today and the "namespaced" name coupled with its inherent uselessness for anything beyond improving diagnostics makes the likelihood of this being a problem low. I am more concerned about not being able to remove this ever, so lets pick a name we can live with.

@m-ou-se
Copy link
Member Author

m-ou-se commented Jan 21, 2021

So our options seem to be:

If these are our only options, the change in this PR seems like the best way forward for now (with a prefix as suggested in #81241 (comment)). If some kind of #[macro_only_in_expr_position] ever gets implemented, we should update vec![] to use that instead.

I'll update this PR and mark it as ready for review.

@m-ou-se m-ou-se added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-experimental Status: Ongoing experiment that does not require reviewing and won't be merged in its current state. labels Jan 21, 2021
@m-ou-se m-ou-se marked this pull request as ready for review January 21, 2021 17:33
@m-ou-se
Copy link
Member Author

m-ou-se commented Jan 21, 2021

r? @oli-obk

@bugadani
Copy link
Contributor

I am more concerned about not being able to remove this ever, so lets pick a name we can live with.

Hm, if the removal of an otherwise hidden macro is a concern, we can revert #81080 and reintroduce in its current form once rust-analyzer can handle pub macro.

@oli-obk
Copy link
Contributor

oli-obk commented Jan 22, 2021

I don't see how removing this (unstable!) macro could be a breaking change, so...

@bors r+

@bors
Copy link
Contributor

bors commented Jan 22, 2021

📌 Commit 1934eaf has been approved by oli-obk

@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 Jan 22, 2021
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 22, 2021
Rollup of 10 pull requests

Successful merges:

 - rust-lang#80573 (Deny rustc::internal lints for rustdoc and clippy)
 - rust-lang#81173 (Expand docs on Iterator::intersperse)
 - rust-lang#81194 (Stabilize std::panic::panic_any.)
 - rust-lang#81202 (Don't prefix 0x for each segments in `dbg!(Ipv6)`)
 - rust-lang#81225 (Make 'docs' nullable in rustdoc-json output)
 - rust-lang#81227 (Remove doctree::StructType)
 - rust-lang#81233 (Document why not use concat! in dbg! macro)
 - rust-lang#81236 (Gracefully handle loop labels missing leading `'` in different positions)
 - rust-lang#81241 (Turn alloc's force_expr macro into a regular macro_rules.)
 - rust-lang#81242 (Enforce statically that `MIN_NON_ZERO_CAP` is calculated at compile time)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 70597f2 into rust-lang:master Jan 22, 2021
@rustbot rustbot added this to the 1.51.0 milestone Jan 22, 2021
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-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants