Skip to content

Commit e7f2979

Browse files
Add regression test for moving variables in let statement
1 parent fa46717 commit e7f2979

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

testing/tests/ref_deref.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ fn test_ref_deref() {
3939
#[derive(Template)]
4040
#[template(
4141
source = r#"
42-
{%- let x = *title -%}
42+
{%- let x = **title -%}
4343
{%- if x == "another" -%}
4444
another2
4545
{%- else -%}

testing/tests/vars.rs

+20
Original file line numberDiff line numberDiff line change
@@ -131,3 +131,23 @@ fn test_decl_assign_range() {
131131
let t = DeclAssignRange;
132132
assert_eq!(t.render().unwrap(), "1");
133133
}
134+
135+
#[derive(Template)]
136+
#[template(
137+
source = "
138+
{%- set t = title -%}
139+
{{t}}/{{title -}}
140+
",
141+
ext = "txt"
142+
)]
143+
struct DoNotMoveFields {
144+
title: String,
145+
}
146+
147+
#[test]
148+
fn test_not_moving_fields_in_var() {
149+
let x = DoNotMoveFields {
150+
title: "a".to_string(),
151+
};
152+
assert_eq!(x.render().unwrap(), "a/a");
153+
}

0 commit comments

Comments
 (0)