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

refactor(core): make borrow_mut more explicit in the ops macro #16025

Merged
merged 3 commits into from
Oct 16, 2022

Conversation

MarinPostma
Copy link
Contributor

This PR fixes a potentially hard to debug compilation failure in the case where std::borrow::BorrowMut is in scope when ops are defined:

use std::borrow::BorrowMut;

//later

#[deno_core::op]
fn my_op(state: &mut deno_core::OpState) //...

This will refuse to compile because Rc::borrow_mut gets called instead of RefCell::borrow_mut on Rc<RefCell<OpState>> in the generated macro code.

see also: rust-lang/rust#39232

@CLAassistant
Copy link

CLAassistant commented Sep 26, 2022

CLA assistant check
All committers have signed the CLA.

@MarinPostma MarinPostma marked this pull request as ready for review September 26, 2022 10:52
Copy link
Member

@littledivy littledivy left a comment

Choose a reason for hiding this comment

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

Thanks for the PR. Maybe std::cell::RefCell::borrow_mut(&ctx.state) is better / more explicit?

@MarinPostma
Copy link
Contributor Author

Fair, let me change that

@MarinPostma MarinPostma force-pushed the fix-ops-borrow-mut branch 2 times, most recently from b9a0e92 to e9f86f1 Compare September 27, 2022 13:14
@bartlomieju
Copy link
Member

@littledivy please take a look

Copy link
Member

@littledivy littledivy left a comment

Choose a reason for hiding this comment

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

LGTM, thank you

@bartlomieju bartlomieju changed the title fix(deno_core): make borrow_mut more explicit in the ops macro refactor(core): make borrow_mut more explicit in the ops macro Oct 16, 2022
@bartlomieju bartlomieju merged commit 07213de into denoland:main Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants