diff --git a/autotests/folding/test.markdown.fold b/autotests/folding/test.markdown.fold --- a/autotests/folding/test.markdown.fold +++ b/autotests/folding/test.markdown.fold @@ -162,9 +162,9 @@ ## Rust ```rust -fn main() { +fn main() { println!("Hello world!"); -} +} ``` ## XML diff --git a/autotests/folding/test.rs.fold b/autotests/folding/test.rs.fold --- a/autotests/folding/test.rs.fold +++ b/autotests/folding/test.rs.fold @@ -1,48 +1,63 @@ // Comment NOTE -/* Comment FIXME ALERT - */ +/* Comment FIXME ALERT + */ // Identifiers hellóñαωΑΩµo!(); HellóñαωΑΩµ::Hello; 'hellóñαωΑΩµo pub use self::PathParameters::*; -pub use symbol::{Ident, Symbol as Name}; -use serialize::{self, Encoder, Decoder}; +pub use symbol::{Ident, Symbol as Name}; +use serialize::{self, Encoder, Decoder}; use std::u32; -#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Copy)] +#[derive(Clone, PartialEq, Eq, Hash, Copy)] -pub struct Lifetime { +pub struct Lifetime { pub id: NodeId, pub span: Span, pub bounds: Vec -} +} -impl fmt::Debug for Lifetime { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { +impl fmt::Debug for Lifetime { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "lifetime({}: {})", self.id, pprust::lifetime_to_string(self)) - } -} -impl<'a> PartialEq<&'a str> for Path { - fn eq(&self, string: &&'a str) -> bool { - self.segments.len() == 1 && self.segments[0].identifier.name == *string - } -} - -enum TraitBoundModifier { + } +} +impl<'a> PartialEq<&'a str> for Path { + fn eq(&self, string: &&'a str) -> bool { + self.segments.len() == 1 && self.segments[0].identifier.name == *string + } +} + +enum TraitBoundModifier { None, Maybe, -} +} -union tests { +union tests { a: i128, b: isize, -} +} + +// Self vs self +trait T { + type Item; + // `Self` will be whatever type that implements `T`. + fn new() -> Self; + // `Self::Item` will be the type alias in the implementation. + fn f(&self) -> Self::Item; +} -#[valid types] -fn types() { +// Raw identifiers +extern crate foo; +fn main() { + foo::r#try(); +} + +#[valid types] +fn types() { let num = 333_3_; let num_u8: u8 = 333u8; let num_u16: u16 = 333u16; @@ -53,35 +68,39 @@ let num_float: f32 = 333.45f32; let binary = 0b1_010; - let invalid_binary= 0b1_015; - let octal = 0o21535; - let invalid_octal = 0o64_92; - let hexadecimal = 0x73A2_F; - let invalid_hexadecimal = 0x7_3AY; let char1: char = 'a'; let char2: char = '\n'; let char3: char = '\u{123_AF}'; - let invalid_char1: char = '\y'; + + let byte1: u8 = b'a'; + let byte2: u8 = b'\x13'; + + let string: str = "hello \n \r \u{123_________fd_} \ + bye"; + let byte_string: str = b"hello \t \0 \u{123} \b bye"; + let raw_string1: str = r"hello \t \b"; + let raw_string2: str = r####"hello \n "### bye"########; + let raw_string3: str = br####"hello \n"####; + + // Invalid + + let invalid_binary= 0b1_015; + let invalid_octal = 0o64_92; + let invalid_hexadecimal = 0x7_3AY; + + let invalid_char1: char = '\y'; let invalid_char2: char = '\324'; let invalid_char3: char = '%%'; let invalid_char4: char = '\n\dfd'; let invalid_char5: char = 'aaaaa'; let open_char: char = '&&&; - let byte1: u8 = b'a'; - let byte2: u8 = b'\x13'; let invalid_byte1: u8 = b'ab'; let invalid_byte2: u8 = b'\b'; let invalid_byte2: u8 = b'\u{123}'; - let string: str = "hello \n \r \u{123_________fd_} \ - bye"; let invalid_string: str = "hello \b \u{_123} \u{1234567} \ bye"; - let byte_string: str = b"hello \t \0 \u{123} \b bye"; - let raw_string1: str = r"hello \t \b"; - let raw_string2: str = r####"hello \n "### bye"########; - let raw_string3: str = br####"hello \n"####; -} +} diff --git a/autotests/html/test.rs.html b/autotests/html/test.rs.html --- a/autotests/html/test.rs.html +++ b/autotests/html/test.rs.html @@ -13,12 +13,12 @@ HellóñαωΑΩµ::Hello; 'hellóñαωΑΩµo -pub use self::PathParameters::*; +pub use self::PathParameters::*; pub use symbol::{Ident, Symbol as Name}; use serialize::{self, Encoder, Decoder}; use std::u32; -#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Copy)] +#[derive(Clone, PartialEq, Eq, Hash, Copy)] pub struct Lifetime { pub id: NodeId, @@ -47,6 +47,21 @@ b: isize, } +// Self vs self +trait T { + type Item; + // `Self` will be whatever type that implements `T`. + fn new() -> Self; + // `Self::Item` will be the type alias in the implementation. + fn f(&self) -> Self::Item; +} + +// Raw identifiers +extern crate foo; +fn main() { + foo::r#try(); +} + #[valid types] fn types() { let num = 333_3_; @@ -59,36 +74,40 @@ let num_float: f32 = 333.45f32; let binary = 0b1_010; - let invalid_binary= 0b1_015; - let octal = 0o21535; - let invalid_octal = 0o64_92; - let hexadecimal = 0x73A2_F; - let invalid_hexadecimal = 0x7_3AY; let char1: char = 'a'; let char2: char = '\n'; let char3: char = '\u{123_AF}'; - let invalid_char1: char = '\y'; + + let byte1: u8 = b'a'; + let byte2: u8 = b'\x13'; + + let string: str = "hello \n \r \u{123_________fd_} \ + bye"; + let byte_string: str = b"hello \t \0 \u{123} \b bye"; + let raw_string1: str = r"hello \t \b"; + let raw_string2: str = r####"hello \n "### bye"########; + let raw_string3: str = br####"hello \n"####; + + // Invalid + + let invalid_binary= 0b1_015; + let invalid_octal = 0o64_92; + let invalid_hexadecimal = 0x7_3AY; + + let invalid_char1: char = '\y'; let invalid_char2: char = '\324'; let invalid_char3: char = '%%'; let invalid_char4: char = '\n\dfd'; let invalid_char5: char = 'aaaaa'; let open_char: char = '&&&; - let byte1: u8 = b'a'; - let byte2: u8 = b'\x13'; let invalid_byte1: u8 = b'ab'; let invalid_byte2: u8 = b'\b'; let invalid_byte2: u8 = b'\u{123}'; - let string: str = "hello \n \r \u{123_________fd_} \ - bye"; let invalid_string: str = "hello \b \u{_123} \u{1234567} \ bye"; - let byte_string: str = b"hello \t \0 \u{123} \b bye"; - let raw_string1: str = r"hello \t \b"; - let raw_string2: str = r####"hello \n "### bye"########; - let raw_string3: str = br####"hello \n"####; } diff --git a/autotests/input/test.rs b/autotests/input/test.rs --- a/autotests/input/test.rs +++ b/autotests/input/test.rs @@ -12,7 +12,7 @@ use serialize::{self, Encoder, Decoder}; use std::u32; -#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Copy)] +#[derive(Clone, PartialEq, Eq, Hash, Copy)] pub struct Lifetime { pub id: NodeId, @@ -41,6 +41,21 @@ b: isize, } +// Self vs self +trait T { + type Item; + // `Self` will be whatever type that implements `T`. + fn new() -> Self; + // `Self::Item` will be the type alias in the implementation. + fn f(&self) -> Self::Item; +} + +// Raw identifiers +extern crate foo; +fn main() { + foo::r#try(); +} + #[valid types] fn types() { let num = 333_3_; @@ -53,35 +68,39 @@ let num_float: f32 = 333.45f32; let binary = 0b1_010; - let invalid_binary= 0b1_015; - let octal = 0o21535; - let invalid_octal = 0o64_92; - let hexadecimal = 0x73A2_F; - let invalid_hexadecimal = 0x7_3AY; let char1: char = 'a'; let char2: char = '\n'; let char3: char = '\u{123_AF}'; - let invalid_char1: char = '\y'; + + let byte1: u8 = b'a'; + let byte2: u8 = b'\x13'; + + let string: str = "hello \n \r \u{123_________fd_} \ + bye"; + let byte_string: str = b"hello \t \0 \u{123} \b bye"; + let raw_string1: str = r"hello \t \b"; + let raw_string2: str = r####"hello \n "### bye"########; + let raw_string3: str = br####"hello \n"####; + + // Invalid + + let invalid_binary= 0b1_015; + let invalid_octal = 0o64_92; + let invalid_hexadecimal = 0x7_3AY; + + let invalid_char1: char = '\y'; let invalid_char2: char = '\324'; let invalid_char3: char = '%%'; let invalid_char4: char = '\n\dfd'; let invalid_char5: char = 'aaaaa'; let open_char: char = '&&&; - let byte1: u8 = b'a'; - let byte2: u8 = b'\x13'; let invalid_byte1: u8 = b'ab'; let invalid_byte2: u8 = b'\b'; let invalid_byte2: u8 = b'\u{123}'; - let string: str = "hello \n \r \u{123_________fd_} \ - bye"; let invalid_string: str = "hello \b \u{_123} \u{1234567} \ bye"; - let byte_string: str = b"hello \t \0 \u{123} \b bye"; - let raw_string1: str = r"hello \t \b"; - let raw_string2: str = r####"hello \n "### bye"########; - let raw_string3: str = br####"hello \n"####; } diff --git a/autotests/reference/test.markdown.ref b/autotests/reference/test.markdown.ref --- a/autotests/reference/test.markdown.ref +++ b/autotests/reference/test.markdown.ref @@ -163,7 +163,7 @@
```rust
fn main() {
- println!("Hello world!");
+ println!("Hello world!");
}
```

