Rollup merge of #105694 - ouz-a:issue_105689, r=estebank

Don't create dummy if val has escaping bounds var

Skips creating/pushing obligations if val has escaping bounds vars.

Fixes #105689
This commit is contained in:
Matthias Krüger 2022-12-15 22:02:59 +01:00 committed by GitHub
commit 24e584b991
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 12 deletions

View file

@ -451,6 +451,7 @@ impl<'tcx> WfPredicates<'tcx> {
GenericArgKind::Const(ct) => { GenericArgKind::Const(ct) => {
match ct.kind() { match ct.kind() {
ty::ConstKind::Unevaluated(uv) => { ty::ConstKind::Unevaluated(uv) => {
if !ct.has_escaping_bound_vars() {
let obligations = self.nominal_obligations(uv.def.did, uv.substs); let obligations = self.nominal_obligations(uv.def.did, uv.substs);
self.out.extend(obligations); self.out.extend(obligations);
@ -465,6 +466,7 @@ impl<'tcx> WfPredicates<'tcx> {
predicate, predicate,
)); ));
} }
}
ty::ConstKind::Infer(_) => { ty::ConstKind::Infer(_) => {
let cause = self.cause(traits::WellFormed(None)); let cause = self.cause(traits::WellFormed(None));

View file

@ -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() {}