Skip to content

[ty] Remove unused code#19949

Merged
AlexWaygood merged 1 commit intomainfrom
alex/unused-ty-code
Aug 17, 2025
Merged

[ty] Remove unused code#19949
AlexWaygood merged 1 commit intomainfrom
alex/unused-ty-code

Conversation

@AlexWaygood
Copy link
Member

Summary

Most functions in types.rs do not need to be pub. Them being pub prevents Clippy from warning about unused code, and also seems to suppress other useful lints such as trivially_copy_pass_by_ref.

Test Plan

cargo build

@AlexWaygood AlexWaygood added internal An internal refactor or improvement ty Multi-file analysis & type inference labels Aug 17, 2025
Comment on lines -9150 to -9152
pub fn iter(&self, db: &'db dyn Db) -> Iter<'_, Type<'db>> {
self.elements(db).iter()
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we really need the indirection here, and removing this method allowed Clippy to point out that there was a callsite in arguments.rs where a union.elements(db).to_vec() call would be more efficient than calling union.elements(db).iter().copied().collect()

@github-actions
Copy link
Contributor

Diagnostic diff on typing conformance tests

Changes were detected when running ty on typing conformance tests
--- old-output.txt	2025-08-17 14:54:19.115031349 +0000
+++ new-output.txt	2025-08-17 14:54:19.185031945 +0000
@@ -1,5 +1,5 @@
 WARN ty is pre-release software and not ready for production use. Expect to encounter bugs, missing features, and fatal errors.
-fatal[panic] Panicked at /home/runner/.cargo/git/checkouts/salsa-e6f3bb7c2a062968/918d35d/src/function/execute.rs:215:25 when checking `/home/runner/work/ruff/ruff/typing/conformance/tests/aliases_typealiastype.py`: `infer_definition_types(Id(1582c)): execute: too many cycle iterations`
+fatal[panic] Panicked at /home/runner/.cargo/git/checkouts/salsa-e6f3bb7c2a062968/918d35d/src/function/execute.rs:215:25 when checking `/home/runner/work/ruff/ruff/typing/conformance/tests/aliases_typealiastype.py`: `infer_definition_types(Id(ac82)): execute: too many cycle iterations`
 _directives_deprecated_library.py:15:31: error[invalid-return-type] Function always implicitly returns `None`, which is not assignable to return type `int`
 _directives_deprecated_library.py:30:26: error[invalid-return-type] Function always implicitly returns `None`, which is not assignable to return type `str`
 _directives_deprecated_library.py:36:41: error[invalid-return-type] Function always implicitly returns `None`, which is not assignable to return type `Self@__add__`

@github-actions
Copy link
Contributor

mypy_primer results

No ecosystem changes detected ✅
No memory usage changes detected ✅

Copy link
Member

@MichaReiser MichaReiser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do except that more methods need to be made public to implement LSP and linter features but I'm fine promoting the methods once that need arises

@AlexWaygood AlexWaygood merged commit ec31637 into main Aug 17, 2025
40 checks passed
@AlexWaygood AlexWaygood deleted the alex/unused-ty-code branch August 17, 2025 17:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal An internal refactor or improvement ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants