[rust] Enable clippy::collection_is_never_read.

This lint checks for collections that accumulate items but are
never accessed.

Adds allows for a small number of cases that use the collections
to hold items to drop them together at a single time. Actual
fixes landed in prior CLs.

Change-Id: I5d66f4207b66a9369cfc0eedb73954acc6dfbd90
Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/1155513
Reviewed-by: Tyler Mandry <tmandry@google.com>
Commit-Queue: Auto-Submit <auto-submit@fuchsia-infra.iam.gserviceaccount.com>
Owners-Override: Kevin Lindkvist <lindkvist@google.com>
Fuchsia-Auto-Submit: Adam Perry <adamperry@google.com>
diff --git a/build/config/rust/lints/BUILD.gn b/build/config/rust/lints/BUILD.gn
index c4b5e9b..e5f4473 100644
--- a/build/config/rust/lints/BUILD.gn
+++ b/build/config/rust/lints/BUILD.gn
@@ -9,6 +9,7 @@
     # go/keep-sorted start
 
     "-Wclippy::clear_with_drain",
+    "-Wclippy::collection_is_never_read",
     "-Wclippy::or_fun_call",
     "-Wclippy::perf",
     "-Wclippy::unnecessary_lazy_evaluation",
diff --git a/examples/components/storage/src/main.rs b/examples/components/storage/src/main.rs
index 965a232..d8b22e6 100644
--- a/examples/components/storage/src/main.rs
+++ b/examples/components/storage/src/main.rs
@@ -26,6 +26,7 @@
 async fn main() -> Result<(), Error> {
     info!("Initializing and serving inspect on servicefs");
     let mut fs = ServiceFs::new();
+    #[allow(clippy::collection_is_never_read)]
     let mut inspect_nodes = Vec::new();
     let _inspect_server_task =
         inspect_runtime::publish(&INSPECTOR, inspect_runtime::PublishOptions::default());
diff --git a/src/connectivity/bluetooth/lib/fuchsia-audio-dai/src/test.rs b/src/connectivity/bluetooth/lib/fuchsia-audio-dai/src/test.rs
index 1ecfeb4..1d653c7 100644
--- a/src/connectivity/bluetooth/lib/fuchsia-audio-dai/src/test.rs
+++ b/src/connectivity/bluetooth/lib/fuchsia-audio-dai/src/test.rs
@@ -128,6 +128,7 @@
         ..Default::default()
     };
 
+    #[allow(clippy::collection_is_never_read)]
     let mut _rb_task = None;
     while let Some(req) = requests.next().await {
         if let Err(e) = req {
diff --git a/src/connectivity/bluetooth/profiles/bt-a2dp/src/main.rs b/src/connectivity/bluetooth/profiles/bt-a2dp/src/main.rs
index 9cd1726..a73d391 100644
--- a/src/connectivity/bluetooth/profiles/bt-a2dp/src/main.rs
+++ b/src/connectivity/bluetooth/profiles/bt-a2dp/src/main.rs
@@ -364,6 +364,7 @@
     });
 
     // The AVRCP Target component is needed if it is requested and A2DP Source is requested.
