1
Fork 0
mirror of https://github.com/RGBCube/cstree synced 2025-07-27 00:57:44 +00:00

Migrate to stable strict provenance APIs and elide some redundant lifetimes (#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>
This commit is contained in:
DQ 2025-02-02 18:43:46 +01:00 committed by GitHub
parent 6c62982f67
commit c061bf5a6b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 12 additions and 17 deletions

View file

@ -16,7 +16,7 @@ authors = [
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
repository = "https://github.com/domenicquirl/cstree" repository = "https://github.com/domenicquirl/cstree"
readme = "README.md" readme = "README.md"
rust-version = "1.71" rust-version = "1.84"
[profile.release] [profile.release]
debug = true debug = true

View file

@ -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 { fn eq(&self, word: &Symbol) -> bool {
*self == word.0 *self == word.0
} }
@ -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 { fn eq(&self, word: &Symbol) -> bool {
self.is_ident(word.0) self.is_ident(word.0)
} }

View file

@ -18,7 +18,6 @@ parking_lot = "0.12.1"
# Arc # Arc
triomphe = { version = "0.1.8", default-features = false, features = ["stable_deref_trait", "std"] } triomphe = { version = "0.1.8", default-features = false, features = ["stable_deref_trait", "std"] }
sptr = "0.3.2"
# Default Interner # Default Interner
indexmap = "2.4.0" indexmap = "2.4.0"

View file

@ -4,8 +4,6 @@ use std::{fmt, hash, mem};
// This MUST be size=1 such that pointer math actually advances the pointer. // This MUST be size=1 such that pointer math actually advances the pointer.
type ErasedPtr = *const u8; type ErasedPtr = *const u8;
use sptr::Strict;
use crate::{ use crate::{
green::{GreenNode, GreenToken}, green::{GreenNode, GreenToken},
text::TextSize, text::TextSize,

View file

@ -65,7 +65,7 @@ impl<'a> Iterator for GreenNodeChildren<'a> {
} }
} }
impl<'a> DoubleEndedIterator for GreenNodeChildren<'a> { impl DoubleEndedIterator for GreenNodeChildren<'_> {
#[inline] #[inline]
fn next_back(&mut self) -> Option<Self::Item> { fn next_back(&mut self) -> Option<Self::Item> {
self.inner.next_back().map(PackedGreenElement::as_ref) self.inner.next_back().map(PackedGreenElement::as_ref)

View file

@ -5,7 +5,6 @@ use crate::{
text::TextSize, text::TextSize,
RawSyntaxKind, RawSyntaxKind,
}; };
use sptr::Strict;
use triomphe::Arc; use triomphe::Arc;
#[repr(align(2))] // to use 1 bit for pointer tagging. NB: this is an at-least annotation #[repr(align(2))] // to use 1 bit for pointer tagging. NB: this is an at-least annotation

View file

@ -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. /// 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). /// To avoid allocating for every element, see [`write_display`](type.SyntaxElementRef.html#method.write_display).

View file

@ -57,13 +57,13 @@ impl<'n> Iterator for Iter<'n> {
} }
} }
impl<'n> ExactSizeIterator for Iter<'n> { impl ExactSizeIterator for Iter<'_> {
#[inline(always)] #[inline(always)]
fn len(&self) -> usize { fn len(&self) -> usize {
self.green.len() self.green.len()
} }
} }
impl<'n> FusedIterator for Iter<'n> {} impl FusedIterator for Iter<'_> {}
/// An iterator over the child nodes of a [`SyntaxNode`]. /// An iterator over the child nodes of a [`SyntaxNode`].
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
@ -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)] #[inline(always)]
fn len(&self) -> usize { fn len(&self) -> usize {
self.inner.len() 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`]. /// An iterator over the children of a [`SyntaxNode`].
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
@ -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)] #[inline(always)]
fn len(&self) -> usize { fn len(&self) -> usize {
self.inner.len() self.inner.len()
} }
} }
impl<'n, S: Syntax, D> FusedIterator for SyntaxElementChildren<'n, S, D> {} impl<S: Syntax, D> FusedIterator for SyntaxElementChildren<'_, S, D> {}

View file

@ -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>> impl<I1, I2, S1, S2, D1, D2> PartialEq<SyntaxText<'_, '_, I2, S2, D2>> for SyntaxText<'_, '_, I1, S1, D1>
for SyntaxText<'n1, 'i1, I1, S1, D1>
where where
S1: Syntax, S1: Syntax,
S2: Syntax, S2: Syntax,