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

Non public QObject struct has non obvious error message #457

Closed
ahayzen-kdab opened this issue Mar 1, 2023 · 0 comments · Fixed by #458
Closed

Non public QObject struct has non obvious error message #457

ahayzen-kdab opened this issue Mar 1, 2023 · 0 comments · Fixed by #458
Assignees
Labels
🪲 bug Something isn't working 📖 documentation Improvements or additions to documentation

Comments

@ahayzen-kdab
Copy link
Collaborator

As part of looking into #38 I found that if you don't mark the QObject struct in Rust as public you get a non obvious warning.

[build] error[E0432]: unresolved import `super`
[build]   --> examples/qml_minimal/rust/src/cxxqt_object.rs:24:12
[build]    |
[build] 24 |     struct MyObject {
[build]    |            ^^^^^^^^ no `MyObject` in `cxxqt_object`
[build]    |
[build] help: consider importing this type alias instead
[build]    |
[build] 24 |     struct crate::cxxqt_object::qobject::MyObject;
[build]    |            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This happens because we put the QObject struct into a child module, then in the CXX module it has a type MyObject where it looks in the parent module for the QObject, but the import pub use self::cxx_qt_ffi::*; has failed to reexport the QObject as it was not public.

Our options seem to be

  • Fail in the parser if the QObject struct is not pub with a nicer error message (this is also potentially a candidate then to go into the checks phase (WIP: cxx-qt-gen: add checks phase #213) if we ever create it with the potential refactor of the parser phase to be a true syn Parse)
  • Implicitly mark all our QObject structs as pub even if the developer doesn't (might be odd?)
@ahayzen-kdab ahayzen-kdab added 🪲 bug Something isn't working 📖 documentation Improvements or additions to documentation labels Mar 1, 2023
@ahayzen-kdab ahayzen-kdab self-assigned this Mar 1, 2023
ahayzen-kdab added a commit to ahayzen-kdab/cxx-qt that referenced this issue Mar 1, 2023
Before this patch if you didn't mark a qobject struct as private
the following error would occur.

```
[build] error[E0432]: unresolved import `super`
[build]   --> examples/qml_minimal/rust/src/cxxqt_object.rs:24:12
[build]    |
[build] 24 |     struct MyObject {
[build]    |            ^^^^^^^^ no `MyObject` in `cxxqt_object`
[build]    |
[build] help: consider importing this type alias instead
[build]    |
[build] 24 |     struct crate::cxxqt_object::qobject::MyObject;
[build]    |            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```

After this patch the error is explicit.

```
[build] error: qobject marked structs must be public
[build]   --> examples/qml_minimal/rust/src/cxxqt_object.rs:24:5
[build]    |
[build] 24 |     struct MyObject {
[build]    |     ^^^^^^
```

Closes KDAB#457
ahayzen-kdab added a commit to ahayzen-kdab/cxx-qt that referenced this issue Mar 1, 2023
Before this patch if you didn't mark a qobject struct as private
the following error would occur.

```
[build] error[E0432]: unresolved import `super`
[build]   --> examples/qml_minimal/rust/src/cxxqt_object.rs:24:12
[build]    |
[build] 24 |     struct MyObject {
[build]    |            ^^^^^^^^ no `MyObject` in `cxxqt_object`
[build]    |
[build] help: consider importing this type alias instead
[build]    |
[build] 24 |     struct crate::cxxqt_object::qobject::MyObject;
[build]    |            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```

After this patch the error is explicit.

```
[build] error: qobject marked structs must be public
[build]   --> examples/qml_minimal/rust/src/cxxqt_object.rs:24:5
[build]    |
[build] 24 |     struct MyObject {
[build]    |     ^^^^^^
```

Closes KDAB#457
ahayzen-kdab added a commit to ahayzen-kdab/cxx-qt that referenced this issue Mar 2, 2023
Before this patch if you didn't mark a qobject struct as public
the following error would occur.

```
[build] error[E0432]: unresolved import `super`
[build]   --> examples/qml_minimal/rust/src/cxxqt_object.rs:24:12
[build]    |
[build] 24 |     struct MyObject {
[build]    |            ^^^^^^^^ no `MyObject` in `cxxqt_object`
[build]    |
[build] help: consider importing this type alias instead
[build]    |
[build] 24 |     struct crate::cxxqt_object::qobject::MyObject;
[build]    |            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```

After this patch the error is explicit.

```
[build] error: qobject marked structs must be public
[build]   --> examples/qml_minimal/rust/src/cxxqt_object.rs:24:5
[build]    |
[build] 24 |     struct MyObject {
[build]    |     ^^^^^^
```

Closes KDAB#457
ahayzen-kdab added a commit that referenced this issue Mar 2, 2023
Before this patch if you didn't mark a qobject struct as public
the following error would occur.

```
[build] error[E0432]: unresolved import `super`
[build]   --> examples/qml_minimal/rust/src/cxxqt_object.rs:24:12
[build]    |
[build] 24 |     struct MyObject {
[build]    |            ^^^^^^^^ no `MyObject` in `cxxqt_object`
[build]    |
[build] help: consider importing this type alias instead
[build]    |
[build] 24 |     struct crate::cxxqt_object::qobject::MyObject;
[build]    |            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```

After this patch the error is explicit.

```
[build] error: qobject marked structs must be public
[build]   --> examples/qml_minimal/rust/src/cxxqt_object.rs:24:5
[build]    |
[build] 24 |     struct MyObject {
[build]    |     ^^^^^^
```

Closes #457
przempore pushed a commit to przempore/cxx-qt that referenced this issue Mar 15, 2023
Before this patch if you didn't mark a qobject struct as public
the following error would occur.

```
[build] error[E0432]: unresolved import `super`
[build]   --> examples/qml_minimal/rust/src/cxxqt_object.rs:24:12
[build]    |
[build] 24 |     struct MyObject {
[build]    |            ^^^^^^^^ no `MyObject` in `cxxqt_object`
[build]    |
[build] help: consider importing this type alias instead
[build]    |
[build] 24 |     struct crate::cxxqt_object::qobject::MyObject;
[build]    |            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```

After this patch the error is explicit.

```
[build] error: qobject marked structs must be public
[build]   --> examples/qml_minimal/rust/src/cxxqt_object.rs:24:5
[build]    |
[build] 24 |     struct MyObject {
[build]    |     ^^^^^^
```

Closes KDAB#457
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🪲 bug Something isn't working 📖 documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant