Unnamed repository; edit this file 'description' to name the repository.
| -rw-r--r-- | crates/proc-macro-srv/src/server_impl/rust_analyzer_span.rs | 14 | ||||
| -rw-r--r-- | crates/proc-macro-srv/src/server_impl/token_id.rs | 14 |
2 files changed, 10 insertions, 18 deletions
diff --git a/crates/proc-macro-srv/src/server_impl/rust_analyzer_span.rs b/crates/proc-macro-srv/src/server_impl/rust_analyzer_span.rs index 0890e72c4f..5eb16c37ac 100644 --- a/crates/proc-macro-srv/src/server_impl/rust_analyzer_span.rs +++ b/crates/proc-macro-srv/src/server_impl/rust_analyzer_span.rs @@ -62,8 +62,9 @@ impl server::Server for RaSpanServer<'_> { self.tracked_paths.insert(path.into()); } - fn literal_from_str(&mut self, s: &str) -> Result<Literal<Self::Span>, ()> { + fn literal_from_str(&mut self, s: &str) -> Result<Literal<Self::Span>, String> { literal_from_str(s, self.call_site) + .map_err(|()| "cannot parse string into literal".to_string()) } fn emit_diagnostic(&mut self, _: Diagnostic<Self::Span>) { @@ -81,14 +82,9 @@ impl server::Server for RaSpanServer<'_> { fn ts_is_empty(&mut self, stream: &Self::TokenStream) -> bool { stream.is_empty() } - fn ts_from_str(&mut self, src: &str) -> Self::TokenStream { - Self::TokenStream::from_str(src, self.call_site).unwrap_or_else(|e| { - Self::TokenStream::from_str( - &format!("compile_error!(\"failed to parse str to token stream: {e}\")"), - self.call_site, - ) - .unwrap() - }) + fn ts_from_str(&mut self, src: &str) -> Result<Self::TokenStream, String> { + Self::TokenStream::from_str(src, self.call_site) + .map_err(|e| format!("failed to parse str to token stream: {e}")) } fn ts_to_string(&mut self, stream: &Self::TokenStream) -> String { stream.to_string() diff --git a/crates/proc-macro-srv/src/server_impl/token_id.rs b/crates/proc-macro-srv/src/server_impl/token_id.rs index 70484c4dc2..e1c96095c8 100644 --- a/crates/proc-macro-srv/src/server_impl/token_id.rs +++ b/crates/proc-macro-srv/src/server_impl/token_id.rs @@ -67,8 +67,9 @@ impl server::Server for SpanIdServer<'_> { self.tracked_paths.insert(path.into()); } - fn literal_from_str(&mut self, s: &str) -> Result<Literal<Self::Span>, ()> { + fn literal_from_str(&mut self, s: &str) -> Result<Literal<Self::Span>, String> { literal_from_str(s, self.call_site) + .map_err(|()| "cannot parse string into literal".to_string()) } fn emit_diagnostic(&mut self, _: Diagnostic<Self::Span>) {} @@ -84,14 +85,9 @@ impl server::Server for SpanIdServer<'_> { fn ts_is_empty(&mut self, stream: &Self::TokenStream) -> bool { stream.is_empty() } - fn ts_from_str(&mut self, src: &str) -> Self::TokenStream { - Self::TokenStream::from_str(src, self.call_site).unwrap_or_else(|e| { - Self::TokenStream::from_str( - &format!("compile_error!(\"failed to parse str to token stream: {e}\")"), - self.call_site, - ) - .unwrap() - }) + fn ts_from_str(&mut self, src: &str) -> Result<Self::TokenStream, String> { + Self::TokenStream::from_str(src, self.call_site) + .map_err(|e| format!("failed to parse str to token stream: {e}")) } fn ts_to_string(&mut self, stream: &Self::TokenStream) -> String { stream.to_string() |