From d72803c027627efedf98d8e3958d3fb71d6f16d2 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Wed, 10 Aug 2022 00:09:34 -0400 Subject: [PATCH] don't mark specified values as volatile This is what we want, but it's not a complete fix. It does make these tests work, though! Good enough to commit. --- components/salsa-2022/src/function/specify.rs | 2 +- salsa-2022-tests/tests/hello_world.rs | 42 +++++++++--------- .../tests/tracked_fn_read_own_entity.rs | 43 +++++++++---------- 3 files changed, 43 insertions(+), 44 deletions(-) diff --git a/components/salsa-2022/src/function/specify.rs b/components/salsa-2022/src/function/specify.rs index 49065fb6..9195805e 100644 --- a/components/salsa-2022/src/function/specify.rs +++ b/components/salsa-2022/src/function/specify.rs @@ -50,7 +50,7 @@ where // - a result that is verified in the current revision, because it was set, which will use the set value // - a result that is NOT verified and has untracked inputs, which will re-execute (and likely panic) let inputs = QueryInputs { - untracked: true, + untracked: false, tracked: runtime.empty_dependencies(), }; diff --git a/salsa-2022-tests/tests/hello_world.rs b/salsa-2022-tests/tests/hello_world.rs index d9898243..2484245e 100644 --- a/salsa-2022-tests/tests/hello_world.rs +++ b/salsa-2022-tests/tests/hello_world.rs @@ -84,27 +84,27 @@ fn execute() { ]"#]]); } -// /// Create and mutate a distinct input. No re-execution required. -// #[test] -// fn red_herring() { -// let mut db = Database::default(); +/// Create and mutate a distinct input. No re-execution required. +#[test] +fn red_herring() { + let mut db = Database::default(); -// let input = MyInput::new(&mut db, 22); -// assert_eq!(final_result(&db, input), 22); -// db.assert_logs(expect![[r#" -// [ -// "final_result(MyInput(Id { value: 1 }))", -// "intermediate_result(MyInput(Id { value: 1 }))", -// ]"#]]); + let input = MyInput::new(&mut db, 22); + assert_eq!(final_result(&db, input), 22); + db.assert_logs(expect![[r#" + [ + "final_result(MyInput(Id { value: 1 }))", + "intermediate_result(MyInput(Id { value: 1 }))", + ]"#]]); -// // Create a distinct input and mutate it. -// // This will trigger a new revision in the database -// // but shouldn't actually invalidate our existing ones. -// let input2 = MyInput::new(&mut db, 44); -// input2.set_field(&mut db, 66); + // Create a distinct input and mutate it. + // This will trigger a new revision in the database + // but shouldn't actually invalidate our existing ones. + let input2 = MyInput::new(&mut db, 44); + input2.set_field(&mut db, 66); -// // Re-run the query on the original input. Nothing re-executes! -// assert_eq!(final_result(&db, input), 22); -// db.assert_logs(expect![[r#" -// []"#]]); -// } + // Re-run the query on the original input. Nothing re-executes! + assert_eq!(final_result(&db, input), 22); + db.assert_logs(expect![[r#" + []"#]]); +} diff --git a/salsa-2022-tests/tests/tracked_fn_read_own_entity.rs b/salsa-2022-tests/tests/tracked_fn_read_own_entity.rs index 18a0ceb8..949a5427 100644 --- a/salsa-2022-tests/tests/tracked_fn_read_own_entity.rs +++ b/salsa-2022-tests/tests/tracked_fn_read_own_entity.rs @@ -85,28 +85,27 @@ fn one_entity() { ]"#]]); } -// /// Create and mutate a distinct input. No re-execution required. -// #[test] -// fn red_herring() { -// let mut db = Database::default(); +/// Create and mutate a distinct input. No re-execution required. +#[test] +fn red_herring() { + let mut db = Database::default(); -// let input = MyInput::new(&mut db, 22); -// assert_eq!(final_result(&db, input), 22); -// db.assert_logs(expect![[r#" -// [ -// "final_result(MyInput(Id { value: 1 }))", -// "intermediate_result(MyInput(Id { value: 1 }))", -// ]"#]]); + let input = MyInput::new(&mut db, 22); + assert_eq!(final_result(&db, input), 22); + db.assert_logs(expect![[r#" + [ + "final_result(MyInput(Id { value: 1 }))", + "intermediate_result(MyInput(Id { value: 1 }))", + ]"#]]); -// // Create a distinct input and mutate it. -// // This will trigger a new revision in the database -// // but shouldn't actually invalidate our existing ones. -// let input2 = MyInput::new(&mut db, 44); -// input2.set_field(&mut db, 66); + // Create a distinct input and mutate it. + // This will trigger a new revision in the database + // but shouldn't actually invalidate our existing ones. + let input2 = MyInput::new(&mut db, 44); + input2.set_field(&mut db, 66); -// // Re-run the query on the original input. Nothing re-executes! -// assert_eq!(final_result(&db, input), 22); -// db.assert_logs(expect![[r#" -// [ -// ]"#]]); -// } + // Re-run the query on the original input. Nothing re-executes! + assert_eq!(final_result(&db, input), 22); + db.assert_logs(expect![[r#" + []"#]]); +}