Skip to content

Commit f91258b

Browse files
committed
remove unused DynamicType variant
1 parent cc2efcf commit f91258b

File tree

5 files changed

+8
-28
lines changed

5 files changed

+8
-28
lines changed

crates/ty_python_semantic/src/types.rs

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ impl<'db> Type<'db> {
589589

590590
pub fn contains_todo(&self, db: &'db dyn Db) -> bool {
591591
match self {
592-
Self::Dynamic(DynamicType::Todo(_) | DynamicType::SubscriptedProtocol) => true,
592+
Self::Dynamic(DynamicType::Todo(_)) => true,
593593

594594
Self::AlwaysFalsy
595595
| Self::AlwaysTruthy
@@ -630,9 +630,7 @@ impl<'db> Type<'db> {
630630
}
631631

632632
Self::SubclassOf(subclass_of) => match subclass_of.subclass_of() {
633-
SubclassOfInner::Dynamic(
634-
DynamicType::Todo(_) | DynamicType::SubscriptedProtocol,
635-
) => true,
633+
SubclassOfInner::Dynamic(DynamicType::Todo(_)) => true,
636634
SubclassOfInner::Dynamic(DynamicType::Unknown | DynamicType::Any) => false,
637635
SubclassOfInner::Class(_) => false,
638636
},
@@ -649,12 +647,10 @@ impl<'db> Type<'db> {
649647
Self::BoundSuper(bound_super) => {
650648
matches!(
651649
bound_super.pivot_class(db),
652-
ClassBase::Dynamic(DynamicType::Todo(_) | DynamicType::SubscriptedProtocol)
650+
ClassBase::Dynamic(DynamicType::Todo(_))
653651
) || matches!(
654652
bound_super.owner(db),
655-
SuperOwnerKind::Dynamic(
656-
DynamicType::Todo(_) | DynamicType::SubscriptedProtocol
657-
)
653+
SuperOwnerKind::Dynamic(DynamicType::Todo(_))
658654
)
659655
}
660656

@@ -5437,9 +5433,6 @@ pub enum DynamicType {
54375433
///
54385434
/// This variant should be created with the `todo_type!` macro.
54395435
Todo(TodoType),
5440-
/// Temporary type until we support generic protocols.
5441-
/// We use a separate variant (instead of `Todo(…)`) in order to be able to match on them explicitly.
5442-
SubscriptedProtocol,
54435436
}
54445437

54455438
impl std::fmt::Display for DynamicType {
@@ -5450,11 +5443,6 @@ impl std::fmt::Display for DynamicType {
54505443
// `DynamicType::Todo`'s display should be explicit that is not a valid display of
54515444
// any other type
54525445
DynamicType::Todo(todo) => write!(f, "@Todo{todo}"),
5453-
DynamicType::SubscriptedProtocol => f.write_str(if cfg!(debug_assertions) {
5454-
"@Todo(`Protocol[]` subscript)"
5455-
} else {
5456-
"@Todo"
5457-
}),
54585446
}
54595447
}
54605448
}

crates/ty_python_semantic/src/types/class_base.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,7 @@ impl<'db> ClassBase<'db> {
7777
ClassBase::Dynamic(DynamicType::Any) => "Any",
7878
ClassBase::Dynamic(DynamicType::Unknown) => "Unknown",
7979
ClassBase::Dynamic(DynamicType::Todo(_)) => "@Todo",
80-
ClassBase::Protocol(_) | ClassBase::Dynamic(DynamicType::SubscriptedProtocol) => {
81-
"Protocol"
82-
}
80+
ClassBase::Protocol(_) => "Protocol",
8381
ClassBase::Generic(_) => "Generic",
8482
}
8583
}
@@ -264,9 +262,6 @@ impl<'db> ClassBase<'db> {
264262
ClassBase::Protocol(context) => {
265263
ClassBaseMroIterator::length_3(db, self, ClassBase::Generic(context))
266264
}
267-
ClassBase::Dynamic(DynamicType::SubscriptedProtocol) => {
268-
ClassBaseMroIterator::length_3(db, self, ClassBase::Generic(None))
269-
}
270265
ClassBase::Dynamic(_) | ClassBase::Generic(_) => {
271266
ClassBaseMroIterator::length_2(db, self)
272267
}

crates/ty_python_semantic/src/types/infer.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5797,8 +5797,6 @@ impl<'db> TypeInferenceBuilder<'db> {
57975797
| (_, unknown @ Type::Dynamic(DynamicType::Unknown), _) => Some(unknown),
57985798
(todo @ Type::Dynamic(DynamicType::Todo(_)), _, _)
57995799
| (_, todo @ Type::Dynamic(DynamicType::Todo(_)), _) => Some(todo),
5800-
(todo @ Type::Dynamic(DynamicType::SubscriptedProtocol), _, _)
5801-
| (_, todo @ Type::Dynamic(DynamicType::SubscriptedProtocol), _) => Some(todo),
58025800
(Type::Never, _, _) | (_, Type::Never, _) => Some(Type::Never),
58035801

58045802
(Type::IntLiteral(n), Type::IntLiteral(m), ast::Operator::Add) => Some(

crates/ty_python_semantic/src/types/mro.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,9 @@ impl<'db> Mro<'db> {
174174
continue;
175175
}
176176
match base {
177-
ClassBase::Class(_) | ClassBase::Generic(_) | ClassBase::Protocol(_) => {
177+
ClassBase::Class(_)
178+
| ClassBase::Generic(_)
179+
| ClassBase::Protocol(_) => {
178180
errors.push(DuplicateBaseError {
179181
duplicate_base: base,
180182
first_index: *first_index,

crates/ty_python_semantic/src/types/type_ordering.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -386,8 +386,5 @@ fn dynamic_elements_ordering(left: DynamicType, right: DynamicType) -> Ordering
386386

387387
#[cfg(not(debug_assertions))]
388388
(DynamicType::Todo(TodoType), DynamicType::Todo(TodoType)) => Ordering::Equal,
389-
390-
(DynamicType::SubscriptedProtocol, _) => Ordering::Less,
391-
(_, DynamicType::SubscriptedProtocol) => Ordering::Greater,
392389
}
393390
}

0 commit comments

Comments
 (0)