diff options
| author | Jacob Hoffman-Andrews <github@hoffman-andrews.com> | 2022-07-16 09:07:40 -0700 |
|---|---|---|
| committer | Jacob Hoffman-Andrews <github@hoffman-andrews.com> | 2022-08-09 20:17:48 -0700 |
| commit | 5938fd704d4358a12081cba810f3055531da4386 (patch) | |
| tree | 6411b7d2f976631ce771535444b07928eee818e9 /src/librustdoc/html/highlight/tests.rs | |
| parent | b573e10d21b69ebfadf41aa9c2f0a27919fe4480 (diff) | |
| download | rust-5938fd704d4358a12081cba810f3055531da4386.tar.gz rust-5938fd704d4358a12081cba810f3055531da4386.zip | |
rustdoc: simplify highlight.rs
Split render_with_highlighting, which took many optional parameters, into three functions for specific purposes, which each take a smaller number of mostly required parameters. Remove some plumbing to pass through an "edition" parameter, which was used solely to avoid highlighting some 2021 Edition keywords in non-2021 code.
Diffstat (limited to 'src/librustdoc/html/highlight/tests.rs')
| -rw-r--r-- | src/librustdoc/html/highlight/tests.rs | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/librustdoc/html/highlight/tests.rs b/src/librustdoc/html/highlight/tests.rs index 1fea7e983b4..4861a8ad32d 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()); }); } @@ -75,7 +74,7 @@ let y = 2;"; decorations.insert("example", vec![(0, 10)]); 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()); }); } |
