Change the type of AssertModuleSource::available_cgus.

It's currently a `BTreeSet<Symbol>`, which is a strange type. The
`BTreeSet` suggests that element order is important, but `Symbol` is a
type whose ordering isn't useful to humans. The ordering of the
collection only manifests in an obscure error message ("no module named
`...`") that doesn't appear in any tests.

This commit changes the `Symbol` to a `String`, which is more
typical.
This commit is contained in:
Nicholas Nethercote 2020-08-06 15:58:23 +10:00
parent 60c2e8d438
commit ebbf07a154

View file

@ -39,8 +39,8 @@ pub fn assert_module_sources(tcx: TyCtxt<'_>) {
.collect_and_partition_mono_items(LOCAL_CRATE) .collect_and_partition_mono_items(LOCAL_CRATE)
.1 .1
.iter() .iter()
.map(|cgu| cgu.name()) .map(|cgu| cgu.name().to_string())
.collect::<BTreeSet<Symbol>>(); .collect::<BTreeSet<String>>();
let ams = AssertModuleSource { tcx, available_cgus }; let ams = AssertModuleSource { tcx, available_cgus };
@ -52,7 +52,7 @@ pub fn assert_module_sources(tcx: TyCtxt<'_>) {
struct AssertModuleSource<'tcx> { struct AssertModuleSource<'tcx> {
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
available_cgus: BTreeSet<Symbol>, available_cgus: BTreeSet<String>,
} }
impl AssertModuleSource<'tcx> { impl AssertModuleSource<'tcx> {
@ -121,12 +121,11 @@ impl AssertModuleSource<'tcx> {
debug!("mapping '{}' to cgu name '{}'", self.field(attr, sym::module), cgu_name); debug!("mapping '{}' to cgu name '{}'", self.field(attr, sym::module), cgu_name);
if !self.available_cgus.contains(&cgu_name) { if !self.available_cgus.contains(&*cgu_name.as_str()) {
self.tcx.sess.span_err( self.tcx.sess.span_err(
attr.span, attr.span,
&format!( &format!(
"no module named `{}` (mangled: {}). \ "no module named `{}` (mangled: {}). Available modules: {}",
Available modules: {}",
user_path, user_path,
cgu_name, cgu_name,
self.available_cgus self.available_cgus