Skip to content

Commit 1ac45eb

Browse files
authored
Merge branch 'master' into kate/rest-pattern-accessible-field
2 parents f843bc2 + 32e7d3f commit 1ac45eb

27 files changed

Lines changed: 774 additions & 128 deletions

‎.github/ISSUE_TEMPLATE/bug_report.yml‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ name: "Bug report 🐛"
22
description: Create a report to help us improve
33
labels: ["C-bug"]
44
body:
5+
- type: checkboxes
6+
attributes:
7+
label: Human words
8+
description: Communication between humans should be written by a human, not an LLM.
9+
options:
10+
- label: The words are written by a [human](https://seanmonstar.com/micro/20260729-i-want-your-own-words/).
511
- type: input
612
id: version
713
attributes:

‎.github/ISSUE_TEMPLATE/feature_request.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ assignees: ''
77

88
---
99

10+
**Are the words provided written by a human, not an LLM?**
11+
- [ ] The words have been written by a [human](https://seanmonstar.com/micro/20260729-i-want-your-own-words/).
12+
1013
**Is your feature request related to a problem? Please describe.**
1114
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
1215

‎.github/workflows/CI.yml‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -181,14 +181,12 @@ jobs:
181181
- uses: Swatinem/rust-cache@v2
182182

183183
- name: check --feature-powerset
184-
run: cargo hack --no-dev-deps check --feature-powerset --depth 2 --skip ffi,tracing
185-
env:
186-
RUSTFLAGS: "-D dead_code -D unused_imports"
184+
run: cargo hack --no-dev-deps check --feature-powerset --depth 2 --features __deny_warnings --skip ffi,tracing
187185

188186
- name: check --feature-powerset with tracing feature
189-
run: cargo hack --no-dev-deps check --feature-powerset --depth 2 --features tracing --skip ffi
187+
run: cargo hack --no-dev-deps check --feature-powerset --depth 2 --features tracing,__deny_warnings --skip ffi
190188
env:
191-
RUSTFLAGS: "--cfg hyper_unstable_tracing -D dead_code -D unused_imports"
189+
RUSTFLAGS: "--cfg hyper_unstable_tracing"
192190

193191
ffi:
194192
name: Test C API (FFI)

‎Cargo.toml‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ capi = []
9696
tracing = ["dep:tracing"]
9797

9898
# internal features used in CI
99+
__deny_warnings = []
99100
nightly = []
100101

101102
[lints.rust.unexpected_cfgs]
@@ -120,17 +121,13 @@ checked_conversions = "allow"
120121
else_if_without_else = "allow"
121122
float_arithmetic = "allow"
122123
indexing_slicing = "allow"
123-
let_unit_value = "allow"
124124
match_wild_err_arm = "allow"
125125
multiple_inherent_impl = "allow"
126126
multiple_unsafe_ops_per_block = "allow"
127127
needless_pass_by_value = "allow"
128128
pattern_type_mismatch = "allow"
129-
redundant_closure_for_method_calls = "allow"
130129
redundant_else = "allow"
131130
struct_excessive_bools = "allow" # TODO: bogus lint?
132-
trivially_copy_pass_by_ref = "allow"
133-
unnested_or_patterns = "allow"
134131
unused_async = "allow" # TODO: is it for API?
135132
unused_trait_names = "allow" # TODO: kinda annoying, but might be good to deny
136133
unwrap_in_result = "allow"

‎src/body/length.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ impl DecodedLength {
6868
))]
6969
pub(crate) fn sub_if(&mut self, amt: u64) {
7070
match self {
71-
&mut DecodedLength::CHUNKED | &mut DecodedLength::CLOSE_DELIMITED => (),
71+
&mut (DecodedLength::CHUNKED | DecodedLength::CLOSE_DELIMITED) => (),
7272
DecodedLength(known) => {
7373
*known -= amt;
7474
}
@@ -81,7 +81,7 @@ impl DecodedLength {
8181
///
8282
/// It would return false if "chunked" or otherwise size-unknown.
8383
#[cfg(all(any(feature = "client", feature = "server"), feature = "http2"))]
84-
pub(crate) fn is_exact(&self) -> bool {
84+
pub(crate) fn is_exact(self) -> bool {
8585
self.0 <= MAX_LEN
8686
}
8787
}

‎src/client/conn/http2.rs‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,11 @@ where
314314
}
315315
}
316316

317+
/// Returns the executor this builder was created with.
318+
pub fn executor(&self) -> &Ex {
319+
&self.exec
320+
}
321+
317322
/// Provide a timer to execute background HTTP2 tasks.
318323
pub fn timer<M>(&mut self, timer: M) -> &mut Builder<Ex>
319324
where

‎src/client/dispatch.rs‎

Lines changed: 26 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,16 @@ pub struct TrySendError<T> {
3030

3131
pub(crate) fn channel<T, U>() -> (Sender<T, U>, Receiver<T, U>) {
3232
let (tx, rx) = mpsc::unbounded_channel();
33-
let (giver, taker) = want::new();
34-
let tx = Sender {
35-
#[cfg(feature = "http1")]
36-
buffered_once: false,
37-
giver,
38-
inner: tx,
33+
let (giver, mut taker) = want::new();
34+
// Seed with one want so the first request can be sent before the
35+
// receiver is polled; every request must consume a want
36+
taker.want();
37+
let tx = Sender { giver, inner: tx };
38+
let rx = Receiver {
39+
inner: rx,
40+
taker,
41+
wanting: true,
3942
};
40-
let rx = Receiver { inner: rx, taker };
4143
(tx, rx)
4244
}
4345

@@ -46,17 +48,11 @@ pub(crate) fn channel<T, U>() -> (Sender<T, U>, Receiver<T, U>) {
4648
/// While the inner sender is unbounded, the Giver is used to determine
4749
/// if the Receiver is ready for another request.
4850
pub(crate) struct Sender<T, U> {
49-
/// One message is always allowed, even if the Receiver hasn't asked
50-
/// for it yet. This boolean keeps track of whether we've sent one
51-
/// without notice.
52-
#[cfg(feature = "http1")]
53-
buffered_once: bool,
54-
/// The Giver helps watch that the Receiver side has been polled
55-
/// when the queue is empty. This helps us know when a request and
56-
/// response have been fully processed, and a connection is ready
57-
/// for more.
51+
// Controls whether the sender is permitted to dispatch a request
52+
// Beyond the initial request, the Receiver only grants readiness once
53+
// the preceding request/response cycle has fully completed
5854
giver: want::Giver,
59-
/// Actually bounded by the Giver, plus `buffered_once`.
55+
// Capacity is enforced via the Giver
6056
inner: mpsc::UnboundedSender<Envelope<T, U>>,
6157
}
6258

@@ -89,23 +85,9 @@ impl<T, U> Sender<T, U> {
8985
self.giver.is_canceled()
9086
}
9187

92-
#[cfg(feature = "http1")]
93-
fn can_send(&mut self) -> bool {
94-
if self.giver.give() || !self.buffered_once {
95-
// If the receiver is ready *now*, then of course we can send.
96-
//
97-
// If the receiver isn't ready yet, but we don't have anything
98-
// in the channel yet, then allow one message.
99-
self.buffered_once = true;
100-
true
101-
} else {
102-
false
103-
}
104-
}
105-
10688
#[cfg(feature = "http1")]
10789
pub(crate) fn try_send(&mut self, val: T) -> Result<RetryPromise<T, U>, T> {
108-
if !self.can_send() {
90+
if !self.giver.give() {
10991
return Err(val);
11092
}
11193
let (tx, rx) = oneshot::channel();
@@ -117,7 +99,7 @@ impl<T, U> Sender<T, U> {
11799

118100
#[cfg(feature = "http1")]
119101
pub(crate) fn send(&mut self, val: T) -> Result<Promise<U>, T> {
120-
if !self.can_send() {
102+
if !self.giver.give() {
121103
return Err(val);
122104
}
123105
let (tx, rx) = oneshot::channel();
@@ -176,34 +158,33 @@ impl<T, U> Clone for UnboundedSender<T, U> {
176158
pub(crate) struct Receiver<T, U> {
177159
inner: mpsc::UnboundedReceiver<Envelope<T, U>>,
178160
taker: want::Taker,
161+
// Tracks whether readiness (`want`) has already been granted for the next request
162+
wanting: bool,
179163
}
180164

181165
impl<T, U> Receiver<T, U> {
182166
pub(crate) fn poll_recv(&mut self, cx: &mut Context<'_>) -> Poll<Option<(T, Callback<T, U>)>> {
167+
if !self.wanting {
168+
self.taker.want();
169+
self.wanting = true;
170+
}
183171
match self.inner.poll_recv(cx) {
184172
Poll::Ready(item) => {
185-
// A want signaled after finding the queue empty can land after
186-
// the Sender's `give()` for the message taken here, as can one
187-
// signaled on a coop-budget Pending with a message queued.
188-
// Withdraw it, or the Sender reports this connection as ready
189-
// while it is still serving this message.
190-
self.taker.unwant();
173+
self.wanting = false;
191174
Poll::Ready(item.map(|mut env| env.0.take().expect("envelope not dropped")))
192175
}
193-
Poll::Pending => {
194-
self.taker.want();
195-
Poll::Pending
196-
}
176+
// Avoid re-signaling `want` here: the sender might have already claimed it
177+
// and enqueued a request, even if polling the channel returns `Pending`
178+
// due to Tokio's coop budget exhaustion or a concurrent send
179+
Poll::Pending => Poll::Pending,
197180
}
198181
}
199182

200-
#[cfg(feature = "http1")]
201183
pub(crate) fn close(&mut self) {
202184
self.taker.cancel();
203185
self.inner.close();
204186
}
205187

206-
#[cfg(feature = "http1")]
207188
pub(crate) fn poll_close(&mut self, cx: &mut Context<'_>) -> Poll<()> {
208189
self.close();
209190
// A send that started before close may still be publishing its envelope.

‎src/common/buf.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ impl<T: Buf> BufList<T> {
2929
impl<T: Buf> Buf for BufList<T> {
3030
#[inline]
3131
fn remaining(&self) -> usize {
32-
self.bufs.iter().map(|buf| buf.remaining()).sum()
32+
self.bufs.iter().map(Buf::remaining).sum()
3333
}
3434

3535
#[inline]

‎src/error.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ impl Error {
193193
pub fn is_parse_too_large(&self) -> bool {
194194
matches!(
195195
self.inner.kind,
196-
Kind::Parse(Parse::TooLarge) | Kind::Parse(Parse::UriTooLong)
196+
Kind::Parse(Parse::TooLarge | Parse::UriTooLong)
197197
)
198198
}
199199

@@ -354,7 +354,7 @@ impl Error {
354354
// Find an h2::Reason somewhere in the cause stack, if it exists,
355355
// otherwise assume an INTERNAL_ERROR.
356356
self.find_source::<h2::Error>()
357-
.and_then(|h2_err| h2_err.reason())
357+
.and_then(h2::Error::reason)
358358
.unwrap_or(h2::Reason::INTERNAL_ERROR)
359359
}
360360

‎src/lib.rs‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
#![deny(missing_docs)]
22
#![deny(missing_debug_implementations)]
33
#![cfg_attr(test, deny(rust_2018_idioms))]
4-
#![cfg_attr(all(test, feature = "full"), deny(unreachable_pub))]
5-
#![cfg_attr(all(test, feature = "full"), deny(warnings))]
4+
#![cfg_attr(
5+
any(all(test, feature = "full"), feature = "__deny_warnings"),
6+
deny(warnings, unreachable_pub)
7+
)]
68
#![cfg_attr(all(test, feature = "nightly"), feature(test))]
79
#![cfg_attr(docsrs, feature(doc_cfg))]
810

0 commit comments

Comments
 (0)