Skip to content

Commit 70ceed0

Browse files
committed
revert unnecessary changes
1 parent 74a3758 commit 70ceed0

File tree

5 files changed

+20
-65
lines changed

5 files changed

+20
-65
lines changed

crates/ty_python_semantic/src/types.rs

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10775,10 +10775,10 @@ fn walk_bound_method_type<'db, V: visitor::TypeVisitor<'db> + ?Sized>(
1077510775

1077610776
fn into_callable_type_cycle_initial<'db>(
1077710777
db: &'db dyn Db,
10778-
id: salsa::Id,
10778+
_id: salsa::Id,
1077910779
_self: BoundMethodType<'db>,
1078010780
) -> CallableType<'db> {
10781-
CallableType::divergent(db, id)
10781+
CallableType::bottom(db)
1078210782
}
1078310783

1078410784
#[salsa::tracked]
@@ -10977,14 +10977,6 @@ impl<'db> CallableType<'db> {
1097710977
Self::new(db, CallableSignature::bottom(), false)
1097810978
}
1097910979

10980-
/// Create a callable type which represents a divergent "bottom" callable.
10981-
///
10982-
/// Specifically, this represents a callable type with a single signature:
10983-
/// `(*args: object, **kwargs: object) -> Divergent`.
10984-
pub(crate) fn divergent(db: &'db dyn Db, id: salsa::Id) -> CallableType<'db> {
10985-
Self::new(db, CallableSignature::divergent(id), false)
10986-
}
10987-
1098810980
/// Return a "normalized" version of this `Callable` type.
1098910981
///
1099010982
/// See [`Type::normalized`] for more details.
@@ -11948,11 +11940,11 @@ impl<'db> PEP695TypeAliasType<'db> {
1194811940

1194911941
#[allow(clippy::unnecessary_wraps)]
1195011942
fn generic_context_cycle_initial<'db>(
11951-
db: &'db dyn Db,
11952-
id: salsa::Id,
11943+
_db: &'db dyn Db,
11944+
_id: salsa::Id,
1195311945
_self: PEP695TypeAliasType<'db>,
1195411946
) -> Option<GenericContext<'db>> {
11955-
Some(GenericContext::cycle_initial(db, id))
11947+
None
1195611948
}
1195711949

1195811950
fn value_type_cycle_initial<'db>(

crates/ty_python_semantic/src/types/class.rs

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -70,36 +70,18 @@ use ruff_text_size::{Ranged, TextRange};
7070
use rustc_hash::FxHashSet;
7171

7272
fn explicit_bases_cycle_initial<'db>(
73-
db: &'db dyn Db,
74-
id: salsa::Id,
75-
class: ClassLiteral<'db>,
73+
_db: &'db dyn Db,
74+
_id: salsa::Id,
75+
_class: ClassLiteral<'db>,
7676
) -> Box<[Type<'db>]> {
77-
let module = parsed_module(db, class.file(db)).load(db);
78-
let class_stmt = class.node(db, &module);
79-
80-
if class.is_known(db, KnownClass::VersionInfo) {
81-
let tuple_type = TupleType::new(db, &TupleSpec::version_info_spec(db))
82-
.expect("sys.version_info tuple spec should always be a valid tuple");
83-
84-
Box::new([
85-
Type::divergent(id),
86-
Type::from(tuple_type.to_class_type(db)),
87-
])
88-
} else {
89-
class_stmt
90-
.bases()
91-
.iter()
92-
.map(|_| Type::divergent(id))
93-
.collect()
94-
}
77+
Box::default()
9578
}
9679

9780
fn inheritance_cycle_initial<'db>(
9881
_db: &'db dyn Db,
9982
_id: salsa::Id,
10083
_self: ClassLiteral<'db>,
10184
) -> Option<InheritanceCycle> {
102-
// Some(InheritanceCycle::Participant)?
10385
None
10486
}
10587

@@ -1272,10 +1254,10 @@ impl<'db> ClassType<'db> {
12721254

12731255
fn into_callable_cycle_initial<'db>(
12741256
db: &'db dyn Db,
1275-
id: salsa::Id,
1257+
_id: salsa::Id,
12761258
_self: ClassType<'db>,
12771259
) -> Type<'db> {
1278-
Type::Callable(CallableType::divergent(db, id))
1260+
Type::Callable(CallableType::bottom(db))
12791261
}
12801262

12811263
impl<'db> From<GenericAlias<'db>> for ClassType<'db> {
@@ -1425,11 +1407,11 @@ impl get_size2::GetSize for ClassLiteral<'_> {}
14251407

