Skip to content

Commit

Permalink
skip if val has ecaping bound vars
Browse files Browse the repository at this point in the history
  • Loading branch information
ouz-a committed Dec 14, 2022
1 parent 37d7de3 commit 75cf31f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 13 deletions.
28 changes: 15 additions & 13 deletions compiler/rustc_trait_selection/src/traits/wf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -451,19 +451,21 @@ impl<'tcx> WfPredicates<'tcx> {
GenericArgKind::Const(ct) => {
match ct.kind() {
ty::ConstKind::Unevaluated(uv) => {
let obligations = self.nominal_obligations(uv.def.did, uv.substs);
self.out.extend(obligations);

let predicate =
ty::Binder::dummy(ty::PredicateKind::ConstEvaluatable(ct));
let cause = self.cause(traits::WellFormed(None));
self.out.push(traits::Obligation::with_depth(
self.tcx(),
cause,
self.recursion_depth,
self.param_env,
predicate,
));
if !ct.has_escaping_bound_vars() {
let obligations = self.nominal_obligations(uv.def.did, uv.substs);
self.out.extend(obligations);

let predicate =
ty::Binder::dummy(ty::PredicateKind::ConstEvaluatable(ct));
let cause = self.cause(traits::WellFormed(None));
self.out.push(traits::Obligation::with_depth(
self.tcx(),
cause,
self.recursion_depth,
self.param_env,
predicate,
));
}
}
ty::ConstKind::Infer(_) => {
let cause = self.cause(traits::WellFormed(None));
Expand Down
14 changes: 14 additions & 0 deletions src/test/ui/const-generics/issue-105689.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// check-pass
// edition:2021
#![feature(generic_const_exprs)]
#![allow(incomplete_features)]

#[allow(unused)]
async fn foo<'a>() {
let _data = &mut [0u8; { 1 + 4 }];
bar().await
}

async fn bar() {}

fn main() {}

0 comments on commit 75cf31f

Please sign in to comment.