Skip to content

Commit 5e6de23

Browse files
committed
Auto merge of #103509 - compiler-errors:opaques-w-bound-vars-r-hard, r=oli-obk
Revert "Normalize opaques with escaping bound vars" This caused a perf regression in #103423, cc `@skyzh` this should fix #103423. reverts #100980 r? `@oli-obk`
2 parents 2f8d804 + 6ae4e5e commit 5e6de23

File tree

5 files changed

+49
-26
lines changed

5 files changed

+49
-26
lines changed

compiler/rustc_trait_selection/src/traits/project.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ impl<'a, 'b, 'tcx> TypeFolder<'tcx> for AssocTypeNormalizer<'a, 'b, 'tcx> {
508508
// This is really important. While we *can* handle this, this has
509509
// severe performance implications for large opaque types with
510510
// late-bound regions. See `issue-88862` benchmark.
511-
ty::Opaque(def_id, substs) => {
511+
ty::Opaque(def_id, substs) if !substs.has_escaping_bound_vars() => {
512512
// Only normalize `impl Trait` outside of type inference, usually in codegen.
513513
match self.param_env.reveal() {
514514
Reveal::UserFacing => ty.super_fold_with(self),

compiler/rustc_trait_selection/src/traits/query/normalize.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ impl<'cx, 'tcx> FallibleTypeFolder<'tcx> for QueryNormalizer<'cx, 'tcx> {
198198
// This is really important. While we *can* handle this, this has
199199
// severe performance implications for large opaque types with
200200
// late-bound regions. See `issue-88862` benchmark.
201-
ty::Opaque(def_id, substs) => {
201+
ty::Opaque(def_id, substs) if !substs.has_escaping_bound_vars() => {
202202
// Only normalize `impl Trait` outside of type inference, usually in codegen.
203203
match self.param_env.reveal() {
204204
Reveal::UserFacing => ty.try_super_fold_with(self),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// known-bug: #103507
2+
// failure-status: 101
3+
// normalize-stderr-test "note: .*\n\n" -> ""
4+
// normalize-stderr-test "thread 'rustc' panicked.*\n" -> ""
5+
// rustc-env:RUST_BACKTRACE=0
6+
7+
#![feature(type_alias_impl_trait)]
8+
#![feature(const_trait_impl)]
9+
#![feature(const_refs_to_cell)]
10+
#![feature(inline_const)]
11+
12+
use std::marker::Destruct;
13+
14+
trait T {
15+
type Item;
16+
}
17+
18+
type Alias<'a> = impl T<Item = &'a ()>;
19+
20+
struct S;
21+
impl<'a> T for &'a S {
22+
type Item = &'a ();
23+
}
24+
25+
const fn filter_positive<'a>() -> &'a Alias<'a> {
26+
&&S
27+
}
28+
29+
const fn with_positive<F: ~const for<'a> Fn(&'a Alias<'a>) + ~const Destruct>(fun: F) {
30+
fun(filter_positive());
31+
}
32+
33+
const fn foo(_: &Alias<'_>) {}
34+
35+
const BAR: () = {
36+
with_positive(foo);
37+
};
38+
39+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error: internal compiler error: compiler/rustc_middle/src/ty/normalize_erasing_regions.rs:198:90: Failed to normalize <for<'a, 'b> fn(&'a Alias<'b>) {foo} as std::ops::FnOnce<(&&S,)>>::Output, maybe try to call `try_normalize_erasing_regions` instead
2+
3+
query stack during panic:
4+
#0 [eval_to_allocation_raw] const-evaluating + checking `BAR`
5+
#1 [eval_to_const_value_raw] simplifying constant for the type system `BAR`
6+
end of query stack
7+
error: aborting due to previous error
8+

src/tools/miri/tests/pass/issues/issue-miri-2433.rs

-24
This file was deleted.

0 commit comments

Comments
 (0)