mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 21:05:02 +00:00
reformat the world
This commit is contained in:
parent
5cb1d41a30
commit
12e3b4c70b
129 changed files with 727 additions and 2509 deletions
|
@ -17,8 +17,6 @@ pub(crate) fn validate_block_node(node: &ast::Block, errors: &mut Vec<SyntaxErro
|
|||
_ => {}
|
||||
}
|
||||
}
|
||||
errors.extend(
|
||||
node.attrs()
|
||||
.map(|attr| SyntaxError::new(InvalidBlockAttr, attr.syntax().range())),
|
||||
)
|
||||
errors
|
||||
.extend(node.attrs().map(|attr| SyntaxError::new(InvalidBlockAttr, attr.syntax().range())))
|
||||
}
|
||||
|
|
|
@ -28,10 +28,7 @@ pub(super) fn validate_byte_node(node: &ast::Byte, errors: &mut Vec<SyntaxError>
|
|||
}
|
||||
|
||||
if let Some(range) = components.suffix {
|
||||
errors.push(SyntaxError::new(
|
||||
InvalidSuffix,
|
||||
range + literal_range.start(),
|
||||
));
|
||||
errors.push(SyntaxError::new(InvalidSuffix, range + literal_range.start()));
|
||||
}
|
||||
|
||||
if len == 0 {
|
||||
|
@ -55,10 +52,7 @@ pub(super) fn validate_byte_component(
|
|||
AsciiCodeEscape => validate_byte_code_escape(text, range, errors),
|
||||
UnicodeEscape => errors.push(SyntaxError::new(UnicodeEscapeForbidden, range)),
|
||||
CodePoint => {
|
||||
let c = text
|
||||
.chars()
|
||||
.next()
|
||||
.expect("Code points should be one character long");
|
||||
let c = text.chars().next().expect("Code points should be one character long");
|
||||
|
||||
// These bytes must always be escaped
|
||||
if c == '\t' || c == '\r' || c == '\n' {
|
||||
|
@ -93,10 +87,7 @@ fn validate_byte_code_escape(text: &str, range: TextRange, errors: &mut Vec<Synt
|
|||
} else if text.chars().count() < 4 {
|
||||
errors.push(SyntaxError::new(TooShortByteCodeEscape, range));
|
||||
} else {
|
||||
assert!(
|
||||
text.chars().count() == 4,
|
||||
"ByteCodeEscape cannot be longer than 4 chars"
|
||||
);
|
||||
assert!(text.chars().count() == 4, "ByteCodeEscape cannot be longer than 4 chars");
|
||||
|
||||
if u8::from_str_radix(&text[2..], 16).is_err() {
|
||||
errors.push(SyntaxError::new(MalformedByteCodeEscape, range));
|
||||
|
@ -115,12 +106,7 @@ mod test {
|
|||
|
||||
fn assert_valid_byte(literal: &str) {
|
||||
let file = build_file(literal);
|
||||
assert!(
|
||||
file.errors().len() == 0,
|
||||
"Errors for literal '{}': {:?}",
|
||||
literal,
|
||||
file.errors()
|
||||
);
|
||||
assert!(file.errors().len() == 0, "Errors for literal '{}': {:?}", literal, file.errors());
|
||||
}
|
||||
|
||||
fn assert_invalid_byte(literal: &str) {
|
||||
|
@ -193,13 +179,7 @@ mod test {
|
|||
|
||||
#[test]
|
||||
fn test_invalid_unicode_escape() {
|
||||
let well_formed = [
|
||||
r"\u{FF}",
|
||||
r"\u{0}",
|
||||
r"\u{F}",
|
||||
r"\u{10FFFF}",
|
||||
r"\u{1_0__FF___FF_____}",
|
||||
];
|
||||
let well_formed = [r"\u{FF}", r"\u{0}", r"\u{F}", r"\u{10FFFF}", r"\u{1_0__FF___FF_____}"];
|
||||
for c in &well_formed {
|
||||
assert_invalid_byte(c);
|
||||
}
|
||||
|
|
|
@ -34,10 +34,7 @@ pub(crate) fn validate_byte_string_node(node: &ast::ByteString, errors: &mut Vec
|
|||
}
|
||||
|
||||
if let Some(range) = components.suffix {
|
||||
errors.push(SyntaxError::new(
|
||||
InvalidSuffix,
|
||||
range + literal_range.start(),
|
||||
));
|
||||
errors.push(SyntaxError::new(InvalidSuffix, range + literal_range.start()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -53,12 +50,7 @@ mod test {
|
|||
|
||||
fn assert_valid_str(literal: &str) {
|
||||
let file = build_file(literal);
|
||||
assert!(
|
||||
file.errors().len() == 0,
|
||||
"Errors for literal '{}': {:?}",
|
||||
literal,
|
||||
file.errors()
|
||||
);
|
||||
assert!(file.errors().len() == 0, "Errors for literal '{}': {:?}", literal, file.errors());
|
||||
}
|
||||
|
||||
fn assert_invalid_str(literal: &str) {
|
||||
|
@ -130,13 +122,7 @@ mod test {
|
|||
|
||||
#[test]
|
||||
fn test_invalid_unicode_escape() {
|
||||
let well_formed = [
|
||||
r"\u{FF}",
|
||||
r"\u{0}",
|
||||
r"\u{F}",
|
||||
r"\u{10FFFF}",
|
||||
r"\u{1_0__FF___FF_____}",
|
||||
];
|
||||
let well_formed = [r"\u{FF}", r"\u{0}", r"\u{F}", r"\u{10FFFF}", r"\u{1_0__FF___FF_____}"];
|
||||
for c in &well_formed {
|
||||
assert_invalid_str(c);
|
||||
}
|
||||
|
|
|
@ -31,10 +31,7 @@ pub(super) fn validate_char_node(node: &ast::Char, errors: &mut Vec<SyntaxError>
|
|||
}
|
||||
|
||||
if let Some(range) = components.suffix {
|
||||
errors.push(SyntaxError::new(
|
||||
InvalidSuffix,
|
||||
range + literal_range.start(),
|
||||
));
|
||||
errors.push(SyntaxError::new(InvalidSuffix, range + literal_range.start()));
|
||||
}
|
||||
|
||||
if len == 0 {
|
||||
|
@ -184,12 +181,7 @@ mod test {
|
|||
|
||||
fn assert_valid_char(literal: &str) {
|
||||
let file = build_file(literal);
|
||||
assert!(
|
||||
file.errors().len() == 0,
|
||||
"Errors for literal '{}': {:?}",
|
||||
literal,
|
||||
file.errors()
|
||||
);
|
||||
assert!(file.errors().len() == 0, "Errors for literal '{}': {:?}", literal, file.errors());
|
||||
}
|
||||
|
||||
fn assert_invalid_char(literal: &str) {
|
||||
|
@ -258,13 +250,7 @@ mod test {
|
|||
|
||||
#[test]
|
||||
fn test_valid_unicode_escape() {
|
||||
let valid = [
|
||||
r"\u{FF}",
|
||||
r"\u{0}",
|
||||
r"\u{F}",
|
||||
r"\u{10FFFF}",
|
||||
r"\u{1_0__FF___FF_____}",
|
||||
];
|
||||
let valid = [r"\u{FF}", r"\u{0}", r"\u{F}", r"\u{10FFFF}", r"\u{1_0__FF___FF_____}"];
|
||||
for c in &valid {
|
||||
assert_valid_char(c);
|
||||
}
|
||||
|
|
|
@ -29,10 +29,7 @@ pub(crate) fn validate_string_node(node: &ast::String, errors: &mut Vec<SyntaxEr
|
|||
}
|
||||
|
||||
if let Some(range) = components.suffix {
|
||||
errors.push(SyntaxError::new(
|
||||
InvalidSuffix,
|
||||
range + literal_range.start(),
|
||||
));
|
||||
errors.push(SyntaxError::new(InvalidSuffix, range + literal_range.start()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,12 +45,7 @@ mod test {
|
|||
|
||||
fn assert_valid_str(literal: &str) {
|
||||
let file = build_file(literal);
|
||||
assert!(
|
||||
file.errors().len() == 0,
|
||||
"Errors for literal '{}': {:?}",
|
||||
literal,
|
||||
file.errors()
|
||||
);
|
||||
assert!(file.errors().len() == 0, "Errors for literal '{}': {:?}", literal, file.errors());
|
||||
}
|
||||
|
||||
fn assert_invalid_str(literal: &str) {
|
||||
|
@ -121,13 +113,7 @@ mod test {
|
|||
|
||||
#[test]
|
||||
fn test_valid_unicode_escape() {
|
||||
let valid = [
|
||||
r"\u{FF}",
|
||||
r"\u{0}",
|
||||
r"\u{F}",
|
||||
r"\u{10FFFF}",
|
||||
r"\u{1_0__FF___FF_____}",
|
||||
];
|
||||
let valid = [r"\u{FF}", r"\u{0}", r"\u{F}", r"\u{10FFFF}", r"\u{1_0__FF___FF_____}"];
|
||||
for c in &valid {
|
||||
assert_valid_str(c);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue