mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 08:13:41 +00:00
rustc_transmute: Directly use types from rustc_abi
This commit is contained in:
parent
5f5c243ca0
commit
27207069d8
@ -4496,6 +4496,7 @@ name = "rustc_transmute"
|
|||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"itertools",
|
"itertools",
|
||||||
|
"rustc_abi",
|
||||||
"rustc_ast_ir",
|
"rustc_ast_ir",
|
||||||
"rustc_data_structures",
|
"rustc_data_structures",
|
||||||
"rustc_hir",
|
"rustc_hir",
|
||||||
@ -4503,7 +4504,6 @@ dependencies = [
|
|||||||
"rustc_macros",
|
"rustc_macros",
|
||||||
"rustc_middle",
|
"rustc_middle",
|
||||||
"rustc_span",
|
"rustc_span",
|
||||||
"rustc_target",
|
|
||||||
"tracing",
|
"tracing",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ edition = "2021"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
# tidy-alphabetical-start
|
# tidy-alphabetical-start
|
||||||
|
rustc_abi = { path = "../rustc_abi", optional = true }
|
||||||
rustc_ast_ir = { path = "../rustc_ast_ir", optional = true }
|
rustc_ast_ir = { path = "../rustc_ast_ir", optional = true }
|
||||||
rustc_data_structures = { path = "../rustc_data_structures" }
|
rustc_data_structures = { path = "../rustc_data_structures" }
|
||||||
rustc_hir = { path = "../rustc_hir", optional = true }
|
rustc_hir = { path = "../rustc_hir", optional = true }
|
||||||
@ -12,19 +13,18 @@ rustc_infer = { path = "../rustc_infer", optional = true }
|
|||||||
rustc_macros = { path = "../rustc_macros", optional = true }
|
rustc_macros = { path = "../rustc_macros", optional = true }
|
||||||
rustc_middle = { path = "../rustc_middle", optional = true }
|
rustc_middle = { path = "../rustc_middle", optional = true }
|
||||||
rustc_span = { path = "../rustc_span", optional = true }
|
rustc_span = { path = "../rustc_span", optional = true }
|
||||||
rustc_target = { path = "../rustc_target", optional = true }
|
|
||||||
tracing = "0.1"
|
tracing = "0.1"
|
||||||
# tidy-alphabetical-end
|
# tidy-alphabetical-end
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
rustc = [
|
rustc = [
|
||||||
|
"dep:rustc_abi",
|
||||||
|
"dep:rustc_ast_ir",
|
||||||
"dep:rustc_hir",
|
"dep:rustc_hir",
|
||||||
"dep:rustc_infer",
|
"dep:rustc_infer",
|
||||||
"dep:rustc_macros",
|
"dep:rustc_macros",
|
||||||
"dep:rustc_middle",
|
"dep:rustc_middle",
|
||||||
"dep:rustc_span",
|
"dep:rustc_span",
|
||||||
"dep:rustc_target",
|
|
||||||
"dep:rustc_ast_ir",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
|
@ -62,10 +62,10 @@ impl Ref for ! {
|
|||||||
pub mod rustc {
|
pub mod rustc {
|
||||||
use std::fmt::{self, Write};
|
use std::fmt::{self, Write};
|
||||||
|
|
||||||
|
use rustc_abi::Layout;
|
||||||
use rustc_middle::mir::Mutability;
|
use rustc_middle::mir::Mutability;
|
||||||
use rustc_middle::ty::layout::{HasTyCtxt, LayoutCx, LayoutError};
|
use rustc_middle::ty::layout::{HasTyCtxt, LayoutCx, LayoutError};
|
||||||
use rustc_middle::ty::{self, Ty};
|
use rustc_middle::ty::{self, Ty};
|
||||||
use rustc_target::abi::Layout;
|
|
||||||
|
|
||||||
/// A reference in the layout.
|
/// A reference in the layout.
|
||||||
#[derive(Debug, Hash, Eq, PartialEq, Clone, Copy)]
|
#[derive(Debug, Hash, Eq, PartialEq, Clone, Copy)]
|
||||||
|
@ -171,12 +171,12 @@ where
|
|||||||
|
|
||||||
#[cfg(feature = "rustc")]
|
#[cfg(feature = "rustc")]
|
||||||
pub(crate) mod rustc {
|
pub(crate) mod rustc {
|
||||||
|
use rustc_abi::{
|
||||||
|
FieldIdx, FieldsShape, Layout, Size, TagEncoding, TyAndLayout, VariantIdx, Variants,
|
||||||
|
};
|
||||||
use rustc_middle::ty::layout::{HasTyCtxt, LayoutCx, LayoutError};
|
use rustc_middle::ty::layout::{HasTyCtxt, LayoutCx, LayoutError};
|
||||||
use rustc_middle::ty::{self, AdtDef, AdtKind, List, ScalarInt, Ty, TyCtxt, TypeVisitableExt};
|
use rustc_middle::ty::{self, AdtDef, AdtKind, List, ScalarInt, Ty, TyCtxt, TypeVisitableExt};
|
||||||
use rustc_span::ErrorGuaranteed;
|
use rustc_span::ErrorGuaranteed;
|
||||||
use rustc_target::abi::{
|
|
||||||
FieldIdx, FieldsShape, Layout, Size, TagEncoding, TyAndLayout, VariantIdx, Variants,
|
|
||||||
};
|
|
||||||
|
|
||||||
use super::Tree;
|
use super::Tree;
|
||||||
use crate::layout::rustc::{Def, Ref, layout_of};
|
use crate::layout::rustc::{Def, Ref, layout_of};
|
||||||
@ -206,7 +206,7 @@ pub(crate) mod rustc {
|
|||||||
|
|
||||||
impl<'tcx> Tree<Def<'tcx>, Ref<'tcx>> {
|
impl<'tcx> Tree<Def<'tcx>, Ref<'tcx>> {
|
||||||
pub(crate) fn from_ty(ty: Ty<'tcx>, cx: LayoutCx<'tcx>) -> Result<Self, Err> {
|
pub(crate) fn from_ty(ty: Ty<'tcx>, cx: LayoutCx<'tcx>) -> Result<Self, Err> {
|
||||||
use rustc_target::abi::HasDataLayout;
|
use rustc_abi::HasDataLayout;
|
||||||
let layout = layout_of(cx, ty)?;
|
let layout = layout_of(cx, ty)?;
|
||||||
|
|
||||||
if let Err(e) = ty.error_reported() {
|
if let Err(e) = ty.error_reported() {
|
||||||
@ -446,7 +446,7 @@ pub(crate) mod rustc {
|
|||||||
|
|
||||||
/// Constructs a `Tree` representing the value of a enum tag.
|
/// Constructs a `Tree` representing the value of a enum tag.
|
||||||
fn from_tag(tag: ScalarInt, tcx: TyCtxt<'tcx>) -> Self {
|
fn from_tag(tag: ScalarInt, tcx: TyCtxt<'tcx>) -> Self {
|
||||||
use rustc_target::abi::Endian;
|
use rustc_abi::Endian;
|
||||||
let size = tag.size();
|
let size = tag.size();
|
||||||
let bits = tag.to_bits(size);
|
let bits = tag.to_bits(size);
|
||||||
let bytes: [u8; 16];
|
let bytes: [u8; 16];
|
||||||
|
Loading…
Reference in New Issue
Block a user