Skip to content

Commit fe76d56

Browse files
committed
Track those structs
1 parent 8048604 commit fe76d56

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

crates/red_knot_python_semantic/src/types/generics.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
use std::sync::Arc;
2-
31
use ruff_python_ast as ast;
42

53
use crate::semantic_index::SemanticIndex;
@@ -11,9 +9,9 @@ use crate::types::{
119
use crate::Db;
1210

1311
/// A list of formal type variables for a generic function, class, or type alias.
14-
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
12+
#[salsa::tracked(debug)]
1513
pub struct GenericContext<'db> {
16-
variables: Arc<[TypeVarInstance<'db>]>,
14+
variables: Box<[TypeVarInstance<'db>]>,
1715
}
1816

1917
impl<'db> GenericContext<'db> {
@@ -26,7 +24,7 @@ impl<'db> GenericContext<'db> {
2624
.iter()
2725
.filter_map(|type_param| Self::variable_from_type_param(db, index, type_param))
2826
.collect();
29-
Self { variables }
27+
Self::new(db, variables)
3028
}
3129

3230
fn variable_from_type_param(
@@ -50,9 +48,9 @@ impl<'db> GenericContext<'db> {
5048
}
5149
}
5250

53-
pub(crate) fn signature(&self, db: &'db dyn Db) -> Signature<'db> {
51+
pub(crate) fn signature(self, db: &'db dyn Db) -> Signature<'db> {
5452
let parameters = Parameters::new(
55-
self.variables
53+
self.variables(db)
5654
.iter()
5755
.map(|typevar| Self::parameter_from_typevar(db, *typevar)),
5856
);

crates/red_knot_python_semantic/src/types/infer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5580,7 +5580,7 @@ impl<'db> TypeInferenceBuilder<'db> {
55805580
return self.infer_explicit_class_specialization(
55815581
subscript,
55825582
value_ty,
5583-
&generic_context,
5583+
generic_context,
55845584
slice,
55855585
);
55865586
}
@@ -5594,7 +5594,7 @@ impl<'db> TypeInferenceBuilder<'db> {
55945594
&mut self,
55955595
subscript: &ast::ExprSubscript,
55965596
value_ty: Type<'db>,
5597-
generic_context: &GenericContext<'db>,
5597+
generic_context: GenericContext<'db>,
55985598
slice_node: &ast::Expr,
55995599
) -> Type<'db> {
56005600
let mut call_argument_types = match slice_node {

0 commit comments

Comments
 (0)