diff options
| -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 |
