mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 14:55:26 +00:00
don't replace opaque types under binders with infer vars
This commit is contained in:
parent
11467b1c2a
commit
2e83a72964
@ -64,7 +64,7 @@ impl<'tcx> InferCtxt<'tcx> {
|
||||
ct_op: |ct| ct,
|
||||
ty_op: |ty| match *ty.kind() {
|
||||
ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. })
|
||||
if replace_opaque_type(def_id) =>
|
||||
if replace_opaque_type(def_id) && !ty.has_escaping_bound_vars() =>
|
||||
{
|
||||
let def_span = self.tcx.def_span(def_id);
|
||||
let span = if span.contains(def_span) { def_span } else { span };
|
||||
|
@ -1,27 +1,9 @@
|
||||
//! This test checks that opaque type collection doesn't try to normalize the projection
|
||||
//! without respecting its binders (which would ICE).
|
||||
//! Unfortunately we don't even reach opaque type collection, as we ICE in typeck before that.
|
||||
// known-bug: #109281
|
||||
// failure-status: 101
|
||||
// error-pattern:internal compiler error
|
||||
// normalize-stderr-test "internal compiler error.*" -> ""
|
||||
// normalize-stderr-test "DefId\([^)]*\)" -> "..."
|
||||
// normalize-stderr-test "\nerror: internal compiler error.*\n\n" -> ""
|
||||
// normalize-stderr-test "note:.*unexpectedly panicked.*\n\n" -> ""
|
||||
// normalize-stderr-test "note: we would appreciate a bug report.*\n\n" -> ""
|
||||
// normalize-stderr-test "note: compiler flags.*\n\n" -> ""
|
||||
// normalize-stderr-test "note: rustc.*running on.*\n\n" -> ""
|
||||
// normalize-stderr-test "thread.*panicked.*:\n.*\n" -> ""
|
||||
// normalize-stderr-test "stack backtrace:\n" -> ""
|
||||
// normalize-stderr-test "\s\d{1,}: .*\n" -> ""
|
||||
// normalize-stderr-test "\s at .*\n" -> ""
|
||||
// normalize-stderr-test ".*note: Some details.*\n" -> ""
|
||||
// normalize-stderr-test "\n\n[ ]*\n" -> ""
|
||||
// normalize-stderr-test "compiler/.*: projection" -> "projection"
|
||||
// normalize-stderr-test ".*omitted \d{1,} frame.*\n" -> ""
|
||||
// normalize-stderr-test "error: [\s\n]*query stack" -> "error: query stack"
|
||||
// normalize-stderr-test "[\n\s]*\nquery stack during panic:" -> "query stack during panic:"
|
||||
//! See #109281 for the original report.
|
||||
// edition:2018
|
||||
// error-pattern: expected generic lifetime parameter, found `'a`
|
||||
|
||||
#![feature(type_alias_impl_trait)]
|
||||
#![allow(incomplete_features)]
|
||||
|
@ -1,12 +1,5 @@
|
||||
error:
|
||||
--> $DIR/issue-90014-tait2.rs:44:27
|
||||
|
|
||||
LL | fn make_fut(&self) -> Box<dyn for<'a> Trait<'a, Thing = Fut<'a>>> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^query stack during panic:
|
||||
#0 [typeck] type-checking `<impl at $DIR/issue-90014-tait2.rs:43:1: 43:13>::make_fut`
|
||||
#1 [type_of] computing type of `Fut::{opaque#0}`
|
||||
#2 [check_mod_item_types] checking item types in top-level module
|
||||
#3 [analysis] running analysis passes on this crate
|
||||
end of query stack
|
||||
error[E0792]: expected generic lifetime parameter, found `'a`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0792`.
|
||||
|
9
tests/ui/type-alias-impl-trait/under-binder.rs
Normal file
9
tests/ui/type-alias-impl-trait/under-binder.rs
Normal file
@ -0,0 +1,9 @@
|
||||
#![feature(type_alias_impl_trait)]
|
||||
|
||||
type Opaque<'a> = impl Sized + 'a;
|
||||
|
||||
fn test(f: fn(u8)) -> fn(Opaque<'_>) {
|
||||
f //~ ERROR E0792
|
||||
}
|
||||
|
||||
fn main() {}
|
12
tests/ui/type-alias-impl-trait/under-binder.stderr
Normal file
12
tests/ui/type-alias-impl-trait/under-binder.stderr
Normal file
@ -0,0 +1,12 @@
|
||||
error[E0792]: expected generic lifetime parameter, found `'_`
|
||||
--> $DIR/under-binder.rs:6:5
|
||||
|
|
||||
LL | type Opaque<'a> = impl Sized + 'a;
|
||||
| -- this generic parameter must be used with a generic lifetime parameter
|
||||
...
|
||||
LL | f
|
||||
| ^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0792`.
|
Loading…
Reference in New Issue
Block a user