Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
42fbaf1
Add a new trait `proc_macro::ToTokens`
SpriteOvO Oct 9, 2024
4839d6e
compiler: Add rustc_abi dependence to the compiler
workingjubilee Oct 28, 2024
cb08e08
Lower AST node id only once
adwinwhite Sep 12, 2024
1a39247
Add duplicate lowering check
adwinwhite Sep 15, 2024
e3bf50e
more consistent debug_assertions
adwinwhite Oct 14, 2024
3f73fe7
compiler: Depend on rustc_abi in rustc_lint
workingjubilee Oct 28, 2024
7cfbe23
Unify variant struct fields margins with struct fields
GuillaumeGomez Oct 28, 2024
26b6ccd
Add GUI regression test for variant structfields margins
GuillaumeGomez Oct 28, 2024
4bd84b2
Use a type-safe helper to cast `&str` and `&[u8]` to `*const c_char`
Zalathar Oct 28, 2024
82bfe05
refactor: cleaner check to return None
ChrisCho-H Oct 28, 2024
2cc9d58
Updating Fuchsia platform-support documentation
claywilkinson Oct 28, 2024
88a9edc
compiler: Add `is_uninhabited` and use LayoutS accessors
workingjubilee Oct 28, 2024
641ce06
rustdoc: Use accessors to interrogate type layouts
workingjubilee Oct 28, 2024
5f91811
stable_mir: Directly use types from rustc_abi
workingjubilee Oct 28, 2024
673867e
fixed wast version was released, remove randomization exemption
the8472 Oct 28, 2024
8edbd04
Rollup merge of #130259 - adwinwhite:lower-node-id-once, r=cjgillot
matthiaskrgr Oct 29, 2024
1ca6a0d
Rollup merge of #131441 - SpriteOvO:proc-macro-to-tokens-trait, r=dto…
matthiaskrgr Oct 29, 2024
6ce571f
Rollup merge of #132247 - workingjubilee:add-rustc-abi-to-smir, r=cel…
matthiaskrgr Oct 29, 2024
ae13340
Rollup merge of #132249 - workingjubilee:add-rustc-abi, r=compiler-er…
matthiaskrgr Oct 29, 2024
baa72e6
Rollup merge of #132255 - workingjubilee:layout-is-🏚️, r=compiler-errors
matthiaskrgr Oct 29, 2024
dcd0693
Rollup merge of #132258 - GuillaumeGomez:variant-structfields-margins…
matthiaskrgr Oct 29, 2024
302bbf6
Rollup merge of #132260 - Zalathar:type-safe-cast, r=compiler-errors
matthiaskrgr Oct 29, 2024
2377cfd
Rollup merge of #132261 - ChrisCho-H:refactor/cleaner-check-none, r=c…
matthiaskrgr Oct 29, 2024
9d9216f
Rollup merge of #132271 - claywilkinson:master, r=tmandry
matthiaskrgr Oct 29, 2024
94ee84f
Rollup merge of #132295 - the8472:remove-randomize-exclusion1, r=onur…
matthiaskrgr Oct 29, 2024
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 compiler/rustc_smir/src/rustc_internal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ impl<'tcx> Tables<'tcx> {
stable_mir::mir::mono::StaticDef(self.create_def_id(did))
}

pub(crate) fn layout_id(&mut self, layout: rustc_target::abi::Layout<'tcx>) -> Layout {
pub(crate) fn layout_id(&mut self, layout: rustc_abi::Layout<'tcx>) -> Layout {
self.layouts.create_or_fetch(layout)
}
}
Expand Down
14 changes: 6 additions & 8 deletions compiler/rustc_smir/src/rustc_smir/alloc.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use rustc_abi::{Align, Size};
use rustc_middle::mir::ConstValue;
use rustc_middle::mir::interpret::{AllocRange, Pointer, alloc_range};
use stable_mir::Error;
Expand All @@ -7,7 +8,7 @@ use stable_mir::ty::{Allocation, ProvenanceMap};
use crate::rustc_smir::{Stable, Tables};

