Skip to content

Raise MSRV to 1.63 #772

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ A set of types for representing HTTP requests and responses.
"""
keywords = ["http"]
categories = ["web-programming"]
edition = "2018"
edition = "2021"
# When updating this value, don't forget to also adjust the GitHub Actions config.
rust-version = "1.49.0"
rust-version = "1.63.0"

[workspace]
members = [
Expand Down
3 changes: 1 addition & 2 deletions src/byte_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ impl ByteStr {
match str::from_utf8(&bytes) {
Ok(_) => (),
Err(err) => panic!(
"ByteStr::from_utf8_unchecked() with invalid bytes; error = {}, bytes = {:?}",
err, bytes
"ByteStr::from_utf8_unchecked() with invalid bytes; error = {err}, bytes = {bytes:?}"
),
}
}
Expand Down
25 changes: 12 additions & 13 deletions src/header/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1460,7 +1460,7 @@ impl<T> HeaderMap<T> {
#[inline]
fn find<K>(&self, key: &K) -> Option<(usize, usize)>
where
K: Hash + Into<HeaderName> + ?Sized,
K: Hash + Into<HeaderName>,
HeaderName: PartialEq<K>,
{
if self.entries.is_empty() {
Expand Down Expand Up @@ -3588,10 +3588,9 @@ fn usable_capacity(cap: usize) -> usize {
fn to_raw_capacity(n: usize) -> usize {
match n.checked_add(n / 3) {
Some(n) => n,
None => panic!(
"requested capacity {} too large: overflow while converting to raw capacity",
n
),
None => {
panic!("requested capacity {n} too large: overflow while converting to raw capacity")
}
}
}

Expand Down Expand Up @@ -3690,7 +3689,7 @@ mod into_header_name {

impl IntoHeaderName for HeaderName {}

impl<'a> Sealed for &'a HeaderName {
impl Sealed for &HeaderName {
#[inline]
fn try_insert<T>(
self,
Expand All @@ -3710,7 +3709,7 @@ mod into_header_name {
}
}

impl<'a> IntoHeaderName for &'a HeaderName {}
impl IntoHeaderName for &HeaderName {}

impl Sealed for &'static str {
#[inline]
Expand Down Expand Up @@ -3800,7 +3799,7 @@ mod as_header_name {

impl AsHeaderName for HeaderName {}

impl<'a> Sealed for &'a HeaderName {
impl Sealed for &HeaderName {
#[inline]
fn try_entry<T>(self, map: &mut HeaderMap<T>) -> Result<Entry<'_, T>, TryEntryError> {
Ok(map.try_entry2(self)?)
Expand All @@ -3816,9 +3815,9 @@ mod as_header_name {
}
}

impl<'a> AsHeaderName for &'a HeaderName {}
impl AsHeaderName for &HeaderName {}

impl<'a> Sealed for &'a str {
impl Sealed for &str {
#[inline]
fn try_entry<T>(self, map: &mut HeaderMap<T>) -> Result<Entry<'_, T>, TryEntryError> {
Ok(HdrName::from_bytes(self.as_bytes(), move |hdr| {
Expand All @@ -3836,7 +3835,7 @@ mod as_header_name {
}
}

impl<'a> AsHeaderName for &'a str {}
impl AsHeaderName for &str {}

impl Sealed for String {
#[inline]
Expand All @@ -3856,7 +3855,7 @@ mod as_header_name {

impl AsHeaderName for String {}

impl<'a> Sealed for &'a String {
impl Sealed for &String {
#[inline]
fn try_entry<T>(self, map: &mut HeaderMap<T>) -> Result<Entry<'_, T>, TryEntryError> {
self.as_str().try_entry(map)
Expand All @@ -3872,7 +3871,7 @@ mod as_header_name {
}
}

impl<'a> AsHeaderName for &'a String {}
impl AsHeaderName for &String {}
}

#[test]
Expand Down
7 changes: 3 additions & 4 deletions src/header/name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1439,7 +1439,7 @@ impl<'a> PartialEq<&'a HeaderName> for HeaderName {
}
}

impl<'a> PartialEq<HeaderName> for &'a HeaderName {
impl PartialEq<HeaderName> for &HeaderName {
#[inline]
fn eq(&self, other: &HeaderName) -> bool {
*other == *self
Expand Down Expand Up @@ -1493,7 +1493,7 @@ impl<'a> PartialEq<&'a str> for HeaderName {
}
}

impl<'a> PartialEq<HeaderName> for &'a str {
impl PartialEq<HeaderName> for &str {
/// Performs a case-insensitive comparison of the string against the header
/// name
#[inline]
Expand Down Expand Up @@ -1688,8 +1688,7 @@ mod tests {
let hdr = vec![1u8; i];
assert!(
HeaderName::from_bytes(&hdr).is_err(),
"{} invalid header chars did not fail",
i
"{i} invalid header chars did not fail"
);
}
}
Expand Down
18 changes: 9 additions & 9 deletions src/header/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ impl fmt::Debug for HeaderValue {
if b == b'"' {
f.write_str("\\\"")?;
} else {
write!(f, "\\x{:x}", b)?;
write!(f, "\\x{b:x}")?;
}
from = i + 1;
}
Expand Down Expand Up @@ -439,7 +439,7 @@ macro_rules! from_integers {
let val = HeaderValue::from(n);
assert_eq!(val, &n.to_string());

let n = ::std::$t::MAX;
let n = $t::MAX;
let val = HeaderValue::from(n);
assert_eq!(val, &n.to_string());
}
Expand Down Expand Up @@ -571,7 +571,7 @@ mod try_from_header_name_tests {
#[test]
fn it_converts_using_try_from() {
assert_eq!(
HeaderValue::try_from(name::UPGRADE).unwrap(),
HeaderValue::from(name::UPGRADE),
HeaderValue::from_bytes(b"upgrade").unwrap()
);
}
Expand Down Expand Up @@ -725,14 +725,14 @@ impl PartialOrd<HeaderValue> for String {
}
}

impl<'a> PartialEq<HeaderValue> for &'a HeaderValue {
impl PartialEq<HeaderValue> for &HeaderValue {
#[inline]
fn eq(&self, other: &HeaderValue) -> bool {
**self == *other
}
}

impl<'a> PartialOrd<HeaderValue> for &'a HeaderValue {
impl PartialOrd<HeaderValue> for &HeaderValue {
#[inline]
fn partial_cmp(&self, other: &HeaderValue) -> Option<cmp::Ordering> {
(**self).partial_cmp(other)
Expand All @@ -759,14 +759,14 @@ where
}
}

impl<'a> PartialEq<HeaderValue> for &'a str {
impl PartialEq<HeaderValue> for &str {
#[inline]
fn eq(&self, other: &HeaderValue) -> bool {
*other == *self
}
}

impl<'a> PartialOrd<HeaderValue> for &'a str {
impl PartialOrd<HeaderValue> for &str {
#[inline]
fn partial_cmp(&self, other: &HeaderValue) -> Option<cmp::Ordering> {
self.as_bytes().partial_cmp(other.as_bytes())
Expand All @@ -788,11 +788,11 @@ fn test_debug() {

for &(value, expected) in cases {
let val = HeaderValue::from_bytes(value.as_bytes()).unwrap();
let actual = format!("{:?}", val);
let actual = format!("{val:?}");
assert_eq!(expected, actual);
}

let mut sensitive = HeaderValue::from_static("password");
sensitive.set_sensitive(true);
assert_eq!("Sensitive", format!("{:?}", sensitive));
assert_eq!("Sensitive", format!("{sensitive:?}"));
}
4 changes: 2 additions & 2 deletions src/method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ impl<'a> PartialEq<&'a Method> for Method {
}
}

impl<'a> PartialEq<Method> for &'a Method {
impl PartialEq<Method> for &Method {
#[inline]
fn eq(&self, other: &Method) -> bool {
*self == other
Expand Down Expand Up @@ -222,7 +222,7 @@ impl<'a> PartialEq<&'a str> for Method {
}
}

impl<'a> PartialEq<Method> for &'a str {
impl PartialEq<Method> for &str {
#[inline]
fn eq(&self, other: &Method) -> bool {
*self == other.as_ref()
Expand Down
4 changes: 1 addition & 3 deletions src/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ pub struct Request<T> {
/// The HTTP request head consists of a method, uri, version, and a set of
/// header fields.
#[derive(Clone)]
#[non_exhaustive]
pub struct Parts {
/// The request's method
pub method: Method,
Expand All @@ -180,8 +181,6 @@ pub struct Parts {

/// The request's extensions
pub extensions: Extensions,

_priv: (),
}

/// An HTTP request builder
Expand Down Expand Up @@ -715,7 +714,6 @@ impl Parts {
version: Version::default(),
headers: HeaderMap::default(),
extensions: Extensions::default(),
_priv: (),
}
}
}
Expand Down
4 changes: 1 addition & 3 deletions src/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ pub struct Response<T> {
/// The HTTP response head consists of a status, version, and a set of
/// header fields.
#[derive(Clone)]
#[non_exhaustive]
pub struct Parts {
/// The response's status
pub status: StatusCode,
Expand All @@ -199,8 +200,6 @@ pub struct Parts {

/// The response's extensions
pub extensions: Extensions,

_priv: (),
}

/// An HTTP response builder
Expand Down Expand Up @@ -507,7 +506,6 @@ impl Parts {
version: Version::default(),
headers: HeaderMap::default(),
extensions: Extensions::default(),
_priv: (),
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/uri/authority.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ impl PartialEq<Authority> for str {
}
}

impl<'a> PartialEq<Authority> for &'a str {
impl PartialEq<Authority> for &str {
fn eq(&self, other: &Authority) -> bool {
self.eq_ignore_ascii_case(other.as_str())
}
Expand Down Expand Up @@ -360,7 +360,7 @@ impl PartialOrd<Authority> for str {
}
}

impl<'a> PartialOrd<Authority> for &'a str {
impl PartialOrd<Authority> for &str {
fn partial_cmp(&self, other: &Authority) -> Option<cmp::Ordering> {
let left = self.as_bytes().iter().map(|b| b.to_ascii_lowercase());
let right = other.data.as_bytes().iter().map(|b| b.to_ascii_lowercase());
Expand Down Expand Up @@ -619,10 +619,10 @@ mod tests {
#[test]
fn compares_with_a_string() {
let authority: Authority = "def.com".parse().unwrap();
assert!(authority < "ghi.com".to_string());
assert!("ghi.com".to_string() > authority);
assert!(authority > "abc.com".to_string());
assert!("abc.com".to_string() < authority);
assert!(authority < "ghi.com");
assert!("ghi.com" > authority);
assert!(authority > "abc.com");
assert!("abc.com" < authority);
}

#[test]
Expand Down
8 changes: 4 additions & 4 deletions src/uri/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,10 @@ mod tests {
fn build_from_string() {
for i in 1..10 {
let uri = Builder::new()
.path_and_query(format!("/foo?a={}", i))
.path_and_query(format!("/foo?a={i}"))
.build()
.unwrap();
let expected_query = format!("a={}", i);
let expected_query = format!("a={i}");
assert_eq!(uri.path(), "/foo");
assert_eq!(uri.query(), Some(expected_query.as_str()));
}
Expand All @@ -194,9 +194,9 @@ mod tests {
#[test]
fn build_from_string_ref() {
for i in 1..10 {
let p_a_q = format!("/foo?a={}", i);
let p_a_q = format!("/foo?a={i}");
let uri = Builder::new().path_and_query(&p_a_q).build().unwrap();
let expected_query = format!("a={}", i);
let expected_query = format!("a={i}");
assert_eq!(uri.path(), "/foo");
assert_eq!(uri.query(), Some(expected_query.as_str()));
}
Expand Down
Loading