-
-
Notifications
You must be signed in to change notification settings - Fork 237
Emit proper compile error while trying to #[export]
Gd<T>
or DynGd<T, D>
.
#1243
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
Conversation
API docs are being generated and will be shortly available at: https://godot-rust.github.io/docs/gdext/pr-1243 |
The result is very nice. But we should generally decide how much we want proc-macros to introspect concrete types, especially in cases where it's "only" informational. For example, initially removing Here, there's tiny small chance that the macro rejects valid code because other types happen to be named However, I also want to be careful about setting a precedent to do all sorts of validations on the proc-macro level.
That lint doesn't work for specific attempts ( |
Also clarified semantics in #1244. |
0366b05
to
8d2c975
Compare
Yeah, it irks me as well – I can't really say what (if anything) can go wrong and I would rather avoid something which might have weird side effects 🤔. It is also yet another thing which can go wrong or stop working during refactors or after heavier changes. I decided to add an extra note to Export diagnostic instead (shame we can't control types shown in second error[E0277]: `#[var]` properties require `Var` trait; #[export] ones require `Export` trait
--> src/lib.rs:16:20
|
16 | faulty_export: Gd<Node>,
| ^^^^^^^^ type cannot be used as a property
|
= help: the trait `Export` is not implemented for `godot::prelude::Gd<godot::prelude::Node>`
= note: see also: https://godot-rust.github.io/book/register/properties.html
= note: `Gd` and `DynGd` cannot be used directly as properties because they are non-nullable. In such a case use `OnEditor<T>` or `Option<T>` instead.
= help: the following other types implement trait `Export`:
Aabb
Array<DynGd<T, D>>
Array<T>
Array<godot::prelude::Gd<T>>
Basis
Color
Dictionary
GString
and 42 others |
The note is too long, it should ideally not need horizontal scrollbar here. Would it be possible to have = note: `Gd` and `DynGd` cannot be exported directly; wrap them in `Option<...>` or `OnEditor<...>`. |
…about `#[export]` of `Gd<T>` or `DynGd<T, D>`.
8d2c975
to
aaa823f
Compare
Changed; Aye, we don't have to be so mouthful after docs has been updated. |
Changes compile error from:
to:
in case if one tries to export non-nullable property such as:
I'm not sure if adding extra info/note to
diagnostic::on_unimplemented
wouldn't be better choice though 🤔. It doesn't seem to break or change anything 🤔 (checked with two medium-sized projects + our tests obviously).Gd<T>
couldn't be an#[export]
anyway, so 🤔It provides a bit better IDE experience (notes are omitted by Zed and RustRover):