mirror of
				https://github.com/rust-lang/rust-analyzer.git
				synced 2025-10-29 19:17:12 +00:00 
			
		
		
		
	fix: Fix proc-macro server crashing when parsing a non-lexable string into a TokenStream
This commit is contained in:
		
							parent
							
								
									6f3356d0dd
								
							
						
					
					
						commit
						d6666b16c4
					
				
					 3 changed files with 15 additions and 3 deletions
				
			
		|  | @ -131,7 +131,13 @@ impl server::TokenStream for TokenIdServer { | |||
|         stream.is_empty() | ||||
|     } | ||||
|     fn from_str(&mut self, src: &str) -> Self::TokenStream { | ||||
|         Self::TokenStream::from_str(src, self.call_site).expect("cannot parse string") | ||||
|         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 to_string(&mut self, stream: &Self::TokenStream) -> String { | ||||
|         stream.to_string() | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Lukas Wirth
						Lukas Wirth