chore: Replace as_any functions with trait upcasting (#28221)

Closes #ISSUE

Release Notes:

- N/A
This commit is contained in:
Piotr Osiewicz 2025-04-08 22:16:27 +02:00 committed by GitHub
parent 38ec45008c
commit 0b75c13034
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 23 additions and 87 deletions

View file

@ -306,7 +306,7 @@ pub enum BufferEvent {
}
/// The file associated with a buffer.
pub trait File: Send + Sync {
pub trait File: Send + Sync + Any {
/// Returns the [`LocalFile`] associated with this file, if the
/// file is local.
fn as_local(&self) -> Option<&dyn LocalFile>;
@ -336,9 +336,6 @@ pub trait File: Send + Sync {
/// This is needed for looking up project-specific settings.
fn worktree_id(&self, cx: &App) -> WorktreeId;
/// Converts this file into an [`Any`] trait object.
fn as_any(&self) -> &dyn Any;
/// Converts this file into a protobuf message.
fn to_proto(&self, cx: &App) -> rpc::proto::File;
@ -4610,10 +4607,6 @@ impl File for TestFile {
WorktreeId::from_usize(0)
}
fn as_any(&self) -> &dyn std::any::Any {
unimplemented!()
}
fn to_proto(&self, _: &App) -> rpc::proto::File {
unimplemented!()
}