Fix compilation errors

This commit is contained in:
Victor Song 2024-01-30 01:40:56 -06:00
parent 027f263ef5
commit 965b14d17a
3 changed files with 10 additions and 9 deletions

View file

@ -55,8 +55,8 @@ fn spacing_to_external(spacing: Spacing) -> proc_macro::Spacing {
} }
} }
fn literal_to_external(literal: ast::LiteralKind) -> Option<proc_macro::bridge::LitKind> { fn literal_to_external(literal_kind: ast::LiteralKind) -> Option<proc_macro::bridge::LitKind> {
Some(match lit.kind() { Some(match literal_kind {
ast::LiteralKind::String(data) => { ast::LiteralKind::String(data) => {
if data.is_raw() { if data.is_raw() {
bridge::LitKind::StrRaw(data.raw_delimiter_count()?) bridge::LitKind::StrRaw(data.raw_delimiter_count()?)

View file

@ -4,7 +4,6 @@
//! It is an unfortunate result of how the proc-macro API works that we need to look into the //! It is an unfortunate result of how the proc-macro API works that we need to look into the
//! concrete representation of the spans, and as such, RustRover cannot make use of this unless they //! concrete representation of the spans, and as such, RustRover cannot make use of this unless they
//! change their representation to be compatible with rust-analyzer's. //! change their representation to be compatible with rust-analyzer's.
use core::num;
use std::{ use std::{
collections::{HashMap, HashSet}, collections::{HashMap, HashSet},
iter, iter,
@ -72,13 +71,14 @@ impl server::FreeFunctions for RaSpanServer {
&mut self, &mut self,
s: &str, s: &str,
) -> Result<bridge::Literal<Self::Span, Self::Symbol>, ()> { ) -> Result<bridge::Literal<Self::Span, Self::Symbol>, ()> {
let literal = str_to_lit_node(s).ok_or(Err(()))?; let literal = str_to_lit_node(s).ok_or(())?;
let kind = literal_to_external(literal.kind()).ok_or(Err(()))?; let kind = literal_to_external(literal.kind()).ok_or(())?;
// FIXME: handle more than just int and float suffixes // FIXME: handle more than just int and float suffixes
let suffix = match literal.kind() { let suffix = match literal.kind() {
ast::LiteralKind::FloatNumber(num) | ast::LiteralKind::IntNumber(num) => num.suffix(), ast::LiteralKind::FloatNumber(num) => num.suffix(),
ast::LiteralKind::IntNumber(num) => num.suffix(),
_ => None, _ => None,
} }
.map(|suffix| Symbol::intern(self.interner, suffix)); .map(|suffix| Symbol::intern(self.interner, suffix));

View file

@ -63,13 +63,14 @@ impl server::FreeFunctions for TokenIdServer {
&mut self, &mut self,
s: &str, s: &str,
) -> Result<bridge::Literal<Self::Span, Self::Symbol>, ()> { ) -> Result<bridge::Literal<Self::Span, Self::Symbol>, ()> {
let literal = str_to_lit_node(s).ok_or(Err(()))?; let literal = str_to_lit_node(s).ok_or(())?;
let kind = literal_to_external(literal.kind()).ok_or(Err(()))?; let kind = literal_to_external(literal.kind()).ok_or(())?;
// FIXME: handle more than just int and float suffixes // FIXME: handle more than just int and float suffixes
let suffix = match literal.kind() { let suffix = match literal.kind() {
ast::LiteralKind::FloatNumber(num) | ast::LiteralKind::IntNumber(num) => num.suffix(), ast::LiteralKind::FloatNumber(num) => num.suffix(),
ast::LiteralKind::IntNumber(num) => num.suffix(),
_ => None, _ => None,
} }
.map(|suffix| Symbol::intern(self.interner, suffix)); .map(|suffix| Symbol::intern(self.interner, suffix));