Skip to content

refactor(error/upgrade): move from the use of ref patterns to & and remove allow for lint ref_patterns - #4141

Open
logan-bobo wants to merge 10 commits into
hyperium:masterfrom
logan-bobo:master
Open

refactor(error/upgrade): move from the use of ref patterns to & and remove allow for lint ref_patterns#4141
logan-bobo wants to merge 10 commits into
hyperium:masterfrom
logan-bobo:master

Conversation

@logan-bobo

@logan-bobo logan-bobo commented Aug 1, 2026

Copy link
Copy Markdown

This PR aims to

  • Remove allow for ref_patterns lint, that will now be caught by a warn on restriction
restriction = { level = "warn", priority = -2 }
  • Move from the use of ref patterns to &

References

progresses #4071

@logan-bobo logan-bobo changed the title refactor(error/upgrade): move from the use of ref patterns to & and remove allow for lint ref_patterns refactor(error/upgrade): move from the use of ref patterns to & and remove allow for lint ref_patterns Aug 1, 2026
Comment thread tests/server.rs
Comment on lines 3564 to 3569
/*
let r = self.thread.take().unwrap().join();
if let Err(ref e) = r {
if let Err(e) = &r {
println!("{:?}", e);
}
r.unwrap();

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if all of this code can be dropped?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can drop this one

Comment thread src/body/incoming.rs
Comment on lines 174 to 183
pub(crate) fn as_ffi_mut(&mut self) -> &mut crate::ffi::UserBody {
match self.kind {
Kind::Ffi(ref mut body) => return body,
_ => {
self.kind = Kind::Ffi(crate::ffi::UserBody::new());
}
if !matches!(self.kind, Kind::Ffi(_)) {
self.kind = Kind::Ffi(crate::ffi::UserBody::new());
}

match self.kind {
Kind::Ffi(ref mut body) => body,
match &mut self.kind {
Kind::Ffi(body) => body,
_ => unreachable!(),
}
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to call this one out as the only place we could not do a straight ref -> & change.

The behaviour however is still the same.

  1. If the kind is ffi return a mutable reference to the body
  2. if the kind is not ffi set self.kind to Kind::Ffi(crate::ffi::UserBody::new())
  3. After creating Kind::Ffi(crate::ffi::UserBody::new()) return as a mutable reference.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine to me 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants