Skip to content

Commit

Permalink
Fix type confusion in some scenarios (#3348)
Browse files Browse the repository at this point in the history
* Fix type confusion in some scenarios

When the feature for rustls 0.22 is enabled, and rustls 0.23 is also
present in a project, there suddently exist multiple paths for errors
when building middleware chains due to the use of two consecutive `?`
operators without specifying the intermediate error type.

This commit addresses the issue by removing the first `?`, so that the
first error type will always be known, and the second `?` always has a
well defined implementation.

* Add CHANGES entry about type confusion

---------

Co-authored-by: Rob Ede <robjtede@icloud.com>
  • Loading branch information
asonix and robjtede committed May 14, 2024
1 parent 3c9a930 commit 33c47c0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions actix-web/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
### Changed

- Minimum supported Rust version (MSRV) is now 1.72.
- Avoid type confusion in rare circumstances

## 4.5.1

Expand Down
5 changes: 3 additions & 2 deletions actix-web/src/app_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,9 @@ impl ServiceFactory<ServiceRequest> for AppRoutingFactory {
let guards = guards.borrow_mut().take().unwrap_or_default();
let factory_fut = factory.new_service(());
async move {
let service = factory_fut.await?;
Ok((path, guards, service))
factory_fut
.await
.map(move |service| (path, guards, service))
}
}));

Expand Down
5 changes: 3 additions & 2 deletions actix-web/src/scope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -470,8 +470,9 @@ impl ServiceFactory<ServiceRequest> for ScopeFactory {
let guards = guards.borrow_mut().take().unwrap_or_default();
let factory_fut = factory.new_service(());
async move {
let service = factory_fut.await?;
Ok((path, guards, service))
factory_fut
.await
.map(move |service| (path, guards, service))
}
}));

Expand Down

0 comments on commit 33c47c0

Please sign in to comment.