mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
Add a test for an ICE with closure captures in erroneous code
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
//! Regression test for <https://github.com/rust-lang/rust/issues/119382>.
|
||||
//!
|
||||
//! The `-Wrust-2021-incompatible-closure-captures` lint used to ICE
|
||||
//! when applied to erroneous code.
|
||||
|
||||
//@ edition: 2018
|
||||
//@ compile-flags: -Wrust-2021-incompatible-closure-captures
|
||||
|
||||
struct V(&mut i32);
|
||||
//~^ ERROR missing lifetime specifier
|
||||
|
||||
fn nested(v: &V) {
|
||||
|| {
|
||||
V(_somename) = v;
|
||||
//~^ ERROR cannot find value `_somename` in this scope
|
||||
//~| ERROR mismatched types
|
||||
v.0 = 0;
|
||||
};
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,34 @@
|
||||
error[E0106]: missing lifetime specifier
|
||||
--> $DIR/closure-2021-captures-lint-field-projection-ice-119382.rs:9:10
|
||||
|
|
||||
LL | struct V(&mut i32);
|
||||
| ^ expected named lifetime parameter
|
||||
|
|
||||
help: consider introducing a named lifetime parameter
|
||||
|
|
||||
LL | struct V<'a>(&'a mut i32);
|
||||
| ++++ ++
|
||||
|
||||
error[E0425]: cannot find value `_somename` in this scope
|
||||
--> $DIR/closure-2021-captures-lint-field-projection-ice-119382.rs:14:11
|
||||
|
|
||||
LL | V(_somename) = v;
|
||||
| ^^^^^^^^^ not found in this scope
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/closure-2021-captures-lint-field-projection-ice-119382.rs:14:9
|
||||
|
|
||||
LL | V(_somename) = v;
|
||||
| ^^^^^^^^^^^^ - this expression has type `&V`
|
||||
| |
|
||||
| expected `&V`, found `V`
|
||||
|
|
||||
help: consider dereferencing to access the inner value using the `Deref` trait
|
||||
|
|
||||
LL | V(_somename) = &*v;
|
||||
| ++
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0106, E0308, E0425.
|
||||
For more information about an error, try `rustc --explain E0106`.
|
||||
Reference in New Issue
Block a user