Revert "Auto merge of #92306 - Aaron1011:opaque-type-op, r=oli-obk"
This reverts commit1f0a96862a
, reversing changes made tobf242bb119
.
This commit is contained in:
parent
7a71b7a99e
commit
2d8b8f3593
14 changed files with 71 additions and 231 deletions
|
@ -4,7 +4,6 @@ use crate::traits::engine::TraitEngineExt as _;
|
|||
use crate::traits::query::type_op::TypeOpOutput;
|
||||
use crate::traits::query::Fallible;
|
||||
use crate::traits::TraitEngine;
|
||||
use rustc_infer::infer::region_constraints::RegionConstraintData;
|
||||
use rustc_infer::traits::TraitEngineExt as _;
|
||||
use rustc_span::source_map::DUMMY_SP;
|
||||
|
||||
|
@ -32,9 +31,6 @@ where
|
|||
G: Fn() -> String,
|
||||
{
|
||||
type Output = R;
|
||||
/// We can't do any custom error reporting for `CustomTypeOp`, so
|
||||
/// we can use `!` to enforce that the implementation never provides it.
|
||||
type ErrorInfo = !;
|
||||
|
||||
/// Processes the operation and all resulting obligations,
|
||||
/// returning the final result along with any region constraints
|
||||
|
@ -44,7 +40,7 @@ where
|
|||
info!("fully_perform({:?})", self);
|
||||
}
|
||||
|
||||
Ok(scrape_region_constraints(infcx, || (self.closure)(infcx))?.0)
|
||||
scrape_region_constraints(infcx, || (self.closure)(infcx))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -59,10 +55,10 @@ where
|
|||
|
||||
/// Executes `op` and then scrapes out all the "old style" region
|
||||
/// constraints that result, creating query-region-constraints.
|
||||
pub fn scrape_region_constraints<'tcx, Op: super::TypeOp<'tcx, Output = R>, R>(
|
||||
fn scrape_region_constraints<'tcx, Op: super::TypeOp<'tcx, Output = R>, R>(
|
||||
infcx: &InferCtxt<'_, 'tcx>,
|
||||
op: impl FnOnce() -> Fallible<InferOk<'tcx, R>>,
|
||||
) -> Fallible<(TypeOpOutput<'tcx, Op>, RegionConstraintData<'tcx>)> {
|
||||
) -> Fallible<TypeOpOutput<'tcx, Op>> {
|
||||
let mut fulfill_cx = <dyn TraitEngine<'_>>::new(infcx.tcx);
|
||||
|
||||
// During NLL, we expect that nobody will register region
|
||||
|
@ -101,18 +97,12 @@ pub fn scrape_region_constraints<'tcx, Op: super::TypeOp<'tcx, Output = R>, R>(
|
|||
);
|
||||
|
||||
if region_constraints.is_empty() {
|
||||
Ok((
|
||||
TypeOpOutput { output: value, constraints: None, error_info: None },
|
||||
region_constraint_data,
|
||||
))
|
||||
Ok(TypeOpOutput { output: value, constraints: None, canonicalized_query: None })
|
||||
} else {
|
||||
Ok((
|
||||
TypeOpOutput {
|
||||
output: value,
|
||||
constraints: Some(Rc::new(region_constraints)),
|
||||
error_info: None,
|
||||
},
|
||||
region_constraint_data,
|
||||
))
|
||||
Ok(TypeOpOutput {
|
||||
output: value,
|
||||
constraints: Some(Rc::new(region_constraints)),
|
||||
canonicalized_query: None,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,6 @@ pub use rustc_middle::traits::query::type_op::*;
|
|||
/// cannot be completed).
|
||||
pub trait TypeOp<'tcx>: Sized + fmt::Debug {
|
||||
type Output;
|
||||
type ErrorInfo;
|
||||
|
||||
/// Processes the operation and all resulting obligations,
|
||||
/// returning the final result along with any region constraints
|
||||
|
@ -42,8 +41,9 @@ pub struct TypeOpOutput<'tcx, Op: TypeOp<'tcx>> {
|
|||
pub output: Op::Output,
|
||||
/// Any region constraints from performing the type op.
|
||||
pub constraints: Option<Rc<QueryRegionConstraints<'tcx>>>,
|
||||
/// Used for error reporting to be able to rerun the query
|
||||
pub error_info: Option<Op::ErrorInfo>,
|
||||
/// The canonicalized form of the query.
|
||||
/// This for error reporting to be able to rerun the query.
|
||||
pub canonicalized_query: Option<Canonical<'tcx, Op>>,
|
||||
}
|
||||
|
||||
/// "Query type ops" are type ops that are implemented using a
|
||||
|
@ -119,11 +119,10 @@ where
|
|||
Q: QueryTypeOp<'tcx>,
|
||||
{
|
||||
type Output = Q::QueryResponse;
|
||||
type ErrorInfo = Canonical<'tcx, ParamEnvAnd<'tcx, Q>>;
|
||||
|
||||
fn fully_perform(self, infcx: &InferCtxt<'_, 'tcx>) -> Fallible<TypeOpOutput<'tcx, Self>> {
|
||||
let mut region_constraints = QueryRegionConstraints::default();
|
||||
let (output, error_info, mut obligations, _) =
|
||||
let (output, canonicalized_query, mut obligations, _) =
|
||||
Q::fully_perform_into(self, infcx, &mut region_constraints)?;
|
||||
|
||||
// Typically, instantiating NLL query results does not
|
||||
|
@ -161,6 +160,6 @@ where
|
|||
let region_constraints =
|
||||
if region_constraints.is_empty() { None } else { Some(Rc::new(region_constraints)) };
|
||||
|
||||
Ok(TypeOpOutput { output, constraints: region_constraints, error_info })
|
||||
Ok(TypeOpOutput { output, constraints: region_constraints, canonicalized_query })
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue