mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-21 17:52:12 +03:00
Rollup merge of #136425 - nnethercote:mv-rustc_middle-infer, r=lcnr
Move `rustc_middle::infer::unify_key` `rustc_infer` is a much better place for it. r? `@lcnr`
This commit is contained in:
@@ -26,7 +26,6 @@
|
||||
pub use rustc_macros::{TypeFoldable, TypeVisitable};
|
||||
use rustc_middle::bug;
|
||||
use rustc_middle::infer::canonical::{CanonicalQueryInput, CanonicalVarValues};
|
||||
use rustc_middle::infer::unify_key::{ConstVariableOrigin, ConstVariableValue, ConstVidKey};
|
||||
use rustc_middle::mir::ConstraintCategory;
|
||||
use rustc_middle::traits::select;
|
||||
pub use rustc_middle::ty::IntVarValue;
|
||||
@@ -46,6 +45,7 @@
|
||||
use type_variable::TypeVariableOrigin;
|
||||
|
||||
use crate::infer::region_constraints::UndoLog;
|
||||
use crate::infer::unify_key::{ConstVariableOrigin, ConstVariableValue, ConstVidKey};
|
||||
use crate::traits::{
|
||||
self, ObligationCause, ObligationInspector, PredicateObligations, TraitEngine,
|
||||
};
|
||||
@@ -64,6 +64,7 @@
|
||||
pub mod resolve;
|
||||
pub(crate) mod snapshot;
|
||||
mod type_variable;
|
||||
mod unify_key;
|
||||
|
||||
/// `InferOk<'tcx, ()>` is used a lot. It may seem like a useless wrapper
|
||||
/// around `PredicateObligations<'tcx>`, but it has one important property:
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
use rustc_data_structures::unify as ut;
|
||||
use rustc_index::IndexVec;
|
||||
use rustc_macros::{TypeFoldable, TypeVisitable};
|
||||
use rustc_middle::infer::unify_key::{RegionVariableValue, RegionVidKey};
|
||||
use rustc_middle::ty::{self, ReBound, ReStatic, ReVar, Region, RegionVid, Ty, TyCtxt};
|
||||
use rustc_middle::{bug, span_bug};
|
||||
use tracing::{debug, instrument};
|
||||
@@ -17,6 +16,7 @@
|
||||
use self::UndoLog::*;
|
||||
use super::{MiscVariable, RegionVariableOrigin, Rollback, SubregionOrigin};
|
||||
use crate::infer::snapshot::undo_log::{InferCtxtUndoLogs, Snapshot};
|
||||
use crate::infer::unify_key::{RegionVariableValue, RegionVidKey};
|
||||
|
||||
mod leak_check;
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
use rustc_data_structures::stack::ensure_sufficient_stack;
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_middle::bug;
|
||||
use rustc_middle::infer::unify_key::ConstVariableValue;
|
||||
use rustc_middle::ty::error::TypeError;
|
||||
use rustc_middle::ty::visit::MaxUniverse;
|
||||
use rustc_middle::ty::{
|
||||
@@ -18,6 +17,7 @@
|
||||
PredicateEmittingRelation, Relate, RelateResult, StructurallyRelateAliases, TypeRelation,
|
||||
};
|
||||
use crate::infer::type_variable::TypeVariableValue;
|
||||
use crate::infer::unify_key::ConstVariableValue;
|
||||
use crate::infer::{InferCtxt, RegionVariableOrigin, relate};
|
||||
|
||||
impl<'tcx> InferCtxt<'tcx> {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
use std::ops::Range;
|
||||
|
||||
use rustc_data_structures::{snapshot_vec as sv, unify as ut};
|
||||
use rustc_middle::infer::unify_key::{ConstVariableValue, ConstVidKey};
|
||||
use rustc_middle::ty::fold::{TypeFoldable, TypeFolder, TypeSuperFoldable};
|
||||
use rustc_middle::ty::{self, ConstVid, FloatVid, IntVid, RegionVid, Ty, TyCtxt, TyVid};
|
||||
use rustc_type_ir::visit::TypeVisitableExt;
|
||||
@@ -10,6 +9,7 @@
|
||||
|
||||
use super::VariableLengths;
|
||||
use crate::infer::type_variable::TypeVariableOrigin;
|
||||
use crate::infer::unify_key::{ConstVariableValue, ConstVidKey};
|
||||
use crate::infer::{ConstVariableOrigin, InferCtxt, RegionVariableOrigin, UnificationTable};
|
||||
|
||||
fn vars_since_snapshot<'tcx, T>(
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
use rustc_data_structures::undo_log::{Rollback, UndoLogs};
|
||||
use rustc_data_structures::{snapshot_vec as sv, unify as ut};
|
||||
use rustc_middle::infer::unify_key::{ConstVidKey, RegionVidKey};
|
||||
use rustc_middle::ty::{self, OpaqueHiddenType, OpaqueTypeKey};
|
||||
use tracing::debug;
|
||||
|
||||
use crate::infer::unify_key::{ConstVidKey, RegionVidKey};
|
||||
use crate::infer::{InferCtxtInner, region_constraints, type_variable};
|
||||
use crate::traits;
|
||||
|
||||
|
||||
+8
-12
@@ -2,23 +2,18 @@
|
||||
use std::marker::PhantomData;
|
||||
|
||||
use rustc_data_structures::unify::{NoError, UnifyKey, UnifyValue};
|
||||
use rustc_middle::{bug, ty};
|
||||
use rustc_span::Span;
|
||||
use rustc_span::def_id::DefId;
|
||||
|
||||
use crate::ty::{self, Ty, TyCtxt};
|
||||
|
||||
pub trait ToType {
|
||||
fn to_type<'tcx>(&self, tcx: TyCtxt<'tcx>) -> Ty<'tcx>;
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
pub enum RegionVariableValue<'tcx> {
|
||||
pub(crate) enum RegionVariableValue<'tcx> {
|
||||
Known { value: ty::Region<'tcx> },
|
||||
Unknown { universe: ty::UniverseIndex },
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Copy, Clone, Debug)]
|
||||
pub struct RegionVidKey<'tcx> {
|
||||
pub(crate) struct RegionVidKey<'tcx> {
|
||||
pub vid: ty::RegionVid,
|
||||
pub phantom: PhantomData<RegionVariableValue<'tcx>>,
|
||||
}
|
||||
@@ -44,7 +39,8 @@ fn tag() -> &'static str {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct RegionUnificationError;
|
||||
pub(crate) struct RegionUnificationError;
|
||||
|
||||
impl<'tcx> UnifyValue for RegionVariableValue<'tcx> {
|
||||
type Error = RegionUnificationError;
|
||||
|
||||
@@ -100,7 +96,7 @@ pub struct ConstVariableOrigin {
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
pub enum ConstVariableValue<'tcx> {
|
||||
pub(crate) enum ConstVariableValue<'tcx> {
|
||||
Known { value: ty::Const<'tcx> },
|
||||
Unknown { origin: ConstVariableOrigin, universe: ty::UniverseIndex },
|
||||
}
|
||||
@@ -108,7 +104,7 @@ pub enum ConstVariableValue<'tcx> {
|
||||
impl<'tcx> ConstVariableValue<'tcx> {
|
||||
/// If this value is known, returns the const it is known to be.
|
||||
/// Otherwise, `None`.
|
||||
pub fn known(&self) -> Option<ty::Const<'tcx>> {
|
||||
pub(crate) fn known(&self) -> Option<ty::Const<'tcx>> {
|
||||
match *self {
|
||||
ConstVariableValue::Unknown { .. } => None,
|
||||
ConstVariableValue::Known { value } => Some(value),
|
||||
@@ -117,7 +113,7 @@ pub fn known(&self) -> Option<ty::Const<'tcx>> {
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Copy, Clone, Debug)]
|
||||
pub struct ConstVidKey<'tcx> {
|
||||
pub(crate) struct ConstVidKey<'tcx> {
|
||||
pub vid: ty::ConstVid,
|
||||
pub phantom: PhantomData<ty::Const<'tcx>>,
|
||||
}
|
||||
@@ -1,2 +1 @@
|
||||
pub mod canonical;
|
||||
pub mod unify_key;
|
||||
|
||||
Reference in New Issue
Block a user