@@ -204,6 +204,17 @@ pub fn upgrade(input: &str) -> Upgrade {
204 continue;
204 continue;
207+ // Directives removed without a replacement: drop the line
209+ && ["@assert ", "@warn ", "@debug ", "@log ", "@deprecated "]
211+ .any(|d| trimmed.starts_with(d) && !user_defined.contains(&&d[1..d.len() - 1]))
207 // --- Line rewrites ---
218 // --- Line rewrites ---
208 let mut new_line = line.to_string();
219 let mut new_line = line.to_string();
209 if attr_depth == 0 {
220 if attr_depth == 0 {
@@ -688,16 +699,6 @@ fn rewrite_directive_line(
688 .unwrap_or(value);
699 .unwrap_or(value);
689 return format!("{pad}@meta og:{} {}", key, value);
700 return format!("{pad}@meta og:{} {}", key, value);
691− if let Some(rest) = trimmed.strip_prefix("@debug ") {
692− return format!("{pad}@warn {}", rest);
694− if let Some(rest) = trimmed.strip_prefix("@log ") {
695− let shown: Vec<String> = rest
697− .map(|v| format!("{} = ${}", v.trim_start_matches('$'), v.trim_start_matches('$')))
699− return format!("{pad}@warn {}", shown.join(", "));
701 // `@let x = $a ~ " " ~ $b` → `@let x "$a $b"` (`~` was removed:
702 // `@let x = $a ~ " " ~ $b` → `@let x "$a $b"` (`~` was removed:
702 // interpolated strings do the same)
703 // interpolated strings do the same)
703 if let Some(rest) = trimmed.strip_prefix("@let ")
704 if let Some(rest) = trimmed.strip_prefix("@let ")
@@ -805,9 +806,6 @@ fn rewrite_directive_line(
805 {pad}@head\n{pad} <link rel=\"preload\" href=\"{url}\" as=\"font\" crossorigin>"
806 {pad}@head\n{pad} <link rel=\"preload\" href=\"{url}\" as=\"font\" crossorigin>"
808− if trimmed.starts_with("@deprecated ") {
809− return String::new();
811 if trimmed.starts_with("@breakpoint ") {
809 if trimmed.starts_with("@breakpoint ") {
812 manual.push((
810 manual.push((
@@ -1209,7 +1207,7 @@ fn rename_filters(line: &str) -> String {
1211/// Turn `$name|filter:arg|...` chains into function calls: bare in
1209/// Turn `$name|filter:arg|...` chains into function calls: bare in
1212−/// expressions (`@if`, `@else if`, `@assert`, `@let x = ...`), and as
1210+/// expressions (`@if`, `@else if`, `@let x = ...`), and as
1213/// `${...}` interpolation everywhere else.
1211/// `${...}` interpolation everywhere else.
1214fn convert_filters(line: &str) -> String {
1212fn convert_filters(line: &str) -> String {
1215 let line = rename_filters(line);
1213 let line = rename_filters(line);
@@ -1217,7 +1215,7 @@ fn convert_filters(line: &str) -> String {
1217 return line;
1215 return line;
1219 let trimmed = line.trim_start();
1217 let trimmed = line.trim_start();
1220− let expression_line = ["@if ", "@else if ", "@assert "]
1218+ let expression_line = ["@if ", "@else if "]
1222 .any(|p| trimmed.starts_with(p))
1220 .any(|p| trimmed.starts_with(p))
1223 || trimmed
1221 || trimmed
@@ -1469,7 +1467,7 @@ mod tests {
1469 "@page [lang en, favicon /f.png] Home\n@text hi\n"
1467 "@page [lang en, favicon /f.png] Home\n@text hi\n"
1471 assert_eq!(up("@og title \"My Page\""), "@meta og:title My Page");
1469 assert_eq!(up("@og title \"My Page\""), "@meta og:title My Page");
1472− assert_eq!(up("@debug hi $x\n@log $a $b"), "@warn hi $x\n@warn a = $a, b = $b");
1470+ assert_eq!(up("@debug hi $x\n@log $a $b\n@assert $x == 1\n@warn hi\n@text x"), "@text x");
1473 assert_eq!(up("@component card $t\n @text $t"), "@let card $t\n @text $t");
1471 assert_eq!(up("@component card $t\n @text $t"), "@let card $t\n @text $t");
1474 assert_eq!(up("@el [color $on ? green : gray]"), "@el [color if($on, green, gray)]");
1472 assert_eq!(up("@el [color $on ? green : gray]"), "@el [color if($on, green, gray)]");
1475 let r = upgrade("@lang en\n@text hi");
1473 let r = upgrade("@lang en\n@text hi");
@@ -1554,7 +1552,7 @@ mod tests {
1554 up("@font-face Inter fonts/inter.woff2"),
1552 up("@font-face Inter fonts/inter.woff2"),
1555 "@style\n @font-face { font-family: 'Inter'; src: url('fonts/inter.woff2') format('woff2'); font-display: swap; }\n@head\n <link rel=\"preload\" href=\"fonts/inter.woff2\" as=\"font\" crossorigin>"
1553 "@style\n @font-face { font-family: 'Inter'; src: url('fonts/inter.woff2') format('woff2'); font-display: swap; }\n@head\n <link rel=\"preload\" href=\"fonts/inter.woff2\" as=\"font\" crossorigin>"
1557− assert_eq!(up("@deprecated old\n@let x 1"), "\n@let x 1");
1555+ assert_eq!(up("@deprecated old\n@let x 1"), "@let x 1");
1558 assert_eq!(upgrade("@breakpoint tablet 600").manual.len(), 1);
1556 assert_eq!(upgrade("@breakpoint tablet 600").manual.len(), 1);