From c6f1b8988aa36dba8991c2ccab46e61d9a619a8d Mon Sep 17 00:00:00 2001 From: Luqman Aden Date: Tue, 11 May 2021 09:39:16 -0700 Subject: [PATCH] Output the missing peripheral name and referencing task instead of panicing. (#151) --- xtask/src/dist.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/xtask/src/dist.rs b/xtask/src/dist.rs index 3558b1dc3..6fc344723 100644 --- a/xtask/src/dist.rs +++ b/xtask/src/dist.rs @@ -709,8 +709,16 @@ fn make_descriptors( // For peripherals referenced by the task, we don't need to allocate // _new_ regions, since we did them all in advance. Just record the // entries for the TaskDesc. - for (j, name) in task.uses.iter().enumerate() { - task_regions[allocs.len() + j] = peripheral_index[name] as u8; + for (j, peripheral_name) in task.uses.iter().enumerate() { + if let Some(&peripheral) = peripheral_index.get(&peripheral_name) { + task_regions[allocs.len() + j] = peripheral as u8; + } else { + bail!( + "Could not find peripheral `{}` referenced by task `{}`.", + peripheral_name, + name + ); + } } let mut flags = abi::TaskFlags::empty();