-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Implement unstable trait impl #140399
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Implement unstable trait impl #140399
Conversation
d01f12a
to
9e139e1
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
486d3d3
to
02f780f
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
567ec89
to
80fd239
Compare
☔ The latest upstream changes (presumably #142299) made this pull request unmergeable. Please resolve the merge conflicts. |
850e3e1
to
27d9e21
Compare
a77d746
to
6e4c902
Compare
This comment has been minimized.
This comment has been minimized.
☔ The latest upstream changes (presumably #142483) made this pull request unmergeable. Please resolve the merge conflicts. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gg gamer
fn enabled(self, symbol: <TyCtxt<'tcx> as Interner>::Symbol) -> bool { | ||
self.enabled(symbol) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fn enabled(self, symbol: <TyCtxt<'tcx> as Interner>::Symbol) -> bool { | |
self.enabled(symbol) | |
} | |
fn feature_bound_holds_in_crate(self, symbol: <TyCtxt<'tcx> as Interner>::Symbol) -> bool { | |
// We don't consider feature bounds to hold in the crate if we `staged_api` feature is | |
// even when the feature is enabled. This is to prevent accidentally leaking unstable APIs | |
// to stable. | |
!self.staged_api() && self.enabled(symbol) | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tweaked the comment by a little bit
// We don't consider feature bounds to hold in the crate when `staged_api` feature is
// enabled, even if it is enabled through `#[feature]`.
// This is to prevent accidentally leaking unstable APIs to stable.
hope this captured what you intended to say :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 I also meant to entirely remove the enabled
function though, I don't think its an API we need to expose if we have feature_bound_holds_in_crate
being used by the new solver
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh yea makes sense.
Co-authored-by: Boxy <[email protected]>
// | ||
// Note: we don't consider a feature to be enabled | ||
// if we are in std/core even if there is a corresponding `feature` attribute on the crate. | ||
if (!self.selcx.tcx().features().staged_api() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to use feature_bound_holds_in_crate
in the old solver, just like what is done in the new solver, but it requires rustc_type_ir::inherent::*
, and has scary message
error: do not use `rustc_type_ir::inherent` unless you're inside of the trait solver
--> compiler/rustc_trait_selection/src/traits/fulfill.rs:15:20
|
15 | use rustc_type_ir::inherent::*;
| ^^^^^^^^
|
= note: the method or struct you're looking for is likely defined somewhere else downstream in the compiler
= note: `-D rustc::usage-of-type-ir-inherent` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(rustc::usage_of_type_ir_inherent)]`
so i decided to just write it out manually :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah only the new solver needs to use the fancy API, old solver can just do the logic manually
#[unstable_feature_bound(feat_bar)] | ||
//~^ ERROR: stability attributes may not be used outside of the standard library |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to change the error message to unstable_feature_bound may not be used outside of the standard library
or it is acceptable to call it stability attribute
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think its okay as-is
I am leaving the conflicts there because I don't want to rebase for now (the conflict also happens quite frequently), so it would be easier for boxy to review. hi @jdonszelmann, it'd be nice to get a vibeck from you for the attribute change :) |
Some changes occurred in compiler/rustc_attr_parsing changes to the core type system Some changes occurred in compiler/rustc_passes/src/check_attr.rs changes to Some changes occurred in compiler/rustc_attr_data_structures |
Hi tiff! Will review this week :) |
This PR allows marking impls of stable trait with stable type as unstable.
The design and mentoring are done by @BoxyUwU