about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-07-25 16:17:58 +0000
committerbors <bors@rust-lang.org>2021-07-25 16:17:58 +0000
commit478126c0f3520ccd95a6f16be2812a78e3da711c (patch)
tree8024b90d76d3e5d0f3f12ddc7395c49b9f59374e
parent70f74719a92ef52bc28610ba04b7e98ada035ec9 (diff)
parent6f0fe9b91b8f217bc889f25e44843ff939ce4aa9 (diff)
downloadrust-478126c0f3520ccd95a6f16be2812a78e3da711c.tar.gz
rust-478126c0f3520ccd95a6f16be2812a78e3da711c.zip
Auto merge of #86438 - FabianWolff:issue-83693, r=jackh726
Fix the ICE described in #83693

This pull request fixes #83693 and fixes #84768.
-rw-r--r--compiler/rustc_resolve/src/late/lifetimes.rs5
-rw-r--r--src/test/ui/typeck/issue-83693.rs19
-rw-r--r--src/test/ui/typeck/issue-83693.stderr39
-rw-r--r--src/test/ui/typeck/issue-84768.rs10
-rw-r--r--src/test/ui/typeck/issue-84768.stderr19
5 files changed, 89 insertions, 3 deletions
diff --git a/compiler/rustc_resolve/src/late/lifetimes.rs b/compiler/rustc_resolve/src/late/lifetimes.rs
index b5033897ae6..43294774042 100644
--- a/compiler/rustc_resolve/src/late/lifetimes.rs
+++ b/compiler/rustc_resolve/src/late/lifetimes.rs
@@ -2681,15 +2681,14 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
                 Scope::Binder { hir_id, .. } => {
                     break *hir_id;
                 }
-                Scope::Body { id, .. } => break id.hir_id,
                 Scope::ObjectLifetimeDefault { ref s, .. }
                 | Scope::Elision { ref s, .. }
                 | Scope::Supertrait { ref s, .. }
                 | Scope::TraitRefBoundary { ref s, .. } => {
                     scope = *s;
                 }
-                Scope::Root => {
-                    // See issue #83907. Just bail out from looking inside.
+                Scope::Root | Scope::Body { .. } => {
+                    // See issues #83907 and #83693. Just bail out from looking inside.
                     self.tcx.sess.delay_span_bug(
                         rustc_span::DUMMY_SP,
                         "In fn_like_elision without appropriate scope above",
diff --git a/src/test/ui/typeck/issue-83693.rs b/src/test/ui/typeck/issue-83693.rs
new file mode 100644
index 00000000000..a4255822056
--- /dev/null
+++ b/src/test/ui/typeck/issue-83693.rs
@@ -0,0 +1,19 @@
+// Regression test for the ICE described in #83693.
+
+#![feature(fn_traits)]
+#![crate_type="lib"]
+
+impl F {
+//~^ ERROR: cannot find type `F` in this scope [E0412]
+    fn call() {
+        <Self as Fn(&TestResult)>::call
+        //~^ ERROR: cannot find type `TestResult` in this scope [E0412]
+        //~| associated type bindings are not allowed here [E0229]
+    }
+}
+
+fn call() {
+    <x as Fn(&usize)>::call
+    //~^ ERROR: cannot find type `x` in this scope [E0412]
+    //~| ERROR: associated type bindings are not allowed here [E0229]
+}
diff --git a/src/test/ui/typeck/issue-83693.stderr b/src/test/ui/typeck/issue-83693.stderr
new file mode 100644
index 00000000000..e5ef0d0d59f
--- /dev/null
+++ b/src/test/ui/typeck/issue-83693.stderr
@@ -0,0 +1,39 @@
+error[E0412]: cannot find type `F` in this scope
+  --> $DIR/issue-83693.rs:6:6
+   |
+LL | impl F {
+   |      ^ help: a trait with a similar name exists: `Fn`
+   | 
+  ::: $SRC_DIR/core/src/ops/function.rs:LL:COL
+   |
+LL | pub trait Fn<Args>: FnMut<Args> {
+   | ------------------------------- similarly named trait `Fn` defined here
+
+error[E0412]: cannot find type `TestResult` in this scope
+  --> $DIR/issue-83693.rs:9:22
+   |
+LL |         <Self as Fn(&TestResult)>::call
+   |                      ^^^^^^^^^^ not found in this scope
+
+error[E0412]: cannot find type `x` in this scope
+  --> $DIR/issue-83693.rs:16:6
+   |
+LL |     <x as Fn(&usize)>::call
+   |      ^ not found in this scope
+
+error[E0229]: associated type bindings are not allowed here
+  --> $DIR/issue-83693.rs:9:18
+   |
+LL |         <Self as Fn(&TestResult)>::call
+   |                  ^^^^^^^^^^^^^^^ associated type not allowed here
+
+error[E0229]: associated type bindings are not allowed here
+  --> $DIR/issue-83693.rs:16:11
+   |
+LL |     <x as Fn(&usize)>::call
+   |           ^^^^^^^^^^ associated type not allowed here
+
+error: aborting due to 5 previous errors
+
+Some errors have detailed explanations: E0229, E0412.
+For more information about an error, try `rustc --explain E0229`.
diff --git a/src/test/ui/typeck/issue-84768.rs b/src/test/ui/typeck/issue-84768.rs
new file mode 100644
index 00000000000..ffa92823b42
--- /dev/null
+++ b/src/test/ui/typeck/issue-84768.rs
@@ -0,0 +1,10 @@
+// Regression test for the ICE described in #84768.
+
+#![feature(fn_traits)]
+#![crate_type="lib"]
+
+fn transform_mut<F>(f: F) where F: for<'b> FnOnce(&'b mut u8) {
+    <F as FnOnce(&mut u8)>::call_once(f, 1)
+    //~^ ERROR: associated type bindings are not allowed here [E0229]
+    //~| ERROR: mismatched types [E0308]
+}
diff --git a/src/test/ui/typeck/issue-84768.stderr b/src/test/ui/typeck/issue-84768.stderr
new file mode 100644
index 00000000000..0a79d539ea9
--- /dev/null
+++ b/src/test/ui/typeck/issue-84768.stderr
@@ -0,0 +1,19 @@
+error[E0229]: associated type bindings are not allowed here
+  --> $DIR/issue-84768.rs:7:11
+   |
+LL |     <F as FnOnce(&mut u8)>::call_once(f, 1)
+   |           ^^^^^^^^^^^^^^^ associated type not allowed here
+
+error[E0308]: mismatched types
+  --> $DIR/issue-84768.rs:7:42
+   |
+LL |     <F as FnOnce(&mut u8)>::call_once(f, 1)
+   |                                          ^ expected tuple, found integer
+   |
+   = note: expected tuple `(&mut u8,)`
+               found type `{integer}`
+
+error: aborting due to 2 previous errors
+
+Some errors have detailed explanations: E0229, E0308.
+For more information about an error, try `rustc --explain E0229`.