mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
cargo clippy --fix
This commit is contained in:
parent
1ab8c7fd27
commit
fad4fa163c
178 changed files with 595 additions and 738 deletions
|
@ -356,8 +356,12 @@ impl ast::UseTreeList {
|
|||
let remove_brace_in_use_tree_list = |u: &ast::UseTreeList| {
|
||||
let use_tree_count = u.use_trees().count();
|
||||
if use_tree_count == 1 {
|
||||
u.l_curly_token().map(ted::remove);
|
||||
u.r_curly_token().map(ted::remove);
|
||||
if let Some(a) = u.l_curly_token() {
|
||||
ted::remove(a)
|
||||
}
|
||||
if let Some(a) = u.r_curly_token() {
|
||||
ted::remove(a)
|
||||
}
|
||||
u.comma().for_each(ted::remove);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -478,6 +478,38 @@ impl Radix {
|
|||
}
|
||||
}
|
||||
|
||||
impl ast::Char {
|
||||
pub fn value(&self) -> Option<char> {
|
||||
let mut text = self.text();
|
||||
if text.starts_with('\'') {
|
||||
text = &text[1..];
|
||||
} else {
|
||||
return None;
|
||||
}
|
||||
if text.ends_with('\'') {
|
||||
text = &text[0..text.len() - 1];
|
||||
}
|
||||
|
||||
unescape_char(text).ok()
|
||||
}
|
||||
}
|
||||
|
||||
impl ast::Byte {
|
||||
pub fn value(&self) -> Option<u8> {
|
||||
let mut text = self.text();
|
||||
if text.starts_with("b\'") {
|
||||
text = &text[2..];
|
||||
} else {
|
||||
return None;
|
||||
}
|
||||
if text.ends_with('\'') {
|
||||
text = &text[0..text.len() - 1];
|
||||
}
|
||||
|
||||
unescape_byte(text).ok()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::ast::{self, make, FloatNumber, IntNumber};
|
||||
|
@ -579,35 +611,3 @@ bcde", b"abcde",
|
|||
check_int_value("1_1_1_1_1_1", 111111);
|
||||
}
|
||||
}
|
||||
|
||||
impl ast::Char {
|
||||
pub fn value(&self) -> Option<char> {
|
||||
let mut text = self.text();
|
||||
if text.starts_with('\'') {
|
||||
text = &text[1..];
|
||||
} else {
|
||||
return None;
|
||||
}
|
||||
if text.ends_with('\'') {
|
||||
text = &text[0..text.len() - 1];
|
||||
}
|
||||
|
||||
unescape_char(text).ok()
|
||||
}
|
||||
}
|
||||
|
||||
impl ast::Byte {
|
||||
pub fn value(&self) -> Option<u8> {
|
||||
let mut text = self.text();
|
||||
if text.starts_with("b\'") {
|
||||
text = &text[2..];
|
||||
} else {
|
||||
return None;
|
||||
}
|
||||
if text.ends_with('\'') {
|
||||
text = &text[0..text.len() - 1];
|
||||
}
|
||||
|
||||
unescape_byte(text).ok()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue