From 2fa359814aab054f4b0c9c764a6d6a36ecf6cde8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?D=C3=A1niel=20Buga?= Date: Wed, 28 Oct 2020 17:05:49 +0100 Subject: [PATCH] Avoid reallocating cgu_path_components --- compiler/rustc_incremental/src/assert_module_sources.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_incremental/src/assert_module_sources.rs b/compiler/rustc_incremental/src/assert_module_sources.rs index 80448c01a26..17d8ac9c882 100644 --- a/compiler/rustc_incremental/src/assert_module_sources.rs +++ b/compiler/rustc_incremental/src/assert_module_sources.rs @@ -111,10 +111,12 @@ fn check_attr(&self, attr: &ast::Attribute) { (&user_path[..], None) }; - let mut cgu_path_components = user_path.split('-').collect::>(); + let mut iter = user_path.split('-'); // Remove the crate name - assert_eq!(cgu_path_components.remove(0), crate_name); + assert_eq!(iter.next().unwrap(), crate_name); + + let cgu_path_components = iter.collect::>(); let cgu_name_builder = &mut CodegenUnitNameBuilder::new(self.tcx); let cgu_name = -- 2.44.0