Skip to content

Add dedicated error message referring to cxx::ExternType when opaque type is used by value#335

Merged
dtolnay merged 3 commits intomasterfrom
kind
Oct 4, 2020
Merged

Add dedicated error message referring to cxx::ExternType when opaque type is used by value#335
dtolnay merged 3 commits intomasterfrom
kind

Conversation

@dtolnay
Copy link
Owner

@dtolnay dtolnay commented Oct 4, 2020

The previous error of "error: passing non-trivial C++ type by value is not supported" was not sufficient to put someone on the right track of how to make their C++ type "trivial". The new error points to your type and very briefly explains what is needed and why, referring to cxx::ExternType where the documentation covers this use case in detail.

error: using opaque C++ type by value is not supported
 --> $DIR/by_value_not_supported.rs:3:16
  |
3 |     struct S { c: C }
  |                ^^^^

error: needs a cxx::ExternType impl in order to be used as a field of `S`
  --> $DIR/by_value_not_supported.rs:10:9
   |
10 |         type C;
   |         ^^^^^^

Follow-up to #325.

@dtolnay dtolnay merged commit 44198dd into master Oct 4, 2020
@dtolnay dtolnay deleted the kind branch October 4, 2020 04:19
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.

1 participant