You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Stability annotation on defaulted generics fails #79499
self.tcx.sess.span_err(item_sp,"This stability annotation is useless");
}
Off the top of my head, I'm not sure which part of the condition is satisfied. There's no reason I see to expect this not to work, so it could well have been a case overlooked in #77118.
@Avi-D-coder: would you be interested in taking a look to see what's going wrong? I should be able to give more immediate response than last time (it'd just take me a little while to find time to debug, myself) :)
Reacted by Avi Dessauer, Eric Shimizu Karbstein, Moritz Mahringer and Michal Hornický
If I remove derive(PartialOrd, Eq, Ord) from struct String (i.e. manually implement them, like PartialEq already was), then I don't get the This stability annotation is useless error anymore, so I think the error might be coming from a derive macro instead of the struct declaration itself.
Specifically, for this code (outside of stdlib, because IDK how to cargo expand inside stdlib)
// error "stability attributes may not be used outside of the standard library" ignored// .. etcimpl<#[unstable(feature = "allocator_api", issue = "32838")]A:Allocator>::core::marker::StructuralEqforString<A>{}// .. etc (None of the other impls have the stability annotation)
and I think this impl is what's causing the error; it just looks like its the struct definition because the Eq derive macro copies the span from the struct definition.
If this is correct, maybe this issue should be renamed to something like "Eq derive macro copies stability annotation on generics into impl StructuralEq, causing compilation error"?
(Either way, if String (/CString/etc) is made allocator-aware, it would be better to manually implement (Partial){Eq,Ord} anyway, so as not to have an <A: Allocator + (Partial){Eq,Ord}> bound.)
Activity
varkor commentedon Nov 28, 2020
The error is occurring here, for reference:
rust/compiler/rustc_passes/src/stability.rs
Lines 156 to 161 in 1d27267
Off the top of my head, I'm not sure which part of the condition is satisfied. There's no reason I see to expect this not to work, so it could well have been a case overlooked in #77118.
@Avi-D-coder: would you be interested in taking a look to see what's going wrong? I should be able to give more immediate response than last time (it'd just take me a little while to find time to debug, myself) :)
zachs18 commentedon Sep 6, 2022
If I remove
derive(PartialOrd, Eq, Ord)fromstruct String(i.e. manually implement them, likePartialEqalready was), then I don't get theThis stability annotation is uselesserror anymore, so I think the error might be coming from a derive macro instead of the struct declaration itself.Specifically, for this code (outside of stdlib, because IDK how to
cargo expandinside stdlib)cargo +nightly expandgivesand I think this
implis what's causing the error; it just looks like its the struct definition because theEqderive macro copies the span from the struct definition.If this is correct, maybe this issue should be renamed to something like "
Eqderive macro copies stability annotation on generics intoimpl StructuralEq, causing compilation error"?(Either way, if
String(/CString/etc) is made allocator-aware, it would be better to manually implement(Partial){Eq,Ord}anyway, so as not to have an<A: Allocator + (Partial){Eq,Ord}>bound.)SaadiSave commentedon Mar 29, 2025
If work here has stalled, I'd like to make progress on this issue
Rollup merge of rust-lang#149328 - shua:stralloc, r=Amanieu
Rollup merge of rust-lang#149328 - shua:stralloc, r=Amanieu
Rollup merge of rust-lang#149328 - shua:stralloc, r=Amanieu