Skip to content

Commit 478126c

Browse files
committed
Auto merge of rust-lang#86438 - FabianWolff:issue-83693, r=jackh726
Fix the ICE described in rust-lang#83693 This pull request fixes rust-lang#83693 and fixes rust-lang#84768.
2 parents 70f7471 + 6f0fe9b commit 478126c

File tree

5 files changed

+89
-3
lines changed

5 files changed

+89
-3
lines changed

compiler/rustc_resolve/src/late/lifetimes.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -2681,15 +2681,14 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
26812681
Scope::Binder { hir_id, .. } => {
26822682
break *hir_id;
26832683
}
2684-
Scope::Body { id, .. } => break id.hir_id,
26852684
Scope::ObjectLifetimeDefault { ref s, .. }
26862685
| Scope::Elision { ref s, .. }
26872686
| Scope::Supertrait { ref s, .. }
26882687
| Scope::TraitRefBoundary { ref s, .. } => {
26892688
scope = *s;
26902689
}
2691-
Scope::Root => {
2692-
// See issue #83907. Just bail out from looking inside.
2690+
Scope::Root | Scope::Body { .. } => {
2691+
// See issues #83907 and #83693. Just bail out from looking inside.
26932692
self.tcx.sess.delay_span_bug(
26942693
rustc_span::DUMMY_SP,
26952694
"In fn_like_elision without appropriate scope above",

src/test/ui/typeck/issue-83693.rs

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Regression test for the ICE described in #83693.
2+
3+
#![feature(fn_traits)]
4+
#![crate_type="lib"]
5+
6+
impl F {
7+
//~^ ERROR: cannot find type `F` in this scope [E0412]
8+
fn call() {
9+
<Self as Fn(&TestResult)>::call
10+
//~^ ERROR: cannot find type `TestResult` in this scope [E0412]
11+
//~| associated type bindings are not allowed here [E0229]
12+
}
13+
}
14+
15+
fn call() {
16+
<x as Fn(&usize)>::call
17+
//~^ ERROR: cannot find type `x` in this scope [E0412]
18+
//~| ERROR: associated type bindings are not allowed here [E0229]
19+
}

src/test/ui/typeck/issue-83693.stderr

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
error[E0412]: cannot find type `F` in this scope
2+
--> $DIR/issue-83693.rs:6:6
3+
|
4+
LL | impl F {
5+
| ^ help: a trait with a similar name exists: `Fn`
6+
|
7+
::: $SRC_DIR/core/src/ops/function.rs:LL:COL
8+
|
9+
LL | pub trait Fn<Args>: FnMut<Args> {
10+
| ------------------------------- similarly named trait `Fn` defined here
11+
12+
error[E0412]: cannot find type `TestResult` in this scope
13+
--> $DIR/issue-83693.rs:9:22
14+
|
15+
LL | <Self as Fn(&TestResult)>::call
16+
| ^^^^^^^^^^ not found in this scope
17+
18+
error[E0412]: cannot find type `x` in this scope
19+
--> $DIR/issue-83693.rs:16:6
20+
|
21+
LL | <x as Fn(&usize)>::call
22+
| ^ not found in this scope
23+
24+
error[E0229]: associated type bindings are not allowed here
25+
--> $DIR/issue-83693.rs:9:18
26+
|
27+
LL | <Self as Fn(&TestResult)>::call
28+
| ^^^^^^^^^^^^^^^ associated type not allowed here
29+
30+
error[E0229]: associated type bindings are not allowed here
31+
--> $DIR/issue-83693.rs:16:11
32+
|
33+
LL | <x as Fn(&usize)>::call
34+
| ^^^^^^^^^^ associated type not allowed here
35+
36+
error: aborting due to 5 previous errors
37+
38+
Some errors have detailed explanations: E0229, E0412.
39+
For more information about an error, try `rustc --explain E0229`.

src/test/ui/typeck/issue-84768.rs

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Regression test for the ICE described in #84768.
2+
3+
#![feature(fn_traits)]
4+
#![crate_type="lib"]
5+
6+
fn transform_mut<F>(f: F) where F: for<'b> FnOnce(&'b mut u8) {
7+
<F as FnOnce(&mut u8)>::call_once(f, 1)
8+
//~^ ERROR: associated type bindings are not allowed here [E0229]
9+
//~| ERROR: mismatched types [E0308]
10+
}

src/test/ui/typeck/issue-84768.stderr

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
error[E0229]: associated type bindings are not allowed here
2+
--> $DIR/issue-84768.rs:7:11
3+
|
4+
LL | <F as FnOnce(&mut u8)>::call_once(f, 1)
5+
| ^^^^^^^^^^^^^^^ associated type not allowed here
6+
7+
error[E0308]: mismatched types
8+
--> $DIR/issue-84768.rs:7:42
9+
|
10+
LL | <F as FnOnce(&mut u8)>::call_once(f, 1)
11+
| ^ expected tuple, found integer
12+
|
13+
= note: expected tuple `(&mut u8,)`
14+
found type `{integer}`
15+
16+
error: aborting due to 2 previous errors
17+
18+
Some errors have detailed explanations: E0229, E0308.
19+
For more information about an error, try `rustc --explain E0229`.

0 commit comments

Comments
 (0)