Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions compiler/rustc_type_ir/src/binder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,13 +375,21 @@ pub struct EarlyBinder<I: Interner, T> {

impl<I: Interner, T: Eq> Eq for EarlyBinder<I, T> {}

// FIXME(154045): Recommended as per https://github.com/rust-lang/rust/issues/154045, this is so sad :((
#[cfg(feature = "nightly")]
macro_rules! generate { ($( $tt:tt )*) => { $( $tt )* } }

/// For early binders, you should first call `instantiate` before using any visitors.
Copy link
Copy Markdown
Member

@bjorn3 bjorn3 Apr 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be inside the generate!() to add docs to the impl, right? Also maybe you can merge both generate!() calls together to avoid duplicating the cfg.

View changes since the review

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can put this in a module and just have a single cfg, like so

#[cfg(feature = "nightly")]
mod nightly_impls {
    macro_rules! define {
        ($($tt:tt)*) => { $($tt)* }
    }
    define! {
        /// docs
        impl<I: Interner, T> !TypeFoldable<I> for ty::EarlyBinder<I, T> {}
        
        /// docs
        impl<I: Interner, T> !TypeVisitable<I> for ty::EarlyBinder<I, T> {}
    }
}

#[cfg(feature = "nightly")]
impl<I: Interner, T> !TypeFoldable<I> for ty::EarlyBinder<I, T> {}
generate!(
impl<I: Interner, T> !TypeFoldable<I> for ty::EarlyBinder<I, T> {}
);

/// For early binders, you should first call `instantiate` before using any visitors.
#[cfg(feature = "nightly")]
impl<I: Interner, T> !TypeVisitable<I> for ty::EarlyBinder<I, T> {}
generate!(
impl<I: Interner, T> !TypeVisitable<I> for ty::EarlyBinder<I, T> {}
);

impl<I: Interner, T> EarlyBinder<I, T> {
pub fn bind(value: T) -> EarlyBinder<I, T> {
Expand Down
9 changes: 5 additions & 4 deletions compiler/rustc_type_ir/src/ir_print.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
use std::fmt;

use crate::{
AliasTerm, AliasTy, Binder, ClosureKind, CoercePredicate, ExistentialProjection,
ExistentialTraitRef, FnSig, HostEffectPredicate, Interner, NormalizesTo, OutlivesPredicate,
PatternKind, Placeholder, ProjectionPredicate, SubtypePredicate, TraitPredicate, TraitRef,
UnevaluatedConst,
AliasTerm, AliasTy, Binder, CoercePredicate, ExistentialProjection, ExistentialTraitRef, FnSig,
HostEffectPredicate, Interner, NormalizesTo, OutlivesPredicate, PatternKind, Placeholder,
ProjectionPredicate, SubtypePredicate, TraitPredicate, TraitRef,
};
#[cfg(feature = "nightly")]
use crate::{ClosureKind, UnevaluatedConst};

pub trait IrPrint<T> {
fn print(t: &T, fmt: &mut fmt::Formatter<'_>) -> fmt::Result;
Expand Down
2 changes: 1 addition & 1 deletion tests/run-make-cargo/rustc-crates-on-stable/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ fn main() {
.env("RUSTC_STAGE", "0")
.env("RUSTC", rustc_path())
// We want to disallow all nightly features to simulate a stable build
.env("RUSTFLAGS", "-Zallow-features=")
.env("RUSTFLAGS", "-D warnings -Zallow-features=")
.arg("build")
.arg("--manifest-path")
.arg(source_root().join("Cargo.toml"))
Expand Down
Loading