Rollup merge of #103355 - compiler-errors:rpitit-default-check, r=oli-obk
Handle return-position `impl Trait` in traits properly in `register_hidden_type` The bounds that we get by calling `bound_explicit_item_bounds` from an RPITIT have projections, not opaques, but when we're *registering* an opaque, we want to treat it like an opaque. Coincidentally fixes #102688 as well, which makes sense, since that was failing because we were inferring an opaque type to be equal to itself (opaque cycle error => "cannot resolve opaque type"). Fixes #103352 r? ```@oli-obk```
This commit is contained in:
commit
ff689a1404
7 changed files with 63 additions and 14 deletions
|
@ -1,6 +1,7 @@
|
|||
use crate::errors::OpaqueHiddenTypeDiag;
|
||||
use crate::infer::{DefiningAnchor, InferCtxt, InferOk};
|
||||
use crate::traits;
|
||||
use hir::def::DefKind;
|
||||
use hir::def_id::{DefId, LocalDefId};
|
||||
use hir::{HirId, OpaqueTyOrigin};
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
|
@ -549,7 +550,12 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||
ty_op: |ty| match *ty.kind() {
|
||||
// We can't normalize associated types from `rustc_infer`,
|
||||
// but we can eagerly register inference variables for them.
|
||||
ty::Projection(projection_ty) if !projection_ty.has_escaping_bound_vars() => {
|
||||
// FIXME(RPITIT): Don't replace RPITITs with inference vars.
|
||||
ty::Projection(projection_ty)
|
||||
if !projection_ty.has_escaping_bound_vars()
|
||||
&& tcx.def_kind(projection_ty.item_def_id)
|
||||
!= DefKind::ImplTraitPlaceholder =>
|
||||
{
|
||||
self.infer_projection(
|
||||
param_env,
|
||||
projection_ty,
|
||||
|
@ -565,6 +571,12 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||
{
|
||||
hidden_ty
|
||||
}
|
||||
// FIXME(RPITIT): This can go away when we move to associated types
|
||||
ty::Projection(proj)
|
||||
if def_id.to_def_id() == proj.item_def_id && substs == proj.substs =>
|
||||
{
|
||||
hidden_ty
|
||||
}
|
||||
_ => ty,
|
||||
},
|
||||
lt_op: |lt| lt,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue