Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
095f89b
Add 'bit' and 'set_bit' methods to integral types;
bjoernager Oct 14, 2025
a812bac
Render `Deref` methods on aliased items
GuillaumeGomez Sep 30, 2026
0c442ea
Improve `is_doc_subtype_of` to work better for doc aliases
GuillaumeGomez Oct 2, 2026
a388dd0
Add new `is_deref[_mut]_trait` methods to simplify code
GuillaumeGomez Oct 2, 2026
6e5f760
Remove duplicated code to query `Deref` impls
GuillaumeGomez Oct 2, 2026
e1e1dc8
Remove `is_same_generic` test as it cannot work with the new argument…
GuillaumeGomez Oct 2, 2026
b747376
Add rustdoc-html test to illustrate known limits to dereferencing to …
GuillaumeGomez Oct 5, 2026
864549d
Support AVX-512 variable logical shifts of 64-bit lanes
elichai Oct 25, 2026
bbcbb18
Support AVX-512 two-table permutations for dwords and 256-bit bytes
elichai Oct 25, 2026
23221df
Add libc direct tests for fsync and fdatasync
mehmettoplu-rs Oct 28, 2026
32fe591
Add target check for fdatasync to reject macOS
mehmettoplu-rs Nov 2, 2026
6bb3f82
Merge pull request #5509 from mehmettoplu-rs/test-fsync-fdatasync
RalfJung Nov 2, 2026
e0e601c
make fs::copy work via fallback
RalfJung Nov 2, 2026
15e862a
support a bit of chmod on windows hosts
RalfJung Nov 2, 2026
4010e6d
also test remaining io::copy specializations
RalfJung Nov 3, 2026
b04a92b
Add libc direct tests for open64 and openat64
mehmettoplu-rs Nov 3, 2026
03542df
Merge pull request #5547 from RalfJung/fs-copy
RalfJung Nov 3, 2026
adbb4dc
Add test for `accept` with nullptr `address_ptr` argument
WhySoBad Nov 2, 2026
4f96d36
Merge pull request #5548 from WhySoBad/fix-socket-address-write
RalfJung Nov 3, 2026
947370b
Prepare for merging from rust-lang/rust
Nov 4, 2026
e5a314b
Merge ref '249cb163c0d0' from rust-lang/rust
Nov 4, 2026
0a66b5c
Merge pull request #5555 from rust-lang/rustup-2026-11-04
RalfJung Nov 4, 2026
0bef4af
diagnostics refactor: unify handling of notes and helps
RalfJung Nov 4, 2026
3005cc8
inform the user when a warning is only shown once
RalfJung Nov 4, 2026
05a1200
Merge pull request #5557 from RalfJung/once-diag
RalfJung Nov 4, 2026
28d9658
Merge pull request #5551 from mehmettoplu-rs/test-open64-openat64
RalfJung Nov 4, 2026
99f6b35
Fix SSE4.2 string comparison intrinsics
TDecking Nov 2, 2026
d165bf7
separate matching logic from bit manipulation
RalfJung Nov 4, 2026
acc2eb1
Change the comments to fit the new matching logic.
TDecking Nov 4, 2026
3ff2d84
ci: Fix `cron-rustc-pull` more securely
hashcatHitman Nov 3, 2026
1889509
Merge pull request #5544 from TDecking/sse42-fix
RalfJung Nov 4, 2026
7614775
Keep cargo-miri arguments in one place
darkraider01 Nov 4, 2026
8d2ef8c
Merge pull request #5549 from hashcatHitman/github-app-haunts-me-in-m…
RalfJung Nov 4, 2026
a7d6531
Merge pull request #5364 from darkraider01/cargo-miri-args
RalfJung Nov 4, 2026
fe72c8a
allow noop-pull for manually dispatched cron workflow
RalfJung Nov 4, 2026
10654ba
sockaddr writing: explicitly initialize sin_zero field
RalfJung Nov 4, 2026
3b041e5
use fn signature types for sockaddr len
RalfJung Nov 4, 2026
41c671e
Merge pull request #5560 from RalfJung/cron-dispatched
RalfJung Nov 4, 2026
7e23685
remove write_null helper
RalfJung Nov 4, 2026
c8a3724
Merge pull request #5562 from RalfJung/write-null
RalfJung Nov 4, 2026
2cab4ca
nuttx: use updated pollfd definition
bkueng Sep 23, 2026
866146c
deal with BSD len fields
RalfJung Nov 4, 2026
4623854
Merge pull request #5564 from WhySoBad/sockaddr-extra-fields
RalfJung Nov 5, 2026
2e1670b
Strenghten `deref` and `deref_mut` checks to ensure we don't compare …
GuillaumeGomez Nov 5, 2026
5cc2524
Migrate basic block ctors to require Terminator where possible
panstromek Nov 5, 2026
2eacd69
Implement per-toolchain cache of std
shvrma Oct 26, 2026
4afc10d
simplify the code a bit
RalfJung Nov 5, 2026
1ce6faf
rename some more this -> ecx
RalfJung Nov 5, 2026
124fb1c
Merge pull request #5493 from elichai/avx512-shifts-permutes
RalfJung Nov 5, 2026
f3cf2db
Merge pull request #5494 from shvrma/issue-2733
RalfJung Nov 5, 2026
2bc2d76
Merge pull request #5568 from RalfJung/ecx
RalfJung Nov 5, 2026
dc5ab20
Add multi-level `Deref` test
GuillaumeGomez Nov 5, 2026
fc618ea
rename this to ecx
programskillforverification Nov 6, 2026
aef7cc3
Add minimal Linux copy_file_range shim
programskillforverification Oct 26, 2026
d912f48
add check for overlap in the same file
RalfJung Nov 6, 2026
74a19c2
add test for Seek::stream_len (already works on Unix)
RalfJung Nov 6, 2026
669b2c8
add return_io_result_via_errno helper
RalfJung Nov 6, 2026
07e7ce8
also support copy_file_range via syscall
RalfJung Nov 6, 2026
176c1a7
Merge pull request #5489 from programskillforverification/copy-file-r…
RalfJung Nov 6, 2026
171221d
Merge pull request #5570 from programskillforverification/this-to-ecx
RalfJung Nov 6, 2026
3d83ab4
use lang item instead of name when assembling builtin `Clone::clone` …
WaffleLapkin Nov 6, 2026
28f1c18
Add `sendto` support to `UnixSocketFileDescription`
WhySoBad Oct 19, 2026
03d499d
Add `recvfrom` support to `UnixSocketFileDescription`
WhySoBad Oct 19, 2026
d9b1e2a
rename this to ecx in intrinsics
hlsxx Nov 6, 2026
b812c13
Add libc direct tests for getcwd and chdir
mehmettoplu-rs Nov 5, 2026
e509b32
recvfrom, sendto: require given address length to be fully dereferenc…
RalfJung Nov 6, 2026
940c91f
Merge pull request #5501 from WhySoBad/socket-sendto-recvfrom
RalfJung Nov 6, 2026
4efd167
Introduce `OptimizationObjective` and fix the entry shim's size attri…
cezarbbb Oct 26, 2026
45bea6c
add tests for -Zcrate-attr ordering
Albab-Hasan Nov 5, 2026
851c9e0
apply -Zcrate-attr attributes before the crate attributes
Albab-Hasan Nov 5, 2026
27d8c79
test too big sockaddr-len on BSD hosts
RalfJung Nov 7, 2026
f3113f7
organize and extend TCP sendto tests
RalfJung Nov 7, 2026
9d7b671
add and use read_to_end helper
RalfJung Nov 7, 2026
4251fb8
Merge pull request #5566 from mehmettoplu-rs/test-getcwd-chdir
RalfJung Nov 7, 2026
e275f47
Merge pull request #5574 from hlsxx/this-to-ecx
RalfJung Nov 7, 2026
a3a5a11
Merge pull request #5576 from RalfJung/sockaddr-len
RalfJung Nov 7, 2026
11040c2
Rollup merge of #165588 - RalfJung:miri, r=RalfJung
Zalathar Nov 7, 2026
3b0585e
Rollup merge of #164784 - cezarbbb:overhaul-size-flags, r=oli-obk
Zalathar Nov 7, 2026
dbfd4f3
Rollup merge of #147696 - bjoernager:bit, r=hanna-kruppe
Zalathar Nov 7, 2026
a14ec8c
Rollup merge of #163202 - bkueng:nuttx_poll_update, r=hanna-kruppe
Zalathar Nov 7, 2026
cae87cf
Rollup merge of #163571 - GuillaumeGomez:deref-on-aliased, r=Urgau
Zalathar Nov 7, 2026
71fa2ec
Rollup merge of #165482 - Albab-Hasan:crate-attr-tests, r=oli-obk
Zalathar Nov 7, 2026
867fa83
Rollup merge of #165517 - panstromek:no-terminator-option-2, r=folker…
Zalathar Nov 7, 2026
66f990e
Rollup merge of #165552 - WaffleLapkin:use-clone-fn-lang-item, r=folk…
Zalathar Nov 7, 2026
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
1 change: 1 addition & 0 deletions compiler/rustc_attr_ir/src/lang_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ language_item_table! {
Copy, sym::copy, copy_trait, Target::Trait, GenericRequirement::Exact(0);
Clone, sym::clone, clone_trait, Target::Trait, GenericRequirement::None;
CloneFn, sym::clone_fn, clone_fn, Target::Method(MethodKind::Trait { body: false }), GenericRequirement::None;
CloneFromFn, sym::clone_from_fn, clone_from_fn, Target::Method(MethodKind::Trait { body: true }), GenericRequirement::None;
UseCloned, sym::use_cloned, use_cloned_trait, Target::Trait, GenericRequirement::None;
TrivialClone, sym::trivial_clone, trivial_clone_trait, Target::Trait, GenericRequirement::None;
Sync, sym::sync, sync_trait, Target::Trait, GenericRequirement::Exact(0);
Expand Down
15 changes: 7 additions & 8 deletions compiler/rustc_builtin_macros/src/cmdline_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use rustc_session::parse::ParseSess;
use rustc_span::FileName;

pub fn inject(krate: &mut ast::Crate, psess: &ParseSess, attrs: &[String]) {
for raw_attr in attrs {
let injected = attrs.iter().filter_map(|raw_attr| {
let source = format!("#![{raw_attr}]");
let parse = || -> Result<ast::Attribute, Vec<Diag<'_>>> {
let tokens = source_str_to_stream(
Expand All @@ -22,16 +22,15 @@ pub fn inject(krate: &mut ast::Crate, psess: &ParseSess, attrs: &[String]) {
})
.map_err(|e| vec![e])
};
let meta = match parse() {
Ok(meta) => meta,
match parse() {
Ok(meta) => Some(meta),
Err(errs) => {
for err in errs {
err.emit();
}
continue;
None
}
};

krate.attrs.push(meta);
}
}
});
krate.attrs.splice(0..0, injected);
}
2 changes: 2 additions & 0 deletions compiler/rustc_codegen_llvm/src/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,8 @@ pub(crate) fn default_optimisation_attrs<'ll>(
sess: &Session,
) -> SmallVec<[&'ll Attribute; 2]> {
let mut attrs = SmallVec::new();
// Either attribute satisfies LLVM's combined size predicate, but the software pipeliner reads
// `optsize` alone, so a `z` build needs both.
match sess.opts.optimize {
OptLevel::Size => {
attrs.push(llvm::AttributeKind::OptimizeForSize.create_attr(cx.llcx));
Expand Down
19 changes: 9 additions & 10 deletions compiler/rustc_codegen_llvm/src/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,15 @@ pub(crate) fn create_target_machine(tcx: TyCtxt<'_>, mod_name: &str) -> OwnedTar
target_machine_factory(tcx.sess, tcx.backend_optimization_level(()))(tcx.dcx(), config)
}

fn to_llvm_opt_settings(cfg: config::OptLevel) -> (llvm::CodeGenOptLevel, llvm::CodeGenOptSize) {
// `s` and `z` are the same codegen level; what tells LLVM that they are size builds is the
// per-function attribute, not this setting.
fn to_llvm_opt_level(cfg: config::OptLevel) -> llvm::CodeGenOptLevel {
use self::config::OptLevel::*;
match cfg {
No => (llvm::CodeGenOptLevel::None, llvm::CodeGenOptSizeNone),
Less => (llvm::CodeGenOptLevel::Less, llvm::CodeGenOptSizeNone),
More => (llvm::CodeGenOptLevel::Default, llvm::CodeGenOptSizeNone),
Aggressive => (llvm::CodeGenOptLevel::Aggressive, llvm::CodeGenOptSizeNone),
Size => (llvm::CodeGenOptLevel::Default, llvm::CodeGenOptSizeDefault),
SizeMin => (llvm::CodeGenOptLevel::Default, llvm::CodeGenOptSizeAggressive),
No => llvm::CodeGenOptLevel::None,
Less => llvm::CodeGenOptLevel::Less,
More | Size | SizeMin => llvm::CodeGenOptLevel::Default,
Aggressive => llvm::CodeGenOptLevel::Aggressive,
}
}

Expand Down Expand Up @@ -184,7 +184,7 @@ pub(crate) fn target_machine_factory(

let reloc_model = to_llvm_relocation_model(sess.relocation_model());

let (opt_level, _) = to_llvm_opt_settings(optlvl);
let opt_level = to_llvm_opt_level(optlvl);
let float_abi = to_llvm_float_abi(sess.target.llvm_floatabi);

let ffunction_sections =
Expand Down Expand Up @@ -594,8 +594,7 @@ pub(crate) unsafe fn llvm_optimize<'ll>(
vectorize_slp = false;
vectorize_loop = false;
} else {
unroll_loops =
opt_level != config::OptLevel::Size && opt_level != config::OptLevel::SizeMin;
unroll_loops = opt_level.objective() != config::OptimizationObjective::Size;
merge_functions = config.merge_functions;
vectorize_slp = config.vectorize_slp;
vectorize_loop = config.vectorize_loop;
Expand Down
5 changes: 5 additions & 0 deletions compiler/rustc_codegen_llvm/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1071,6 +1071,11 @@ impl<'ll, 'tcx> MiscCodegenMethods<'tcx> for CodegenCx<'ll, 'tcx> {
attributes::apply_to_llfn(llfn, llvm::AttributePlace::Function, &attrs);
}

fn apply_default_optimisation_attrs(&self, llfn: &'ll Value) {
let attrs = attributes::default_optimisation_attrs(self, self.sess());
attributes::apply_to_llfn(llfn, llvm::AttributePlace::Function, &attrs);
}

fn declare_c_main(&self, fn_type: Self::Type) -> Option<Self::Function> {
let entry_name = self.sess().target.entry_name.as_ref();
if self.get_declared_value(entry_name).is_none() {
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_codegen_llvm/src/intrinsic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1707,6 +1707,7 @@ fn gen_fn<'a, 'll, 'tcx>(
let llfn = cx.declare_fn(name, fn_abi, None);
cx.set_frame_pointer_type(llfn);
cx.apply_target_cpu_attr(llfn);
cx.apply_default_optimisation_attrs(llfn);
// FIXME(eddyb) find a nicer way to do this.
llvm::set_linkage(llfn, llvm::Linkage::InternalLinkage);
let llbb = Builder::append_block(cx, llfn, "entry-block");
Expand Down
9 changes: 0 additions & 9 deletions compiler/rustc_codegen_llvm/src/llvm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use rustc_abi::{AddressSpace, Align, Size, WrappingRange};
use rustc_llvm::RustString;

pub(crate) use self::CallConv::*;
pub(crate) use self::CodeGenOptSize::*;
pub(crate) use self::conversions::*;
pub(crate) use self::ffi::*;
pub(crate) use self::metadata_kind::*;
Expand Down Expand Up @@ -195,14 +194,6 @@ impl AttributePlace {
}
}

#[derive(Copy, Clone, PartialEq)]
#[repr(C)]
pub(crate) enum CodeGenOptSize {
CodeGenOptSizeNone = 0,
CodeGenOptSizeDefault = 1,
CodeGenOptSizeAggressive = 2,
}

pub(crate) fn SetInstructionCallConv(instr: &Value, cc: CallConv) {
unsafe {
LLVMSetInstructionCallConv(instr, cc as c_uint);
Expand Down
7 changes: 3 additions & 4 deletions compiler/rustc_codegen_ssa/src/back/linker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@ impl<'a> GccLinker<'a> {
self.link_arg(&arg);
}

// The plugin has no distinct size setting: `s` and `z` both map to `O2`, as `More` does.
let opt_level = match self.sess.opts.optimize {
config::OptLevel::No => "O0",
config::OptLevel::Less => "O1",
Expand Down Expand Up @@ -698,9 +699,7 @@ impl<'a> Linker for GccLinker<'a> {

// GNU-style linkers support optimization with -O. GNU ld doesn't
// need a numeric argument, but other linkers do.
if self.sess.opts.optimize == config::OptLevel::More
|| self.sess.opts.optimize == config::OptLevel::Aggressive
{
if self.sess.optimization_objective() == config::OptimizationObjective::Speed {
self.link_arg("-O1");
}
}
Expand Down Expand Up @@ -1021,7 +1020,7 @@ impl<'a> Linker for MsvcLinker<'a> {
// MSVC's ICF (Identical COMDAT Folding) link optimization is
// slow for Rust and thus we disable it by default when not in
// optimization build.
if self.sess.opts.optimize != config::OptLevel::No {
if self.sess.optimization_objective() != config::OptimizationObjective::None {
self.link_arg("/OPT:REF,ICF");
} else {
// It is necessary to specify NOICF here, because /OPT:REF
Expand Down
18 changes: 7 additions & 11 deletions compiler/rustc_codegen_ssa/src/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ use rustc_metadata::fs::copy_to_stdout;
use rustc_middle::dep_graph::{WorkProduct, WorkProductMap};
use rustc_middle::ty::TyCtxt;
use rustc_session::config::{
self, JobsMode, Lto, OptLevel, OutFileName, OutputFilenames, OutputType, Passes,
SwitchWithOptPath,
self, JobsMode, Lto, OptLevel, OptimizationObjective, OutFileName, OutputFilenames, OutputType,
Passes, SwitchWithOptPath,
};
use rustc_session::{BorrowedIncrCompSession, IncrCompSession, Session};
use rustc_span::source_map::SourceMap;
Expand Down Expand Up @@ -231,8 +231,7 @@ impl ModuleConfig {
// Copy what clang does by turning on loop vectorization at O2 and
// slp vectorization at O3.
vectorize_loop: !sess.opts.cg.no_vectorize_loops
&& (sess.opts.optimize == config::OptLevel::More
|| sess.opts.optimize == config::OptLevel::Aggressive),
&& sess.optimization_objective() == OptimizationObjective::Speed,
vectorize_slp: !sess.opts.cg.no_vectorize_slp
&& sess.opts.optimize == config::OptLevel::Aggressive,

Expand All @@ -247,13 +246,10 @@ impl ModuleConfig {
// O2 and O3) since it can be useful for reducing code size.
merge_functions: match sess.merge_functions() {
MergeFunctions::Disabled => false,
MergeFunctions::Trampolines | MergeFunctions::Aliases => {
use config::OptLevel::*;
match sess.opts.optimize {
Aggressive | More | SizeMin | Size => true,
Less | No => false,
}
}
MergeFunctions::Trampolines | MergeFunctions::Aliases => matches!(
sess.optimization_objective(),
OptimizationObjective::Speed | OptimizationObjective::Size
),
},

emit_lifetime_markers: sess.emit_lifetime_markers(),
Expand Down
35 changes: 13 additions & 22 deletions compiler/rustc_codegen_ssa/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,8 @@ pub fn maybe_create_entry_wrapper<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
// `main` should respect same config for frame pointer elimination as rest of code
cx.set_frame_pointer_type(llfn);
cx.apply_target_cpu_attr(llfn);
// The shim has no item behind it, so it does not go through the per-item attribute path.
cx.apply_default_optimisation_attrs(llfn);

let llbb = Bx::append_block(cx, llfn, "top");
let mut bx = Bx::build(cx, llbb);
Expand Down Expand Up @@ -1217,23 +1219,16 @@ impl CrateInfo {

pub(crate) fn provide(providers: &mut Providers) {
providers.backend_optimization_level = |tcx, cratenum| {
let for_speed = match tcx.sess.opts.optimize {
// If globally no optimisation is done, #[optimize] has no effect.
//
// This is done because if we ended up "upgrading" to `-O2` here, we’d populate the
// pass manager and it is likely that some module-wide passes (such as inliner or
// cross-function constant propagation) would ignore the `optnone` annotation we put
// on the functions, thus necessarily involving these functions into optimisations.
config::OptLevel::No => return config::OptLevel::No,
// If globally optimise-speed is already specified, just use that level.
config::OptLevel::Less => return config::OptLevel::Less,
config::OptLevel::More => return config::OptLevel::More,
config::OptLevel::Aggressive => return config::OptLevel::Aggressive,
// If globally optimize-for-size has been requested, use -O2 instead (if optimize(size)
// are present).
config::OptLevel::Size => config::OptLevel::More,
config::OptLevel::SizeMin => config::OptLevel::More,
};
let global = tcx.sess.opts.optimize;

// Nothing to promote outside a size build. At `-Copt-level=0` the upgrade would populate
// the pass manager, and its module-wide passes ignore the `optnone` annotation.
if global.objective() != config::OptimizationObjective::Size {
return global;
}

// A speed-marked body in a size build needs a speed level, and `-O2` is the lowest one.
let for_speed = config::OptLevel::More;

let defids = tcx.collect_and_partition_mono_items(cratenum).all_mono_items;

Expand All @@ -1242,11 +1237,7 @@ pub(crate) fn provide(providers: &mut Providers) {
matches!(optimize, OptimizeAttr::Speed)
});

if any_for_speed {
return for_speed;
}

tcx.sess.opts.optimize
if any_for_speed { for_speed } else { global }
};
}

Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_codegen_ssa/src/traits/misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ pub trait MiscCodegenMethods<'tcx>: BackendTypes {
fn sess(&self) -> &Session;
fn set_frame_pointer_type(&self, llfn: Self::Function);
fn apply_target_cpu_attr(&self, llfn: Self::Function);
/// Applies the compilation's optimization attributes to a function that no item produced,
/// such as the C entry shim.
fn apply_default_optimisation_attrs(&self, _llfn: Self::Function) {}
/// Declares the extern "C" main function for the entry point. Returns None if the symbol
/// already exists.
fn declare_c_main(&self, fn_type: Self::FunctionSignature) -> Option<Self::Function>;
Expand Down
24 changes: 23 additions & 1 deletion compiler/rustc_middle/src/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1346,11 +1346,33 @@ pub struct BasicBlockData<'tcx> {
}

impl<'tcx> BasicBlockData<'tcx> {
pub fn new(terminator: Option<Terminator<'tcx>>, is_cleanup: bool) -> BasicBlockData<'tcx> {
pub fn new(terminator: Terminator<'tcx>, is_cleanup: bool) -> BasicBlockData<'tcx> {
BasicBlockData::new_stmts(Vec::new(), terminator, is_cleanup)
}

pub fn new_stmts(
statements: Vec<Statement<'tcx>>,
terminator: Terminator<'tcx>,
is_cleanup: bool,
) -> BasicBlockData<'tcx> {
BasicBlockData {
statements,
after_last_stmt_debuginfos: StmtDebugInfos::default(),
terminator: Some(terminator),
is_cleanup,
}
}

/// This is being phased out. Use [`BasicBlockData::new`] instead.
pub fn maybe_unterminated(
terminator: Option<Terminator<'tcx>>,
is_cleanup: bool,
) -> BasicBlockData<'tcx> {
BasicBlockData::maybe_unterminated_stmts(Vec::new(), terminator, is_cleanup)
}

/// This is being phased out. Use [`BasicBlockData::new_stmts`] instead.
pub fn maybe_unterminated_stmts(
statements: Vec<Statement<'tcx>>,
terminator: Option<Terminator<'tcx>>,
is_cleanup: bool,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir_build/src/builder/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ impl<'tcx> CFG<'tcx> {
// it as #[inline(never)] to keep rustc's stack use in check.
#[inline(never)]
pub(crate) fn start_new_block(&mut self) -> BasicBlock {
self.basic_blocks.push(BasicBlockData::new(None, false))
self.basic_blocks.push(BasicBlockData::maybe_unterminated(None, false))
}

pub(crate) fn start_new_cleanup_block(&mut self) -> BasicBlock {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir_build/src/builder/custom/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ pub(super) fn build_custom_mir<'tcx>(
};

body.local_decls.push(LocalDecl::new(return_ty, return_ty_span));
body.basic_blocks_mut().push(BasicBlockData::new(None, false));
body.basic_blocks_mut().push(BasicBlockData::maybe_unterminated(None, false));
body.source_scopes.push(SourceScopeData {
span,
parent_scope: None,
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_mir_build/src/builder/custom/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ impl<'a, 'tcx> ParseCtxt<'a, 'tcx> {
match &self.thir[stmt].kind {
StmtKind::Let { pattern, initializer: Some(initializer), .. } => {
let (var, ..) = self.parse_var(pattern)?;
let data = BasicBlockData::new(
let data = BasicBlockData::maybe_unterminated(
None,
parse_by_kind!(self, *initializer, _, "basic block declaration",
@variant(mir_basic_block, Normal) => false,
Expand Down Expand Up @@ -303,7 +303,7 @@ impl<'a, 'tcx> ParseCtxt<'a, 'tcx> {
ExprKind::Block { block } => &self.thir[*block],
);

let mut data = BasicBlockData::new(None, is_cleanup);
let mut data = BasicBlockData::maybe_unterminated(None, is_cleanup);
for stmt_id in &*block.stmts {
let stmt = self.statement_as_expr(*stmt_id)?;
let span = self.thir[stmt].span;
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir_build/src/builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -833,7 +833,7 @@ fn mir_for_direct_const<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> Body<'tc
let rvalue = Rvalue::Use(Operand::Constant(Box::new(value)), WithRetag::Yes);
let statement_kind = StatementKind::Assign(Box::new((Place::return_place(), rvalue)));
let statement = Statement::new(source_info, statement_kind);
let terminator = Some(Terminator { source_info, kind: TerminatorKind::Return });
let terminator = Terminator { source_info, kind: TerminatorKind::Return };
let block = BasicBlockData::new_stmts(vec![statement], terminator, false);
let basic_blocks = IndexVec::from_elem_n(block, 1);

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir_dataflow/src/framework/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,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 }),
mir::Terminator { source_info, kind },
false,
))
};
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir_transform/src/add_call_guards.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +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) }),
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
Expand Up @@ -94,7 +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) }),
Terminator { source_info, kind: TerminatorKind::goto(target) },
is_cleanup,
));

Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_mir_transform/src/check_enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ fn split_block(
let block_data = &mut basic_blocks[location.block];

// Drain every statement after this one and move the current terminator to a new basic block.
let new_block = BasicBlockData::new_stmts(
let new_block = BasicBlockData::maybe_unterminated_stmts(
block_data.statements.split_off(location.statement_index),
block_data.terminator.take(),
block_data.is_cleanup,
Expand Down Expand Up @@ -348,7 +348,7 @@ fn insert_direct_enum_check<'tcx>(
new_block: BasicBlock,
) {
// Insert a new target block that is branched to in case of an invalid discriminant.
let invalid_discr_block_data = BasicBlockData::new(None, false);
let invalid_discr_block_data = BasicBlockData::maybe_unterminated(None, false);
let invalid_discr_block = basic_blocks.push(invalid_discr_block_data);
let block_data = &mut basic_blocks[current_block];
let discr_place = insert_discr_cast_to_u128(
Expand Down
Loading
Loading