Normalize opaques during codegen in new solver

This commit is contained in:
Michael Goulet 2023-07-04 18:49:13 +00:00
parent 713f9bb5d1
commit f55b046931
5 changed files with 46 additions and 6 deletions

View File

@ -167,9 +167,7 @@ impl<'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for NormalizationFolder<'_, 'tcx> {
// We don't normalize opaque types unless we have // We don't normalize opaque types unless we have
// `Reveal::All`, even if we're in the defining scope. // `Reveal::All`, even if we're in the defining scope.
let data = match *ty.kind() { let data = match *ty.kind() {
ty::Alias(kind, alias_ty) if kind != ty::Opaque || reveal == Reveal::UserFacing => { ty::Alias(kind, alias_ty) if kind != ty::Opaque || reveal == Reveal::All => alias_ty,
alias_ty
}
_ => return ty.try_super_fold_with(self), _ => return ty.try_super_fold_with(self),
}; };

View File

@ -1,5 +1,5 @@
error[E0282]: type annotations needed error[E0282]: type annotations needed
--> $DIR/param-env-region-infer.rs:16:10 --> $DIR/param-env-region-infer.rs:18:10
| |
LL | t as _ LL | t as _
| ^ cannot infer type | ^ cannot infer type

View File

@ -0,0 +1,29 @@
error[E0391]: cycle detected when computing type of `make_dyn_star::{opaque#0}`
--> $DIR/param-env-region-infer.rs:16:60
|
LL | fn make_dyn_star<'a, T: PointerLike + Debug + 'a>(t: T) -> impl PointerLike + Debug + 'a {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: ...which requires type-checking `make_dyn_star`...
--> $DIR/param-env-region-infer.rs:16:1
|
LL | fn make_dyn_star<'a, T: PointerLike + Debug + 'a>(t: T) -> impl PointerLike + Debug + 'a {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: ...which requires computing layout of `make_dyn_star::{opaque#0}`...
= note: ...which requires normalizing `make_dyn_star::{opaque#0}`...
= note: ...which again requires computing type of `make_dyn_star::{opaque#0}`, completing the cycle
note: cycle used when checking item types in top-level module
--> $DIR/param-env-region-infer.rs:10:1
|
LL | / #![feature(dyn_star, pointer_like_trait)]
LL | | #![allow(incomplete_features)]
LL | |
LL | | use std::fmt::Debug;
... |
LL | |
LL | | fn main() {}
| |____________^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0391`.

View File

@ -1,6 +1,7 @@
// revisions: current next // revisions: current next
//[next] compile-flags: -Ztrait-solver=next // Need `-Zdeduplicate-diagnostics=yes` because the number of cycle errors
//[next] check-pass // emitted is for some horrible reason platform-specific.
//[next] compile-flags: -Ztrait-solver=next -Zdeduplicate-diagnostics=yes
// incremental // incremental
// checks that we don't ICE if there are region inference variables in the environment // checks that we don't ICE if there are region inference variables in the environment
@ -13,6 +14,7 @@ use std::fmt::Debug;
use std::marker::PointerLike; use std::marker::PointerLike;
fn make_dyn_star<'a, T: PointerLike + Debug + 'a>(t: T) -> impl PointerLike + Debug + 'a { fn make_dyn_star<'a, T: PointerLike + Debug + 'a>(t: T) -> impl PointerLike + Debug + 'a {
//[next]~^ ERROR cycle detected when computing
t as _ t as _
//[current]~^ ERROR type annotations needed //[current]~^ ERROR type annotations needed
} }

View File

@ -0,0 +1,11 @@
// build-pass
// revisions: current next
//[next] compile-flags: -Ztrait-solver=next
fn test() -> Option<impl Sized> {
Some("")
}
fn main() {
test();
}