/// Creates new empty `Allocation` from given `Align`.
fn new_empty_allocation(align: rustc_target::abi::Align) -> Allocation {
fn new_empty_allocation(align: Align) -> Allocation {
Allocation {
bytes: Vec::new(),
provenance: ProvenanceMap { ptrs: Vec::new() },
Expand Down Expand Up @@ -45,7 +46,7 @@ pub(crate) fn try_new_allocation<'tcx>(
.align;
let mut allocation = rustc_middle::mir::interpret::Allocation::uninit(size, align.abi);
allocation
.write_scalar(&tables.tcx, alloc_range(rustc_target::abi::Size::ZERO, size), scalar)
.write_scalar(&tables.tcx, alloc_range(Size::ZERO, size), scalar)
.map_err(|e| e.stable(tables))?;
allocation.stable(tables)
}
Expand All @@ -59,7 +60,7 @@ pub(crate) fn try_new_allocation<'tcx>(
}
ConstValue::Slice { data, meta } => {
let alloc_id = tables.tcx.reserve_and_set_memory_alloc(data);
let ptr = Pointer::new(alloc_id.into(), rustc_target::abi::Size::ZERO);
let ptr = Pointer::new(alloc_id.into(), Size::ZERO);
let scalar_ptr = rustc_middle::mir::interpret::Scalar::from_pointer(ptr, &tables.tcx);
let scalar_meta =
rustc_middle::mir::interpret::Scalar::from_target_usize(meta, &tables.tcx);
Expand All @@ -72,7 +73,7 @@ pub(crate) fn try_new_allocation<'tcx>(
allocation
.write_scalar(
&tables.tcx,
alloc_range(rustc_target::abi::Size::ZERO, tables.tcx.data_layout.pointer_size),
alloc_range(Size::ZERO, tables.tcx.data_layout.pointer_size),
scalar_ptr,
)
.map_err(|e| e.stable(tables))?;
Expand Down Expand Up @@ -112,10 +113,7 @@ pub(super) fn allocation_filter<'tcx>(
.map(Some)
.collect();
for (i, b) in bytes.iter_mut().enumerate() {
if !alloc
.init_mask()
.get(rustc_target::abi::Size::from_bytes(i + alloc_range.start.bytes_usize()))
{
if !alloc.init_mask().get(Size::from_bytes(i + alloc_range.start.bytes_usize())) {
*b = None;
}
}
Expand Down
50 changes: 22 additions & 28 deletions compiler/rustc_smir/src/rustc_smir/convert/abi.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
//! Conversion of internal Rust compiler `rustc_target::abi` and `rustc_abi` items to stable ones.
//! Conversion of internal Rust compiler `rustc_target` and `rustc_abi` items to stable ones.

#![allow(rustc::usage_of_qualified_ty)]

use rustc_middle::ty;
use rustc_target::abi::call::Conv;
use rustc_target::callconv::{self, Conv};
use stable_mir::abi::{
AddressSpace, ArgAbi, CallConvention, FieldsShape, FloatLength, FnAbi, IntegerLength, Layout,
LayoutShape, PassMode, Primitive, Scalar, TagEncoding, TyAndLayout, ValueAbi, VariantsShape,
Expand All @@ -15,7 +15,7 @@ use stable_mir::ty::{Align, IndexedVal, VariantIdx};

use crate::rustc_smir::{Stable, Tables};

impl<'tcx> Stable<'tcx> for rustc_target::abi::VariantIdx {
impl<'tcx> Stable<'tcx> for rustc_abi::VariantIdx {
type T = VariantIdx;
fn stable(&self, _: &mut Tables<'_>) -> Self::T {
VariantIdx::to_val(self.as_usize())
Expand All @@ -33,25 +33,23 @@ impl<'tcx> Stable<'tcx> for rustc_abi::Endian {
}
}

impl<'tcx> Stable<'tcx> for rustc_target::abi::TyAndLayout<'tcx, ty::Ty<'tcx>> {
impl<'tcx> Stable<'tcx> for rustc_abi::TyAndLayout<'tcx, ty::Ty<'tcx>> {
type T = TyAndLayout;

fn stable(&self, tables: &mut Tables<'_>) -> Self::T {
TyAndLayout { ty: self.ty.stable(tables), layout: self.layout.stable(tables) }
}
}

impl<'tcx> Stable<'tcx> for rustc_target::abi::Layout<'tcx> {
impl<'tcx> Stable<'tcx> for rustc_abi::Layout<'tcx> {
type T = Layout;

fn stable(&self, tables: &mut Tables<'_>) -> Self::T {
tables.layout_id(tables.tcx.lift(*self).unwrap())
}
}

impl<'tcx> Stable<'tcx>
for rustc_abi::LayoutData<rustc_target::abi::FieldIdx, rustc_target::abi::VariantIdx>
{
impl<'tcx> Stable<'tcx> for rustc_abi::LayoutData<rustc_abi::FieldIdx, rustc_abi::VariantIdx> {
type T = LayoutShape;

fn stable(&self, tables: &mut Tables<'_>) -> Self::T {
Expand All @@ -65,7 +63,7 @@ impl<'tcx> Stable<'tcx>
}
}

impl<'tcx> Stable<'tcx> for rustc_target::abi::call::FnAbi<'tcx, ty::Ty<'tcx>> {
impl<'tcx> Stable<'tcx> for callconv::FnAbi<'tcx, ty::Ty<'tcx>> {
type T = FnAbi;

fn stable(&self, tables: &mut Tables<'_>) -> Self::T {
Expand All @@ -81,7 +79,7 @@ impl<'tcx> Stable<'tcx> for rustc_target::abi::call::FnAbi<'tcx, ty::Ty<'tcx>> {
}
}

impl<'tcx> Stable<'tcx> for rustc_target::abi::call::ArgAbi<'tcx, ty::Ty<'tcx>> {
impl<'tcx> Stable<'tcx> for callconv::ArgAbi<'tcx, ty::Ty<'tcx>> {
type T = ArgAbi;

fn stable(&self, tables: &mut Tables<'_>) -> Self::T {
Expand All @@ -93,7 +91,7 @@ impl<'tcx> Stable<'tcx> for rustc_target::abi::call::ArgAbi<'tcx, ty::Ty<'tcx>>
}
}

impl<'tcx> Stable<'tcx> for rustc_target::abi::call::Conv {
impl<'tcx> Stable<'tcx> for callconv::Conv {
type T = CallConvention;

fn stable(&self, _tables: &mut Tables<'_>) -> Self::T {
Expand Down Expand Up @@ -122,31 +120,29 @@ impl<'tcx> Stable<'tcx> for rustc_target::abi::call::Conv {
}
}

impl<'tcx> Stable<'tcx> for rustc_target::abi::call::PassMode {
impl<'tcx> Stable<'tcx> for callconv::PassMode {
type T = PassMode;

fn stable(&self, _tables: &mut Tables<'_>) -> Self::T {
match self {
rustc_target::abi::call::PassMode::Ignore => PassMode::Ignore,
rustc_target::abi::call::PassMode::Direct(attr) => PassMode::Direct(opaque(attr)),
rustc_target::abi::call::PassMode::Pair(first, second) => {
callconv::PassMode::Ignore => PassMode::Ignore,
callconv::PassMode::Direct(attr) => PassMode::Direct(opaque(attr)),
callconv::PassMode::Pair(first, second) => {
PassMode::Pair(opaque(first), opaque(second))
}
rustc_target::abi::call::PassMode::Cast { pad_i32, cast } => {
callconv::PassMode::Cast { pad_i32, cast } => {
PassMode::Cast { pad_i32: *pad_i32, cast: opaque(cast) }
}
rustc_target::abi::call::PassMode::Indirect { attrs, meta_attrs, on_stack } => {
PassMode::Indirect {
attrs: opaque(attrs),
meta_attrs: opaque(meta_attrs),
on_stack: *on_stack,
}
}
callconv::PassMode::Indirect { attrs, meta_attrs, on_stack } => PassMode::Indirect {
attrs: opaque(attrs),
meta_attrs: opaque(meta_attrs),
on_stack: *on_stack,
},
}
}
}

impl<'tcx> Stable<'tcx> for rustc_abi::FieldsShape<rustc_target::abi::FieldIdx> {
impl<'tcx> Stable<'tcx> for rustc_abi::FieldsShape<rustc_abi::FieldIdx> {
type T = FieldsShape;

fn stable(&self, tables: &mut Tables<'_>) -> Self::T {
Expand All @@ -163,9 +159,7 @@ impl<'tcx> Stable<'tcx> for rustc_abi::FieldsShape<rustc_target::abi::FieldIdx>
}
}

impl<'tcx> Stable<'tcx>
for rustc_abi::Variants<rustc_target::abi::FieldIdx, rustc_target::abi::VariantIdx>
{
impl<'tcx> Stable<'tcx> for rustc_abi::Variants<rustc_abi::FieldIdx, rustc_abi::VariantIdx> {
type T = VariantsShape;

fn stable(&self, tables: &mut Tables<'_>) -> Self::T {
Expand All @@ -185,7 +179,7 @@ impl<'tcx> Stable<'tcx>
}
}

impl<'tcx> Stable<'tcx> for rustc_abi::TagEncoding<rustc_target::abi::VariantIdx> {
impl<'tcx> Stable<'tcx> for rustc_abi::TagEncoding<rustc_abi::VariantIdx> {
type T = TagEncoding;

fn stable(&self, tables: &mut Tables<'_>) -> Self::T {
Expand Down
6 changes: 1 addition & 5 deletions compiler/rustc_smir/src/rustc_smir/convert/mir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -691,11 +691,7 @@ impl<'tcx> Stable<'tcx> for mir::interpret::Allocation {
type T = stable_mir::ty::Allocation;

fn stable(&self, tables: &mut Tables<'_>) -> Self::T {
alloc::allocation_filter(
self,
alloc_range(rustc_target::abi::Size::ZERO, self.size()),
tables,
)
alloc::allocation_filter(self, alloc_range(rustc_abi::Size::ZERO, self.size()), tables)
}
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_smir/src/rustc_smir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub struct Tables<'tcx> {
pub(crate) instances: IndexMap<ty::Instance<'tcx>, InstanceDef>,
pub(crate) ty_consts: IndexMap<ty::Const<'tcx>, TyConstId>,
pub(crate) mir_consts: IndexMap<mir::Const<'tcx>, MirConstId>,
pub(crate) layouts: IndexMap<rustc_target::abi::Layout<'tcx>, Layout>,
pub(crate) layouts: IndexMap<rustc_abi::Layout<'tcx>, Layout>,
}

impl<'tcx> Tables<'tcx> {
Expand Down