diff options
| author | Lzu Tao <taolzu@gmail.com> | 2024-06-22 06:19:07 +0700 |
|---|---|---|
| committer | Lzu Tao <taolzu@gmail.com> | 2024-07-03 21:09:38 +0700 |
| commit | 7b76b947800bac94d041aaf8156450c8e7289da9 (patch) | |
| tree | dfe3ef784a88a925941072231de1bf89e672a2cb | |
| parent | 0ce07f61db8c9de51e6ecd38aa62eb3145417c0f (diff) | |
| download | rust-7b76b947800bac94d041aaf8156450c8e7289da9.tar.gz rust-7b76b947800bac94d041aaf8156450c8e7289da9.zip | |
add test 12969 and 9841
| -rw-r--r-- | tests/ui/explicit_auto_deref.fixed | 32 | ||||
| -rw-r--r-- | tests/ui/explicit_auto_deref.rs | 32 | ||||
| -rw-r--r-- | tests/ui/explicit_auto_deref.stderr | 14 |
3 files changed, 77 insertions, 1 deletions
diff --git a/tests/ui/explicit_auto_deref.fixed b/tests/ui/explicit_auto_deref.fixed index e6ca4bb66cc..22bc0949659 100644 --- a/tests/ui/explicit_auto_deref.fixed +++ b/tests/ui/explicit_auto_deref.fixed @@ -345,3 +345,35 @@ fn main() { let _ = &mut ({ *x.u }).x; } } + +mod issue_12969 { + use std::ops::Deref; + + struct Wrapper<T>(T); + + impl<T> Deref for Wrapper<T> { + type Target = T; + + fn deref(&self) -> &T { + &self.0 + } + } + + fn foo(_bar: &str) {} + + fn bar() { + let wrapped_bar = Wrapper(""); + + foo(wrapped_bar); + } +} + +mod issue_9841 { + fn takes_array_ref<T, const N: usize>(array: &&[T; N]) { + takes_slice(array) + } + + fn takes_slice<T>(slice: &[T]) { + todo!() + } +} diff --git a/tests/ui/explicit_auto_deref.rs b/tests/ui/explicit_auto_deref.rs index 7531e1f87b7..2b3a28f8b6f 100644 --- a/tests/ui/explicit_auto_deref.rs +++ b/tests/ui/explicit_auto_deref.rs @@ -345,3 +345,35 @@ fn main() { let _ = &mut ({ *x.u }).x; } } + +mod issue_12969 { + use std::ops::Deref; + + struct Wrapper<T>(T); + + impl<T> Deref for Wrapper<T> { + type Target = T; + + fn deref(&self) -> &T { + &self.0 + } + } + + fn foo(_bar: &str) {} + + fn bar() { + let wrapped_bar = Wrapper(""); + + foo(&*wrapped_bar); + } +} + +mod issue_9841 { + fn takes_array_ref<T, const N: usize>(array: &&[T; N]) { + takes_slice(*array) + } + + fn takes_slice<T>(slice: &[T]) { + todo!() + } +} diff --git a/tests/ui/explicit_auto_deref.stderr b/tests/ui/explicit_auto_deref.stderr index 56a183de348..45059267362 100644 --- a/tests/ui/explicit_auto_deref.stderr +++ b/tests/ui/explicit_auto_deref.stderr @@ -271,5 +271,17 @@ error: deref which would be done by auto-deref LL | let _ = &mut (*{ x.u }).x; | ^^^^^^^^^^ help: try: `{ x.u }` -error: aborting due to 45 previous errors +error: deref which would be done by auto-deref + --> tests/ui/explicit_auto_deref.rs:367:13 + | +LL | foo(&*wrapped_bar); + | ^^^^^^^^^^^^^ help: try: `wrapped_bar` + +error: deref which would be done by auto-deref + --> tests/ui/explicit_auto_deref.rs:373:21 + | +LL | takes_slice(*array) + | ^^^^^^ help: try: `array` + +error: aborting due to 47 previous errors |
