mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-21 17:52:12 +03:00
add regression test for closure receiver suggestion ICE
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
// Regression test for https://github.com/rust-lang/rust/issues/156299.
|
||||
|
||||
struct A;
|
||||
|
||||
fn foo(_: &A) {}
|
||||
|
||||
fn test_foo() {
|
||||
(|a: A| foo(a)).bar();
|
||||
//~^ ERROR mismatched types
|
||||
//~| ERROR no method named `bar` found
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,28 @@
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/closure-arg-type-mismatch-method-receiver.rs:8:17
|
||||
|
|
||||
LL | (|a: A| foo(a)).bar();
|
||||
| --- ^ expected `&A`, found `A`
|
||||
| |
|
||||
| arguments to this function are incorrect
|
||||
|
|
||||
note: function defined here
|
||||
--> $DIR/closure-arg-type-mismatch-method-receiver.rs:5:4
|
||||
|
|
||||
LL | fn foo(_: &A) {}
|
||||
| ^^^ -----
|
||||
help: consider borrowing here
|
||||
|
|
||||
LL | (|a: A| foo(&a)).bar();
|
||||
| +
|
||||
|
||||
error[E0599]: no method named `bar` found for closure `{closure@$DIR/closure-arg-type-mismatch-method-receiver.rs:8:6: 8:12}` in the current scope
|
||||
--> $DIR/closure-arg-type-mismatch-method-receiver.rs:8:21
|
||||
|
|
||||
LL | (|a: A| foo(a)).bar();
|
||||
| ^^^ method not found in `{closure@$DIR/closure-arg-type-mismatch-method-receiver.rs:8:6: 8:12}`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0308, E0599.
|
||||
For more information about an error, try `rustc --explain E0308`.
|
||||
Reference in New Issue
Block a user