1
Fork 0

Remove query normalize from dropck outlives type op

This commit is contained in:
Michael Goulet 2025-01-23 01:19:12 +00:00
parent 11067c4742
commit 00a0ef4206

View file

@ -6,8 +6,7 @@ use rustc_span::{DUMMY_SP, Span};
use tracing::{debug, instrument}; use tracing::{debug, instrument};
use crate::traits::query::NoSolution; use crate::traits::query::NoSolution;
use crate::traits::query::normalize::QueryNormalizeExt; use crate::traits::{ObligationCause, ObligationCtxt};
use crate::traits::{Normalized, ObligationCause, ObligationCtxt};
/// This returns true if the type `ty` is "trivial" for /// This returns true if the type `ty` is "trivial" for
/// dropck-outlives -- that is, if it doesn't require any types to /// dropck-outlives -- that is, if it doesn't require any types to
@ -172,13 +171,18 @@ pub fn compute_dropck_outlives_inner<'tcx>(
// do not themselves define a destructor", more or less. We have // do not themselves define a destructor", more or less. We have
// to push them onto the stack to be expanded. // to push them onto the stack to be expanded.
for ty in constraints.dtorck_types.drain(..) { for ty in constraints.dtorck_types.drain(..) {
let Normalized { value: ty, obligations } = let normalized_ty = ocx.normalize(&cause, param_env, ty);
ocx.infcx.at(&cause, param_env).query_normalize(ty)?;
ocx.register_obligations(obligations);
debug!("dropck_outlives: ty from dtorck_types = {:?}", ty); let errors = ocx.select_where_possible();
if !errors.is_empty() {
debug!("failed to normalize dtorck type: {ty} ~> {errors:#?}");
return Err(NoSolution);
}
match ty.kind() { let normalized_ty = ocx.infcx.resolve_vars_if_possible(normalized_ty);
debug!("dropck_outlives: ty from dtorck_types = {:?}", normalized_ty);
match normalized_ty.kind() {
// All parameters live for the duration of the // All parameters live for the duration of the
// function. // function.
ty::Param(..) => {} ty::Param(..) => {}
@ -186,12 +190,12 @@ pub fn compute_dropck_outlives_inner<'tcx>(
// A projection that we couldn't resolve - it // A projection that we couldn't resolve - it
// might have a destructor. // might have a destructor.
ty::Alias(..) => { ty::Alias(..) => {
result.kinds.push(ty.into()); result.kinds.push(normalized_ty.into());
} }
_ => { _ => {
if ty_set.insert(ty) { if ty_set.insert(normalized_ty) {
ty_stack.push((ty, depth + 1)); ty_stack.push((normalized_ty, depth + 1));
} }
} }
} }