mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-02 06:42:02 +00:00
[red-knot] Reduce usage of From<Type>
implementations when working with Symbol
s (#16076)
This commit is contained in:
parent
69d86d1d69
commit
df1d430294
3 changed files with 94 additions and 77 deletions
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue