Skip to content

Commit 5da2bf1

Browse files
arora-amanroxelo
authored andcommitted
Remove extra call to upvar_tys
Fixes #78720
1 parent 349b3b3 commit 5da2bf1

File tree

3 files changed

+74
-10
lines changed

3 files changed

+74
-10
lines changed

compiler/rustc_trait_selection/src/opaque_types.rs

-10
Original file line numberDiff line numberDiff line change
@@ -722,11 +722,6 @@ where
722722
// Skip lifetime parameters of the enclosing item(s)
723723

724724
substs.as_closure().tupled_upvars_ty().visit_with(self);
725-
726-
for upvar_ty in substs.as_closure().upvar_tys() {
727-
upvar_ty.visit_with(self);
728-
}
729-
730725
substs.as_closure().sig_as_fn_ptr_ty().visit_with(self);
731726
}
732727

@@ -735,11 +730,6 @@ where
735730
// Also skip the witness type, because that has no free regions.
736731

737732
substs.as_generator().tupled_upvars_ty().visit_with(self);
738-
739-
for upvar_ty in substs.as_generator().upvar_tys() {
740-
upvar_ty.visit_with(self);
741-
}
742-
743733
substs.as_generator().return_ty().visit_with(self);
744734
substs.as_generator().yield_ty().visit_with(self);
745735
substs.as_generator().resume_ty().visit_with(self);

src/test/ui/issues/issue-78720.rs

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
fn server() -> impl {
2+
//~^ ERROR at least one trait must be specified
3+
().map2(|| "")
4+
}
5+
6+
trait FilterBase2 {
7+
fn map2<F>(self, F) -> Map2<F> {}
8+
//~^ ERROR mismatched types
9+
//~^^ ERROR the size for values of type `Self` cannot be known at compilation time
10+
}
11+
12+
struct Map2<Segment2> {
13+
_func: F,
14+
//~^ ERROR cannot find type `F` in this scope
15+
}
16+
17+
impl<F> FilterBase2 for F {}
18+
19+
fn main() {}

src/test/ui/issues/issue-78720.stderr

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
error: at least one trait must be specified
2+
--> $DIR/issue-78720.rs:1:16
3+
|
4+
LL | fn server() -> impl {
5+
| ^^^^
6+
7+
error[E0412]: cannot find type `F` in this scope
8+
--> $DIR/issue-78720.rs:13:12
9+
|
10+
LL | _func: F,
11+
| ^
12+
|
13+
::: $SRC_DIR/core/src/ops/function.rs:LL:COL
14+
|
15+
LL | pub trait Fn<Args>: FnMut<Args> {
16+
| ------------------------------- similarly named trait `Fn` defined here
17+
|
18+
help: a trait with a similar name exists
19+
|
20+
LL | _func: Fn,
21+
| ^^
22+
help: you might be missing a type parameter
23+
|
24+
LL | struct Map2<Segment2, F> {
25+
| ^^^
26+
27+
error[E0308]: mismatched types
28+
--> $DIR/issue-78720.rs:7:36
29+
|
30+
LL | fn map2<F>(self, F) -> Map2<F> {}
31+
| ^^ expected struct `Map2`, found `()`
32+
|
33+
= note: expected struct `Map2<F>`
34+
found unit type `()`
35+
36+
error[E0277]: the size for values of type `Self` cannot be known at compilation time
37+
--> $DIR/issue-78720.rs:7:16
38+
|
39+
LL | fn map2<F>(self, F) -> Map2<F> {}
40+
| ^^^^ doesn't have a size known at compile-time
41+
|
42+
= help: unsized fn params are gated as an unstable feature
43+
help: consider further restricting `Self`
44+
|
45+
LL | fn map2<F>(self, F) -> Map2<F> where Self: Sized {}
46+
| ^^^^^^^^^^^^^^^^^
47+
help: function arguments must have a statically known size, borrowed types always have a known size
48+
|
49+
LL | fn map2<F>(&self, F) -> Map2<F> {}
50+
| ^
51+
52+
error: aborting due to 4 previous errors
53+
54+
Some errors have detailed explanations: E0277, E0308, E0412.
55+
For more information about an error, try `rustc --explain E0277`.

0 commit comments

Comments
 (0)