Skip to content
Closed
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 compiler/rustc_codegen_ssa/src/mir/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1645,7 +1645,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
}

mir::TerminatorKind::Goto { target } => {
helper.funclet_br(self, bx, target, mergeable_succ(), &terminator.attributes)
helper.funclet_br(self, bx, target, mergeable_succ(), &[])
}

mir::TerminatorKind::SwitchInt { ref discr, ref targets } => {
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_middle/src/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1732,11 +1732,11 @@ mod size_asserts {

use super::*;
// tidy-alphabetical-start
static_assert_size!(BasicBlockData<'_>, 144);
static_assert_size!(BasicBlockData<'_>, 136);
static_assert_size!(LocalDecl<'_>, 40);
static_assert_size!(SourceScopeData<'_>, 64);
static_assert_size!(Statement<'_>, 40);
static_assert_size!(Terminator<'_>, 104);
static_assert_size!(Terminator<'_>, 96);
static_assert_size!(VarDebugInfo<'_>, 88);
// tidy-alphabetical-end
}
3 changes: 0 additions & 3 deletions compiler/rustc_middle/src/mir/terminator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ use std::slice;

use rustc_ast::InlineAsmOptions;
use rustc_data_structures::packed::Pu128;
use rustc_hir::attrs::AttributeKind;
use rustc_hir::attrs::lang_items::LangItem;
use rustc_macros::{StableHash, TyDecodable, TyEncodable, TypeFoldable, TypeVisitable};
use smallvec::{SmallVec, smallvec};
use thin_vec::ThinVec;

use super::*;

Expand Down Expand Up @@ -418,7 +416,6 @@ impl<O: fmt::Debug> fmt::Display for AssertKind<O> {
pub struct Terminator<'tcx> {
pub source_info: SourceInfo,
pub kind: TerminatorKind<'tcx>,
pub attributes: ThinVec<AttributeKind>,
}

impl<'tcx> Terminator<'tcx> {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/mir/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ macro_rules! make_mir_visitor {
terminator: &$($mutability)? Terminator<'tcx>,
location: Location
) {
let Terminator { source_info, kind, attributes: _ } = terminator;
let Terminator { source_info, kind } = terminator;

self.visit_source_info(source_info);
match kind {
Expand Down
4 changes: 1 addition & 3 deletions compiler/rustc_mir_build/src/builder/cfg.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//! Routines for manipulating the control-flow graph.

use rustc_data_structures::thin_vec::ThinVec;
use rustc_middle::mir::*;
use rustc_middle::ty::TyCtxt;
use tracing::debug;
Expand Down Expand Up @@ -131,8 +130,7 @@ impl<'tcx> CFG<'tcx> {
block,
self.block_data(block)
);
self.block_data_mut(block).terminator =
Some(Terminator { source_info, kind, attributes: ThinVec::new() });
self.block_data_mut(block).terminator = Some(Terminator { source_info, kind });
self.block_data_mut(block).terminator.as_mut().unwrap()
}

Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_mir_build/src/builder/custom/parse.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use rustc_data_structures::thin_vec::ThinVec;
use rustc_index::IndexSlice;
use rustc_middle::mir::*;
use rustc_middle::thir::*;
Expand Down Expand Up @@ -319,7 +318,6 @@ impl<'a, 'tcx> ParseCtxt<'a, 'tcx> {
data.terminator = Some(Terminator {
source_info: SourceInfo { span, scope: self.source_scope },
kind: terminator,
attributes: ThinVec::new(),
});

Ok(data)
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_mir_build/src/builder/expr/into.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
// Execute the body, branching back to the test.
let body_block_end = this.expr_into_dest(tmp, body_block, body).into_block();

let goto = this.cfg.goto(body_block_end, source_info, loop_block);
let _goto = this.cfg.goto(body_block_end, source_info, loop_block);
if let Some(attrs) = this.thir.attributes.get(&expr_id) {
goto.attributes = attrs.clone();
let _ = attrs.clone();
}

// Loops are only exited by `break` expressions.
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_mir_dataflow/src/framework/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

use std::marker::PhantomData;

use rustc_data_structures::thin_vec::ThinVec;
use rustc_index::IndexVec;
use rustc_middle::ty;
use rustc_span::DUMMY_SP;
Expand All @@ -22,7 +21,7 @@ fn mock_body<'tcx>() -> mir::Body<'tcx> {

blocks.push(mir::BasicBlockData::new_stmts(
std::iter::repeat(&nop).cloned().take(n).collect(),
Some(mir::Terminator { source_info, kind, attributes: ThinVec::new() }),
Some(mir::Terminator { source_info, kind }),
false,
))
};
Expand Down
7 changes: 1 addition & 6 deletions compiler/rustc_mir_transform/src/add_call_guards.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
//!
//! NOTE: Simplify CFG will happily undo most of the work this pass does.

use rustc_data_structures::thin_vec::ThinVec;
use rustc_index::{Idx, IndexVec};
use rustc_middle::mir::*;
use rustc_middle::ty::TyCtxt;
Expand Down Expand Up @@ -89,11 +88,7 @@ impl<'tcx> crate::MirPass<'tcx> for AddCallGuards {
let cur_len = body.basic_blocks.len();
let mut new_block = |source_info: SourceInfo, is_cleanup: bool, target: BasicBlock| {
let block = BasicBlockData::new(
Some(Terminator {
source_info,
kind: TerminatorKind::Goto { target },
attributes: ThinVec::new(),
}),
Some(Terminator { source_info, kind: TerminatorKind::Goto { target } }),
is_cleanup,
);
let idx = cur_len + new_blocks.len();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use rustc_data_structures::thin_vec::ThinVec;
use rustc_middle::mir::*;
use rustc_middle::ty::{self, TyCtxt};
use tracing::debug;
Expand Down Expand Up @@ -95,11 +94,7 @@ fn add_move_for_packed_drop<'tcx>(

let storage_dead_block = patch.new_block(BasicBlockData::new_stmts(
vec![Statement::new(source_info, StatementKind::StorageDead(temp))],
Some(Terminator {
source_info,
kind: TerminatorKind::Goto { target },
attributes: ThinVec::new(),
}),
Some(Terminator { source_info, kind: TerminatorKind::Goto { target } }),
is_cleanup,
));

Expand Down
6 changes: 0 additions & 6 deletions compiler/rustc_mir_transform/src/check_enums.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use rustc_abi::{Scalar, Size, TagEncoding, Variants, WrappingRange};
use rustc_data_structures::thin_vec::ThinVec;
use rustc_hir::attrs::lang_items::LangItem;
use rustc_index::IndexVec;
use rustc_middle::bug;
Expand Down Expand Up @@ -65,7 +64,6 @@ impl<'tcx> crate::MirPass<'tcx> for CheckEnums {
basic_blocks[block].terminator = Some(Terminator {
source_info,
kind: TerminatorKind::Goto { target: new_block },
attributes: ThinVec::new(),
});
}
EnumCheckType::Direct { source_op, discr, op_size, valid_discrs } => {
Expand Down Expand Up @@ -396,7 +394,6 @@ fn insert_direct_enum_check<'tcx>(
invalid_discr_block,
),
},
attributes: ThinVec::new(),
});

// Abort in case of an invalid enum discriminant.
Expand All @@ -416,7 +413,6 @@ fn insert_direct_enum_check<'tcx>(
// make a failing UB check turn into much worse UB when we start unwinding.
unwind: UnwindAction::Unreachable,
},
attributes: ThinVec::new(),
});
}

Expand Down Expand Up @@ -462,7 +458,6 @@ fn insert_uninhabited_enum_check<'tcx>(
// make a failing UB check turn into much worse UB when we start unwinding.
unwind: UnwindAction::Unreachable,
},
attributes: ThinVec::new(),
});
}

Expand Down Expand Up @@ -540,6 +535,5 @@ fn insert_niche_check<'tcx>(
// make a failing UB check turn into much worse UB when we start unwinding.
unwind: UnwindAction::Unreachable,
},
attributes: ThinVec::new(),
});
}
2 changes: 0 additions & 2 deletions compiler/rustc_mir_transform/src/check_pointers.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use rustc_data_structures::thin_vec::ThinVec;
use rustc_hir::attrs::lang_items::LangItem;
use rustc_index::IndexVec;
use rustc_middle::mir::visit::{MutatingUseContext, NonMutatingUseContext, PlaceContext, Visitor};
Expand Down Expand Up @@ -117,7 +116,6 @@ pub(crate) fn check_pointers<'tcx, F>(
// worse UB when we start unwinding.
unwind: UnwindAction::Unreachable,
},
attributes: ThinVec::new(),
});
}
}
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_mir_transform/src/coroutine/drop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,7 @@ pub(super) fn create_coroutine_drop_shim_proxy_async<'tcx>(
replace: false,
drop: None,
};
body.basic_blocks_mut()[call_bb].terminator =
Some(Terminator { source_info, kind, attributes: ThinVec::new() });
body.basic_blocks_mut()[call_bb].terminator = Some(Terminator { source_info, kind });

