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

Try passing uncopyable types by value #870

Closed
wants to merge 1 commit into from

Conversation

bsilver8192
Copy link
Contributor

It results in generated Rust code that doesn't compile. Not sure if
there's an easy fix, or if this would make more sense as copies of these
tests which are skipped. Also not sure if there's an existing bug that
is intended to include this one, or of it should be a new bug.

It results in generated Rust code that doesn't compile. Not sure if
there's an easy fix, or if this would make more sense as copies of these
tests which are skipped. Also not sure if there's an existing bug that
is intended to include this one, or of it should be a new bug.
@adetaylor
Copy link
Collaborator

I don't think you're quite right... the test is indeed failing, but the error I'm seeing is presented in the test code itself not in generated code:

error[E0277]: the trait bound `root::A: CopyNew` is not satisfied
 --> /var/folders/9l/cjqbc3ws3bxcjh6h2rykj90800m02d/T/.tmpCftczo/input.rs:1:247
  |
1 | ... . as_mut () . set (42) ; ffi :: take_a (& * stack_obj) ; } # [link (name = "autocxx-demo")] extern { }
  |                              -------------  ^^^^^^^^^^^^^ the trait `CopyNew` is not implemented for `root::A`
  |                              |
  |                              required by a bound introduced by this call
  |
  = note: required because of the requirements on the impl of `ValueParam<root::A>` for `&root::A`
note: required by a bound in `take_a`
 --> /var/folders/9l/cjqbc3ws3bxcjh6h2rykj90800m02d/T/.tmpgPCYdY/autocxx-ffi-default-gen.rs:1:1095
  |
1 | ...; 32] } pub fn take_a (a : impl autocxx :: ValueParam < root :: A >) { let mut a_space = autocxx :: ValueParamHandler :: new (a) ; let...
  |                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `take_a`

That's exactly saying "hey, you can't pass this here, because it doesn't have a copy constructor!" which is just the way it's supposed to work. What do you expect to see?

I do want us to be a bit more flexible here in what types of parameters we accept as value params, but I initially went for the conservative option in order to avoid too many merge conflicts with your work in #843. I just raised #873 to note future ambitions here.

@bsilver8192
Copy link
Contributor Author

You're right, ValueParam isn't implemented for that type, so never mind. Still something that'd be nice to support eventually. Thanks for waiting on #843, thinking about how they'll play together is why I came up with this.

@bsilver8192 bsilver8192 closed this Mar 3, 2022
@bsilver8192 bsilver8192 deleted the uncopyable-by-value branch March 13, 2022 04:55
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.

2 participants