+    #[allow(clippy::collection_is_never_read)]
     let mut _avrcp_target = None;
     if config.source.is_some() && config.enable_avrcp_target {
         match fuchsia_component::client::connect_to_protocol::<BinderMarker>() {
diff --git a/src/connectivity/lowpan/service/src/inspect.rs b/src/connectivity/lowpan/service/src/inspect.rs
index c2caa464..36e0067 100644
--- a/src/connectivity/lowpan/service/src/inspect.rs
+++ b/src/connectivity/lowpan/service/src/inspect.rs
@@ -221,6 +221,7 @@
     inspect_tree: Arc<LowpanServiceTree>,
     lookup: Arc<LP>,
 ) {
+    #[allow(clippy::collection_is_never_read)]
     let mut device_table: HashMap<String, Arc<Task<()>>> = HashMap::new();
     let lookup_clone = lookup.clone();
     let mut lookup_stream = HangingGetStream::new(lookup_clone, |lookup| lookup.watch_devices());
diff --git a/src/connectivity/wlan/lib/rsn/src/key/exchange/handshake/fourway/supplicant.rs b/src/connectivity/wlan/lib/rsn/src/key/exchange/handshake/fourway/supplicant.rs
index 9e4a785..eaf0ced 100644
--- a/src/connectivity/wlan/lib/rsn/src/key/exchange/handshake/fourway/supplicant.rs
+++ b/src/connectivity/wlan/lib/rsn/src/key/exchange/handshake/fourway/supplicant.rs
@@ -124,6 +124,7 @@
     let mut gtk: Option<key_data::kde::Gtk> = None;
     let mut igtk: Option<Igtk> = None;
     let mut protection: Option<ProtectionInfo> = None;
+    #[allow(clippy::collection_is_never_read)]
     let mut _second_protection: Option<ProtectionInfo> = None;
     for element in key_data_elements {
         match (element, &protection) {
diff --git a/src/lib/diagnostics/inspect/rust/bench/reader/src/main.rs b/src/lib/diagnostics/inspect/rust/bench/reader/src/main.rs
index 344df09..e82b440 100644
--- a/src/lib/diagnostics/inspect/rust/bench/reader/src/main.rs
+++ b/src/lib/diagnostics/inspect/rust/bench/reader/src/main.rs
@@ -136,6 +136,7 @@
         fuchsia_inspect_bench_utils::spawn_server(inspector.clone()).unwrap();
     let task = fasync::Task::local(tree_server_fut);
 
+    #[allow(clippy::collection_is_never_read)]
     let mut nodes = vec![];
     if filled_size > 0 {
         let ints_for_filling: i64 = filled_size / 16 - 1;
diff --git a/src/lib/scoped_task/test/spawner.rs b/src/lib/scoped_task/test/spawner.rs
index 746f74b..0319cd4 100644
--- a/src/lib/scoped_task/test/spawner.rs
+++ b/src/lib/scoped_task/test/spawner.rs
@@ -57,6 +57,7 @@
     // print logs and non-fatal errors directly to stdout instead.
     let mut stdout = unsafe { File::from_raw_fd(1) };
 
+    #[allow(clippy::collection_is_never_read)]
     let mut _process = None;
     let (sender, receiver) = mpsc::channel();
     if opts.spawn {
diff --git a/src/starnix/kernel/vfs/fd_table.rs b/src/starnix/kernel/vfs/fd_table.rs
index 4b76f31..057356d 100644
--- a/src/starnix/kernel/vfs/fd_table.rs
+++ b/src/starnix/kernel/vfs/fd_table.rs
@@ -276,6 +276,7 @@
         profile_duration!("DuplicateFd");
         // Drop the removed entry only after releasing the writer lock in case
         // the close() function on the FileOps calls back into the FdTable.
+        #[allow(clippy::collection_is_never_read)]
         let _removed_entry;
         let result = {
             let rlimit = task.thread_group.get_rlimit(Resource::NOFILE);
diff --git a/src/starnix/kernel/vfs/inotify.rs b/src/starnix/kernel/vfs/inotify.rs
index ca9dcfb4..56b7f46 100644
--- a/src/starnix/kernel/vfs/inotify.rs
+++ b/src/starnix/kernel/vfs/inotify.rs
@@ -169,6 +169,7 @@
         remove_watcher_after_notify: bool,
     ) {
         // Holds a DirEntry pending deletion to be dropped after releasing the state mutex.
+        #[allow(clippy::collection_is_never_read)]
         let _dir_entry: Option<DirEntryHandle>;
         {
             let mut state = self.state.lock();
diff --git a/src/storage/fxfs/platform/src/fuchsia/dirent_cache.rs b/src/storage/fxfs/platform/src/fuchsia/dirent_cache.rs
index 8d72965..db9bb70 100644
--- a/src/storage/fxfs/platform/src/fuchsia/dirent_cache.rs
+++ b/src/storage/fxfs/platform/src/fuchsia/dirent_cache.rs
@@ -107,6 +107,7 @@
 
     /// Set a new limit for the cache size.
     pub fn set_limit(&self, limit: usize) {
+        #[allow(clippy::collection_is_never_read)]
         let mut dropped_items;
         {
             let mut this = self.inner.lock().unwrap();
@@ -128,6 +129,7 @@
     #[trace]
     pub fn recycle_stale_files(&self) {
         // Drop outside the lock.
+        #[allow(clippy::collection_is_never_read)]
         let mut dropped_items = Vec::new();
         {
             let mut this = self.inner.lock().unwrap();
diff --git a/src/storage/lib/block_server/src/c_interface.rs b/src/storage/lib/block_server/src/c_interface.rs
index ccd8a68..c88e1ed 100644
--- a/src/storage/lib/block_server/src/c_interface.rs
+++ b/src/storage/lib/block_server/src/c_interface.rs
@@ -33,6 +33,7 @@
         {
             // We must drop references to sessions whilst we're not holding the lock for
             // `open_sessions` because `Session::drop` needs to take that same lock.
+            #[allow(clippy::collection_is_never_read)]
             let mut terminated_sessions = Vec::new();
             for (_, session) in &*self.open_sessions.lock().unwrap() {
                 if let Some(session) = session.upgrade() {
diff --git a/src/testing/sl4f/src/media_session/facade.rs b/src/testing/sl4f/src/media_session/facade.rs
index 013a99e..18bf753 100644
--- a/src/testing/sl4f/src/media_session/facade.rs
+++ b/src/testing/sl4f/src/media_session/facade.rs
@@ -95,6 +95,7 @@
                 .await
                 .expect("Failed to publish Player");
 
+            #[allow(clippy::collection_is_never_read)]
             let mut _player_info_change_responder = None;
             let mut sent_response = false;
 
diff --git a/src/ui/tests/integration_graphics_tests/carnelian-pixel-tests/carnelian_pixel_client/src/main.rs b/src/ui/tests/integration_graphics_tests/carnelian-pixel-tests/carnelian_pixel_client/src/main.rs
index 5b4f2fe..84a63a4 100644
--- a/src/ui/tests/integration_graphics_tests/carnelian-pixel-tests/carnelian_pixel_client/src/main.rs
+++ b/src/ui/tests/integration_graphics_tests/carnelian-pixel-tests/carnelian_pixel_client/src/main.rs
@@ -123,6 +123,7 @@
         if self.scene_details.is_none() {
             let mut builder =
                 SceneBuilder::new().background_color(self.background_color).animated(true);
+            #[allow(clippy::collection_is_never_read)]
             let mut square = None;
             builder.group().stack().center().contents(|builder| {
                 let square_facet = StaticSquareFacet::new(self.square_color, size);