Skip to content

Commit

Permalink
Migrate to stable strict provenance APIs and elide some redundant lif…
Browse files Browse the repository at this point in the history
…etimes (#71)

* elide unnecessary lifetimes in `PartialEq` impls for `Symbol`

* remove strict provenance polyfill after std APIs are now stable

this raises MSRV to 1.84

* elide more redundant lifetimes

---------

Co-authored-by: Domenic Quirl <DomenicQuirl@protonmail.com>
  • Loading branch information
domenicquirl and Domenic Quirl authored Feb 2, 2025
1 parent 6c62982 commit c061bf5
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ authors = [
license = "MIT OR Apache-2.0"
repository = "https://github.com/domenicquirl/cstree"
readme = "README.md"
rust-version = "1.71"
rust-version = "1.84"

[profile.release]
debug = true
4 changes: 2 additions & 2 deletions cstree-derive/src/symbols.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ impl PartialEq<Symbol> for Ident {
}
}

impl<'a> PartialEq<Symbol> for &'a Ident {
impl PartialEq<Symbol> for &Ident {
fn eq(&self, word: &Symbol) -> bool {
*self == word.0
}
Expand All @@ -32,7 +32,7 @@ impl PartialEq<Symbol> for Path {
}
}

impl<'a> PartialEq<Symbol> for &'a Path {
impl PartialEq<Symbol> for &Path {
fn eq(&self, word: &Symbol) -> bool {
self.is_ident(word.0)
}
Expand Down
1 change: 0 additions & 1 deletion cstree/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ parking_lot = "0.12.1"

# Arc
triomphe = { version = "0.1.8", default-features = false, features = ["stable_deref_trait", "std"] }
sptr = "0.3.2"

# Default Interner
indexmap = "2.4.0"
Expand Down
2 changes: 0 additions & 2 deletions cstree/src/green/element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ use std::{fmt, hash, mem};
// This MUST be size=1 such that pointer math actually advances the pointer.
type ErasedPtr = *const u8;

use sptr::Strict;

use crate::{
green::{GreenNode, GreenToken},
text::TextSize,
Expand Down
2 changes: 1 addition & 1 deletion cstree/src/green/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ impl<'a> Iterator for GreenNodeChildren<'a> {
}
}

impl<'a> DoubleEndedIterator for GreenNodeChildren<'a> {
impl DoubleEndedIterator for GreenNodeChildren<'_> {
#[inline]
fn next_back(&mut self) -> Option<Self::Item> {
self.inner.next_back().map(PackedGreenElement::as_ref)
Expand Down
1 change: 0 additions & 1 deletion cstree/src/green/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use crate::{
text::TextSize,
RawSyntaxKind,
};
use sptr::Strict;
use triomphe::Arc;

#[repr(align(2))] // to use 1 bit for pointer tagging. NB: this is an at-least annotation
Expand Down
2 changes: 1 addition & 1 deletion cstree/src/syntax/element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ impl<'a, S: Syntax, D> From<&'a SyntaxElement<S, D>> for SyntaxElementRef<'a, S,
}
}

impl<'a, S: Syntax, D> SyntaxElementRef<'a, S, D> {
impl<S: Syntax, D> SyntaxElementRef<'_, S, D> {
/// Returns this element's [`Display`](fmt::Display) representation as a string.
///
/// To avoid allocating for every element, see [`write_display`](type.SyntaxElementRef.html#method.write_display).
Expand Down
12 changes: 6 additions & 6 deletions cstree/src/syntax/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ impl<'n> Iterator for Iter<'n> {
}
}

impl<'n> ExactSizeIterator for Iter<'n> {
impl ExactSizeIterator for Iter<'_> {
#[inline(always)]
fn len(&self) -> usize {
self.green.len()
}
}
impl<'n> FusedIterator for Iter<'n> {}
impl FusedIterator for Iter<'_> {}

/// An iterator over the child nodes of a [`SyntaxNode`].
#[derive(Clone, Debug)]
Expand Down Expand Up @@ -109,13 +109,13 @@ impl<'n, S: Syntax, D> Iterator for SyntaxNodeChildren<'n, S, D> {
}
}

impl<'n, S: Syntax, D> ExactSizeIterator for SyntaxNodeChildren<'n, S, D> {
impl<S: Syntax, D> ExactSizeIterator for SyntaxNodeChildren<'_, S, D> {
#[inline(always)]
fn len(&self) -> usize {
self.inner.len()
}
}
impl<'n, S: Syntax, D> FusedIterator for SyntaxNodeChildren<'n, S, D> {}
impl<S: Syntax, D> FusedIterator for SyntaxNodeChildren<'_, S, D> {}

/// An iterator over the children of a [`SyntaxNode`].
#[derive(Clone, Debug)]
Expand Down Expand Up @@ -159,10 +159,10 @@ impl<'n, S: Syntax, D> Iterator for SyntaxElementChildren<'n, S, D> {
}
}

impl<'n, S: Syntax, D> ExactSizeIterator for SyntaxElementChildren<'n, S, D> {
impl<S: Syntax, D> ExactSizeIterator for SyntaxElementChildren<'_, S, D> {
#[inline(always)]
fn len(&self) -> usize {
self.inner.len()
}
}
impl<'n, S: Syntax, D> FusedIterator for SyntaxElementChildren<'n, S, D> {}
impl<S: Syntax, D> FusedIterator for SyntaxElementChildren<'_, S, D> {}
3 changes: 1 addition & 2 deletions cstree/src/syntax/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,7 @@ impl<I: Resolver<TokenKey> + ?Sized, S: Syntax, D> PartialEq<SyntaxText<'_, '_,
}
}

impl<'n1, 'i1, 'n2, 'i2, I1, I2, S1, S2, D1, D2> PartialEq<SyntaxText<'n2, 'i2, I2, S2, D2>>
for SyntaxText<'n1, 'i1, I1, S1, D1>
impl<I1, I2, S1, S2, D1, D2> PartialEq<SyntaxText<'_, '_, I2, S2, D2>> for SyntaxText<'_, '_, I1, S1, D1>
where
S1: Syntax,
S2: Syntax,
Expand Down

0 comments on commit c061bf5

Please sign in to comment.