[EXPERIMENT] Don't monomorphize things that are unused due to if <T as Trait>::CONST by scottmcm · Pull Request #91222 · rust-lang/rust (original) (raw)

Hmm, interesting that the try failed. I built a full stage2 locally without issue. Oh well, TBH I was surprised that just referencing these things "worked", so I'll take a look at removing the references to them too. Emitting less LLVM is always good.

--

@the8472 If you're excited to I'd happily take it in the branch, but this is still experimental enough that I can't honestly say that you should. It's still perfectly likely that this will go nowhere, so I wouldn't want you to waste time.

Honestly this PR might not be worth it until inline consts work so that could just be

    if const {
        mem::size_of::<T>() == 0
            || mem::size_of::<T>()
                != mem::size_of::<<<I as SourceIter>::Source as AsIntoIter>::Item>()
            || mem::align_of::<T>()
                != mem::align_of::<<<I as SourceIter>::Source as AsIntoIter>::Item>()
    } {
        // fallback to more generic implementations
        return SpecFromIterNested::from_iter(iterator);
    }

instead, and not need a whole bunch of these little one-use traits.

But right now they're using the basic "sugar for const item" implementation strategy which doesn't allow generic parameters to be referenced, making them unhelpful here.

(The context for this PR was seeing if I could get #85836 working.)