document & impl the transmutation modeled by BikeshedIntrinsicFrom
Documents that `BikeshedIntrinsicFrom` models transmute-via-union,
which is slightly more expressive than the transmute-via-cast
implemented by `transmute_copy`. Additionally, we provide an
implementation of transmute-via-union as a method on the
`BikeshedIntrinsicFrom` trait with additional documentation on
the boundary between trait invariants and caller obligations.
Whether or not transmute-via-union is the right kind of transmute
to model remains up for discussion [1]. Regardless, it seems wise
to document the present behavior.
[1] 426331967
This commit is contained in:
parent
4d5b3b1962
commit
2540070fd4
17 changed files with 372 additions and 38 deletions
|
@ -363,6 +363,11 @@ fn resolve_associated_item<'tcx>(
|
|||
tcx.item_name(trait_item_id)
|
||||
),
|
||||
}
|
||||
} else if tcx.is_lang_item(trait_ref.def_id, LangItem::TransmuteTrait) {
|
||||
let name = tcx.item_name(trait_item_id);
|
||||
assert_eq!(name, sym::transmute);
|
||||
let args = tcx.erase_regions(rcvr_args);
|
||||
Some(ty::Instance::new(trait_item_id, args))
|
||||
} else {
|
||||
Instance::try_resolve_item_for_coroutine(tcx, trait_item_id, trait_id, rcvr_args)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue