add test 12969 and 9841
This commit is contained in:
parent
0ce07f61db
commit
7b76b94780
@ -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!()
|
||||
}
|
||||
}
|
||||
|
@ -345,3 +345,35 @@ struct S8 {
|
||||
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!()
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user