Report unrecognized shorthands when loading from the root module

This commit is contained in:
Agus Zubiaga 2024-06-08 14:12:01 -03:00
parent 5a1bf2b891
commit 7faff12cbf
No known key found for this signature in database
7 changed files with 245 additions and 29 deletions

View file

@ -463,6 +463,13 @@ impl<'a, T> PackageQualified<'a, T> {
}
}
pub fn package_shorthand(&self) -> Option<&'a str> {
match self {
PackageQualified::Unqualified(_) => None,
PackageQualified::Qualified(package, _) => Some(package),
}
}
pub fn map_module<B>(&self, f: impl FnOnce(&T) -> B) -> PackageQualified<'a, B> {
match self {
PackageQualified::Unqualified(name) => PackageQualified::Unqualified(f(name)),