on master help sign in
bump MSRV to 1.70.0 (#8877)

* rust-toolchain.toml: bump MSRV to 1.70.0 With Firefox 120 released on 21 November 2023, the MSRV is now 1.70.0. * Fix cargo fmt with Rust 1.70.0 * Fix cargo clippy with Rust 1.70.0 * Fix cargo doc with Rust 1.70.0 * rust-toolchain.toml: add clippy component * .github: bump dtolnay/rust-toolchain to 1.70 * helix-term: bump rust-version to 1.70 * helix-view/gutter: use checked_ilog10 to count digits * helix-core/syntax: use MAIN_SEPARATOR_STR constant * helix-view/handlers/dap: use Display impl for displaying process spawn error * WIP: helix-term/commands: use checked math to assert ranges cannot overlap

commit8b0ae3d27912799d59e4948ff11d3a5428e32ce4 authorCole Helbling <cole.e.helbling@outlook.com> dateSat 25 Nov 2023, 04:55 (3 years ago) parent090ed97
10 files changed+26−31
.github/workflows/build.yml+3−3 helix-core/src/syntax.rs+1−4 helix-term/Cargo.toml+1−1 helix-term/src/commands.rs+11−5 helix-term/src/commands/lsp.rs+1−1 helix-tui/src/buffer.rs+2−2 helix-view/src/editor.rs+3−8 helix-view/src/gutter.rs+1−2 helix-view/src/handlers/dap.rs+1−3 rust-toolchain.toml+2−2
.github/workflows/build.yml+3−3
@@ -39,7 +39,7 @@ jobs:
3939 uses: actions/checkout@v4
4040
4141 - name: Install stable toolchain
42− uses: dtolnay/rust-toolchain@1.65
42+ uses: dtolnay/rust-toolchain@1.70
4343
4444 - uses: Swatinem/rust-cache@v2
4545 with:
@@ -70,7 +70,7 @@ jobs:
7070 uses: actions/checkout@v4
7171
7272 - name: Install stable toolchain
73− uses: dtolnay/rust-toolchain@1.65
73+ uses: dtolnay/rust-toolchain@1.70
7474 with:
7575 components: rustfmt, clippy
7676
@@ -97,7 +97,7 @@ jobs:
9797 uses: actions/checkout@v4
9898
9999 - name: Install stable toolchain
100− uses: dtolnay/rust-toolchain@1.65
100+ uses: dtolnay/rust-toolchain@1.70
101101
102102 - uses: Swatinem/rust-cache@v2
103103 with:
helix-core/src/syntax.rs+1−4
@@ -212,10 +212,7 @@ impl<'de> Deserialize<'de> for FileType {
212212 {
213213 match map.next_entry::<String, String>()? {
214214 Some((key, suffix)) if key == "suffix" => Ok(FileType::Suffix({
215− // FIXME: use `suffix.replace('/', std::path::MAIN_SEPARATOR_STR)`
216− // if MSRV is updated to 1.68
217− let mut separator = [0; 1];
218− suffix.replace('/', std::path::MAIN_SEPARATOR.encode_utf8(&mut separator))
215+ suffix.replace('/', std::path::MAIN_SEPARATOR_STR)
219216 })),
220217 Some((key, _value)) => Err(serde::de::Error::custom(format!(
221218 "unknown key in `file-types` list: {}",
helix-term/Cargo.toml+1−1
@@ -10,7 +10,7 @@ repository = "https://github.com/helix-editor/helix"
1010homepage = "https://helix-editor.com"
1111include = ["src/**/*", "README.md"]
1212default-run = "hx"
13−rust-version = "1.65"
13+rust-version = "1.70"
1414
1515[features]
1616default = ["git"]
helix-term/src/commands.rs+11−5
@@ -1318,7 +1318,7 @@ fn extend_next_long_word_end(cx: &mut Context) {
13181318 extend_word_impl(cx, movement::move_next_long_word_end)
13191319}
13201320
1321−/// Separate branch to find_char designed only for <ret> char.
1321+/// Separate branch to find_char designed only for `<ret>` char.
13221322//
13231323// This is necessary because the one document can have different line endings inside. And we
13241324// cannot predict what character to find when <ret> is pressed. On the current line it can be `lf`
@@ -5606,12 +5606,18 @@ fn shell(cx: &mut compositor::Context, cmd: &str, behavior: &ShellBehavior) {
56065606 };
56075607
56085608 // These `usize`s cannot underflow because selection ranges cannot overlap.
5609− // Once the MSRV is 1.66.0 (mixed_integer_ops is stabilized), we can use checked
5610− // arithmetic to assert this.
5611− let anchor = (to as isize + offset - deleted_len as isize) as usize;
5609+ let anchor = to
5610+ .checked_add_signed(offset)
5611+ .expect("Selection ranges cannot overlap")
5612+ .checked_sub(deleted_len)
5613+ .expect("Selection ranges cannot overlap");
56125614 let new_range = Range::new(anchor, anchor + output_len).with_direction(range.direction());
56135615 ranges.push(new_range);
5614− offset = offset + output_len as isize - deleted_len as isize;
5616+ offset = offset
5617+ .checked_add_unsigned(output_len)
5618+ .expect("Selection ranges cannot overlap")
5619+ .checked_sub_unsigned(deleted_len)
5620+ .expect("Selection ranges cannot overlap");
56155621
56165622 changes.push((from, to, Some(output)));
56175623 }
helix-term/src/commands/lsp.rs+1−1
@@ -49,7 +49,7 @@ use std::{
4949/// If there is no configured language server that supports the feature, this displays a status message.
5050/// Using this macro in a context where the editor automatically queries the LSP
5151/// (instead of when the user explicitly does so via a keybind like `gd`)
52−/// will spam the "No configured language server supports <feature>" status message confusingly.
52+/// will spam the "No configured language server supports \<feature>" status message confusingly.
5353#[macro_export]
5454macro_rules! language_server_with_feature {
5555 ($editor:expr, $doc:expr, $feature:expr) => {{
helix-tui/src/buffer.rs+2−2
@@ -213,7 +213,7 @@ impl Buffer {
213213 && y < self.area.bottom()
214214 }
215215
216− /// Returns the index in the Vec<Cell> for the given global (x, y) coordinates.
216+ /// Returns the index in the `Vec<Cell>` for the given global (x, y) coordinates.
217217 ///
218218 /// Global coordinates are offset by the Buffer's area offset (`x`/`y`).
219219 ///
@@ -242,7 +242,7 @@ impl Buffer {
242242 ((y - self.area.y) as usize) * (self.area.width as usize) + ((x - self.area.x) as usize)
243243 }
244244
245− /// Returns the index in the Vec<Cell> for the given global (x, y) coordinates,
245+ /// Returns the index in the `Vec<Cell>` for the given global (x, y) coordinates,
246246 /// or `None` if the coordinates are outside the buffer's area.
247247 fn index_of_opt(&self, x: u16, y: u16) -> Option<usize> {
248248 if self.in_bounds(x, y) {
helix-view/src/editor.rs+3−8
@@ -727,7 +727,7 @@ pub struct WhitespaceCharacters {
727727impl Default for WhitespaceCharacters {
728728 fn default() -> Self {
729729 Self {
730− space: '·', // U+00B7
730+ space: '·', // U+00B7
731731 nbsp: '⍽', // U+237D
732732 tab: '→', // U+2192
733733 newline: '⏎', // U+23CE
@@ -755,12 +755,13 @@ impl Default for IndentGuidesConfig {
755755}
756756
757757/// Line ending configuration.
758−#[derive(Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize)]
758+#[derive(Default, Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize)]
759759#[serde(rename_all = "lowercase")]
760760pub enum LineEndingConfig {
761761 /// The platform's native line ending.
762762 ///
763763 /// `crlf` on Windows, otherwise `lf`.
764+ #[default]
764765 Native,
765766 /// Line feed.
766767 LF,
@@ -777,12 +778,6 @@ pub enum LineEndingConfig {
777778 Nel,
778779}
779780
780−impl Default for LineEndingConfig {
781− fn default() -> Self {
782− LineEndingConfig::Native
783− }
784−}
785−
786781impl From<LineEndingConfig> for LineEnding {
787782 fn from(line_ending: LineEndingConfig) -> Self {
788783 match line_ending {
helix-view/src/gutter.rs+1−2
@@ -9,8 +9,7 @@ use crate::{
99};
1010
1111fn count_digits(n: usize) -> usize {
12− // TODO: use checked_log10 when MSRV reaches 1.67
13− std::iter::successors(Some(n), |&n| (n >= 10).then_some(n / 10)).count()
12+ (usize::checked_ilog10(n).unwrap_or(0) + 1) as usize
1413}
1514
1615pub type GutterFn<'doc> = Box<dyn FnMut(usize, bool, bool, &mut String) -> Option<Style> + 'doc>;
helix-view/src/handlers/dap.rs+1−3
@@ -369,9 +369,7 @@ impl Editor {
369369 {
370370 Ok(process) => process,
371371 Err(err) => {
372− // TODO replace the pretty print {:?} with a regular format {}
373− // when the MSRV is raised to 1.60.0
374− self.set_error(format!("Error starting external terminal: {:?}", err));
372+ self.set_error(format!("Error starting external terminal: {}", err));
375373 return true;
376374 }
377375 };
rust-toolchain.toml+2−2
@@ -1,3 +1,3 @@
11[toolchain]
2−channel = "1.65.0"
3−components = ["rustfmt", "rust-src"]
2+channel = "1.70.0"
3+components = ["rustfmt", "rust-src", "clippy"]