This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +77
-1
lines changed Expand file tree Collapse file tree 3 files changed +77
-1
lines changed Original file line number Diff line number Diff line change @@ -345,3 +345,35 @@ fn main() {
345345 let _ = &mut ({ *x.u }).x;
346346 }
347347}
348+
349+ mod issue_12969 {
350+ use std::ops::Deref;
351+
352+ struct Wrapper<T>(T);
353+
354+ impl<T> Deref for Wrapper<T> {
355+ type Target = T;
356+
357+ fn deref(&self) -> &T {
358+ &self.0
359+ }
360+ }
361+
362+ fn foo(_bar: &str) {}
363+
364+ fn bar() {
365+ let wrapped_bar = Wrapper("");
366+
367+ foo(wrapped_bar);
368+ }
369+ }
370+
371+ mod issue_9841 {
372+ fn takes_array_ref<T, const N: usize>(array: &&[T; N]) {
373+ takes_slice(array)
374+ }
375+
376+ fn takes_slice<T>(slice: &[T]) {
377+ todo!()
378+ }
379+ }
Original file line number Diff line number Diff line change @@ -345,3 +345,35 @@ fn main() {
345345 let _ = & mut ( { * x. u } ) . x;
346346 }
347347}
348+
349+ mod issue_12969 {
350+ use std:: ops:: Deref ;
351+
352+ struct Wrapper < T > ( T ) ;
353+
354+ impl <T > Deref for Wrapper <T > {
355+ type Target = T ;
356+
357+ fn deref( & self ) -> & T {
358+ & self . 0
359+ }
360+ }
361+
362+ fn foo( _bar: & str ) { }
363+
364+ fn bar( ) {
365+ let wrapped_bar = Wrapper ( "") ;
366+
367+ foo( & * wrapped_bar) ;
368+ }
369+ }
370+
371+ mod issue_9841 {
372+ fn takes_array_ref<T , const N : usize >( array: &&[ T ; N ] ) {
373+ takes_slice( * array)
374+ }
375+
376+ fn takes_slice<T >( slice: & [ T ] ) {
377+ todo!( )
378+ }
379+ }
Original file line number Diff line number Diff line change @@ -271,5 +271,17 @@ error: deref which would be done by auto-deref
271271LL | let _ = &mut (*{ x.u }).x;
272272 | ^^^^^^^^^^ help: try: `{ x.u }`
273273
274- error: aborting due to 45 previous errors
274+ error: deref which would be done by auto-deref
275+ --> tests/ui/explicit_auto_deref.rs:367:13
276+ |
277+ LL | foo(&*wrapped_bar);
278+ | ^^^^^^^^^^^^^ help: try: `wrapped_bar`
279+
280+ error: deref which would be done by auto-deref
281+ --> tests/ui/explicit_auto_deref.rs:373:21
282+ |
283+ LL | takes_slice(*array)
284+ | ^^^^^^ help: try: `array`
285+
286+ error: aborting due to 47 previous errors
275287
You can’t perform that action at this time.
0 commit comments