Make rustc_type_ir nightly again

This commit is contained in:
Michael Goulet 2024-06-18 12:49:43 -04:00
parent 8fcd4dd08e
commit c20d909701
11 changed files with 40 additions and 20 deletions

View File

@ -7,7 +7,7 @@ edition = "2021"
# tidy-alphabetical-start
bitflags = "2.4.1"
derivative = "2.2.0"
rustc_ast_ir = { path = "../rustc_ast_ir" }
rustc_ast_ir = { path = "../rustc_ast_ir", default-features = false }
rustc_data_structures = { path = "../rustc_data_structures", optional = true }
rustc_index = { path = "../rustc_index", default-features = false }
rustc_macros = { path = "../rustc_macros", optional = true }

View File

@ -5,14 +5,16 @@ use std::ops::{ControlFlow, Deref};
#[cfg(feature = "nightly")]
use rustc_macros::{HashStable_NoContext, TyDecodable, TyEncodable};
#[cfg(feature = "nightly")]
use rustc_serialize::Decodable;
use tracing::debug;
use crate::data_structures::SsoHashSet;
use crate::fold::{FallibleTypeFolder, TypeFoldable, TypeFolder, TypeSuperFoldable};
use crate::inherent::*;
use crate::lift::Lift;
use crate::visit::{Flags, TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor};
use crate::{self as ty, Interner, SsoHashSet};
use crate::{self as ty, Interner};
/// Binder is a binder for higher-ranked lifetimes or types. It is part of the
/// compiler's representation for things like `for<'a> Fn(&'a isize)`
@ -55,6 +57,7 @@ where
}
}
#[cfg(feature = "nightly")]
macro_rules! impl_binder_encode_decode {
($($t:ty),+ $(,)?) => {
$(
@ -82,6 +85,7 @@ macro_rules! impl_binder_encode_decode {
}
}
#[cfg(feature = "nightly")]
impl_binder_encode_decode! {
ty::FnSig<I>,
ty::TraitPredicate<I>,

View File

@ -0,0 +1,19 @@
#[cfg(feature = "nightly")]
mod impl_ {
pub use rustc_data_structures::fx::FxHashMap as HashMap;
pub use rustc_data_structures::fx::FxHashSet as HashSet;
pub use rustc_data_structures::sso::SsoHashMap as SsoHashMap;
pub use rustc_data_structures::sso::SsoHashSet as SsoHashSet;
pub use rustc_data_structures::sync::Lrc;
}
#[cfg(not(feature = "nightly"))]
mod impl_ {
pub use std::collections::HashMap;
pub use std::collections::HashSet;
pub use std::collections::HashMap as SsoHashMap;
pub use std::collections::HashSet as SsoHashSet;
pub use std::sync::Arc as Lrc;
}
pub use impl_::*;

View File

@ -30,7 +30,7 @@ impl<T> ExpectedFound<T> {
Debug(bound = "")
)]
#[derive(TypeVisitable_Generic)]
#[rustc_pass_by_value]
#[cfg_attr(feature = "nightly", rustc_pass_by_value)]
pub enum TypeError<I: Interner> {
Mismatch,
ConstnessMismatch(ExpectedFound<ty::BoundConstness>),

View File

@ -49,9 +49,10 @@ use rustc_index::{Idx, IndexVec};
use std::mem;
use tracing::debug;
use crate::data_structures::Lrc;
use crate::inherent::*;
use crate::visit::{TypeVisitable, TypeVisitableExt as _};
use crate::{self as ty, Interner, Lrc};
use crate::{self as ty, Interner};
#[cfg(feature = "nightly")]
type Never = !;

View File

@ -1,3 +1,4 @@
#[cfg(feature = "nightly")]
use rustc_macros::{HashStable_NoContext, TyDecodable, TyEncodable};
use crate::Interner;

View File

@ -8,8 +8,8 @@ use std::hash::Hash;
use std::ops::Deref;
use rustc_ast_ir::Mutability;
use rustc_data_structures::fx::FxHashSet;
use crate::data_structures::HashSet;
use crate::fold::{TypeFoldable, TypeSuperFoldable};
use crate::relate::Relate;
use crate::solve::{CacheData, CanonicalInput, QueryResult, Reveal};
@ -530,7 +530,7 @@ pub trait EvaluationCache<I: Interner> {
proof_tree: Option<I::CanonicalGoalEvaluationStepRef>,
additional_depth: usize,
encountered_overflow: bool,
cycle_participants: FxHashSet<CanonicalInput<I>>,
cycle_participants: HashSet<CanonicalInput<I>>,
dep_node: I::DepNodeIndex,
result: QueryResult<I>,
);

View File

@ -7,27 +7,19 @@
#![cfg_attr(feature = "nightly", allow(internal_features))]
// tidy-alphabetical-end
#[cfg(feature = "nightly")]
extern crate self as rustc_type_ir;
#[cfg(feature = "nightly")]
use rustc_data_structures::sso::SsoHashSet;
#[cfg(feature = "nightly")]
use rustc_data_structures::sync::Lrc;
#[cfg(feature = "nightly")]
use rustc_macros::{Decodable, Encodable, HashStable_NoContext};
#[cfg(not(feature = "nightly"))]
use std::collections::HashSet as SsoHashSet;
use std::fmt;
use std::hash::Hash;
#[cfg(not(feature = "nightly"))]
use std::sync::Arc as Lrc;
// These modules are `pub` since they are not glob-imported.
#[macro_use]
pub mod visit;
#[cfg(feature = "nightly")]
pub mod codec;
pub mod data_structures;
pub mod error;
pub mod fold;
pub mod inherent;

View File

@ -1,3 +1,4 @@
#[cfg(feature = "nightly")]
use rustc_macros::{HashStable_NoContext, TyDecodable, TyEncodable};
use rustc_type_ir_macros::{TypeFoldable_Generic, TypeVisitable_Generic};

View File

@ -1,12 +1,13 @@
use std::iter;
use rustc_ast_ir::Mutability;
use rustc_type_ir::error::{ExpectedFound, TypeError};
use rustc_type_ir::fold::TypeFoldable;
use rustc_type_ir::inherent::*;
use rustc_type_ir::{self as ty, Interner};
use tracing::{debug, instrument};
use crate::error::{ExpectedFound, TypeError};
use crate::fold::TypeFoldable;
use crate::inherent::*;
use crate::{self as ty, Interner};
pub type RelateResult<I, T> = Result<T, TypeError<I>>;
/// Extra information about why we ended up with a particular variance.

View File

@ -47,8 +47,9 @@ use rustc_index::{Idx, IndexVec};
use std::fmt;
use std::ops::ControlFlow;
use crate::data_structures::Lrc;
use crate::inherent::*;
use crate::{self as ty, Interner, Lrc, TypeFlags};
use crate::{self as ty, Interner, TypeFlags};
/// This trait is implemented for every type that can be visited,
/// providing the skeleton of the traversal.