Hackily fix an opaque type ICE
This commit is contained in:
parent
e405dabf7d
commit
c9588d5bf8
@ -18,9 +18,9 @@
|
||||
use rustc_middle::hir::place::PlaceBase;
|
||||
use rustc_middle::mir::{ConstraintCategory, ReturnConstraint};
|
||||
use rustc_middle::ty::subst::InternalSubsts;
|
||||
use rustc_middle::ty::Region;
|
||||
use rustc_middle::ty::TypeVisitor;
|
||||
use rustc_middle::ty::{self, RegionVid, Ty};
|
||||
use rustc_middle::ty::{Region, TyCtxt};
|
||||
use rustc_span::symbol::{kw, Ident};
|
||||
use rustc_span::{Span, DUMMY_SP};
|
||||
|
||||
@ -70,14 +70,16 @@ fn description(&self) -> &'static str {
|
||||
///
|
||||
/// Usually we expect this to either be empty or contain a small number of items, so we can avoid
|
||||
/// allocation most of the time.
|
||||
#[derive(Default)]
|
||||
pub(crate) struct RegionErrors<'tcx>(Vec<RegionErrorKind<'tcx>>);
|
||||
pub(crate) struct RegionErrors<'tcx>(Vec<RegionErrorKind<'tcx>>, TyCtxt<'tcx>);
|
||||
|
||||
impl<'tcx> RegionErrors<'tcx> {
|
||||
pub fn new(tcx: TyCtxt<'tcx>) -> Self {
|
||||
Self(vec![], tcx)
|
||||
}
|
||||
#[track_caller]
|
||||
pub fn push(&mut self, val: impl Into<RegionErrorKind<'tcx>>) {
|
||||
let val = val.into();
|
||||
ty::tls::with(|tcx| tcx.sess.delay_span_bug(DUMMY_SP, "{val:?}"));
|
||||
self.1.sess.delay_span_bug(DUMMY_SP, "{val:?}");
|
||||
self.0.push(val);
|
||||
}
|
||||
pub fn is_empty(&self) -> bool {
|
||||
|
@ -562,7 +562,7 @@ pub(super) fn solve(
|
||||
let mir_def_id = body.source.def_id();
|
||||
self.propagate_constraints(body);
|
||||
|
||||
let mut errors_buffer = RegionErrors::default();
|
||||
let mut errors_buffer = RegionErrors::new(infcx.tcx);
|
||||
|
||||
// If this is a closure, we can propagate unsatisfied
|
||||
// `outlives_requirements` to our creator, so create a vector
|
||||
|
@ -1159,6 +1159,12 @@ fn relate_type_and_user_type(
|
||||
let tcx = self.infcx.tcx;
|
||||
|
||||
for proj in &user_ty.projs {
|
||||
if let ty::Alias(ty::Opaque, ..) = curr_projected_ty.ty.kind() {
|
||||
// There is nothing that we can compare here if we go through an opaque type.
|
||||
// We're always in its defining scope as we can otherwise not project through
|
||||
// it, so we're constraining it anyways.
|
||||
return Ok(());
|
||||
}
|
||||
let projected_ty = curr_projected_ty.projection_ty_core(
|
||||
tcx,
|
||||
self.param_env,
|
||||
|
10
src/test/ui/type-alias-impl-trait/destructuring.rs
Normal file
10
src/test/ui/type-alias-impl-trait/destructuring.rs
Normal file
@ -0,0 +1,10 @@
|
||||
#![feature(type_alias_impl_trait)]
|
||||
|
||||
// check-pass
|
||||
|
||||
// issue: https://github.com/rust-lang/rust/issues/104551
|
||||
|
||||
fn main() {
|
||||
type T = impl Sized;
|
||||
let (_a, _b): T = (1u32, 2u32);
|
||||
}
|
Loading…
Reference in New Issue
Block a user