Skip to content

Commit

Permalink
Rollup merge of #105694 - ouz-a:issue_105689, r=estebank
Browse files Browse the repository at this point in the history
Don't create dummy if val has escaping bounds var

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

Fixes #105689
  • Loading branch information
matthiaskrgr committed Dec 15, 2022
2 parents 86cedb4 + 75cf31f commit 24e584b
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 24e584b

Please sign in to comment.