Skip to content

Commit

Permalink
* Fix clippy lint in test. Use suggestion
Browse files Browse the repository at this point in the history
* Widen acceptable versions of hashbrown
* Use conditional compilation to choose more efficient implementation
  This allows rust 1.70 but gives no perf penalty for 1.75.
  There may well be another way around CI failure.
  • Loading branch information
jlapeyre committed Feb 15, 2024
1 parent c175b77 commit 12cbfa4
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
10 changes: 5 additions & 5 deletions crates/oq3_lexer/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
use super::*;

use expect_test::{expect, Expect};
use std::fmt::Write;

// FIXME: Probably do what clippy asks for here
#[allow(clippy::format_collect)]
fn check_lexing(src: &str, expect: Expect) {
let actual: String = tokenize(src)
.map(|token| format!("{:?}\n", token))
.collect();
let actual: String = tokenize(src).fold(String::new(), |mut output, token| {
let _ = writeln!(output, "{token:?}");
output
});
expect.assert_eq(&actual)
}

Expand Down
2 changes: 1 addition & 1 deletion crates/oq3_semantics/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ doctest = false
[dependencies]
oq3_source_file.workspace = true
oq3_syntax.workspace = true
hashbrown = { version = "0.14" }
hashbrown = { version = "0.12.3" }
rowan = "0.15.11"
boolenum = "0.1"

Expand Down
1 change: 1 addition & 0 deletions crates/oq3_syntax/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ smol_str = "0.2.0"
stdx = { version = "0.0.188", package = "ra_ap_stdx"}
triomphe = { version = "0.1.8", default-features = false, features = ["std"] }
xshell = "0.2.2"
rustversion = "1.0"
# local crates
oq3_lexer.workspace = true
oq3_parser.workspace = true
Expand Down
14 changes: 14 additions & 0 deletions crates/oq3_syntax/src/ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ pub struct AstPtr<N: AstNode> {
}

impl<N: AstNode> Clone for AstPtr<N> {
#[rustversion::before(1.74)]
fn clone(&self) -> AstPtr<N> {
AstPtr {
raw: self.raw.clone(),
_ty: PhantomData,
}
}
#[rustversion::since(1.74)]
fn clone(&self) -> AstPtr<N> {
AstPtr {
raw: self.raw,
Expand Down Expand Up @@ -67,10 +75,16 @@ impl<N: AstNode> AstPtr<N> {
N::cast(syntax_node).unwrap()
}

#[rustversion::since(1.74)]
pub fn syntax_node_ptr(&self) -> SyntaxNodePtr {
self.raw
}

#[rustversion::before(1.74)]
pub fn syntax_node_ptr(&self) -> SyntaxNodePtr {
self.raw.clone()
}

pub fn text_range(&self) -> TextRange {
self.raw.text_range()
}
Expand Down

0 comments on commit 12cbfa4

Please sign in to comment.