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>
This commit is contained in:
parent
f262ca12aa
commit
d0cc98689e
15 changed files with 56 additions and 65 deletions
|
@ -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(", ")
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue