1
Fork 0

fix: add cfg diagnostic for unresolved import error

This commit is contained in:
bohan 2023-06-21 02:20:55 +08:00
parent e0ba2d038d
commit 8c8c7ef78a
3 changed files with 71 additions and 4 deletions

View file

@ -609,7 +609,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
}
}
fn throw_unresolved_import_error(&self, errors: Vec<(&Import<'_>, UnresolvedImportError)>) {
fn throw_unresolved_import_error(&mut self, errors: Vec<(&Import<'_>, UnresolvedImportError)>) {
if errors.is_empty() {
return;
}
@ -679,6 +679,17 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
_ => {}
}
}
match &import.kind {
ImportKind::Single { source, .. } => {
if let Some(ModuleOrUniformRoot::Module(module)) = import.imported_module.get()
&& let Some(module) = module.opt_def_id()
{
self.find_cfg_stripped(&mut diag, &source.name, module)
}
},
_ => {}
}
}
diag.emit();