From 80ffe297a32aba9efe1d625a85f5a338b7dbf59d Mon Sep 17 00:00:00 2001 From: Aditya-PS-05 Date: Thu, 20 Nov 2025 14:21:39 +0530 Subject: [PATCH] feat: update test --- .../hir-ty/src/tests/regression/new_solver.rs | 49 +++++++++++-------- 1 file changed, 29 insertions(+), 20 deletions(-) diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/tests/regression/new_solver.rs b/src/tools/rust-analyzer/crates/hir-ty/src/tests/regression/new_solver.rs index ef0c03803cf2..4866a038d64a 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/tests/regression/new_solver.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/tests/regression/new_solver.rs @@ -554,49 +554,58 @@ fn do_something(&self) -> impl Future { } #[test] +// #[should_panic(expected = "Unexpected type mismatches")] fn regression_19957() { - // async-trait patterns should not produce false type mismatches between - // Pin> and Pin> + // This test documents issue #19957: async-trait patterns incorrectly produce + // type mismatches between Pin> and Pin>. + // + // The test currently FAILS (as expected) because the bug is not yet fixed. + // When the bug is fixed, remove the #[should_panic] attribute. check_no_mismatches( r#" -//- minicore: future, pin, result, error, send +//- minicore: future, pin, result, error, send, coerce_unsized, dispatch_from_dyn use core::{future::Future, pin::Pin}; -pub enum SimpleAsyncTraitResult { - Ok, - Error, +#[lang = "owned_box"] +pub struct Box { + inner: *mut T, } +impl Box { + fn pin(value: T) -> Pin> { + // Implementation details don't matter here for type checking + loop {} + } +} + +impl, U: ?Sized> core::ops::CoerceUnsized> for Box {} + +impl, U: ?Sized> core::ops::DispatchFromDyn> for Box {} + pub struct ExampleData { pub id: i32, - pub name: String, } -// As we can't directly use #[async_trait] directly in tests -// This simulates what #[async_trait] expands to -pub trait SimpleAsyncTraitModel { + +// Simulates what #[async_trait] expands to +pub trait SimpleModel { fn save<'life0, 'async_trait>( &'life0 self, - ) -> Pin>> + Send + 'async_trait>> + ) -> Pin + Send + 'async_trait>> where 'life0: 'async_trait, Self: 'async_trait; } -impl SimpleAsyncTraitModel for ExampleData { +impl SimpleModel for ExampleData { fn save<'life0, 'async_trait>( &'life0 self, - ) -> Pin>> + Send + 'async_trait>> + ) -> Pin + Send + 'async_trait>> where 'life0: 'async_trait, Self: 'async_trait, { - Box::pin(async move { - if self.id > 0 { - Ok(SimpleAsyncTraitResult::Ok) - } else { - Ok(SimpleAsyncTraitResult::Error) - } - }) + // Body creates Pin>, which should coerce to Pin> + Box::pin(async move { self.id }) } } "#,