Uh oh!
There was an error while loading. Please reload this page.
Enforce that dyn* coercions are actually pointer-sized - #104338
Conversation
rustbot
commented
Nov 12, 2022
Hey! It looks like you've submitted a new PR for the library teams! If this PR contains changes to any Examples of
|
workingjubilee
commented
Nov 12, 2022
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;fnpolymorphic<T:Debug + ?Sized + Thin>(t:&T){let _ = t asdyn*Debug;}In which case: This happens. Layout computation is not smart enough to take in account that |
workingjubilee
commented
Nov 13, 2022
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. |
compiler-errors
commented
Nov 13, 2022
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. |
bors
commented
Nov 15, 2022
☔ The latest upstream changes (presumably #104428) made this pull request unmergeable. Please resolve the merge conflicts. |
59c99fb to
84b06d5CompareUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
eholk
commented
Nov 15, 2022
@bors r+ |
bors
commented
Nov 15, 2022
…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) Fixesrust-lang#102141Fixesrust-lang#102173
This comment has been minimized.
This comment has been minimized.
compiler-errors
commented
Nov 16, 2022
@bors r- |
compiler-errors
commented
Nov 16, 2022
@rustbot ready |
eholk
commented
Nov 17, 2022
@bors r+ |
bors
commented
Nov 17, 2022
📌 Commit 4e20fa5209c868c48a6f044e76447bef004a87a7 has been approved by It is now in the queue for this repository. |
bors
commented
Nov 18, 2022
☔ The latest upstream changes (presumably #104555) made this pull request unmergeable. Please resolve the merge conflicts. |
4e20fa5 to
39e076aComparecompiler-errors
commented
Nov 18, 2022
Rebased past oli's Obligation constructor PR. @bors r=eholk |
bors
commented
Nov 18, 2022
…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) Fixesrust-lang#102141Fixesrust-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) Fixesrust-lang#102141Fixesrust-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
PointerSizedtrait 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