diff --git a/autotests/reference/test.rs.ref b/autotests/reference/test.rs.ref --- a/autotests/reference/test.rs.ref +++ b/autotests/reference/test.rs.ref @@ -3,85 +3,104 @@ */

// Identifiers
-hellóñαωΑΩµo!();
-HellóñαωΑΩµ::Hello;
+hellóñαωΑΩµo!();
+HellóñαωΑΩµ::Hello;
'hellóñαωΑΩµo

-pub use self::PathParameters::*;
-pub use symbol::{Ident, Symbol as Name};
-use serialize::{self, Encoder, Decoder};
-use std::u32;
+pub use self::PathParameters::*;
+pub use symbol::{Ident, Symbol as Name};
+use serialize::{self, Encoder, Decoder};
+use std::u32;

-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Copy)]
+#[derive(Clone, PartialEq, Eq, Hash, Copy)]

pub struct Lifetime {
- pub id: NodeId,
- pub span: Span,
- pub bounds: Vec
+ pub id: NodeId,
+ pub span: Span,
+ pub bounds: Vec<PathSegment>
}

impl fmt::Debug for Lifetime {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- write!(f, "lifetime({}: {})", self.id, pprust::lifetime_to_string(self))
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ write!(f, "lifetime({}: {})", self.id, pprust::lifetime_to_string(self))
}
}
-impl<'a> PartialEq<&'a str> for Path {
- fn eq(&self, string: &&'a str) -> bool {
- self.segments.len() == 1 && self.segments[0].identifier.name == *string
+impl<'a> PartialEq<&'a str> for Path {
+ fn eq(&self, string: &&'a str) -> bool {
+ self.segments.len() == 1 && self.segments[0].identifier.name == *string
}
}

enum TraitBoundModifier {
- None,
- Maybe,
+ None,
+ Maybe,
}

union tests {
- a: i128,
- b: isize,
+ a: i128,
+ b: isize,
+}
+
+// Self vs self
+trait T {
+ type Item;
+ // `Self` will be whatever type that implements `T`.
+ fn new() -> Self;
+ // `Self::Item` will be the type alias in the implementation.
+ fn f(&self) -> Self::Item;
+}
+
+// Raw identifiers
+extern crate foo;
+fn main() {
+ foo::r#try();
}

#[valid types]
fn types() {
- let num = 333_3_;
- let num_u8: u8 = 333u8;
- let num_u16: u16 = 333u16;
- let num_u32: u32 = 333u32;
- let num_u64: u64 = 333u64;
- let num_u128: u128 = 333u128;
- let num_usize: usize = 333usize;
- let num_float: f32 = 333.45f32;
-
- let binary = 0b1_010;
- let invalid_binary= 0b1_015;
-
- let octal = 0o21535;
- let invalid_octal = 0o64_92;
-
- let hexadecimal = 0x73A2_F;
- let invalid_hexadecimal = 0x7_3AY;
-
- let char1: char = 'a';
- let char2: char = '\n';
- let char3: char = '\u{123_AF}';
- let invalid_char1: char = '\y';
- let invalid_char2: char = '\324';
- let invalid_char3: char = '%%';
- let invalid_char4: char = '\n\dfd';
- let invalid_char5: char = 'aaaaa';
- let open_char: char = '&&&;
-
- let byte1: u8 = b'a';
- let byte2: u8 = b'\x13';
- let invalid_byte1: u8 = b'ab';
- let invalid_byte2: u8 = b'\b';
- let invalid_byte2: u8 = b'\u{123}';
-
- let string: str = "hello \n \r \u{123_________fd_} \
- bye";
- let invalid_string: str = "hello \b \u{_123} \u{1234567} \ bye";
- let byte_string: str = b"hello \t \0 \u{123} \b bye";
- let raw_string1: str = r"hello \t \b";
- let raw_string2: str = r####"hello \n "### bye"########;
- let raw_string3: str = br####"hello \n"####;
+ let num = 333_3_;
+ let num_u8: u8 = 333u8;
+ let num_u16: u16 = 333u16;
+ let num_u32: u32 = 333u32;
+ let num_u64: u64 = 333u64;
+ let num_u128: u128 = 333u128;
+ let num_usize: usize = 333usize;
+ let num_float: f32 = 333.45f32;
+
+ let binary = 0b1_010;
+ let octal = 0o21535;
+ let hexadecimal = 0x73A2_F;
+
+ let char1: char = 'a';
+ let char2: char = '\n';
+ let char3: char = '\u{123_AF}';
+
+ let byte1: u8 = b'a';
+ let byte2: u8 = b'\x13';
+
+ let string: str = "hello \n \r \u{123_________fd_} \
+ bye";
+ let byte_string: str = b"hello \t \0 \u{123} \b bye";
+ let raw_string1: str = r"hello \t \b";
+ let raw_string2: str = r####"hello \n "### bye"########;
+ let raw_string3: str = br####"hello \n"####;
+
+ // Invalid
+
+ let invalid_binary= 0b1_015;
+ let invalid_octal = 0o64_92;
+ let invalid_hexadecimal = 0x7_3AY;
+
+ let invalid_char1: char = '\y';
+ let invalid_char2: char = '\324';
+ let invalid_char3: char = '%%';
+ let invalid_char4: char = '\n\dfd';
+ let invalid_char5: char = 'aaaaa';
+ let open_char: char = '&&&;
+
+ let invalid_byte1: u8 = b'ab';
+ let invalid_byte2: u8 = b'\b';
+ let invalid_byte2: u8 = b'\u{123}';
+
+ let invalid_string: str = "hello \b \u{_123} \u{1234567} \ bye";
}
diff --git a/data/syntax/rust.xml b/data/syntax/rust.xml --- a/data/syntax/rust.xml +++ b/data/syntax/rust.xml @@ -33,7 +33,7 @@ ]> - + fn @@ -45,14 +45,17 @@ abstract alignof as + async + await become box break const continue crate default do + dyn else enum extern @@ -76,14 +79,12 @@ pure ref return - Self - self sizeof static struct super trait - type + try typeof union unsafe @@ -93,52 +94,125 @@ where while yield + - + + Add + AddAssign + Alloc + Any AsMut AsRef - AsSlice - CharExt + Binary + BitAnd + BitAndAssign + BitOr + BitOrAssign + BitXor + BitXorAssign + Borrow + BorrowMut + BuildHasher Clone + CoerceUnsized Copy Debug - Decodable Default + Deref + DerefMut + DispatchFromDyn Display + Div + DivAssign DoubleEndedIterator Drop - Encodable Eq ExactSizeIterator Extend + FixedSizeArray Fn + FnBox FnMut FnOnce From - FromPrimitive + FromIterator + FromStr + FusedIterator + Future + Generator + GlobalAlloc Hash + Hasher + Index + IndexMut Into IntoIterator Iterator - IteratorExt - MutPtrExt + LowerExp + LowerHex + Mul + MulAssign + Neg + Not + Octal Ord PartialEq PartialOrd - PtrExt - Rand - RustcDecodable - RustcEncodable + Pointer + Product + RangeBounds + Rem + RemAssign Send + Shl + ShlAssign + Shr + ShrAssign Sized + SliceIndex + Step + Sub + SubAssign + Sum + Sync + TrustedLen + Try + TryFrom + TryInto + Unpin + Unsize + UpperExp + UpperHex + Write + + AsSlice + BufRead + CharExt + Decodable + Encodable + Error + FromPrimitive + IteratorExt + MultiSpan + MutPtrExt + Pattern + PtrExt + Rand + Read + RefUnwindSafe + Seek SliceConcatExt SliceExt Str StrExt - Sync + TDynBenchFn + Termination ToOwned + ToSocketAddrs ToString + UnwindSafe bool @@ -213,6 +287,32 @@ Failure Cons Nil + + + MAX + + REPLACEMENT_CHARACTER + UNICODE_VERSION + + DIGITS + EPSILON + INFINITY + MANTISSA_DIGITS + MAX_10_EXP + MAX_EXP + MIN + MIN_10_EXP + MIN_EXP + MIN_POSITIVE + NAN + NEG_INFINITY + RADIX + + MAIN_SEPARATOR + + ONCE_INIT + + UNIX_EPOCH EXIT_FAILURE @@ -263,62 +363,75 @@ + - - - - - - - + + + + + + + + + + + + - + + + - - + + + + + - - + + + - - - + + + + + + + + + - - - - - - + @@ -333,6 +446,10 @@ + + + + @@ -365,6 +482,7 @@ + @@ -376,4 +494,4 @@ - +