godot_core/
lib.rs

1#![cfg_attr(published_docs, feature(doc_cfg))]
2/*
3 * Copyright (c) godot-rust; Bromeon and contributors.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at https://mozilla.org/MPL/2.0/.
7 */
8
9//! # Internal crate of [**godot-rust**](https://godot-rust.github.io)
10//!
11//! Do not depend on this crate directly, instead use the `godot` crate.
12//! No SemVer or other guarantees are provided.
13
14// Note that a lot of those are public, but the godot crate still has the final say on what it wants to re-export.
15// Doing fine-grained visibility restrictions on every level is a useless maintenance chore.
16pub mod builder;
17pub mod builtin;
18pub mod classes;
19#[cfg(all(since_api = "4.3", feature = "register-docs"))] #[cfg_attr(published_docs, doc(cfg(all(since_api = "4.3", feature = "register-docs"))))]
20pub mod docs;
21#[doc(hidden)]
22pub mod possibly_docs {
23    #[cfg(all(since_api = "4.3", feature = "register-docs"))] #[cfg_attr(published_docs, doc(cfg(all(since_api = "4.3", feature = "register-docs"))))]
24    pub use crate::docs::*;
25}
26pub mod global;
27pub mod init;
28pub mod meta;
29pub mod obj;
30pub mod registry;
31pub mod task;
32pub mod tools;
33
34mod storage;
35pub use godot_ffi as sys;
36
37pub use crate::private::{fetch_last_panic_context, set_gdext_hook};
38
39// ----------------------------------------------------------------------------------------------------------------------------------------------
40// Validations (see also godot/lib.rs)
41
42#[cfg(all(feature = "register-docs", before_api = "4.3"))] #[cfg_attr(published_docs, doc(cfg(all(feature = "register-docs", before_api = "4.3"))))]
43compile_error!("Generating editor docs for Rust symbols requires at least Godot 4.3.");
44
45// ----------------------------------------------------------------------------------------------------------------------------------------------
46// Generated code
47
48// Output of generated code. Mimics the file structure, symbols are re-exported.
49#[rustfmt::skip]
50#[allow(unused_imports, dead_code, non_upper_case_globals, non_snake_case)]
51#[allow(clippy::too_many_arguments, clippy::let_and_return, clippy::new_ret_no_self)]
52#[allow(clippy::let_unit_value)] // let args = ();
53#[allow(clippy::wrong_self_convention)] // to_string() is const
54#[allow(clippy::upper_case_acronyms)] // TODO remove this line once we transform names
55#[allow(clippy::needless_lifetimes)]  // the following explicit lifetimes could be elided: 'a
56#[allow(unreachable_code, clippy::unimplemented)] // TODO remove once #153 is implemented
57mod gen {
58    include!(concat!(env!("OUT_DIR"), "/mod.rs"));
59}
60
61// ----------------------------------------------------------------------------------------------------------------------------------------------
62// Hidden but accessible symbols
63
64/// Module which is used for deprecated warnings. It stays even if there is nothing currently deprecated.
65#[doc(hidden)]
66#[path = "deprecated.rs"]
67pub mod __deprecated;
68
69/// All internal machinery that is accessed by various gdext tools (e.g. proc macros).
70#[doc(hidden)]
71pub mod private;
72
73/// Re-export logging macro.
74#[doc(hidden)]
75pub use godot_ffi::out;
76
77// ----------------------------------------------------------------------------------------------------------------------------------------------
78
79/// Tests for code that must not compile.
80///
81/// To add a new one, simply add a new `__*` named function with a `compile_fail` doc attribute.
82mod no_compile_tests {
83    /// With Godot 4.6+, functions with required parameters accept `Gd<T>` instead of `Option<Gd<T>>`.
84    ///
85    /// ```compile_fail
86    /// use godot::prelude::*;
87    /// let mut node: Gd<Node> = unimplemented!();
88    /// let option = Some(node.clone());
89    /// let option: Option<&Gd<Node>> = option.as_ref();
90    ///
91    /// // Following must not compile since `add_child` accepts only required (non-null) arguments.
92    /// node.add_child(option);
93    /// ```
94    ///
95    /// Sanity check that without the last line, it _does_ compile. This catches any regressions in the previous statements that would not
96    /// be caught by the above `compile_fail` test.
97    /// ```no_run
98    /// use godot::prelude::*;
99    /// let mut node: Gd<Node> = unimplemented!();
100    /// let option = Some(node.clone());
101    /// let option: Option<&Gd<Node>> = option.as_ref();
102    /// ```
103    #[cfg(since_api = "4.6")] #[cfg_attr(published_docs, doc(cfg(since_api = "4.6")))]
104    fn __required_param_must_not_take_option() {}
105}