Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add method for querying whether a given short type path is ambiguous (#…
…11840) # Objective Currently, the `ambiguous_names` hash set in `TypeRegistry` is used to keep track of short type names that are ambiguous, and to require the use of long type names for these types. However, there's no way for the consumer of `TypeRegistry` to known whether a given call to `get_with_short_type_path()` or `get_with_short_type_path_mut()` failed because a type was not registered at all, or because the short name is ambiguous. This can be used, for example, for better error reporting to the user by an editor tool. Here's some code that uses this, from my remote protocol exploration branch: ```rust let type_registration = type_registry .get_with_type_path(component_name) .or_else(|| registry.get_with_short_type_path(component_name)) .ok_or_else(|| { if type_registry.is_ambiguous(component_name) { BrpError::ComponentAmbiguous(component_name.clone()) } else { BrpError::MissingTypeRegistration(component_name.clone()) } })? ``` ## Solution - Introduces a `is_ambiguous()` method. - Also drive-by fixes two documentation comments that had broken links. --- ## Changelog - Added a `TypeRegistry::is_ambiguous()` method, for checking whether a given short type path is ambiguous (e.g. `MyType` potentially matching either `some_crate::MyType` or `another_crate::MyType`) --------- Co-authored-by: François <mockersf@gmail.com>
- Loading branch information