From edd26add3b20ad399c7e53f245b5e12e3e1bac70 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sun, 5 Jun 2022 23:37:59 +0200 Subject: [PATCH] Update minifier version to 0.2.1 --- Cargo.lock | 4 ++-- src/librustdoc/Cargo.toml | 2 +- src/librustdoc/html/render/write_shared.rs | 10 ++++++---- src/librustdoc/theme.rs | 1 + src/librustdoc/theme/tests.rs | 2 +- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bea0c13000ca6..fde30506b60a3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2391,9 +2391,9 @@ dependencies = [ [[package]] name = "minifier" -version = "0.1.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7071d17e2898e134cabf624f43cdefa0cedf57c739e964df3d0df9d028701a72" +checksum = "ac96d1e7a65f206443f95afff6de8f1690c77c97d6fc9c9bb2d2cd0662e9ff9f" [[package]] name = "minimal-lexical" diff --git a/src/librustdoc/Cargo.toml b/src/librustdoc/Cargo.toml index 03ceb63168c06..78470e8deb342 100644 --- a/src/librustdoc/Cargo.toml +++ b/src/librustdoc/Cargo.toml @@ -11,7 +11,7 @@ arrayvec = { version = "0.7", default-features = false } askama = { version = "0.11", default-features = false, features = ["config"] } atty = "0.2" pulldown-cmark = { version = "0.9", default-features = false } -minifier = "0.1.0" +minifier = "0.2.1" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" smallvec = "1.6.1" diff --git a/src/librustdoc/html/render/write_shared.rs b/src/librustdoc/html/render/write_shared.rs index 325d3a3143426..8f08ff2ece3f6 100644 --- a/src/librustdoc/html/render/write_shared.rs +++ b/src/librustdoc/html/render/write_shared.rs @@ -122,11 +122,13 @@ impl Context<'_> { if minify { let contents = contents.as_ref(); let contents = if resource.extension() == Some(OsStr::new("css")) { - minifier::css::minify(contents).map_err(|e| { - Error::new(format!("failed to minify CSS file: {}", e), resource.path(self)) - })? + minifier::css::minify(contents) + .map_err(|e| { + Error::new(format!("failed to minify CSS file: {}", e), resource.path(self)) + })? + .to_string() } else { - minifier::js::minify(contents) + minifier::js::minify(contents).to_string() }; self.write_shared(resource, contents, emit) } else { diff --git a/src/librustdoc/theme.rs b/src/librustdoc/theme.rs index 20258c3b1dc1c..0118d7dd20722 100644 --- a/src/librustdoc/theme.rs +++ b/src/librustdoc/theme.rs @@ -185,6 +185,7 @@ fn build_rule(v: &[u8], positions: &[usize]) -> String { .intersperse(" ") .collect::(), ) + .map(|css| css.to_string()) .unwrap_or_else(|_| String::new()) } diff --git a/src/librustdoc/theme/tests.rs b/src/librustdoc/theme/tests.rs index 4968ffd5a27a7..ae8f43c6d55ba 100644 --- a/src/librustdoc/theme/tests.rs +++ b/src/librustdoc/theme/tests.rs @@ -106,7 +106,7 @@ fn check_invalid_css() { #[test] fn test_with_minification() { let text = include_str!("../html/static/css/themes/dark.css"); - let minified = minifier::css::minify(&text).expect("CSS minification failed"); + let minified = minifier::css::minify(&text).expect("CSS minification failed").to_string(); let against = load_css_paths(text.as_bytes()); let other = load_css_paths(minified.as_bytes());