diff --git a/CHANGES.md b/CHANGES.md index 82b956d9e0..76fa83e573 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,8 @@ +## Version 11.11.1 + +- Fixes regression with Rust grammar. + + ## Version 11.11.0 CAVEATS / POTENTIALLY BREAKING CHANGES diff --git a/src/languages/rust.js b/src/languages/rust.js index 7c88d6045b..a4cef4f6eb 100644 --- a/src/languages/rust.js +++ b/src/languages/rust.js @@ -198,6 +198,10 @@ export default function(hljs) { begin: /b?"/, illegal: null }), + { + className: 'symbol', + begin: /'[a-zA-Z_][a-zA-Z0-9_]*/ + }, { scope: 'string', variants: [ @@ -214,10 +218,6 @@ export default function(hljs) { } ] }, - { - className: 'symbol', - begin: /'[a-zA-Z_][a-zA-Z0-9_]*/ - }, { className: 'number', variants: [ diff --git a/test/markup/rust/sample1.expect.txt b/test/markup/rust/sample1.expect.txt new file mode 100644 index 0000000000..662f246c18 --- /dev/null +++ b/test/markup/rust/sample1.expect.txt @@ -0,0 +1,30 @@ +use std::fmt::Debug; // Trait to bound with. + +#[derive(Debug)] +struct Ref<'a, T: 'a>(&'a T); +// `Ref` contains a reference to a generic type `T` that has +// some lifetime `'a` unknown by `Ref`. `T` is bounded such that any +// *references* in `T` must outlive `'a`. Additionally, the lifetime +// of `Ref` may not exceed `'a`. + +// A generic function which prints using the `Debug` trait. +fn print<T>(t: T) where + T: Debug { + println!("`print`: t is {:?}", t); +} + +// Here a reference to `T` is taken where `T` implements +// `Debug` and all *references* in `T` outlive `'a`. In +// addition, `'a` must outlive the function. +fn print_ref<'a, T>(t: &'a T) where + T: Debug + 'a { + println!("`print_ref`: t is {:?}", t); +} + +fn main() { + let x = 7; + let ref_x = Ref(&x); + + print_ref(&ref_x); + print(ref_x); +} diff --git a/test/markup/rust/sample1.txt b/test/markup/rust/sample1.txt new file mode 100644 index 0000000000..1e263307a9 --- /dev/null +++ b/test/markup/rust/sample1.txt @@ -0,0 +1,30 @@ +use std::fmt::Debug; // Trait to bound with. + +#[derive(Debug)] +struct Ref<'a, T: 'a>(&'a T); +// `Ref` contains a reference to a generic type `T` that has +// some lifetime `'a` unknown by `Ref`. `T` is bounded such that any +// *references* in `T` must outlive `'a`. Additionally, the lifetime +// of `Ref` may not exceed `'a`. + +// A generic function which prints using the `Debug` trait. +fn print(t: T) where + T: Debug { + println!("`print`: t is {:?}", t); +} + +// Here a reference to `T` is taken where `T` implements +// `Debug` and all *references* in `T` outlive `'a`. In +// addition, `'a` must outlive the function. +fn print_ref<'a, T>(t: &'a T) where + T: Debug + 'a { + println!("`print_ref`: t is {:?}", t); +} + +fn main() { + let x = 7; + let ref_x = Ref(&x); + + print_ref(&ref_x); + print(ref_x); +}