// Run derefer to fix Derefs that are not in the first place
deref_finder(tcx, &mut body, false);
Expand Down
43 changes: 9 additions & 34 deletions compiler/rustc_mir_transform/src/coroutine/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ use drop::{
pub(super) use layout::mir_coroutine_witnesses;
use layout::{CoroutineSavedLocals, compute_layout, locals_live_across_suspend_points};
use rustc_abi::{FieldIdx, VariantIdx};
use rustc_data_structures::thin_vec::ThinVec;
use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::{self as hir, CoroutineDesugaring, CoroutineKind};
use rustc_index::bit_set::{BitMatrix, DenseBitSet, GrowableBitSet};
Expand Down Expand Up @@ -253,11 +252,7 @@ impl<'tcx> TransformVisitor<'tcx> {

body.basic_blocks_mut().push(BasicBlockData::new_stmts(
statements,
Some(Terminator {
source_info,
kind: TerminatorKind::Return,
attributes: ThinVec::new(),
}),
Some(Terminator { source_info, kind: TerminatorKind::Return }),
false,
));

Expand Down Expand Up @@ -740,19 +735,13 @@ fn insert_switch<'tcx>(
}

let switch = TerminatorKind::SwitchInt { discr: Operand::Move(discr), targets: switch_targets };
body.basic_blocks_mut()[START_BLOCK].terminator = Some(Terminator {
source_info: SourceInfo::outermost(body.span),
kind: switch,
attributes: ThinVec::new(),
});
body.basic_blocks_mut()[START_BLOCK].terminator =
Some(Terminator { source_info: SourceInfo::outermost(body.span), kind: switch });
}

