-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Enforce that dyn*
coercions are actually pointer-sized
#104338
Conversation
Hey! It looks like you've submitted a new PR for the library teams! If this PR contains changes to any Examples of
|
what busts |
@workingjubilee -- are you asking why this is enforcing something that's stricter than just We could probably relax this to check If that isn't what you're asking, then could you maybe re-explain? |
Unless you were asking what happens in the case like this: #![feature(ptr_metadata)]
#![feature(dyn_star)]
use std::fmt::Debug;
use std::ptr::Thin;
fn polymorphic<T: Debug + ?Sized + Thin>(t: &T) {
let _ = t as dyn* Debug;
} In which case:
This happens. Layout computation is not smart enough to take in account that |
Hmm, I'm not sure which I was asking, honestly, but I am satisfied with that answer, aside from the question of whether or not layout computation could simply be taught that instead I suppose. But that can be tabled for now. |
Yeah, I have a follow-up commit to teach layout computation exactly that, but I want to separate that from this PR since it maybe needs a bit more inspection. |
☔ The latest upstream changes (presumably #104428) made this pull request unmergeable. Please resolve the merge conflicts. |
59c99fb
to
84b06d5
Compare
compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs
Outdated
Show resolved
Hide resolved
@bors r+ |
…holk Enforce that `dyn*` coercions are actually pointer-sized Implement a perma-unstable, rudimentary `PointerSized` trait to enforce `dyn*` casts are `usize`-sized for now, at least to prevent ICEs and weird codegen issues from cropping up after monomorphization since currently we enforce *nothing*. This probably can/should be removed in favor of a more sophisticated trait for handling `dyn*` conversions when we decide on one, but I just want to get something up for discussion and experimentation for now. r? `@eholk` cc `@tmandry` (though feel free to claim/reassign) Fixes rust-lang#102141 Fixes rust-lang#102173
This comment has been minimized.
This comment has been minimized.
@bors r- |
@rustbot ready |
@bors r+ |
📌 Commit 4e20fa5209c868c48a6f044e76447bef004a87a7 has been approved by It is now in the queue for this repository. |
☔ The latest upstream changes (presumably #104555) made this pull request unmergeable. Please resolve the merge conflicts. |
4e20fa5
to
39e076a
Compare
Rebased past oli's Obligation constructor PR. @bors r=eholk |
…holk Enforce that `dyn*` coercions are actually pointer-sized Implement a perma-unstable, rudimentary `PointerSized` trait to enforce `dyn*` casts are `usize`-sized for now, at least to prevent ICEs and weird codegen issues from cropping up after monomorphization since currently we enforce *nothing*. This probably can/should be removed in favor of a more sophisticated trait for handling `dyn*` conversions when we decide on one, but I just want to get something up for discussion and experimentation for now. r? `@eholk` cc `@tmandry` (though feel free to claim/reassign) Fixes rust-lang#102141 Fixes rust-lang#102173
…holk Enforce that `dyn*` coercions are actually pointer-sized Implement a perma-unstable, rudimentary `PointerSized` trait to enforce `dyn*` casts are `usize`-sized for now, at least to prevent ICEs and weird codegen issues from cropping up after monomorphization since currently we enforce *nothing*. This probably can/should be removed in favor of a more sophisticated trait for handling `dyn*` conversions when we decide on one, but I just want to get something up for discussion and experimentation for now. r? ``@eholk`` cc ``@tmandry`` (though feel free to claim/reassign) Fixes rust-lang#102141 Fixes rust-lang#102173
…earth Rollup of 8 pull requests Successful merges: - rust-lang#102977 (remove HRTB from `[T]::is_sorted_by{,_key}`) - rust-lang#103378 (Fix mod_inv termination for the last iteration) - rust-lang#103456 (`unchecked_{shl|shr}` should use `u32` as the RHS) - rust-lang#103701 (Simplify some pointer method implementations) - rust-lang#104047 (Diagnostics `icu4x` based list formatting.) - rust-lang#104338 (Enforce that `dyn*` coercions are actually pointer-sized) - rust-lang#104498 (Edit docs for `rustc_errors::Handler::stash_diagnostic`) - rust-lang#104556 (rustdoc: use `code-header` class to format enum variants) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
…s-thin-ptr, r=wesleywiser layout_of: `T: Thin` implies `sizeof(&T) == sizeof(usize)` Use the `<T as Pointee>::Metadata` associated type to calculate the layout of a pointee's metadata, instead of hard-coding rules about certain types. Maybe this approach is overkill -- we could instead hard-code this approach as a fallback, with the matching on `Slice`/`Dynamic`/etc. happening first Fixes this issue here rust-lang#104338 (comment) .. But is also useful with transmutes, for example, given the UI test I added below.
Implement a perma-unstable, rudimentary
PointerSized
trait to enforcedyn*
casts areusize
-sized for now, at least to prevent ICEs and weird codegen issues from cropping up after monomorphization since currently we enforce nothing.This probably can/should be removed in favor of a more sophisticated trait for handling
dyn*
conversions when we decide on one, but I just want to get something up for discussion and experimentation for now.r? @eholk cc @tmandry (though feel free to claim/reassign)
Fixes #102141
Fixes #102173