-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
safe transmute: use Assume
struct to provide analysis options
#100726
Conversation
Hey! It looks like you've submitted a new PR for the library teams! If this PR contains changes to any Examples of
|
I also attempted to implement #[unstable(feature = "transmutability", issue = "99571")]
#[rustc_const_unstable(feature = "transmutability", issue = "99571")]
impl const core::ops::Add for Assume {
type Output = Assume;
fn add(self, rhs: Assume) -> Assume {
Assume {
alignment: self.alignment || rhs.alignment,
lifetimes: self.lifetimes || rhs.lifetimes,
safety: self.safety || rhs.safety,
validity: self.validity || rhs.validity,
}
}
}
#[unstable(feature = "transmutability", issue = "99571")]
#[rustc_const_unstable(feature = "transmutability", issue = "99571")]
impl const core::ops::Sub for Assume {
type Output = Assume;
fn sub(self, rhs: Assume) -> Assume {
Assume {
alignment: self.alignment && !rhs.alignment,
lifetimes: self.lifetimes && !rhs.lifetimes,
safety: self.safety && !rhs.safety,
validity: self.validity && !rhs.validity,
}
}
} ...but attempting to use these impls in the UI tests results in errors; e.g.:
Anyone know what's going on here? The error message seems non-sensical. |
☔ The latest upstream changes (presumably #100654) made this pull request unmergeable. Please resolve the merge conflicts. |
This was left as a TODO in rust-lang#92268, and brings the trait more in line with what was defined in MCP411. `Assume::visibility` has been renamed to `Assume::safety`, as library safety is what's actually being assumed; visibility is just the mechanism by which it is currently checked (this may change). ref: rust-lang/compiler-team#411 ref: rust-lang#99571
resolves query instability issues, and probably better for performance
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.
small suggestion for the future: your first commit did 3 different things at once, it can be easier to review if they are done in separate commits.
@bors r+ |
safe transmute: use `Assume` struct to provide analysis options This task was left as a TODO in rust-lang#92268; resolving it brings [`BikeshedIntrinsicFrom`](https://doc.rust-lang.org/nightly/core/mem/trait.BikeshedIntrinsicFrom.html) more in line with the API defined in [MCP411](rust-lang/compiler-team#411). **Before:** ```rust pub unsafe trait BikeshedIntrinsicFrom< Src, Context, const ASSUME_ALIGNMENT: bool, const ASSUME_LIFETIMES: bool, const ASSUME_VALIDITY: bool, const ASSUME_VISIBILITY: bool, > where Src: ?Sized, {} ``` **After:** ```rust pub unsafe trait BikeshedIntrinsicFrom<Src, Context, const ASSUME: Assume = { Assume::NOTHING }> where Src: ?Sized, {} ``` `Assume::visibility` has also been renamed to `Assume::safety`, as library safety invariants are what's actually being assumed; visibility is just the mechanism by which it is currently checked (and that may change). r? `@oli-obk` --- Related: - rust-lang/compiler-team#411 - rust-lang#99571
☀️ Test successful - checks-actions |
Finished benchmarking commit (8521a8c): comparison URL. Overall result: ❌✅ regressions and improvements - no action needed@rustbot label: -perf-regression Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Footnotes |
@@ -93,6 +93,7 @@ | |||
#![warn(missing_debug_implementations)] | |||
#![warn(missing_docs)] | |||
#![allow(explicit_outlives_requirements)] | |||
#![allow(incomplete_features)] |
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 am quite concerned about this allow
. That makes it way too easy to use features such as generic_const_exprs
that are just not ready yet for use in the standard library.
This PR should at least have consulted t-types to ensure that adt_const_params
is sufficiently stable that it can be used internally in the standard library. Cc @lcnr
But even then I think we actually want forbid(incomplete_features)
here to avoid people just adding feature gates when it seems convenient. Or even better, set some flag in bootstrap which ensures that the entire sysroot is built without incomplete features.
This task was left as a TODO in #92268; resolving it brings
BikeshedIntrinsicFrom
more in line with the API defined in MCP411.Before:
After:
Assume::visibility
has also been renamed toAssume::safety
, as library safety invariants are what's actually being assumed; visibility is just the mechanism by which it is currently checked (and that may change).r? @oli-obk
Related:
#[transmutability]
#99571