fn insert_term_block<'tcx>(body: &mut Body<'tcx>, kind: TerminatorKind<'tcx>) -> BasicBlock {
let source_info = SourceInfo::outermost(body.span);
body.basic_blocks_mut().push(BasicBlockData::new(
Some(Terminator { source_info, kind, attributes: ThinVec::new() }),
false,
))
body.basic_blocks_mut().push(BasicBlockData::new(Some(Terminator { source_info, kind }), false))
}

fn return_poll_ready_assign<'tcx>(tcx: TyCtxt<'tcx>, source_info: SourceInfo) -> Statement<'tcx> {
Expand All @@ -775,7 +764,7 @@ fn insert_poll_ready_block<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) -> Ba
let source_info = SourceInfo::outermost(body.span);
body.basic_blocks_mut().push(BasicBlockData::new_stmts(
[return_poll_ready_assign(tcx, source_info)].to_vec(),
Some(Terminator { source_info, kind: TerminatorKind::Return, attributes: ThinVec::new() }),
Some(Terminator { source_info, kind: TerminatorKind::Return }),
false,
))
}
Expand Down Expand Up @@ -830,12 +819,7 @@ fn generate_poison_block_and_redirect_unwinds_there<'tcx>(
let source_info = SourceInfo::outermost(body.span);
let poison_block = body.basic_blocks_mut().push(BasicBlockData::new_stmts(
vec![transform.set_discr(VariantIdx::new(CoroutineArgs::POISONED), source_info)],
Some(Terminator {
source_info,
kind: TerminatorKind::UnwindResume,

attributes: ThinVec::new(),
}),
Some(Terminator { source_info, kind: TerminatorKind::UnwindResume }),
true,
));

