Skip to content

rustc_transmute: Directly use types from rustc_abi #132248

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

Merged
merged 1 commit into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4496,14 +4496,14 @@ name = "rustc_transmute"
version = "0.0.0"
dependencies = [
"itertools",
"rustc_abi",
"rustc_ast_ir",
"rustc_data_structures",
"rustc_hir",
"rustc_infer",
"rustc_macros",
"rustc_middle",
"rustc_span",
"rustc_target",
"tracing",
]

Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_transmute/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,26 @@ edition = "2021"

[dependencies]
# tidy-alphabetical-start
rustc_abi = { path = "../rustc_abi", optional = true }
rustc_ast_ir = { path = "../rustc_ast_ir", optional = true }
rustc_data_structures = { path = "../rustc_data_structures" }
rustc_hir = { path = "../rustc_hir", optional = true }
rustc_infer = { path = "../rustc_infer", optional = true }
rustc_macros = { path = "../rustc_macros", optional = true }
rustc_middle = { path = "../rustc_middle", optional = true }
rustc_span = { path = "../rustc_span", optional = true }
rustc_target = { path = "../rustc_target", optional = true }
tracing = "0.1"
# tidy-alphabetical-end

[features]
rustc = [
"dep:rustc_abi",
"dep:rustc_ast_ir",
"dep:rustc_hir",
"dep:rustc_infer",
"dep:rustc_macros",
"dep:rustc_middle",
"dep:rustc_span",
"dep:rustc_target",
"dep:rustc_ast_ir",
]

[dev-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_transmute/src/layout/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ impl Ref for ! {
pub mod rustc {
use std::fmt::{self, Write};

use rustc_abi::Layout;
use rustc_middle::mir::Mutability;
use rustc_middle::ty::layout::{HasTyCtxt, LayoutCx, LayoutError};
use rustc_middle::ty::{self, Ty};
use rustc_target::abi::Layout;

/// A reference in the layout.
#[derive(Debug, Hash, Eq, PartialEq, Clone, Copy)]
Expand Down
10 changes: 5 additions & 5 deletions compiler/rustc_transmute/src/layout/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,12 @@ where

#[cfg(feature = "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::{self, AdtDef, AdtKind, List, ScalarInt, Ty, TyCtxt, TypeVisitableExt};
use rustc_span::ErrorGuaranteed;
use rustc_target::abi::{
FieldIdx, FieldsShape, Layout, Size, TagEncoding, TyAndLayout, VariantIdx, Variants,
};

use super::Tree;
use crate::layout::rustc::{Def, Ref, layout_of};
Expand Down Expand Up @@ -206,7 +206,7 @@ pub(crate) mod rustc {

impl<'tcx> Tree<Def<'tcx>, Ref<'tcx>> {
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)?;

if let Err(e) = ty.error_reported() {
Expand Down Expand Up @@ -446,7 +446,7 @@ pub(crate) mod rustc {

/// Constructs a `Tree` representing the value of a enum tag.
fn from_tag(tag: ScalarInt, tcx: TyCtxt<'tcx>) -> Self {
use rustc_target::abi::Endian;
use rustc_abi::Endian;
let size = tag.size();
let bits = tag.to_bits(size);
let bytes: [u8; 16];
Expand Down
Loading