diff --git a/devices/src/virtio/fs/passthrough.rs b/devices/src/virtio/fs/passthrough.rs index cc581100a8..5d62bfe906 100644 --- a/devices/src/virtio/fs/passthrough.rs +++ b/devices/src/virtio/fs/passthrough.rs @@ -354,7 +354,7 @@ fn set_creds( ScopedGid::new(gid, oldgid).and_then(|gid| Ok((ScopedUid::new(uid, olduid)?, gid))) } -thread_local!(static THREAD_FSCREATE: RefCell> = RefCell::new(None)); +thread_local!(static THREAD_FSCREATE: RefCell> = const { RefCell::new(None) }); // Opens and returns a write-only handle to /proc/thread-self/attr/fscreate. Panics if it fails to // open the file. diff --git a/devices/src/virtio/vhost/user/device/net.rs b/devices/src/virtio/vhost/user/device/net.rs index 1ed1e06b2d..8df6c41e77 100644 --- a/devices/src/virtio/vhost/user/device/net.rs +++ b/devices/src/virtio/vhost/user/device/net.rs @@ -40,7 +40,7 @@ use crate::virtio::Interrupt; use crate::virtio::Queue; thread_local! { - pub(crate) static NET_EXECUTOR: OnceCell = OnceCell::new(); + pub(crate) static NET_EXECUTOR: OnceCell = const { OnceCell::new() }; } // TODO(b/188947559): Come up with better way to include these constants. Compiler errors happen diff --git a/kvm/src/lib.rs b/kvm/src/lib.rs index 6a0284b87d..f38b487841 100644 --- a/kvm/src/lib.rs +++ b/kvm/src/lib.rs @@ -1033,7 +1033,7 @@ pub struct VcpuThread { signal_num: Option, } -thread_local!(static VCPU_THREAD: RefCell> = RefCell::new(None)); +thread_local!(static VCPU_THREAD: RefCell> = const { RefCell::new(None) }); impl Vcpu { /// Constructs a new VCPU for `vm`. diff --git a/src/crosvm/sys/linux/vcpu.rs b/src/crosvm/sys/linux/vcpu.rs index 4a80280ade..718e49133b 100644 --- a/src/crosvm/sys/linux/vcpu.rs +++ b/src/crosvm/sys/linux/vcpu.rs @@ -168,7 +168,7 @@ where Ok(vcpu) } -thread_local!(static VCPU_THREAD: RefCell> = RefCell::new(None)); +thread_local!(static VCPU_THREAD: RefCell> = const { RefCell::new(None) }); fn set_vcpu_thread_local(vcpu: Option<&dyn VcpuArch>, signal_num: c_int) { // Block signal while we add -- if a signal fires (very unlikely,