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

+1-1
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

+1-1
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

+1-1
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

+1
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

+1-5
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

+1-2
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

+38-5
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

+1
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

+1-1
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

+1-1
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.

regex-syntax/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ documentation = "https://docs.rs/regex-syntax"
88
description = "A regular expression parser."
99
workspace = ".."
1010
edition = "2021"
11-
rust-version = "1.60.0"
11+
rust-version = "1.65"
1212

1313
# Features are documented in the "Crate features" section of the crate docs:
1414
# https://docs.rs/regex-syntax/*/#crate-features

regex-syntax/src/hir/literal.rs

+8-13
Original file line numberDiff line numberDiff line change
@@ -2235,24 +2235,19 @@ impl PreferenceTrie {
22352235
/// after them and because any removed literals are guaranteed to never
22362236
/// match.
22372237
fn minimize(literals: &mut Vec<Literal>, keep_exact: bool) {
2238-
use core::cell::RefCell;
2239-
2240-
// MSRV(1.61): Use retain_mut here to avoid interior mutability.
2241-
let trie = RefCell::new(PreferenceTrie {
2238+
let mut trie = PreferenceTrie {
22422239
states: vec![],
22432240
matches: vec![],
22442241
next_literal_index: 1,
2245-
});
2242+
};
22462243
let mut make_inexact = vec![];
2247-
literals.retain(|lit| {
2248-
match trie.borrow_mut().insert(lit.as_bytes()) {
2249-
Ok(_) => true,
2250-
Err(i) => {
2251-
if !keep_exact {
2252-
make_inexact.push(i.checked_sub(1).unwrap());
2253-
}
2254-
false
2244+
literals.retain_mut(|lit| match trie.insert(lit.as_bytes()) {
2245+
Ok(_) => true,
2246+
Err(i) => {
2247+
if !keep_exact {
2248+
make_inexact.push(i.checked_sub(1).unwrap());
22552249
}
2250+
false
22562251
}
22572252
});
22582253
for i in make_inexact {

regex-syntax/src/lib.rs

-12
Original file line numberDiff line numberDiff line change
@@ -168,18 +168,6 @@ The following features are available:
168168
#![forbid(unsafe_code)]
169169
#![deny(missing_docs, rustdoc::broken_intra_doc_links)]
170170
#![warn(missing_debug_implementations)]
171-
// MSRV(1.62): Allow unused warnings. Needed for the 'allow' below,
172-
// since the warning is no longer triggered in newer Rust releases.
173-
// Once the 'allow(mutable_borrow_reservation_conflict)' can be
174-
// removed, we can remove the 'allow(renamed_and_removed_lints)' too.
175-
#![allow(renamed_and_removed_lints)]
176-
// MSRV(1.62): This gets triggered on Rust <1.62, and since our MSRV
177-
// is Rust 1.60 at the time of writing, a warning is displayed. But
178-
// the lang team decided the code pattern flagged by this warning is
179-
// OK, so the warning is innocuous. We can remove this explicit allow
180-
// once we get to a Rust release where the warning is no longer
181-
// triggered. I believe that's Rust 1.62.
182-
#![allow(mutable_borrow_reservation_conflict)]
183171
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
184172

185173
#[cfg(any(test, feature = "std"))]

0 commit comments

Comments
 (0)