mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 21:35:20 +00:00
ra_mbe: convert_literal now works with malformed tokens
This commit is contained in:
parent
baf832d6d9
commit
93a19bda17
1 changed files with 3 additions and 2 deletions
|
@ -1,7 +1,7 @@
|
||||||
//! FIXME: write short doc here
|
//! FIXME: write short doc here
|
||||||
|
|
||||||
use ra_parser::{Token, TokenSource};
|
use ra_parser::{Token, TokenSource};
|
||||||
use ra_syntax::{lex_single_valid_syntax_kind, SmolStr, SyntaxKind, SyntaxKind::*, T};
|
use ra_syntax::{lex_single_syntax_kind, SmolStr, SyntaxKind, SyntaxKind::*, T};
|
||||||
use std::cell::{Cell, Ref, RefCell};
|
use std::cell::{Cell, Ref, RefCell};
|
||||||
use tt::buffer::{Cursor, TokenBuffer};
|
use tt::buffer::{Cursor, TokenBuffer};
|
||||||
|
|
||||||
|
@ -129,7 +129,8 @@ fn convert_delim(d: Option<tt::DelimiterKind>, closing: bool) -> TtToken {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn convert_literal(l: &tt::Literal) -> TtToken {
|
fn convert_literal(l: &tt::Literal) -> TtToken {
|
||||||
let kind = lex_single_valid_syntax_kind(&l.text)
|
let kind = lex_single_syntax_kind(&l.text)
|
||||||
|
.map(|(kind, _error)| kind)
|
||||||
.filter(|kind| kind.is_literal())
|
.filter(|kind| kind.is_literal())
|
||||||
.unwrap_or_else(|| match l.text.as_ref() {
|
.unwrap_or_else(|| match l.text.as_ref() {
|
||||||
"true" => T![true],
|
"true" => T![true],
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue