[red-knot] Reduce usage of From<Type> implementations when working with Symbols (#16076)

This commit is contained in:
Alex Waygood 2025-02-11 11:09:37 +00:00 committed by GitHub
parent 69d86d1d69
commit df1d430294
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 94 additions and 77 deletions

View file

@ -1,5 +1,5 @@
use crate::{
types::{Type, UnionType},
types::{todo_type, Type, UnionType},
Db,
};
@ -33,6 +33,17 @@ pub(crate) enum Symbol<'db> {
}
impl<'db> Symbol<'db> {
/// Constructor that creates a `Symbol` with boundness [`Boundness::Bound`].
pub(crate) fn bound(ty: impl Into<Type<'db>>) -> Self {
Symbol::Type(ty.into(), Boundness::Bound)
}
/// Constructor that creates a [`Symbol`] with a [`crate::types::TodoType`] type
/// and boundness [`Boundness::Bound`].
pub(crate) fn todo(message: &'static str) -> Self {
Symbol::Type(todo_type!(message), Boundness::Bound)
}
pub(crate) fn is_unbound(&self) -> bool {
matches!(self, Symbol::Unbound)
}