]> git.lizzy.rs Git - rust.git/commitdiff
Remove extra call to upvar_tys
authorAman Arora <me@aman-arora.com>
Wed, 4 Nov 2020 08:07:40 +0000 (03:07 -0500)
committerRoxane <roxane.fruytier@hotmail.com>
Mon, 30 Nov 2020 00:11:20 +0000 (19:11 -0500)
Fixes #78720

compiler/rustc_trait_selection/src/opaque_types.rs
src/test/ui/issues/issue-78720.rs [new file with mode: 0644]
src/test/ui/issues/issue-78720.stderr [new file with mode: 0644]

index ca547bf88b588187d1fd0682517d4da214394d1f..f5bc90e6f962102e5b790c8394cdcfc691574793 100644 (file)
@@ -722,11 +722,6 @@ fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
                 // Skip lifetime parameters of the enclosing item(s)
 
                 substs.as_closure().tupled_upvars_ty().visit_with(self);
-
-                for upvar_ty in substs.as_closure().upvar_tys() {
-                    upvar_ty.visit_with(self);
-                }
-
                 substs.as_closure().sig_as_fn_ptr_ty().visit_with(self);
             }
 
@@ -735,11 +730,6 @@ fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
                 // Also skip the witness type, because that has no free regions.
 
                 substs.as_generator().tupled_upvars_ty().visit_with(self);
-
-                for upvar_ty in substs.as_generator().upvar_tys() {
-                    upvar_ty.visit_with(self);
-                }
-
                 substs.as_generator().return_ty().visit_with(self);
                 substs.as_generator().yield_ty().visit_with(self);
                 substs.as_generator().resume_ty().visit_with(self);
diff --git a/src/test/ui/issues/issue-78720.rs b/src/test/ui/issues/issue-78720.rs
new file mode 100644 (file)
index 0000000..57615d1
--- /dev/null
@@ -0,0 +1,19 @@
+fn server() -> impl {
+//~^ ERROR at least one trait must be specified
+    ().map2(|| "")
+}
+
+trait FilterBase2 {
+    fn map2<F>(self, F) -> Map2<F> {}
+    //~^ ERROR mismatched types
+    //~^^ ERROR the size for values of type `Self` cannot be known at compilation time
+}
+
+struct Map2<Segment2> {
+    _func: F,
+    //~^ ERROR cannot find type `F` in this scope
+}
+
+impl<F> FilterBase2 for F {}
+
+fn main() {}
diff --git a/src/test/ui/issues/issue-78720.stderr b/src/test/ui/issues/issue-78720.stderr
new file mode 100644 (file)
index 0000000..a3a14e3
--- /dev/null
@@ -0,0 +1,55 @@
+error: at least one trait must be specified
+  --> $DIR/issue-78720.rs:1:16
+   |
+LL | fn server() -> impl {
+   |                ^^^^
+
+error[E0412]: cannot find type `F` in this scope
+  --> $DIR/issue-78720.rs:13:12
+   |
+LL |     _func: F,
+   |            ^
+   | 
+  ::: $SRC_DIR/core/src/ops/function.rs:LL:COL
+   |
+LL | pub trait Fn<Args>: FnMut<Args> {
+   | ------------------------------- similarly named trait `Fn` defined here
+   |
+help: a trait with a similar name exists
+   |
+LL |     _func: Fn,
+   |            ^^
+help: you might be missing a type parameter
+   |
+LL | struct Map2<Segment2, F> {
+   |                     ^^^
+
+error[E0308]: mismatched types
+  --> $DIR/issue-78720.rs:7:36
+   |
+LL |     fn map2<F>(self, F) -> Map2<F> {}
+   |                                    ^^ expected struct `Map2`, found `()`
+   |
+   = note: expected struct `Map2<F>`
+           found unit type `()`
+
+error[E0277]: the size for values of type `Self` cannot be known at compilation time
+  --> $DIR/issue-78720.rs:7:16
+   |
+LL |     fn map2<F>(self, F) -> Map2<F> {}
+   |                ^^^^ doesn't have a size known at compile-time
+   |
+   = help: unsized fn params are gated as an unstable feature
+help: consider further restricting `Self`
+   |
+LL |     fn map2<F>(self, F) -> Map2<F> where Self: Sized {}
+   |                                    ^^^^^^^^^^^^^^^^^
+help: function arguments must have a statically known size, borrowed types always have a known size
+   |
+LL |     fn map2<F>(&self, F) -> Map2<F> {}
+   |                ^
+
+error: aborting due to 4 previous errors
+
+Some errors have detailed explanations: E0277, E0308, E0412.
+For more information about an error, try `rustc --explain E0277`.