diff options
Diffstat (limited to 'src/librustdoc/html/highlight')
7 files changed, 45 insertions, 39 deletions
diff --git a/src/librustdoc/html/highlight/fixtures/decorations.html b/src/librustdoc/html/highlight/fixtures/decorations.html index 45f567880..ebf29f9cb 100644 --- a/src/librustdoc/html/highlight/fixtures/decorations.html +++ b/src/librustdoc/html/highlight/fixtures/decorations.html @@ -1,2 +1,4 @@ -<span class="example"><span class="kw">let</span> <span class="ident">x</span> <span class="op">=</span> <span class="number">1</span>;</span> -<span class="kw">let</span> <span class="ident">y</span> <span class="op">=</span> <span class="number">2</span>;
\ No newline at end of file +<span class="example"><span class="kw">let </span>x = <span class="number">1</span>; +<span class="kw">let </span>y = <span class="number">2</span>; +</span><span class="example2"><span class="kw">let </span>z = <span class="number">3</span>; +</span><span class="kw">let </span>a = <span class="number">4</span>;
\ No newline at end of file diff --git a/src/librustdoc/html/highlight/fixtures/dos_line.html b/src/librustdoc/html/highlight/fixtures/dos_line.html index 1c8dbffe7..30b50ca7c 100644 --- a/src/librustdoc/html/highlight/fixtures/dos_line.html +++ b/src/librustdoc/html/highlight/fixtures/dos_line.html @@ -1,3 +1,3 @@ -<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">foo</span>() { +<span class="kw">pub fn </span>foo() { <span class="macro">println!</span>(<span class="string">"foo"</span>); } diff --git a/src/librustdoc/html/highlight/fixtures/highlight.html b/src/librustdoc/html/highlight/fixtures/highlight.html index abc2db179..9f73e03f9 100644 --- a/src/librustdoc/html/highlight/fixtures/highlight.html +++ b/src/librustdoc/html/highlight/fixtures/highlight.html @@ -1,4 +1,4 @@ -<span class="kw">use</span> <span class="ident"><span class="kw">crate</span>::a::foo</span>; -<span class="kw">use</span> <span class="ident"><span class="self">self</span>::whatever</span>; -<span class="kw">let</span> <span class="ident">x</span> <span class="op">=</span> <span class="ident"><span class="kw">super</span>::b::foo</span>; -<span class="kw">let</span> <span class="ident">y</span> <span class="op">=</span> <span class="ident"><span class="self">Self</span>::whatever</span>;
\ No newline at end of file +<span class="kw">use </span><span class="kw">crate</span>::a::foo; +<span class="kw">use </span><span class="self">self</span>::whatever; +<span class="kw">let </span>x = <span class="kw">super</span>::b::foo; +<span class="kw">let </span>y = <span class="self">Self</span>::whatever;
\ No newline at end of file diff --git a/src/librustdoc/html/highlight/fixtures/sample.html b/src/librustdoc/html/highlight/fixtures/sample.html index b117a12e3..4a5a3cf60 100644 --- a/src/librustdoc/html/highlight/fixtures/sample.html +++ b/src/librustdoc/html/highlight/fixtures/sample.html @@ -8,30 +8,31 @@ .lifetime { color: #B76514; } .question-mark { color: #ff9011; } </style> -<pre><code><span class="attribute">#![<span class="ident">crate_type</span> <span class="op">=</span> <span class="string">"lib"</span>]</span> +<pre><code><span class="attribute">#![crate_type = <span class="string">"lib"</span>] -<span class="kw">use</span> <span class="ident">std::path</span>::{<span class="ident">Path</span>, <span class="ident">PathBuf</span>}; +</span><span class="kw">use </span>std::path::{Path, PathBuf}; -<span class="attribute">#[<span class="ident">cfg</span>(<span class="ident">target_os</span> <span class="op">=</span> <span class="string">"linux"</span>)]</span> -<span class="kw">fn</span> <span class="ident">main</span>() -> () { - <span class="kw">let</span> <span class="ident">foo</span> <span class="op">=</span> <span class="bool-val">true</span> <span class="op">&&</span> <span class="bool-val">false</span> <span class="op">|</span><span class="op">|</span> <span class="bool-val">true</span>; - <span class="kw">let</span> <span class="kw">_</span>: <span class="kw-2">*const</span> () <span class="op">=</span> <span class="number">0</span>; - <span class="kw">let</span> <span class="kw">_</span> <span class="op">=</span> <span class="kw-2">&</span><span class="ident">foo</span>; - <span class="kw">let</span> <span class="kw">_</span> <span class="op">=</span> <span class="op">&&</span><span class="ident">foo</span>; - <span class="kw">let</span> <span class="kw">_</span> <span class="op">=</span> <span class="kw-2">*</span><span class="ident">foo</span>; - <span class="macro">mac!</span>(<span class="ident">foo</span>, <span class="kw-2">&mut</span> <span class="ident">bar</span>); - <span class="macro">assert!</span>(<span class="self">self</span>.<span class="ident">length</span> <span class="op"><</span> <span class="ident">N</span> <span class="op">&&</span> <span class="ident">index</span> <span class="op"><</span><span class="op">=</span> <span class="self">self</span>.<span class="ident">length</span>); - <span class="ident">::std::env::var</span>(<span class="string">"gateau"</span>).<span class="ident">is_ok</span>(); - <span class="attribute">#[<span class="ident">rustfmt::skip</span>]</span> - <span class="kw">let</span> <span class="ident">s</span>:<span class="ident">std::path::PathBuf</span> <span class="op">=</span> <span class="ident">std::path::PathBuf::new</span>(); - <span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">s</span> <span class="op">=</span> <span class="ident">String::new</span>(); +<span class="attribute">#[cfg(target_os = <span class="string">"linux"</span>)] +#[cfg(target_os = <span class="string">"windows"</span>)] +</span><span class="kw">fn </span>main() -> () { + <span class="kw">let </span>foo = <span class="bool-val">true </span>&& <span class="bool-val">false </span>|| <span class="bool-val">true</span>; + <span class="kw">let _</span>: <span class="kw-2">*const </span>() = <span class="number">0</span>; + <span class="kw">let _ </span>= <span class="kw-2">&</span>foo; + <span class="kw">let _ </span>= &&foo; + <span class="kw">let _ </span>= <span class="kw-2">*</span>foo; + <span class="macro">mac!</span>(foo, <span class="kw-2">&mut </span>bar); + <span class="macro">assert!</span>(<span class="self">self</span>.length < N && index <= <span class="self">self</span>.length); + ::std::env::var(<span class="string">"gateau"</span>).is_ok(); + <span class="attribute">#[rustfmt::skip] + </span><span class="kw">let </span>s:std::path::PathBuf = std::path::PathBuf::new(); + <span class="kw">let </span><span class="kw-2">mut </span>s = String::new(); - <span class="kw">match</span> <span class="kw-2">&</span><span class="ident">s</span> { - <span class="kw-2">ref</span> <span class="kw-2">mut</span> <span class="ident">x</span> => {} + <span class="kw">match </span><span class="kw-2">&</span>s { + <span class="kw-2">ref mut </span>x => {} } } -<span class="macro">macro_rules!</span> <span class="ident">bar</span> { - (<span class="macro-nonterminal">$</span><span class="macro-nonterminal">foo</span>:<span class="ident">tt</span>) => {}; +<span class="macro">macro_rules! </span>bar { + (<span class="macro-nonterminal">$foo</span>:tt) => {}; } </code></pre> diff --git a/src/librustdoc/html/highlight/fixtures/sample.rs b/src/librustdoc/html/highlight/fixtures/sample.rs index fbfdc6767..ef85b566c 100644 --- a/src/librustdoc/html/highlight/fixtures/sample.rs +++ b/src/librustdoc/html/highlight/fixtures/sample.rs @@ -3,6 +3,7 @@ use std::path::{Path, PathBuf}; #[cfg(target_os = "linux")] +#[cfg(target_os = "windows")] fn main() -> () { let foo = true && false || true; let _: *const () = 0; diff --git a/src/librustdoc/html/highlight/fixtures/union.html b/src/librustdoc/html/highlight/fixtures/union.html index c0acf31a0..9f8915282 100644 --- a/src/librustdoc/html/highlight/fixtures/union.html +++ b/src/librustdoc/html/highlight/fixtures/union.html @@ -1,8 +1,8 @@ -<span class="kw">union</span> <span class="ident">Foo</span> { - <span class="ident">i</span>: <span class="ident">i8</span>, - <span class="ident">u</span>: <span class="ident">i8</span>, +<span class="kw">union </span>Foo { + i: i8, + u: i8, } -<span class="kw">fn</span> <span class="ident">main</span>() { - <span class="kw">let</span> <span class="ident">union</span> <span class="op">=</span> <span class="number">0</span>; +<span class="kw">fn </span>main() { + <span class="kw">let </span>union = <span class="number">0</span>; } diff --git a/src/librustdoc/html/highlight/tests.rs b/src/librustdoc/html/highlight/tests.rs index 1fea7e983..a5e633df4 100644 --- a/src/librustdoc/html/highlight/tests.rs +++ b/src/librustdoc/html/highlight/tests.rs @@ -3,7 +3,6 @@ use crate::html::format::Buffer; use expect_test::expect_file; use rustc_data_structures::fx::FxHashMap; use rustc_span::create_default_session_globals_then; -use rustc_span::edition::Edition; const STYLE: &str = r#" <style> @@ -23,7 +22,7 @@ fn test_html_highlighting() { let src = include_str!("fixtures/sample.rs"); let html = { let mut out = Buffer::new(); - write_code(&mut out, src, Edition::Edition2018, None, None); + write_code(&mut out, src, None, None); format!("{}<pre><code>{}</code></pre>\n", STYLE, out.into_inner()) }; expect_file!["fixtures/sample.html"].assert_eq(&html); @@ -37,7 +36,7 @@ fn test_dos_backline() { println!(\"foo\");\r\n\ }\r\n"; let mut html = Buffer::new(); - write_code(&mut html, src, Edition::Edition2018, None, None); + write_code(&mut html, src, None, None); expect_file!["fixtures/dos_line.html"].assert_eq(&html.into_inner()); }); } @@ -51,7 +50,7 @@ let x = super::b::foo; let y = Self::whatever;"; let mut html = Buffer::new(); - write_code(&mut html, src, Edition::Edition2018, None, None); + write_code(&mut html, src, None, None); expect_file!["fixtures/highlight.html"].assert_eq(&html.into_inner()); }); } @@ -61,7 +60,7 @@ fn test_union_highlighting() { create_default_session_globals_then(|| { let src = include_str!("fixtures/union.rs"); let mut html = Buffer::new(); - write_code(&mut html, src, Edition::Edition2018, None, None); + write_code(&mut html, src, None, None); expect_file!["fixtures/union.html"].assert_eq(&html.into_inner()); }); } @@ -70,12 +69,15 @@ fn test_union_highlighting() { fn test_decorations() { create_default_session_globals_then(|| { let src = "let x = 1; -let y = 2;"; +let y = 2; +let z = 3; +let a = 4;"; let mut decorations = FxHashMap::default(); - decorations.insert("example", vec![(0, 10)]); + decorations.insert("example", vec![(0, 10), (11, 21)]); + decorations.insert("example2", vec![(22, 32)]); let mut html = Buffer::new(); - write_code(&mut html, src, Edition::Edition2018, None, Some(DecorationInfo(decorations))); + write_code(&mut html, src, None, Some(DecorationInfo(decorations))); expect_file!["fixtures/decorations.html"].assert_eq(&html.into_inner()); }); } |