Skip to content

Commit

Permalink
Make rustc_type_ir nightly again
Browse files Browse the repository at this point in the history
  • Loading branch information
compiler-errors committed Jun 18, 2024
1 parent 8fcd4dd commit c20d909
Show file tree
Hide file tree
Showing 11 changed files with 40 additions and 20 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_type_ir/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
6 changes: 5 additions & 1 deletion compiler/rustc_type_ir/src/binder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)`
Expand Down Expand Up @@ -55,6 +57,7 @@ where
}
}

#[cfg(feature = "nightly")]
macro_rules! impl_binder_encode_decode {
($($t:ty),+ $(,)?) => {
$(
Expand Down Expand Up @@ -82,6 +85,7 @@ macro_rules! impl_binder_encode_decode {
}
}

#[cfg(feature = "nightly")]
impl_binder_encode_decode! {
ty::FnSig<I>,
ty::TraitPredicate<I>,
Expand Down
19 changes: 19 additions & 0 deletions compiler/rustc_type_ir/src/data_structures.rs
Original file line number Diff line number Diff line change
@@ -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_::*;
2 changes: 1 addition & 1 deletion compiler/rustc_type_ir/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>),
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_type_ir/src/fold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = !;
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_type_ir/src/generic_arg.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#[cfg(feature = "nightly")]
use rustc_macros::{HashStable_NoContext, TyDecodable, TyEncodable};

use crate::Interner;
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_type_ir/src/inherent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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>,
);
Expand Down
10 changes: 1 addition & 9 deletions compiler/rustc_type_ir/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_type_ir/src/opaque_ty.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#[cfg(feature = "nightly")]
use rustc_macros::{HashStable_NoContext, TyDecodable, TyEncodable};
use rustc_type_ir_macros::{TypeFoldable_Generic, TypeVisitable_Generic};

Expand Down
9 changes: 5 additions & 4 deletions compiler/rustc_type_ir/src/relate.rs
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_type_ir/src/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit c20d909

Please sign in to comment.