14261408
#[allow(clippy::unnecessary_wraps)]
14271409
fn generic_context_cycle_initial<'db>(
1428-
db: &'db dyn Db,
1429-
id: salsa::Id,
1410+
_db: &'db dyn Db,
1411+
_id: salsa::Id,
14301412
_self: ClassLiteral<'db>,
14311413
) -> Option<GenericContext<'db>> {
1432-
Some(GenericContext::cycle_initial(db, id))
1414+
None
14331415
}
14341416

14351417
#[salsa::tracked]

crates/ty_python_semantic/src/types/function.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,18 +1236,18 @@ fn is_mode_with_nontrivial_return_type<'db>(db: &'db dyn Db, mode: Type<'db>) ->
12361236

12371237
fn signature_cycle_initial<'db>(
12381238
_db: &'db dyn Db,
1239-
id: salsa::Id,
1239+
_id: salsa::Id,
12401240
_function: FunctionType<'db>,
12411241
) -> CallableSignature<'db> {
1242-
CallableSignature::single(Signature::divergent(id))
1242+
CallableSignature::single(Signature::bottom())
12431243
}
12441244

12451245
fn last_definition_signature_cycle_initial<'db>(
12461246
_db: &'db dyn Db,
1247-
id: salsa::Id,
1247+
_id: salsa::Id,
12481248
_function: FunctionType<'db>,
12491249
) -> Signature<'db> {
1250-
Signature::divergent(id)
1250+
Signature::bottom()
12511251
}
12521252

12531253
/// Non-exhaustive enumeration of known functions (e.g. `builtins.reveal_type`, ...) that might

crates/ty_python_semantic/src/types/generics.rs

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,6 @@ impl<'db> GenericContextTypeVar<'db> {
212212
pub struct GenericContext<'db> {
213213
#[returns(ref)]
214214
variables_inner: FxOrderMap<BoundTypeVarIdentity<'db>, GenericContextTypeVar<'db>>,
215-
cycle_recovery: Option<Type<'db>>,
216215
}
217216

218217
pub(super) fn walk_generic_context<'db, V: super::visitor::TypeVisitor<'db> + ?Sized>(
@@ -229,10 +228,6 @@ pub(super) fn walk_generic_context<'db, V: super::visitor::TypeVisitor<'db> + ?S
229228
impl get_size2::GetSize for GenericContext<'_> {}
230229

231230
impl<'db> GenericContext<'db> {
232-
pub(crate) fn cycle_initial(db: &'db dyn Db, id: salsa::Id) -> Self {
233-
Self::new_internal(db, FxOrderMap::default(), Some(Type::divergent(id)))
234-
}
235-
236231
fn from_variables(
237232
db: &'db dyn Db,
238233
variables: impl IntoIterator<Item = GenericContextTypeVar<'db>>,
@@ -243,7 +238,6 @@ impl<'db> GenericContext<'db> {
243238
.into_iter()
244239
.map(|variable| (variable.bound_typevar.identity(db), variable))
245240
.collect::<FxOrderMap<_, _>>(),
246-
None,
247241
)
248242
}
249243

@@ -630,14 +624,9 @@ impl<'db> GenericContext<'db> {
630624
}
631625

632626
fn heap_size(
633-
(variables, cycle_recovery): &(
634-
FxOrderMap<BoundTypeVarIdentity<'db>, GenericContextTypeVar<'db>>,
635-
Option<Type<'db>>,
636-
),
627+
(variables,): &(FxOrderMap<BoundTypeVarIdentity<'db>, GenericContextTypeVar<'db>>,),
637628
) -> usize {
638-
use get_size2::GetSize;
639-
640-
ruff_memory_usage::order_map_heap_size(variables) + cycle_recovery.get_heap_size()
629+
ruff_memory_usage::order_map_heap_size(variables)
641630
}
642631
}
643632

crates/ty_python_semantic/src/types/signatures.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,6 @@ impl<'db> CallableSignature<'db> {
137137
Self::single(Signature::bottom())
138138
}
139139

140-
pub(crate) fn divergent(id: salsa::Id) -> Self {
141-
Self::single(Signature::divergent(id))
142-
}
143-
144140
/// Creates a new `CallableSignature` from an iterator of [`Signature`]s. Returns a
145141
/// non-callable signature if the iterator is empty.
146142
pub(crate) fn from_overloads<I>(overloads: I) -> Self
@@ -519,10 +515,6 @@ impl<'db> Signature<'db> {
519515
Self::new(Parameters::object(), Some(Type::Never))
520516
}
521517

522-
pub(crate) fn divergent(id: salsa::Id) -> Self {
523-
Self::new(Parameters::object(), Some(Type::divergent(id)))
524-
}
525-
526518
pub(crate) fn with_inherited_generic_context(
527519
mut self,
528520
db: &'db dyn Db,

0 commit comments

Comments
 (0)