Expand All @@ -846,12 +830,8 @@ fn generate_poison_block_and_redirect_unwinds_there<'tcx>(
// An existing `Resume` terminator is redirected to jump to our dedicated
// "poisoning block" above.
if idx != poison_block {
*block.terminator_mut() = Terminator {
source_info,
kind: TerminatorKind::Goto { target: poison_block },

attributes: ThinVec::new(),
};
*block.terminator_mut() =
Terminator { source_info, kind: TerminatorKind::Goto { target: poison_block } };
}
} else if !block.is_cleanup
// Any terminators that *can* unwind but don't have an unwind target set are also
Expand Down Expand Up @@ -1014,12 +994,7 @@ fn create_cases<'tcx>(
// Then jump to the real target
let block = body.basic_blocks_mut().push(BasicBlockData::new_stmts(
statements,
Some(Terminator {
source_info,
kind: TerminatorKind::Goto { target },

attributes: ThinVec::new(),
}),
Some(Terminator { source_info, kind: TerminatorKind::Goto { target } }),
false,
));

Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_mir_transform/src/coverage/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

use itertools::Itertools;
use rustc_data_structures::graph::{DirectedGraph, Successors};
use rustc_data_structures::thin_vec::ThinVec;
use rustc_index::{Idx, IndexVec};
use rustc_middle::mir::*;
use rustc_middle::{bug, ty};
Expand Down Expand Up @@ -73,7 +72,6 @@ impl<'tcx> MockBlocks<'tcx> {
Some(Terminator {
source_info: SourceInfo::outermost(Span::with_root_ctxt(next_lo, next_hi)),
kind,
attributes: ThinVec::new(),
}),
false,
))
Expand Down
3 changes: 0 additions & 3 deletions compiler/rustc_mir_transform/src/early_otherwise_branch.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::fmt::Debug;

use rustc_data_structures::thin_vec::ThinVec;
use rustc_middle::mir::*;
use rustc_middle::ty::{Ty, TyCtxt};
use tracing::trace;
Expand Down Expand Up @@ -175,7 +174,6 @@ impl<'tcx> crate::MirPass<'tcx> for EarlyOtherwiseBranch {
discr: parent_op,
targets: eq_targets,
},
attributes: ThinVec::new(),
}),
bbs[parent].is_cleanup,
);
Expand Down Expand Up @@ -230,7 +228,6 @@ fn evaluate_candidate<'tcx>(
let Terminator {
kind: TerminatorKind::SwitchInt { targets: child_targets, discr: child_discr },
source_info,
attributes: _,
} = bbs[child].terminator()
else {
return None;
Expand Down
5 changes: 2 additions & 3 deletions compiler/rustc_mir_transform/src/elaborate_drop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use std::{fmt, iter, mem};

use itertools::Itertools;
use rustc_abi::{FIRST_VARIANT, FieldIdx, VariantIdx};
use rustc_data_structures::thin_vec::ThinVec;
use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::{CoroutineDesugaring, CoroutineKind};
use rustc_index::Idx;
Expand Down Expand Up @@ -1641,7 +1640,7 @@ where
#[instrument(level = "trace", skip(self), ret)]
fn new_block(&mut self, unwind: Unwind, k: TerminatorKind<'tcx>) -> BasicBlock {
self.elaborator.patch().new_block(BasicBlockData::new(
Some(Terminator { source_info: self.source_info, kind: k, attributes: ThinVec::new() }),
Some(Terminator { source_info: self.source_info, kind: k }),
unwind.is_cleanup(),
))
}
Expand All @@ -1655,7 +1654,7 @@ where
) -> BasicBlock {
self.elaborator.patch().new_block(BasicBlockData::new_stmts(
statements,
Some(Terminator { source_info: self.source_info, kind: k, attributes: ThinVec::new() }),
Some(Terminator { source_info: self.source_info, kind: k }),
unwind.is_cleanup(),
))
}
Expand Down
Loading
Loading