mirror of
https://github.com/rwf2/Rocket.git
synced 2025-01-09 11:09:08 +00:00
4f3511786c
The core 'Rocket' type is parameterized: 'Rocket<P: Phase>', where 'Phase' is a newly introduced, sealed marker trait. The trait is implemented by three new marker types representing the three launch phases: 'Build', 'Ignite', and 'Orbit'. Progression through these three phases, in order, is enforced, as are the invariants guaranteed by each phase. In particular, an instance of 'Rocket' is guaranteed to be in its final configuration after the 'Build' phase and represent a running local or public server in the 'Orbit' phase. The 'Ignite' phase serves as an intermediate, enabling inspection of a finalized but stationary instance. Transition between phases validates the invariants required by the transition. All APIs have been adjusted appropriately, requiring either an instance of 'Rocket' in a particular phase ('Rocket<Build>', 'Rocket<Ignite>', or 'Rocket<Orbit>') or operating generically on a 'Rocket<P>'. Documentation is also updated and substantially improved to mention required and guaranteed invariants. Additionally, this commit makes the following relevant changes: * 'Rocket::ignite()' is now a public interface. * 'Rocket::{build,custom}' methods can no longer panic. * 'Launch' fairings are now 'ignite' fairings. * 'Liftoff' fairings are always run, even in local mode. * All 'ignite' fairings run concurrently at ignition. * Launch logging occurs on launch, not any point prior. * Launch log messages have improved formatting. * A new launch error kind, 'Config', was added. * A 'fairing::Result' type alias was introduced. * 'Shutdown::shutdown()' is now 'Shutdown::notify()'. Some internal changes were also introduced: * Fairing 'Info' name for 'Templates' is now 'Templating'. * Shutdown is implemented using 'tokio::sync::Notify'. * 'Client::debug()' is used nearly universally in tests. Resolves #1154. Resolves #1136.
163 lines
4.9 KiB
Plaintext
163 lines
4.9 KiB
Plaintext
error: attribute can only be applied to `async` functions
|
|
--> $DIR/async-entry.rs:4:5
|
|
|
|
|
4 | #[rocket::main]
|
|
| ^^^^^^^^^^^^^^^
|
|
|
|
|
= note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
|
|
|
error: [note] this function must be `async`
|
|
--> $DIR/async-entry.rs:5:5
|
|
|
|
|
5 | fn foo() { }
|
|
| ^^
|
|
|
|
error: attribute can only be applied to `async` functions
|
|
--> $DIR/async-entry.rs:16:5
|
|
|
|
|
16 | #[rocket::main]
|
|
| ^^^^^^^^^^^^^^^
|
|
|
|
|
= note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
|
|
|
error: [note] this function must be `async`
|
|
--> $DIR/async-entry.rs:17:5
|
|
|
|
|
17 | fn main() {
|
|
| ^^
|
|
|
|
error: attribute cannot be applied to `main` function
|
|
--- note: this attribute generates a `main` function
|
|
--> $DIR/async-entry.rs:49:5
|
|
|
|
|
49 | #[rocket::launch]
|
|
| ^^^^^^^^^^^^^^^^^
|
|
|
|
|
= note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
|
|
|
error: [note] this function cannot be `main`
|
|
--> $DIR/async-entry.rs:50:8
|
|
|
|
|
50 | fn main() -> rocekt::Rocket<rocket::Build> {
|
|
| ^^^^
|
|
|
|
error: attribute can only be applied to functions that return a value
|
|
--> $DIR/async-entry.rs:56:5
|
|
|
|
|
56 | #[rocket::launch]
|
|
| ^^^^^^^^^^^^^^^^^
|
|
|
|
|
= note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
|
|
|
error: [note] this function must return a value
|
|
--> $DIR/async-entry.rs:57:5
|
|
|
|
|
57 | async fn rocket() {
|
|
| ^^^^^
|
|
|
|
error: attribute can only be applied to functions that return a value
|
|
--> $DIR/async-entry.rs:64:5
|
|
|
|
|
64 | #[rocket::launch]
|
|
| ^^^^^^^^^^^^^^^^^
|
|
|
|
|
= note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
|
|
|
error: [note] this function must return a value
|
|
--> $DIR/async-entry.rs:65:5
|
|
|
|
|
65 | fn rocket() {
|
|
| ^^
|
|
|
|
error: attribute cannot be applied to `main` function
|
|
--- note: this attribute generates a `main` function
|
|
--> $DIR/async-entry.rs:79:5
|
|
|
|
|
79 | #[rocket::launch]
|
|
| ^^^^^^^^^^^^^^^^^
|
|
|
|
|
= note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
|
|
|
error: [note] this function cannot be `main`
|
|
--> $DIR/async-entry.rs:80:8
|
|
|
|
|
80 | fn main() -> &'static str {
|
|
| ^^^^
|
|
|
|
error: attribute cannot be applied to `main` function
|
|
--- note: this attribute generates a `main` function
|
|
--> $DIR/async-entry.rs:87:5
|
|
|
|
|
87 | #[rocket::launch]
|
|
| ^^^^^^^^^^^^^^^^^
|
|
|
|
|
= note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
|
|
|
error: [note] this function cannot be `main`
|
|
--> $DIR/async-entry.rs:88:14
|
|
|
|
|
88 | async fn main() -> _ {
|
|
| ^^^^
|
|
|
|
error[E0728]: `await` is only allowed inside `async` functions and blocks
|
|
--> $DIR/async-entry.rs:73:17
|
|
|
|
|
72 | fn rocket() -> _ {
|
|
| ------ this is not `async`
|
|
73 | let _ = rocket::build().launch().await;
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ only allowed inside `async` functions and blocks
|
|
|
|
error[E0308]: mismatched types
|
|
--> $DIR/async-entry.rs:35:9
|
|
|
|
|
35 | rocket::build()
|
|
| ^^^^^^^^^^^^^^^ expected struct `std::string::String`, found struct `Rocket`
|
|
|
|
|
= note: expected struct `std::string::String`
|
|
found struct `Rocket<Build>`
|
|
|
|
error[E0308]: mismatched types
|
|
--> $DIR/async-entry.rs:44:9
|
|
|
|
|
44 | "hi".to_string()
|
|
| ^^^^^^^^^^^^^^^^ expected struct `Rocket`, found struct `std::string::String`
|
|
|
|
|
= note: expected struct `Rocket<Build>`
|
|
found struct `std::string::String`
|
|
|
|
error[E0308]: mismatched types
|
|
--> $DIR/async-entry.rs:24:21
|
|
|
|
|
24 | async fn main() {
|
|
| ^ expected `()` because of default return type
|
|
| _____________________|
|
|
| |
|
|
25 | | rocket::build()
|
|
26 | | }
|
|
| | ^- help: try adding a semicolon: `;`
|
|
| |_____|
|
|
| expected `()`, found struct `Rocket`
|
|
|
|
|
= note: expected unit type `()`
|
|
found struct `Rocket<Build>`
|
|
|
|
error[E0308]: mismatched types
|
|
--> $DIR/async-entry.rs:33:26
|
|
|
|
|
33 | async fn rocket() -> String {
|
|
| ^^^^^^
|
|
| |
|
|
| expected struct `Rocket`, found struct `std::string::String`
|
|
| expected due to this
|
|
|
|
|
= note: expected struct `Rocket<Build>`
|
|
found struct `std::string::String`
|
|
|
|
error[E0277]: `main` has invalid return type `Rocket<Build>`
|
|
--> $DIR/async-entry.rs:94:20
|
|
|
|
|
94 | async fn main() -> rocket::Rocket<rocket::Build> {
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `main` can only return types that implement `Termination`
|
|
|
|
|
= help: consider using `()`, or a `Result`
|