diff options
| author | klensy <klensy@users.noreply.github.com> | 2022-04-05 15:52:53 +0300 |
|---|---|---|
| committer | klensy <klensy@users.noreply.github.com> | 2022-04-08 11:45:57 +0300 |
| commit | d0cc98689e3db7841c54c0ad1104dea87f811ff5 (patch) | |
| tree | 9b577f2fe457711704db64063c5fd64d43b61850 /compiler/rustc_incremental/src/assert_module_sources.rs | |
| parent | f262ca12aac76152c4b46cefcf8300f0249a5eb2 (diff) | |
| download | rust-d0cc98689e3db7841c54c0ad1104dea87f811ff5.tar.gz rust-d0cc98689e3db7841c54c0ad1104dea87f811ff5.zip | |
check_doc_keyword: don't alloc string for emptiness check
check_doc_alias_value: get argument as Symbol to prevent needless string convertions check_doc_attrs: don't alloc vec, iterate over slice. Vec introduced in #83149, but no perf run posted on merge replace as_str() check with symbol check get_single_str_from_tts: don't prealloc string trivial string to str replace LifetimeScopeForPath::NonElided use Vec<Symbol> instead of Vec<String> AssertModuleSource use BTreeSet<Symbol> instead of BTreeSet<String> CrateInfo.crate_name replace FxHashMap<CrateNum, String> with FxHashMap<CrateNum, Symbol>
Diffstat (limited to 'compiler/rustc_incremental/src/assert_module_sources.rs')
| -rw-r--r-- | compiler/rustc_incremental/src/assert_module_sources.rs | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/compiler/rustc_incremental/src/assert_module_sources.rs b/compiler/rustc_incremental/src/assert_module_sources.rs index 4b235213f7f..7569abfbb10 100644 --- a/compiler/rustc_incremental/src/assert_module_sources.rs +++ b/compiler/rustc_incremental/src/assert_module_sources.rs @@ -22,12 +22,12 @@ //! was re-used. use rustc_ast as ast; +use rustc_data_structures::stable_set::FxHashSet; use rustc_hir::def_id::LOCAL_CRATE; use rustc_middle::mir::mono::CodegenUnitNameBuilder; use rustc_middle::ty::TyCtxt; use rustc_session::cgu_reuse_tracker::*; use rustc_span::symbol::{sym, Symbol}; -use std::collections::BTreeSet; #[allow(missing_docs)] pub fn assert_module_sources(tcx: TyCtxt<'_>) { @@ -36,12 +36,8 @@ pub fn assert_module_sources(tcx: TyCtxt<'_>) { return; } - let available_cgus = tcx - .collect_and_partition_mono_items(()) - .1 - .iter() - .map(|cgu| cgu.name().to_string()) - .collect::<BTreeSet<String>>(); + let available_cgus = + tcx.collect_and_partition_mono_items(()).1.iter().map(|cgu| cgu.name()).collect(); let ams = AssertModuleSource { tcx, available_cgus }; @@ -53,7 +49,7 @@ pub fn assert_module_sources(tcx: TyCtxt<'_>) { struct AssertModuleSource<'tcx> { tcx: TyCtxt<'tcx>, - available_cgus: BTreeSet<String>, + available_cgus: FxHashSet<Symbol>, } impl<'tcx> AssertModuleSource<'tcx> { @@ -124,18 +120,17 @@ impl<'tcx> AssertModuleSource<'tcx> { debug!("mapping '{}' to cgu name '{}'", self.field(attr, sym::module), cgu_name); - if !self.available_cgus.contains(cgu_name.as_str()) { + if !self.available_cgus.contains(&cgu_name) { + let mut cgu_names: Vec<&str> = + self.available_cgus.iter().map(|cgu| cgu.as_str()).collect(); + cgu_names.sort(); self.tcx.sess.span_err( attr.span, &format!( "no module named `{}` (mangled: {}). Available modules: {}", user_path, cgu_name, - self.available_cgus - .iter() - .map(|cgu| cgu.to_string()) - .collect::<Vec<_>>() - .join(", ") + cgu_names.join(", ") ), ); } |
