Skip to content

Commit e595409

Browse files
committed
Auto merge of #113648 - aliemjay:opaque-binder-ice, r=oli-obk
don't replace opaque types under binders with infer vars Fixes an ICE in the ui test code. Fixes #109636 Fixes #109281 Fixes #86800 r? `@oli-obk`
2 parents bc720ad + 2e83a72 commit e595409

File tree

5 files changed

+27
-31
lines changed

5 files changed

+27
-31
lines changed

compiler/rustc_infer/src/infer/opaque_types.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ impl<'tcx> InferCtxt<'tcx> {
6464
ct_op: |ct| ct,
6565
ty_op: |ty| match *ty.kind() {
6666
ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. })
67-
if replace_opaque_type(def_id) =>
67+
if replace_opaque_type(def_id) && !ty.has_escaping_bound_vars() =>
6868
{
6969
let def_span = self.tcx.def_span(def_id);
7070
let span = if span.contains(def_span) { def_span } else { span };

tests/ui/generic-associated-types/issue-90014-tait2.rs

+2-20
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,9 @@
11
//! This test checks that opaque type collection doesn't try to normalize the projection
22
//! without respecting its binders (which would ICE).
33
//! Unfortunately we don't even reach opaque type collection, as we ICE in typeck before that.
4-
// known-bug: #109281
5-
// failure-status: 101
6-
// error-pattern:internal compiler error
7-
// normalize-stderr-test "internal compiler error.*" -> ""
8-
// normalize-stderr-test "DefId\([^)]*\)" -> "..."
9-
// normalize-stderr-test "\nerror: internal compiler error.*\n\n" -> ""
10-
// normalize-stderr-test "note:.*unexpectedly panicked.*\n\n" -> ""
11-
// normalize-stderr-test "note: we would appreciate a bug report.*\n\n" -> ""
12-
// normalize-stderr-test "note: compiler flags.*\n\n" -> ""
13-
// normalize-stderr-test "note: rustc.*running on.*\n\n" -> ""
14-
// normalize-stderr-test "thread.*panicked.*:\n.*\n" -> ""
15-
// normalize-stderr-test "stack backtrace:\n" -> ""
16-
// normalize-stderr-test "\s\d{1,}: .*\n" -> ""
17-
// normalize-stderr-test "\s at .*\n" -> ""
18-
// normalize-stderr-test ".*note: Some details.*\n" -> ""
19-
// normalize-stderr-test "\n\n[ ]*\n" -> ""
20-
// normalize-stderr-test "compiler/.*: projection" -> "projection"
21-
// normalize-stderr-test ".*omitted \d{1,} frame.*\n" -> ""
22-
// normalize-stderr-test "error: [\s\n]*query stack" -> "error: query stack"
23-
// normalize-stderr-test "[\n\s]*\nquery stack during panic:" -> "query stack during panic:"
4+
//! See #109281 for the original report.
245
// edition:2018
6+
// error-pattern: expected generic lifetime parameter, found `'a`
257

268
#![feature(type_alias_impl_trait)]
279
#![allow(incomplete_features)]
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
1-
error:
2-
--> $DIR/issue-90014-tait2.rs:44:27
3-
|
4-
LL | fn make_fut(&self) -> Box<dyn for<'a> Trait<'a, Thing = Fut<'a>>> {
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^query stack during panic:
6-
#0 [typeck] type-checking `<impl at $DIR/issue-90014-tait2.rs:43:1: 43:13>::make_fut`
7-
#1 [type_of] computing type of `Fut::{opaque#0}`
8-
#2 [check_mod_item_types] checking item types in top-level module
9-
#3 [analysis] running analysis passes on this crate
10-
end of query stack
1+
error[E0792]: expected generic lifetime parameter, found `'a`
2+
113
error: aborting due to previous error
124

5+
For more information about this error, try `rustc --explain E0792`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#![feature(type_alias_impl_trait)]
2+
3+
type Opaque<'a> = impl Sized + 'a;
4+
5+
fn test(f: fn(u8)) -> fn(Opaque<'_>) {
6+
f //~ ERROR E0792
7+
}
8+
9+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
error[E0792]: expected generic lifetime parameter, found `'_`
2+
--> $DIR/under-binder.rs:6:5
3+
|
4+
LL | type Opaque<'a> = impl Sized + 'a;
5+
| -- this generic parameter must be used with a generic lifetime parameter
6+
...
7+
LL | f
8+
| ^
9+
10+
error: aborting due to previous error
11+
12+
For more information about this error, try `rustc --explain E0792`.

0 commit comments

Comments
 (0)