diff --git a/crates/red_knot_python_semantic/src/types.rs b/crates/red_knot_python_semantic/src/types.rs index 3eb267638a..ca28059d45 100644 --- a/crates/red_knot_python_semantic/src/types.rs +++ b/crates/red_knot_python_semantic/src/types.rs @@ -361,6 +361,7 @@ impl<'db> Type<'db> { #[salsa::interned] pub struct FunctionType<'db> { /// name of the function at definition + #[return_ref] pub name: ast::name::Name, definition: Definition<'db>, @@ -408,6 +409,7 @@ impl<'db> FunctionType<'db> { #[salsa::interned] pub struct ClassType<'db> { /// Name of the class at definition + #[return_ref] pub name: ast::name::Name, definition: Definition<'db>, @@ -464,6 +466,7 @@ impl<'db> ClassType<'db> { #[salsa::interned] pub struct UnionType<'db> { /// The union type includes values in any of these types. + #[return_ref] elements: FxOrderSet>, } @@ -476,6 +479,7 @@ impl<'db> UnionType<'db> { #[salsa::interned] pub struct IntersectionType<'db> { /// The intersection type includes only values in all of these types. + #[return_ref] positive: FxOrderSet>, /// The intersection type does not include any value in any of these types. @@ -483,6 +487,7 @@ pub struct IntersectionType<'db> { /// Negation types aren't expressible in annotations, and are most likely to arise from type /// narrowing along with intersections (e.g. `if not isinstance(...)`), so we represent them /// directly in intersections rather than as a separate type. + #[return_ref] negative: FxOrderSet>, } diff --git a/crates/red_knot_python_semantic/src/types/builder.rs b/crates/red_knot_python_semantic/src/types/builder.rs index 5b7593837b..1688ea7f19 100644 --- a/crates/red_knot_python_semantic/src/types/builder.rs +++ b/crates/red_knot_python_semantic/src/types/builder.rs @@ -49,7 +49,7 @@ impl<'db> UnionBuilder<'db> { pub(crate) fn add(mut self, ty: Type<'db>) -> Self { match ty { Type::Union(union) => { - self.elements.extend(&union.elements(self.db)); + self.elements.extend(union.elements(self.db)); } Type::Never => {} _ => { @@ -284,7 +284,7 @@ mod tests { impl<'db> UnionType<'db> { fn elements_vec(self, db: &'db TestDb) -> Vec> { - self.elements(db).into_iter().collect() + self.elements(db).into_iter().copied().collect() } } @@ -389,11 +389,11 @@ mod tests { impl<'db> IntersectionType<'db> { fn pos_vec(self, db: &'db TestDb) -> Vec> { - self.positive(db).into_iter().collect() + self.positive(db).into_iter().copied().collect() } fn neg_vec(self, db: &'db TestDb) -> Vec> { - self.negative(db).into_iter().collect() + self.negative(db).into_iter().copied().collect() } } diff --git a/crates/red_knot_python_semantic/src/types/display.rs b/crates/red_knot_python_semantic/src/types/display.rs index b703bb51ed..8c3cf67ff5 100644 --- a/crates/red_knot_python_semantic/src/types/display.rs +++ b/crates/red_knot_python_semantic/src/types/display.rs @@ -33,7 +33,7 @@ impl Display for DisplayType<'_> { } // TODO functions and classes should display using a fully qualified name Type::Class(class) => write!(f, "Literal[{}]", class.name(self.db)), - Type::Instance(class) => f.write_str(&class.name(self.db)), + Type::Instance(class) => f.write_str(class.name(self.db)), Type::Function(function) => write!(f, "Literal[{}]", function.name(self.db)), Type::Union(union) => union.display(self.db).fmt(f), Type::Intersection(intersection) => intersection.display(self.db).fmt(f), diff --git a/crates/red_knot_workspace/src/lint.rs b/crates/red_knot_workspace/src/lint.rs index 72db387168..1bb3a6a3f2 100644 --- a/crates/red_knot_workspace/src/lint.rs +++ b/crates/red_knot_workspace/src/lint.rs @@ -164,7 +164,7 @@ fn lint_bad_override(context: &SemanticLintContext, class: &ast::StmtClassDef) { if ty.has_decorator(db, override_ty) { let method_name = ty.name(db); if class_ty - .inherited_class_member(db, &method_name) + .inherited_class_member(db, method_name) .is_unbound() { // TODO should have a qualname() method to support nested classes diff --git a/crates/red_knot_workspace/src/workspace.rs b/crates/red_knot_workspace/src/workspace.rs index 0bd22ffe2c..02c901871b 100644 --- a/crates/red_knot_workspace/src/workspace.rs +++ b/crates/red_knot_workspace/src/workspace.rs @@ -297,7 +297,6 @@ impl Workspace { } } -#[salsa::tracked] impl Package { pub fn root(self, db: &dyn Db) -> &SystemPath { self.root_buf(db)