From 07fe79796f058ab12683ff9e344558bece263274 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E6=9D=B0=E5=8F=8B=20Jieyou=20Xu=20=28Joe=29?= Date: Sun, 30 Jul 2023 21:32:05 +0800 Subject: [PATCH] Use Span::mixed_site to avoid let unit warnings. Closes #2568. --- core/codegen/src/attribute/route/mod.rs | 2 +- .../tests/ui-fail-nightly/async-entry.stderr | 7 +++---- .../tests/ui-fail-nightly/responder-types.stderr | 3 +++ .../tests/ui-fail-stable/async-entry.stderr | 16 ++++++++-------- core/codegen/tests/ui-fail-stable/catch.stderr | 2 +- .../tests/ui-fail-stable/responder-types.stderr | 3 +++ .../ui-fail-stable/route-type-errors.stderr | 2 +- 7 files changed, 20 insertions(+), 15 deletions(-) diff --git a/core/codegen/src/attribute/route/mod.rs b/core/codegen/src/attribute/route/mod.rs index 8003dda4..1079f306 100644 --- a/core/codegen/src/attribute/route/mod.rs +++ b/core/codegen/src/attribute/route/mod.rs @@ -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) } diff --git a/core/codegen/tests/ui-fail-nightly/async-entry.stderr b/core/codegen/tests/ui-fail-nightly/async-entry.stderr index 74374c65..f6acb157 100644 --- a/core/codegen/tests/ui-fail-nightly/async-entry.stderr +++ b/core/codegen/tests/ui-fail-nightly/async-entry.stderr @@ -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: `;` diff --git a/core/codegen/tests/ui-fail-nightly/responder-types.stderr b/core/codegen/tests/ui-fail-nightly/responder-types.stderr index 58956ef8..c54893bf 100644 --- a/core/codegen/tests/ui-fail-nightly/responder-types.stderr +++ b/core/codegen/tests/ui-fail-nightly/responder-types.stderr @@ -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` | @@ -122,3 +124,4 @@ note: required by a bound in `route::handler:: | | pub fn from>(req: &'r Request<'_>, responder: R) -> Outcome<'r> { | ^^^^^^^^^^^^^^^^^ required by this bound in `route::handler::, 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) diff --git a/core/codegen/tests/ui-fail-stable/async-entry.stderr b/core/codegen/tests/ui-fail-stable/async-entry.stderr index dbd9512c..d3ac4cc7 100644 --- a/core/codegen/tests/ui-fail-stable/async-entry.stderr +++ b/core/codegen/tests/ui-fail-stable/async-entry.stderr @@ -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` + --> tests/ui-fail-stable/async-entry.rs:94:20 + | +94 | async fn main() -> rocket::Rocket { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `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 | @@ -165,11 +173,3 @@ error[E0308]: mismatched types | = note: expected struct `Rocket` found struct `std::string::String` - -error[E0277]: `main` has invalid return type `Rocket` - --> tests/ui-fail-stable/async-entry.rs:94:20 - | -94 | async fn main() -> rocket::Rocket { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `main` can only return types that implement `Termination` - | - = help: consider using `()`, or a `Result` diff --git a/core/codegen/tests/ui-fail-stable/catch.stderr b/core/codegen/tests/ui-fail-stable/catch.stderr index 49ded6be..fdb47184 100644 --- a/core/codegen/tests/ui-fail-stable/catch.stderr +++ b/core/codegen/tests/ui-fail-stable/catch.stderr @@ -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 */) | diff --git a/core/codegen/tests/ui-fail-stable/responder-types.stderr b/core/codegen/tests/ui-fail-stable/responder-types.stderr index 1ee3af24..2526127e 100644 --- a/core/codegen/tests/ui-fail-stable/responder-types.stderr +++ b/core/codegen/tests/ui-fail-stable/responder-types.stderr @@ -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` | @@ -122,3 +124,4 @@ note: required by a bound in `route::handler:: | | pub fn from>(req: &'r Request<'_>, responder: R) -> Outcome<'r> { | ^^^^^^^^^^^^^^^^^ required by this bound in `route::handler::, 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) diff --git a/core/codegen/tests/ui-fail-stable/route-type-errors.stderr b/core/codegen/tests/ui-fail-stable/route-type-errors.stderr index 40dd0d27..dbde5a88 100644 --- a/core/codegen/tests/ui-fail-stable/route-type-errors.stderr +++ b/core/codegen/tests/ui-fail-stable/route-type-errors.stderr @@ -74,8 +74,8 @@ error[E0277]: the trait bound `Q: FromData<'_>` is not satisfied Cow<'_, str> Capped> Capped> - Capped Capped> + Capped Capped<&'r str> Capped<&'r RawStr> and $N others