Skip to content

Commit

Permalink
Don't look for late bound vars if the closure has no input.
Browse files Browse the repository at this point in the history
  • Loading branch information
lenko-d committed Jul 6, 2023
1 parent b7bc6f8 commit 6920064
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 2 deletions.
7 changes: 5 additions & 2 deletions compiler/rustc_hir_typeck/src/closure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use rustc_infer::infer::{InferOk, InferResult};
use rustc_macros::{TypeFoldable, TypeVisitable};
use rustc_middle::ty::subst::InternalSubsts;
use rustc_middle::ty::visit::{TypeVisitable, TypeVisitableExt};
use rustc_middle::ty::{self, Ty, TyCtxt, TypeSuperVisitable, TypeVisitor};
use rustc_middle::ty::{self, List, Ty, TyCtxt, TypeSuperVisitable, TypeVisitor};
use rustc_span::def_id::LocalDefId;
use rustc_span::source_map::Span;
use rustc_span::sym;
Expand Down Expand Up @@ -622,7 +622,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
debug!(?body.generator_kind);

let hir_id = self.tcx.hir().local_def_id_to_hir_id(expr_def_id);
let bound_vars = self.tcx.late_bound_vars(hir_id);
let bound_vars = match decl.inputs.len() {
0 => List::empty(),
_ => self.tcx.late_bound_vars(hir_id),
};

// First, convert the types that the user supplied (if any).
let supplied_arguments = decl.inputs.iter().map(|a| astconv.ast_ty_to_ty(a));
Expand Down
15 changes: 15 additions & 0 deletions tests/ui/closures/issue-112547.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#![feature(non_lifetime_binders)]
//~^ WARNING the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes

pub fn bar()
where
for<const N: usize = {
(||1usize)()
}> V: IntoIterator
//~^ ERROR cannot find type `V` in this scope [E0412]
{
}

fn main() {
bar();
}
23 changes: 23 additions & 0 deletions tests/ui/closures/issue-112547.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
error[E0412]: cannot find type `V` in this scope
--> $DIR/issue-112547.rs:8:4
|
LL | }> V: IntoIterator
| ^ not found in this scope
|
help: you might be missing a type parameter
|
LL | pub fn bar<V>()
| +++

warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/issue-112547.rs:1:12
|
LL | #![feature(non_lifetime_binders)]
| ^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #108185 <https://github.com/rust-lang/rust/issues/108185> for more information
= note: `#[warn(incomplete_features)]` on by default

error: aborting due to previous error; 1 warning emitted

For more information about this error, try `rustc --explain E0412`.

0 comments on commit 6920064

Please sign in to comment.