From 9a942d055fe93636116d6e8ab36e243da9d811c0 Mon Sep 17 00:00:00 2001 From: Jason White Date: Fri, 18 Nov 2022 12:36:51 -0800 Subject: [PATCH] Remove dependencies on associated_type_defaults unstable feature Summary: Removes usage of the `associated_type_defaults` unstable feature, but does not actually disable the feature yet. This brings us one step closer to removing all usage of unstable nightly features, which will allow publishing a crate on https://crates.io. Reviewed By: rrnewton Differential Revision: D41388745 fbshipit-source-id: f347a577857a713fe3088a556cbf37ffe92e5553 --- reverie-examples/chaos.rs | 4 +++- reverie-examples/chrome-trace/global_state.rs | 1 + reverie-examples/chunky_print.rs | 2 ++ reverie-examples/counter1.rs | 3 +++ reverie-examples/counter2.rs | 3 +++ reverie-examples/debug.rs | 3 +++ reverie-examples/noop.rs | 3 +++ reverie-examples/pedigree.rs | 1 + reverie-examples/strace/tool.rs | 1 + reverie-examples/strace_minimal.rs | 3 +++ reverie/src/guest.rs | 5 +++++ tests/backtrace.rs | 3 +++ tests/basics.rs | 9 ++++++++- tests/busywait.rs | 1 + tests/convert.rs | 6 ++++++ tests/cpuid.rs | 2 ++ tests/delay_signal.rs | 2 ++ tests/exit.rs | 2 ++ .../gdbserver-integration/gdbserver-helper/src/server.rs | 3 +++ tests/parallelism.rs | 4 ++++ tests/rdtsc.rs | 2 ++ tests/signal.rs | 3 +++ tests/signalfd.rs | 1 + tests/spinlock.rs | 5 ++++- tests/stack.rs | 9 +++++++++ tests/standalone/at_random.rs | 3 +++ tests/standalone/inject_then_tail_inject.rs | 3 +++ tests/standalone/parallel_tasks.rs | 1 + tests/stat.rs | 5 ++++- tests/state.rs | 1 + tests/suppression.rs | 3 +++ tests/vdso.rs | 3 +++ tests/vfork.rs | 6 ++++++ 33 files changed, 102 insertions(+), 4 deletions(-) diff --git a/reverie-examples/chaos.rs b/reverie-examples/chaos.rs index 4bbe008..6b08ed6 100644 --- a/reverie-examples/chaos.rs +++ b/reverie-examples/chaos.rs @@ -71,6 +71,8 @@ struct ChaosToolGlobal {} #[reverie::global_tool] impl GlobalTool for ChaosToolGlobal { + type Request = (); + type Response = (); type Config = ChaosOpts; async fn receive_rpc(&self, _from: Pid, _request: ()) {} @@ -78,8 +80,8 @@ impl GlobalTool for ChaosToolGlobal { #[reverie::tool] impl Tool for ChaosTool { - type ThreadState = bool; type GlobalState = ChaosToolGlobal; + type ThreadState = bool; fn new(_pid: Pid, _cfg: &ChaosOpts) -> Self { Self { diff --git a/reverie-examples/chrome-trace/global_state.rs b/reverie-examples/chrome-trace/global_state.rs index c680623..d975fd7 100644 --- a/reverie-examples/chrome-trace/global_state.rs +++ b/reverie-examples/chrome-trace/global_state.rs @@ -46,6 +46,7 @@ impl Default for GlobalState { impl GlobalTool for GlobalState { type Request = ThreadExit; type Response = (); + type Config = (); async fn receive_rpc(&self, _pid: Pid, event: ThreadExit) { let mut events = self.events.lock().unwrap(); diff --git a/reverie-examples/chunky_print.rs b/reverie-examples/chunky_print.rs index 2710ce4..e3bbe3f 100644 --- a/reverie-examples/chunky_print.rs +++ b/reverie-examples/chunky_print.rs @@ -68,6 +68,8 @@ struct Inner { impl GlobalTool for ChunkyPrintGlobal { type Request = Msg; type Response = (); + type Config = (); + async fn receive_rpc(&self, from: Tid, m: Msg) { let mut mg = self.0.lock().unwrap(); match m { diff --git a/reverie-examples/counter1.rs b/reverie-examples/counter1.rs index 013554e..dcaba93 100644 --- a/reverie-examples/counter1.rs +++ b/reverie-examples/counter1.rs @@ -41,6 +41,8 @@ pub struct IncrMsg(Sysno); impl GlobalTool for CounterGlobal { type Request = IncrMsg; type Response = (); + type Config = (); + async fn init_global_state(_: &Self::Config) -> Self { CounterGlobal { num_syscalls: AtomicU64::new(0), @@ -55,6 +57,7 @@ impl GlobalTool for CounterGlobal { #[reverie::tool] impl Tool for CounterLocal { type GlobalState = CounterGlobal; + type ThreadState = (); async fn handle_syscall_event>( &self, diff --git a/reverie-examples/counter2.rs b/reverie-examples/counter2.rs index 3ed94a7..68e8e6b 100644 --- a/reverie-examples/counter2.rs +++ b/reverie-examples/counter2.rs @@ -65,6 +65,8 @@ pub struct IncrMsg(u64, u64); impl GlobalTool for CounterGlobal { type Request = IncrMsg; type Response = (); + type Config = (); + async fn init_global_state(_: &Self::Config) -> Self { CounterGlobal { inner: Mutex::new(GlobalInner { @@ -74,6 +76,7 @@ impl GlobalTool for CounterGlobal { }), } } + async fn receive_rpc(&self, _from: Pid, IncrMsg(n, t): IncrMsg) -> Self::Response { let mut mg = self.inner.lock().unwrap(); mg.total_syscalls += n; diff --git a/reverie-examples/debug.rs b/reverie-examples/debug.rs index a7a4dd3..a6289e1 100644 --- a/reverie-examples/debug.rs +++ b/reverie-examples/debug.rs @@ -16,6 +16,9 @@ use reverie_util::CommonToolArguments; #[derive(Debug, Default)] struct DebugTool; impl Tool for DebugTool { + type GlobalState = (); + type ThreadState = (); + fn subscriptions(_cfg: &()) -> Subscription { Subscription::none() } diff --git a/reverie-examples/noop.rs b/reverie-examples/noop.rs index 704951c..242890c 100644 --- a/reverie-examples/noop.rs +++ b/reverie-examples/noop.rs @@ -20,6 +20,9 @@ struct NoopTool; #[reverie::tool] impl Tool for NoopTool { + type GlobalState = (); + type ThreadState = (); + fn subscriptions(_cfg: &()) -> Subscription { Subscription::none() } diff --git a/reverie-examples/pedigree.rs b/reverie-examples/pedigree.rs index 970f925..7397770 100644 --- a/reverie-examples/pedigree.rs +++ b/reverie-examples/pedigree.rs @@ -28,6 +28,7 @@ struct PedigreeLocal(Pedigree); #[reverie::tool] impl Tool for PedigreeLocal { + type GlobalState = (); type ThreadState = PedigreeLocal; fn new(pid: Pid, _cfg: &()) -> Self { diff --git a/reverie-examples/strace/tool.rs b/reverie-examples/strace/tool.rs index a0220a5..bae4c3d 100644 --- a/reverie-examples/strace/tool.rs +++ b/reverie-examples/strace/tool.rs @@ -32,6 +32,7 @@ pub struct Strace; #[reverie::tool] impl Tool for Strace { type GlobalState = GlobalState; + type ThreadState = (); fn subscriptions(cfg: &Config) -> Subscription { // Check if we're only excluding things. diff --git a/reverie-examples/strace_minimal.rs b/reverie-examples/strace_minimal.rs index 985058b..c167b8a 100644 --- a/reverie-examples/strace_minimal.rs +++ b/reverie-examples/strace_minimal.rs @@ -19,6 +19,9 @@ struct StraceTool {} #[reverie::tool] impl Tool for StraceTool { + type GlobalState = (); + type ThreadState = (); + async fn handle_syscall_event>( &self, guest: &mut T, diff --git a/reverie/src/guest.rs b/reverie/src/guest.rs index b368698..ecc58b5 100644 --- a/reverie/src/guest.rs +++ b/reverie/src/guest.rs @@ -130,6 +130,8 @@ pub trait Guest: Send + GlobalRPC { /// /// #[reverie::tool] /// impl Tool for MyTool { + /// /// Global state is unused + /// type GlobalState = (); /// /// Count of successful syscalls. /// type ThreadState = u64; /// @@ -219,6 +221,9 @@ pub trait Guest: Send + GlobalRPC { /// /// #[reverie::tool] /// impl Tool for MyTool { + /// type GlobalState = (); + /// type ThreadState = (); + /// /// async fn handle_syscall_event>( /// &self, /// guest: &mut T, diff --git a/tests/backtrace.rs b/tests/backtrace.rs index cb97acb..39cae89 100644 --- a/tests/backtrace.rs +++ b/tests/backtrace.rs @@ -21,6 +21,9 @@ struct TestTool; #[reverie::tool] impl Tool for TestTool { + type GlobalState = (); + type ThreadState = (); + async fn handle_syscall_event>( &self, guest: &mut T, diff --git a/tests/basics.rs b/tests/basics.rs index 9b53f59..c74a095 100644 --- a/tests/basics.rs +++ b/tests/basics.rs @@ -43,7 +43,10 @@ use serde::Serialize; #[derive(Debug, Default)] struct NoopTool; -impl Tool for NoopTool {} +impl Tool for NoopTool { + type GlobalState = (); + type ThreadState = (); +} #[test] fn noop_tool_test() { @@ -71,6 +74,8 @@ pub struct IncrMsg(Sysno); impl GlobalTool for CounterGlobal { type Request = IncrMsg; type Response = (); + type Config = (); + async fn receive_rpc(&self, _from: Pid, _: IncrMsg) -> Self::Response { AtomicU64::fetch_add(&self.num_syscalls, 1, Ordering::SeqCst); } @@ -79,6 +84,8 @@ impl GlobalTool for CounterGlobal { #[reverie::tool] impl Tool for CounterLocal { type GlobalState = CounterGlobal; + type ThreadState = (); + async fn handle_syscall_event>( &self, guest: &mut T, diff --git a/tests/busywait.rs b/tests/busywait.rs index c716750..3bc4e3d 100644 --- a/tests/busywait.rs +++ b/tests/busywait.rs @@ -93,6 +93,7 @@ const TIMEOUT: TimerSchedule = TimerSchedule::Rcbs(120_000_000); #[reverie::tool] impl Tool for LocalState { type GlobalState = GlobalState; + type ThreadState = (); async fn handle_thread_start>(&self, guest: &mut T) -> Result<(), Error> { guest.send_rpc(IncrMsg::Increment).await; diff --git a/tests/convert.rs b/tests/convert.rs index e71ae22..3161378 100644 --- a/tests/convert.rs +++ b/tests/convert.rs @@ -25,6 +25,9 @@ struct LocalStateInject; #[reverie::tool] impl Tool for LocalStateTailInject { + type GlobalState = (); + type ThreadState = (); + async fn handle_syscall_event>( &self, guest: &mut T, @@ -43,6 +46,9 @@ impl Tool for LocalStateTailInject { #[reverie::tool] impl Tool for LocalStateInject { + type GlobalState = (); + type ThreadState = (); + async fn handle_syscall_event>( &self, guest: &mut T, diff --git a/tests/cpuid.rs b/tests/cpuid.rs index 9a8e31e..e66d0e5 100644 --- a/tests/cpuid.rs +++ b/tests/cpuid.rs @@ -28,6 +28,7 @@ struct GlobalState { impl GlobalTool for GlobalState { type Request = (); type Response = u64; + type Config = (); // Just get the current time. async fn receive_rpc(&self, _from: Pid, _request: ()) -> u64 { @@ -42,6 +43,7 @@ struct LocalState {} #[reverie::tool] impl Tool for LocalState { type GlobalState = GlobalState; + type ThreadState = (); fn subscriptions(_cfg: &()) -> Subscription { let mut s = Subscription::none(); diff --git a/tests/delay_signal.rs b/tests/delay_signal.rs index fc843b6..6cfec0d 100644 --- a/tests/delay_signal.rs +++ b/tests/delay_signal.rs @@ -53,7 +53,9 @@ fn is_syscall_restarted(errno: Errno) -> bool { #[reverie::tool] impl Tool for LocalState { + type GlobalState = (); type ThreadState = ThreadState; + async fn handle_signal_event>( &self, guest: &mut T, diff --git a/tests/exit.rs b/tests/exit.rs index cd09fa6..ce5ebfc 100644 --- a/tests/exit.rs +++ b/tests/exit.rs @@ -33,6 +33,7 @@ struct GlobalState { impl GlobalTool for GlobalState { type Request = ExitStatus; type Response = (); + type Config = (); async fn receive_rpc(&self, from: Pid, exit_status: ExitStatus) -> Self::Response { self.exited @@ -48,6 +49,7 @@ struct InjectExitTool {} #[reverie::tool] impl Tool for InjectExitTool { type GlobalState = GlobalState; + type ThreadState = (); async fn on_exit_process>( self, diff --git a/tests/gdbserver-integration/gdbserver-helper/src/server.rs b/tests/gdbserver-integration/gdbserver-helper/src/server.rs index a7d49f6..273c5c4 100644 --- a/tests/gdbserver-integration/gdbserver-helper/src/server.rs +++ b/tests/gdbserver-integration/gdbserver-helper/src/server.rs @@ -30,6 +30,9 @@ pub struct GdbServerCommand { struct TestTool; impl Tool for TestTool { + type GlobalState = (); + type ThreadState = (); + fn subscriptions(_cfg: &()) -> Subscription { Subscription::all() } diff --git a/tests/parallelism.rs b/tests/parallelism.rs index 74d95e1..fb1a99f 100644 --- a/tests/parallelism.rs +++ b/tests/parallelism.rs @@ -27,6 +27,7 @@ struct TestTool {} impl GlobalTool for GlobalState { type Request = (); type Response = (); + type Config = (); async fn receive_rpc(&self, _from: Tid, _threads: Self::Request) -> Self::Response { // TODO: replace this with an ivar read: @@ -106,6 +107,9 @@ struct TestTool2 {} #[reverie::tool] impl Tool for TestTool2 { + type GlobalState = (); + type ThreadState = (); + async fn handle_syscall_event>( &self, guest: &mut T, diff --git a/tests/rdtsc.rs b/tests/rdtsc.rs index cb95766..b042fb8 100644 --- a/tests/rdtsc.rs +++ b/tests/rdtsc.rs @@ -30,6 +30,7 @@ struct GlobalState { impl GlobalTool for GlobalState { type Request = Rdtsc; type Response = RdtscResult; + type Config = (); async fn init_global_state(_: &Self::Config) -> Self { GlobalState { @@ -59,6 +60,7 @@ struct LocalState {} #[reverie::tool] impl Tool for LocalState { type GlobalState = GlobalState; + type ThreadState = (); fn subscriptions(_cfg: &()) -> Subscription { let mut s = Subscription::none(); diff --git a/tests/signal.rs b/tests/signal.rs index 692b6e8..3a2ba68 100644 --- a/tests/signal.rs +++ b/tests/signal.rs @@ -25,6 +25,9 @@ struct LocalState; #[reverie::tool] impl Tool for LocalState { + type GlobalState = (); + type ThreadState = (); + async fn handle_syscall_event>( &self, guest: &mut T, diff --git a/tests/signalfd.rs b/tests/signalfd.rs index 5e3c1a5..deb8eeb 100644 --- a/tests/signalfd.rs +++ b/tests/signalfd.rs @@ -25,6 +25,7 @@ struct ThreadState; #[reverie::tool] impl Tool for LocalState { + type GlobalState = (); type ThreadState = ThreadState; async fn handle_syscall_event>( diff --git a/tests/spinlock.rs b/tests/spinlock.rs index aa5f8af..1598240 100644 --- a/tests/spinlock.rs +++ b/tests/spinlock.rs @@ -12,7 +12,10 @@ use reverie::Tool; struct LocalState; #[reverie::tool] -impl Tool for LocalState {} +impl Tool for LocalState { + type GlobalState = (); + type ThreadState = (); +} #[cfg(all(not(sanitized), test))] mod tests { diff --git a/tests/stack.rs b/tests/stack.rs index f2ce6a7..504300a 100644 --- a/tests/stack.rs +++ b/tests/stack.rs @@ -28,6 +28,9 @@ struct LocalState; #[reverie::tool] impl Tool for LocalState { + type GlobalState = (); + type ThreadState = (); + async fn handle_syscall_event>( &self, guest: &mut T, @@ -96,6 +99,9 @@ struct LocalState2; #[reverie::tool] impl Tool for LocalState2 { + type GlobalState = (); + type ThreadState = (); + async fn handle_syscall_event>( &self, guest: &mut T, @@ -130,6 +136,9 @@ struct LocalState3; #[reverie::tool] impl Tool for LocalState3 { + type GlobalState = (); + type ThreadState = (); + async fn handle_syscall_event>( &self, guest: &mut T, diff --git a/tests/standalone/at_random.rs b/tests/standalone/at_random.rs index 302cd50..6023d35 100644 --- a/tests/standalone/at_random.rs +++ b/tests/standalone/at_random.rs @@ -24,6 +24,9 @@ const PRNG_SEED: [u8; 16] = [ #[reverie::tool] impl Tool for TestTool { + type GlobalState = (); + type ThreadState = (); + async fn handle_post_exec>(&self, guest: &mut T) -> Result<(), Errno> { if let Some(ptr) = guest.auxv().at_random() { // It is safe to mutate this address since libc has not yet had a diff --git a/tests/standalone/inject_then_tail_inject.rs b/tests/standalone/inject_then_tail_inject.rs index 57515de..43ec537 100644 --- a/tests/standalone/inject_then_tail_inject.rs +++ b/tests/standalone/inject_then_tail_inject.rs @@ -29,6 +29,8 @@ type Dupcount = u64; #[reverie::global_tool] impl GlobalTool for TestTool { + type Request = (); + type Response = (); type Config = Dupcount; async fn receive_rpc(&self, _from: Pid, _message: ()) {} @@ -43,6 +45,7 @@ const NUM_REPS: Dupcount = 3; #[reverie::tool] impl Tool for TestTool { type GlobalState = TestTool; + type ThreadState = (); async fn handle_syscall_event>( &self, diff --git a/tests/standalone/parallel_tasks.rs b/tests/standalone/parallel_tasks.rs index 40f895e..772bb42 100644 --- a/tests/standalone/parallel_tasks.rs +++ b/tests/standalone/parallel_tasks.rs @@ -23,6 +23,7 @@ struct TestTool {} #[reverie::tool] impl Tool for TestTool { type GlobalState = (); + type ThreadState = (); } const NUM_ELEMENTS: usize = 1_000_000; diff --git a/tests/stat.rs b/tests/stat.rs index 1cf41fe..dc8ea6c 100644 --- a/tests/stat.rs +++ b/tests/stat.rs @@ -14,7 +14,10 @@ use reverie::Tool; struct LocalState; #[reverie::tool] -impl Tool for LocalState {} +impl Tool for LocalState { + type GlobalState = (); + type ThreadState = (); +} #[cfg(all(not(sanitized), test))] mod tests { diff --git a/tests/state.rs b/tests/state.rs index 4fc533d..aa77184 100644 --- a/tests/state.rs +++ b/tests/state.rs @@ -43,6 +43,7 @@ struct ThreadState { impl GlobalTool for GlobalState { type Request = Vec<(i32, usize, usize)>; type Response = (); + type Config = (); async fn receive_rpc(&self, from: Pid, threads: Self::Request) -> Self::Response { // Merge with global state. diff --git a/tests/suppression.rs b/tests/suppression.rs index 91d05ef..e7e5f3d 100644 --- a/tests/suppression.rs +++ b/tests/suppression.rs @@ -19,6 +19,9 @@ struct TestTool; #[reverie::tool] impl Tool for TestTool { + type GlobalState = (); + type ThreadState = (); + async fn handle_syscall_event>( &self, guest: &mut T, diff --git a/tests/vdso.rs b/tests/vdso.rs index c888c9c..0c40490 100644 --- a/tests/vdso.rs +++ b/tests/vdso.rs @@ -19,6 +19,9 @@ struct LocalState; #[reverie::tool] impl Tool for LocalState { + type GlobalState = (); + type ThreadState = (); + async fn handle_syscall_event>( &self, guest: &mut T, diff --git a/tests/vfork.rs b/tests/vfork.rs index b77eaa7..cdff0ec 100644 --- a/tests/vfork.rs +++ b/tests/vfork.rs @@ -27,6 +27,9 @@ struct LocalStateVforkClone; #[reverie::tool] impl Tool for LocalStateVfork { + type GlobalState = (); + type ThreadState = (); + async fn handle_syscall_event>( &self, guest: &mut T, @@ -49,6 +52,9 @@ impl Tool for LocalStateVfork { #[reverie::tool] impl Tool for LocalStateVforkClone { + type GlobalState = (); + type ThreadState = (); + async fn handle_syscall_event>( &self, guest: &mut T,