Skip to content

Commit 549c4e4

Browse files
authored
Rollup merge of rust-lang#154821 - jakubadamw:issue-112588-113793-119382, r=Kivooeo
Add three tests for fixed issues (two ICEs and one coherence checking failure that now passes) Closes rust-lang#112588. Closes rust-lang#113793. Closes rust-lang#119382.
2 parents 8ae94a9 + 028e00b commit 549c4e4

4 files changed

Lines changed: 96 additions & 0 deletions
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//! Regression test for <https://github.com/rust-lang/rust/issues/119382>.
2+
//!
3+
//! The `-Wrust-2021-incompatible-closure-captures` lint used to ICE
4+
//! when applied to erroneous code.
5+
6+
//@ edition: 2018
7+
//@ compile-flags: -Wrust-2021-incompatible-closure-captures
8+
9+
struct V(&mut i32);
10+
//~^ ERROR missing lifetime specifier
11+
12+
fn nested(v: &V) {
13+
|| {
14+
V(_somename) = v;
15+
//~^ ERROR cannot find value `_somename` in this scope
16+
//~| ERROR mismatched types
17+
v.0 = 0;
18+
};
19+
}
20+
21+
fn main() {}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
error[E0106]: missing lifetime specifier
2+
--> $DIR/closure-2021-captures-lint-field-projection-ice-119382.rs:9:10
3+
|
4+
LL | struct V(&mut i32);
5+
| ^ expected named lifetime parameter
6+
|
7+
help: consider introducing a named lifetime parameter
8+
|
9+
LL | struct V<'a>(&'a mut i32);
10+
| ++++ ++
11+
12+
error[E0425]: cannot find value `_somename` in this scope
13+
--> $DIR/closure-2021-captures-lint-field-projection-ice-119382.rs:14:11
14+
|
15+
LL | V(_somename) = v;
16+
| ^^^^^^^^^ not found in this scope
17+
18+
error[E0308]: mismatched types
19+
--> $DIR/closure-2021-captures-lint-field-projection-ice-119382.rs:14:9
20+
|
21+
LL | V(_somename) = v;
22+
| ^^^^^^^^^^^^ - this expression has type `&V`
23+
| |
24+
| expected `&V`, found `V`
25+
|
26+
help: consider dereferencing to access the inner value using the `Deref` trait
27+
|
28+
LL | V(_somename) = &*v;
29+
| ++
30+
31+
error: aborting due to 3 previous errors
32+
33+
Some errors have detailed explanations: E0106, E0308, E0425.
34+
For more information about an error, try `rustc --explain E0106`.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//! Regression test for <https://github.com/rust-lang/rust/issues/112588>.
2+
3+
//@ check-pass
4+
5+
#![feature(negative_impls, with_negative_coherence)]
6+
7+
trait Trait {}
8+
impl<T: ?Sized> !Trait for &T {}
9+
10+
trait OtherTrait<T> {}
11+
12+
impl<T: Trait> OtherTrait<T> for T {}
13+
impl<T, U> OtherTrait<&U> for &T {}
14+
15+
fn main() {}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//! Regression test for <https://github.com/rust-lang/rust/issues/113793>.
2+
//!
3+
//! Using a GAT with a self-referential lifetime bound (`'b: 'b`) in a
4+
//! fully-qualified path with anonymous lifetimes used to ICE.
5+
6+
//@ check-pass
7+
8+
trait Gat {
9+
type FooArg<'a, 'b: 'b>;
10+
}
11+
12+
impl Gat for () {
13+
type FooArg<'a, 'b: 'b> = &'a dyn ToString;
14+
}
15+
16+
struct Test;
17+
18+
impl Iterator for Test {
19+
type Item = Box<dyn Fn(<() as Gat>::FooArg<'_, '_>)>;
20+
21+
fn next(&mut self) -> Option<Self::Item> {
22+
None
23+
}
24+
}
25+
26+
fn main() {}

0 commit comments

Comments
 (0)