Skip to content

Commit 8e13494

Browse files
committed
msrv: bump to Rust 1.65
This MSRV bump is mostly motivated by "good sense," and in particular, Rust 1.65 means we can use 'let ... else'. We don't actually start peppering the code with 'let ... else' just yet, but we fix a few outstanding small issues and update our Rust version everywhere. Also, Rust 1.65 is about a year old at time of writing. Let's keep the trains moving.
1 parent 356d3c9 commit 8e13494

File tree

13 files changed

+56
-43
lines changed

13 files changed

+56
-43
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ jobs:
141141
- name: Install Rust
142142
uses: dtolnay/rust-toolchain@master
143143
with:
144-
toolchain: 1.60.0
144+
toolchain: 1.65.0
145145
# The memchr 2.6 release purportedly bumped its MSRV to Rust 1.60, but it
146146
# turned out that on aarch64, it was using something that wasn't stabilized
147147
# until Rust 1.61[1]. (This was an oversight on my part. I had previously

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ categories = ["text-processing"]
1515
autotests = false
1616
exclude = ["/scripts/*", "/.github/*"]
1717
edition = "2021"
18-
rust-version = "1.60.0"
18+
rust-version = "1.65"
1919

2020
[workspace]
2121
members = [

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ goes into more depth.
307307

308308
### Minimum Rust version policy
309309

310-
This crate's minimum supported `rustc` version is `1.60.0`.
310+
This crate's minimum supported `rustc` version is `1.65.0`.
311311

312312
The policy is that the minimum Rust version required to use this crate can be
313313
increased in minor version updates. For example, if regex 1.0 requires Rust

regex-automata/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ license = "MIT OR Apache-2.0"
1111
categories = ["text-processing"]
1212
edition = "2021"
1313
autoexamples = false
14+
rust-version = "1.65"
1415

1516
[lib]
1617
bench = false

regex-automata/src/util/lazy.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -384,11 +384,7 @@ mod lazy {
384384
// SAFETY: state is DONE if and only if data has been fully
385385
// initialized. At which point, it is safe to drop.
386386
unsafe {
387-
// MSRV(1.60): Use assume_init_drop. The below is how
388-
// assume_init_drop is implemented.
389-
core::ptr::drop_in_place(
390-
(*self.data.as_ptr()).as_mut_ptr(),
391-
)
387+
self.data.get_mut().assume_init_drop();
392388
}
393389
}
394390
}

regex-automata/src/util/look.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1651,8 +1651,7 @@ mod is_word_char {
16511651
fn is_word_character(c: char) -> bool {
16521652
use crate::util::{unicode_data::perl_word::PERL_WORD, utf8};
16531653

1654-
// MSRV(1.59): Use 'u8::try_from(c)' instead.
1655-
if u8::try_from(u32::from(c)).map_or(false, utf8::is_word_byte) {
1654+
if u8::try_from(c).map_or(false, utf8::is_word_byte) {
16561655
return true;
16571656
}
16581657
PERL_WORD

regex-automata/src/util/pool.rs

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -455,11 +455,44 @@ mod inner {
455455
/// Create a new pool. The given closure is used to create values in
456456
/// the pool when necessary.
457457
pub(super) fn new(create: F) -> Pool<T, F> {
458-
// MSRV(1.63): Mark this function as 'const'. I've arranged the
459-
// code such that it should "just work." Then mark the public
460-
// 'Pool::new' method as 'const' too. (The alloc-only Pool::new
461-
// is already 'const', so that should "just work" too.) The only
462-
// thing we're waiting for is Mutex::new to be const.
458+
// FIXME: Now that we require 1.65+, Mutex::new is available as
459+
// const... So we can almost mark this function as const. But of
460+
// course, we're creating a Vec of stacks below (we didn't when I
461+
// originally wrote this code). It seems like the best way to work
462+
// around this would be to use a `[Stack; MAX_POOL_STACKS]` instead
463+
// of a `Vec<Stack>`. I refrained from making this change at time
464+
// of writing (2023/10/08) because I was making a lot of other
465+
// changes at the same time and wanted to do this more carefully.
466+
// Namely, because of the cache line optimization, that `[Stack;
467+
// MAX_POOL_STACKS]` would be quite big. It's unclear how bad (if
468+
// at all) that would be.
469+
//
470+
// Another choice would be to lazily allocate the stacks, but...
471+
// I'm not so sure about that. Seems like a fair bit of complexity?
472+
//
473+
// Maybe there's a simple solution I'm missing.
474+
//
475+
// ... OK, I tried to fix this. First, I did it by putting `stacks`
476+
// in an `UnsafeCell` and using a `Once` to lazily initialize it.
477+
// I benchmarked it and everything looked okay. I then made this
478+
// function `const` and thought I was just about done. But the
479+
// public pool type wraps its inner pool in a `Box` to keep its
480+
// size down. Blech.
481+
//
482+
// So then I thought that I could push the box down into this
483+
// type (and leave the non-std version unboxed) and use the same
484+
// `UnsafeCell` technique to lazily initialize it. This has the
485+
// downside of the `Once` now needing to get hit in the owner fast
486+
// path, but maybe that's OK? However, I then realized that we can
487+
// only lazily initialize `stacks`, `owner` and `owner_val`. The
488+
// `create` function needs to be put somewhere outside of the box.
489+
// So now the pool is a `Box`, `Once` and a function. Now we're
490+
// starting to defeat the point of boxing in the first place. So I
491+
// backed out that change too.
492+
//
493+
// Back to square one. I maybe we just don't make a pool's
494+
// constructor const and live with it. It's probably not a huge
495+
// deal.
463496
let mut stacks = Vec::with_capacity(MAX_POOL_STACKS);
464497
for _ in 0..stacks.capacity() {
465498
stacks.push(CacheLine(Mutex::new(vec![])));

regex-cli/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ license = "MIT OR Apache-2.0"
1212
categories = ["text-processing"]
1313
autotests = false
1414
edition = "2021"
15+
rust-version = "1.65"
1516

1617
[[bin]]
1718
name = "regex-cli"

regex-lite/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ A lightweight regex engine that optimizes for binary size and compilation time.
1010
"""
1111
workspace = ".."
1212
edition = "2021"
13-
rust-version = "1.60.0"
13+
rust-version = "1.65"
1414
autotests = false
1515

1616
# Features are documented in the "Crate features" section of the crate docs:

regex-lite/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ year: 2014, month: 10, day: 14
7878

7979
### Minimum Rust version policy
8080

81-
This crate's minimum supported `rustc` version is `1.60.0`.
81+
This crate's minimum supported `rustc` version is `1.65.0`.
8282

8383
The policy is that the minimum Rust version required to use this crate can be
8484
increased in semver compatible updates.

0 commit comments

Comments
 (0)