Skip to content

Commit

Permalink
Use Span::mixed_site to avoid let unit warnings.
Browse files Browse the repository at this point in the history
Closes #2568.
  • Loading branch information
jieyouxu authored and SergioBenitez committed Oct 17, 2023
1 parent ac01e55 commit 07fe797
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 15 deletions.
2 changes: 1 addition & 1 deletion core/codegen/src/attribute/route/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ fn responder_outcome_expr(route: &Route) -> TokenStream {
.map(|a| quote_spanned!(a.span() => .await));

define_spanned_export!(ret_span => __req, _route);
quote_spanned! { ret_span =>
quote_spanned! { Span::mixed_site().located_at(ret_span) =>
let ___responder = #user_handler_fn_name(#(#parameter_names),*) #_await;
#_route::Outcome::from(#__req, ___responder)
}
Expand Down
7 changes: 3 additions & 4 deletions core/codegen/tests/ui-fail-nightly/async-entry.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,9 @@ error[E0308]: mismatched types
--> tests/ui-fail-nightly/async-entry.rs:24:21
|
24 | async fn main() {
| ^
| |
| _____________________expected `()` because of default return type
| |
| ____________________-^
| | |
| | expected `()` because of default return type
25 | | rocket::build()
26 | | }
| | ^- help: consider using a semicolon here: `;`
Expand Down
3 changes: 3 additions & 0 deletions core/codegen/tests/ui-fail-nightly/responder-types.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ note: required by a bound in `rocket::Response::<'r>::set_header`
error[E0277]: the trait bound `usize: Responder<'_, '_>` is not satisfied
--> tests/ui-fail-nightly/responder-types.rs:28:13
|
27 | #[get("/")]
| ----------- in this procedural macro expansion
28 | fn foo() -> usize { 0 }
| ^^^^^ the trait `Responder<'_, '_>` is not implemented for `usize`
|
Expand All @@ -122,3 +124,4 @@ note: required by a bound in `route::handler::<impl Outcome<rocket::Response<'o>
|
| pub fn from<R: Responder<'r, 'o>>(req: &'r Request<'_>, responder: R) -> Outcome<'r> {
| ^^^^^^^^^^^^^^^^^ required by this bound in `route::handler::<impl Outcome<Response<'o>, Status, (Data<'o>, Status)>>::from`
= note: this error originates in the attribute macro `get` (in Nightly builds, run with -Z macro-backtrace for more info)
16 changes: 8 additions & 8 deletions core/codegen/tests/ui-fail-stable/async-entry.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,14 @@ error[E0728]: `await` is only allowed inside `async` functions and blocks
73 | let _ = rocket::build().launch().await;
| ^^^^^ only allowed inside `async` functions and blocks

error[E0277]: `main` has invalid return type `Rocket<Build>`
--> tests/ui-fail-stable/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`

error[E0308]: mismatched types
--> tests/ui-fail-stable/async-entry.rs:35:9
|
Expand Down Expand Up @@ -165,11 +173,3 @@ error[E0308]: mismatched types
|
= note: expected struct `Rocket<Build>`
found struct `std::string::String`

error[E0277]: `main` has invalid return type `Rocket<Build>`
--> tests/ui-fail-stable/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`
2 changes: 1 addition & 1 deletion core/codegen/tests/ui-fail-stable/catch.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ note: function defined here
|
30 | fn f3(_request: &Request, other: bool) { }
| ^^ ------------------ -----------
help: did you mean
help: provide the argument
|
29 | f3(bool, /* bool */)
|
3 changes: 3 additions & 0 deletions core/codegen/tests/ui-fail-stable/responder-types.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ note: required by a bound in `rocket::Response::<'r>::set_header`
error[E0277]: the trait bound `usize: Responder<'_, '_>` is not satisfied
--> tests/ui-fail-stable/responder-types.rs:28:13
|
27 | #[get("/")]
| ----------- in this procedural macro expansion
28 | fn foo() -> usize { 0 }
| ^^^^^ the trait `Responder<'_, '_>` is not implemented for `usize`
|
Expand All @@ -122,3 +124,4 @@ note: required by a bound in `route::handler::<impl Outcome<rocket::Response<'o>
|
| pub fn from<R: Responder<'r, 'o>>(req: &'r Request<'_>, responder: R) -> Outcome<'r> {
| ^^^^^^^^^^^^^^^^^ required by this bound in `route::handler::<impl Outcome<Response<'o>, Status, (Data<'o>, Status)>>::from`
= note: this error originates in the attribute macro `get` (in Nightly builds, run with -Z macro-backtrace for more info)
2 changes: 1 addition & 1 deletion core/codegen/tests/ui-fail-stable/route-type-errors.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ error[E0277]: the trait bound `Q: FromData<'_>` is not satisfied
Cow<'_, str>
Capped<Cow<'_, str>>
Capped<Vec<u8>>
Capped<std::string::String>
Capped<TempFile<'_>>
Capped<std::string::String>
Capped<&'r str>
Capped<&'r RawStr>
and $N others
Expand Down

0 comments on commit 07fe797

Please sign in to comment.