Skip to content

Commit f32902f

Browse files
committed
[ty] Make use of salsa Lookup when interning values
1 parent 4f60f0e commit f32902f

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

crates/ty_python_semantic/src/semantic_index/builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2692,7 +2692,7 @@ impl ExpressionsScopeMapBuilder {
26922692
let mut interval_map = Vec::new();
26932693

26942694
let mut current_scope = first.1;
2695-
let mut range = first.0..=NodeIndex::from(first.0.as_u32() + 1);
2695+
let mut range = first.0..=first.0;
26962696

26972697
for (index, scope) in iter {
26982698
if scope == current_scope {

crates/ty_python_semantic/src/types.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3135,7 +3135,7 @@ impl<'db> Type<'db> {
31353135
db,
31363136
"__getattr__",
31373137
CallArgumentTypes::positional([Type::StringLiteral(
3138-
StringLiteralType::new(db, Box::from(name.as_str())),
3138+
StringLiteralType::new(db, name.as_str()),
31393139
)]),
31403140
)
31413141
.map(|outcome| Place::bound(outcome.return_type(db)))
@@ -3156,7 +3156,7 @@ impl<'db> Type<'db> {
31563156
db,
31573157
"__getattribute__",
31583158
&mut CallArgumentTypes::positional([Type::StringLiteral(
3159-
StringLiteralType::new(db, Box::from(name.as_str())),
3159+
StringLiteralType::new(db, name.as_str()),
31603160
)]),
31613161
MemberLookupPolicy::MRO_NO_OBJECT_FALLBACK,
31623162
)
@@ -4988,7 +4988,7 @@ impl<'db> Type<'db> {
49884988
);
49894989
Ok(Type::TypeVar(TypeVarInstance::new(
49904990
db,
4991-
ast::name::Name::new("Self"),
4991+
ast::name::Name::new_static("Self"),
49924992
Some(class.definition(db)),
49934993
Some(TypeVarBoundOrConstraints::UpperBound(instance)),
49944994
TypeVarVariance::Invariant,
@@ -8195,7 +8195,7 @@ impl<'db> StringLiteralType<'db> {
81958195
pub(crate) fn iter_each_char(self, db: &'db dyn Db) -> impl Iterator<Item = Self> {
81968196
self.value(db)
81978197
.chars()
8198-
.map(|c| StringLiteralType::new(db, c.to_string().as_str()))
8198+
.map(|c| StringLiteralType::new(db, c.to_string().into_boxed_str()))
81998199
}
82008200
}
82018201

crates/ty_python_semantic/src/types/class.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3502,7 +3502,7 @@ impl KnownClass {
35023502
Some(Type::KnownInstance(KnownInstanceType::TypeVar(
35033503
TypeVarInstance::new(
35043504
db,
3505-
target.id.clone(),
3505+
&target.id,
35063506
Some(containing_assignment),
35073507
bound_or_constraint,
35083508
variance,

crates/ty_python_semantic/src/types/infer.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2366,7 +2366,7 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> {
23662366
let function_literal =
23672367
FunctionLiteral::new(self.db(), overload_literal, inherited_generic_context);
23682368

2369-
let type_mappings = Box::from([]);
2369+
let type_mappings = Box::default();
23702370
let mut inferred_ty = Type::FunctionLiteral(FunctionType::new(
23712371
self.db(),
23722372
function_literal,
@@ -3070,7 +3070,7 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> {
30703070
let default_ty = self.infer_optional_type_expression(default.as_deref());
30713071
let ty = Type::KnownInstance(KnownInstanceType::TypeVar(TypeVarInstance::new(
30723072
self.db(),
3073-
name.id.clone(),
3073+
&name.id,
30743074
Some(definition),
30753075
bound_or_constraint,
30763076
TypeVarVariance::Invariant, // TODO: infer this
@@ -3462,7 +3462,7 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> {
34623462
db,
34633463
"__setattr__",
34643464
&mut CallArgumentTypes::positional([
3465-
Type::StringLiteral(StringLiteralType::new(db, Box::from(attribute))),
3465+
Type::StringLiteral(StringLiteralType::new(db, attribute)),
34663466
value_ty,
34673467
]),
34683468
MemberLookupPolicy::MRO_NO_OBJECT_FALLBACK,

0 commit comments

Comments
 (0)