Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
38d5ee3
autodiff: fix sysroot candidates in libEnzyme not found error
sgasho Sep 19, 2026
483372d
Split PassMode::IndirectUnsized out of PassMode::Indirect
bjorn3 Sep 14, 2026
314a75b
`TrivialTypeTraversalImpls!`: also impl `GenericTypeVisitable`
ada4a Sep 16, 2026
e394051
dogfood: add missing `GenericTypeVisitable` impls
ada4a Sep 30, 2026
4ba952a
Fix more `incoherent_impl` linking
GuillaumeGomez Oct 5, 2026
9a6d547
Update Enzyme submodule
ZuseZ4 Oct 6, 2026
48156cc
Store loop hints as `UnrollAttr` rather than `AttributeKind`
joshtriplett Oct 7, 2026
6545abe
Use BasicBlock::start_location and Location::START
tmiasko Oct 7, 2026
6321136
Fix debug assert failure in `note_obligation_cause_code_inner` and co…
RuleOfSix Oct 7, 2026
0d7fdb5
Update Enzyme submodule again
ZuseZ4 Oct 7, 2026
23fa0f4
codegen: tell LLVM that the discriminant is a power of two
dianqk Sep 13, 2026
6396944
relax_elf_relocations is x86-only
RalfJung Oct 7, 2026
7870b60
disable next-solver with higher-ranked-assumptions
lcnr Oct 7, 2026
ec45ecf
Move `loop_hint_attrs` from `Terminator` into `TerminatorKind::Goto`
joshtriplett Oct 7, 2026
6257faf
add MISSING_GENERIC_TYPE_VISITABLE lint
ada4a Aug 1, 2026
22a7c9e
Rollup merge of #162741 - dianqk:codegen-discriminants-cast, r=saethlin
jhpratt Oct 8, 2026
248d9de
Rollup merge of #162758 - bjorn3:pass_mode_indirect_unsized, r=beetrees
jhpratt Oct 8, 2026
161d192
Rollup merge of #163931 - joshtriplett:mir-loop-hint-attrs-in-goto, r…
jhpratt Oct 8, 2026
3a7494d
Rollup merge of #163028 - sgasho:enzyme-wrapper-cleanup, r=ZuseZ4
jhpratt Oct 8, 2026
f604e7b
Rollup merge of #163538 - ada4a:missing-generic-type-visitable, r=Jon…
jhpratt Oct 8, 2026
3a3f8c3
Rollup merge of #163841 - GuillaumeGomez:incoherent-impl, r=Urgau
jhpratt Oct 8, 2026
7f26248
Rollup merge of #163908 - ZuseZ4:update-enzyme-oct-06-2026, r=ZuseZ4
jhpratt Oct 8, 2026
07507f9
Rollup merge of #163912 - RuleOfSix:ice-escaping-bounds, r=lcnr
jhpratt Oct 8, 2026
c3f8d47
Rollup merge of #163935 - tmiasko:start-location, r=beetrees
jhpratt Oct 8, 2026
6b09a06
Rollup merge of #163949 - lcnr:higher-ranked-assumptions-yeet, r=lqd
jhpratt Oct 8, 2026
e8b84a3
Rollup merge of #163951 - RalfJung:relax_elf_relocations, r=wesleywiser
jhpratt Oct 8, 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
4 changes: 2 additions & 2 deletions compiler/rustc_abi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2441,8 +2441,8 @@ impl<FieldIdx: Idx, VariantIdx: Idx> LayoutData<FieldIdx, VariantIdx> {
/// Checks if these two `Layout` are equal enough to be considered "the same for all function
/// call ABIs". Note however that real ABIs depend on more details that are not reflected in the
/// `Layout`; the `PassMode` need to be compared as well. Also note that we assume
/// aggregates are passed via `PassMode::Indirect` or `PassMode::Cast`; more strict
/// checks would otherwise be required.
/// aggregates are passed via `PassMode::Indirect`, `PassMode::IndirectUnsized` or
/// `PassMode::Cast`; more strict checks would otherwise be required.
pub fn eq_abi(&self, other: &Self) -> bool {
// The one thing that we are not capturing here is that for unsized types, the metadata must
// also have the same ABI, and moreover that the same metadata leads to the same size. The
Expand Down
9 changes: 9 additions & 0 deletions compiler/rustc_ast_passes/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ pub(crate) struct NextSolverDisabledForGenericConstExprs {
pub span: Span,
}

#[derive(Diagnostic)]
#[diag("`-Zhigher-ranked-assumptions` is not supported with the next-generation trait solver")]
#[note("the feature flag will be superseded by `-Zassumptions-on-binders`")]
#[note("`-Znext-solver=globally` is currently enabled by default for testing")]
#[note("reverted the setting to `-Znext-solver=coherence` for this crate")]
#[note("the currently stable trait solver will be used for this crate")]
#[note("see issues #160895 <https://github.com/rust-lang/rust/issues/160895> for more information")]
pub(crate) struct NextSolverDisabledForHigherRankedAssumptions;

#[derive(Diagnostic)]
#[diag("functions in {$in_impl ->
[true] trait impls
Expand Down
15 changes: 13 additions & 2 deletions compiler/rustc_ast_passes/src/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) {
check_incompatible_features(sess, features);
check_dependent_features(sess, features);
warn_next_solver_and_gce(sess, features);
warn_next_solver_and_higher_ranked_assumptions(sess);
check_features_requiring_new_solver(sess, features);

let mut visitor = PostExpansionVisitor { sess, features };
Expand Down Expand Up @@ -703,8 +704,8 @@ fn warn_next_solver_and_gce(sess: &Session, features: &Features) {
return;
}

// Warn people who uses GCE and -Znext-solver=globally
// that their trait solver was downgraded to -Znext-solver=no
// Warn people who use GCE and -Znext-solver=globally
// that their trait solver was downgraded to -Znext-solver=coherence
if let Some(gce_span) = features
.enabled_lang_features()
.iter()
Expand All @@ -716,6 +717,16 @@ fn warn_next_solver_and_gce(sess: &Session, features: &Features) {
}
}

fn warn_next_solver_and_higher_ranked_assumptions(sess: &Session) {
// Warn people who use -Zhigher-ranked-assumptions and -Znext-solver=globally
// that their trait solver was downgraded to -Znext-solver=coherence
if sess.opts.unstable_opts.next_solver == NextSolverConfig::Globally
&& sess.opts.unstable_opts.higher_ranked_assumptions
{
sess.dcx().emit_warn(diagnostics::NextSolverDisabledForHigherRankedAssumptions);
}
}

fn check_features_requiring_new_solver(sess: &Session, features: &Features) {
if sess.opts.unstable_opts.next_solver == NextSolverConfig::Globally {
return;
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -978,7 +978,7 @@ impl<'a, 'tcx> ResultsVisitor<'tcx, Borrowck<'a, 'tcx>> for MirBorrowckCtxt<'a,
}
}

TerminatorKind::Goto { target: _ }
TerminatorKind::Goto { target: _, loop_hint_attrs: _ }
| TerminatorKind::UnwindTerminate(_)
| TerminatorKind::Unreachable
| TerminatorKind::UnwindResume
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_borrowck/src/polonius/constraints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,7 @@ impl LocalizedConstraintGraph {
// Inter-block edges, from the block's terminator to each successor block's
// entry point.
for successor_block in body[location.block].terminator().successors() {
let next_location =
Location { block: successor_block, statement_index: 0 };
let next_location = successor_block.start_location();
let next_point = location_map.point_from_location(next_location);
if liveness.is_live_at(next_point) {
successor_found(LocalizedNode {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LoanInvalidationsGenerator<'a, 'tcx> {
}
}
}
TerminatorKind::Goto { target: _ }
TerminatorKind::Goto { target: _, loop_hint_attrs: _ }
| TerminatorKind::UnwindTerminate(_)
| TerminatorKind::Unreachable
| TerminatorKind::FalseEdge { real_target: _, imaginary_target: _ }
Expand Down
7 changes: 3 additions & 4 deletions compiler/rustc_borrowck/src/polonius/legacy/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use std::iter;

use either::Either;
use rustc_middle::mir::{Body, Local, LocalKind, Location, START_BLOCK};
use rustc_middle::mir::{Body, Local, LocalKind, Location};
use rustc_middle::ty::{GenericArg, TyCtxt};
use rustc_mir_dataflow::move_paths::{InitKind, InitLocation, MoveData};
use tracing::debug;
Expand Down Expand Up @@ -80,8 +80,7 @@ fn emit_move_facts(
}
}

let fn_entry_start =
location_table.start_index(Location { block: START_BLOCK, statement_index: 0 });
let fn_entry_start = location_table.start_index(Location::START);

// initialized_at
for init in move_data.inits.iter() {
Expand All @@ -101,7 +100,7 @@ fn emit_move_facts(

// The initialization happened in (or rather, when arriving at)
// the successors, but not in the unwind block.
let first_statement = Location { block: successor, statement_index: 0 };
let first_statement = successor.start_location();
facts
.path_assigned_at_base
.push((init.path, location_table.start_index(first_statement)));
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_borrowck/src/type_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
}

for (block, block_data) in body.basic_blocks.iter_enumerated() {
let mut location = Location { block, statement_index: 0 };
let mut location = block.start_location();
for stmt in &block_data.statements {
self.visit_statement(stmt, location);
location.statement_index += 1;
Expand Down Expand Up @@ -2082,7 +2082,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
fn check_iscleanup(&mut self, block_data: &BasicBlockData<'tcx>) {
let is_cleanup = block_data.is_cleanup;
match block_data.terminator().kind {
TerminatorKind::Goto { target } => {
TerminatorKind::Goto { target, .. } => {
self.assert_iscleanup(block_data, target, is_cleanup)
}
TerminatorKind::SwitchInt { ref targets, .. } => {
Expand Down
15 changes: 7 additions & 8 deletions compiler/rustc_codegen_cranelift/src/abi/pass_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ impl<'tcx> ArgAbiExt<'tcx> for ArgAbi<'tcx, Ty<'tcx>> {
assert_eq!(pad_i32_count, 0, "padding support not yet implemented");
cast_target_to_abi_params(cast).into_iter().map(|(_, param)| param).collect()
}
PassMode::Indirect { attrs, meta_attrs: None, address_space: _, mode } => {
PassMode::Indirect { attrs, address_space: _, mode } => {
assert!(
mode != IndirectMode::AmdgpuKernelArg,
"unsupported amdgpu kernel argument"
Expand All @@ -143,8 +143,7 @@ impl<'tcx> ArgAbiExt<'tcx> for ArgAbi<'tcx, Ty<'tcx>> {
smallvec![apply_attrs_to_abi_param(AbiParam::new(pointer_ty(tcx)), attrs)]
}
}
PassMode::Indirect { attrs, meta_attrs: Some(meta_attrs), address_space: _, mode } => {
assert!(mode == IndirectMode::Pointer);
PassMode::IndirectUnsized { attrs, meta_attrs } => {
smallvec![
apply_attrs_to_abi_param(AbiParam::new(pointer_ty(tcx)), attrs),
apply_attrs_to_abi_param(AbiParam::new(pointer_ty(tcx)), meta_attrs),
Expand Down Expand Up @@ -188,7 +187,7 @@ impl<'tcx> ArgAbiExt<'tcx> for ArgAbi<'tcx, Ty<'tcx>> {
None,
cast_target_to_abi_params(cast).into_iter().map(|(_, param)| param).collect(),
),
PassMode::Indirect { attrs, meta_attrs: None, address_space: _, mode } => {
PassMode::Indirect { attrs, address_space: _, mode } => {
assert!(mode == IndirectMode::Pointer);
(
Some(apply_attrs_to_abi_param(
Expand All @@ -198,7 +197,7 @@ impl<'tcx> ArgAbiExt<'tcx> for ArgAbi<'tcx, Ty<'tcx>> {
vec![],
)
}
PassMode::Indirect { attrs: _, meta_attrs: Some(_), address_space: _, mode: _ } => {
PassMode::IndirectUnsized { attrs: _, meta_attrs: _ } => {
unreachable!("unsized return value")
}
}
Expand Down Expand Up @@ -268,7 +267,7 @@ pub(super) fn adjust_arg_for_abi<'tcx>(
smallvec![a, b]
}
PassMode::Cast { ref cast, .. } => to_casted_value(fx, arg, cast),
PassMode::Indirect { .. } => {
PassMode::Indirect { .. } | PassMode::IndirectUnsized { .. } => {
if is_owned {
match arg.force_stack(fx) {
(ptr, None) => smallvec![ptr.get_addr(fx)],
Expand Down Expand Up @@ -328,7 +327,7 @@ pub(super) fn cvalue_for_param<'tcx>(
PassMode::Cast { ref cast, .. } => {
from_casted_value(fx, &block_params, arg_abi.layout, cast)
}
PassMode::Indirect { attrs, meta_attrs: None, address_space: _, mode: _ } => {
PassMode::Indirect { attrs, address_space: _, mode: _ } => {
assert_eq!(block_params.len(), 1, "{:?}", block_params);
if let Some(pointee_align) = attrs.pointee_align
&& pointee_align < arg_abi.layout.align.abi
Expand All @@ -346,7 +345,7 @@ pub(super) fn cvalue_for_param<'tcx>(
CValue::by_ref(Pointer::new(block_params[0]), arg_abi.layout)
}
}
PassMode::Indirect { attrs: _, meta_attrs: Some(_), address_space: _, mode: _ } => {
PassMode::IndirectUnsized { attrs: _, meta_attrs: _ } => {
assert_eq!(block_params.len(), 2, "{:?}", block_params);
CValue::by_ref_unsized(Pointer::new(block_params[0]), block_params[1], arg_abi.layout)
}
Expand Down
17 changes: 8 additions & 9 deletions compiler/rustc_codegen_cranelift/src/abi/returning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ pub(super) fn codegen_return_param<'tcx>(
let is_ssa = ssa_analyzed[RETURN_PLACE].is_ssa(fx, fx.fn_abi.ret.layout.ty);
(super::make_local_place(fx, RETURN_PLACE, fx.fn_abi.ret.layout, is_ssa), smallvec![])
}
PassMode::Indirect { attrs: _, meta_attrs: None, address_space: _, mode: _ } => {
PassMode::Indirect { attrs: _, address_space: _, mode: _ } => {
let ret_param = block_params_iter.next().unwrap();
assert_eq!(fx.bcx.func.dfg.value_type(ret_param), fx.pointer_type);
(CPlace::for_ptr(Pointer::new(ret_param), fx.fn_abi.ret.layout), smallvec![ret_param])
}
PassMode::Indirect { attrs: _, meta_attrs: Some(_), address_space: _, mode: _ } => {
PassMode::IndirectUnsized { attrs: _, meta_attrs: _ } => {
unreachable!("unsized return value")
}
};
Expand Down Expand Up @@ -50,7 +50,7 @@ pub(super) fn codegen_with_call_return_arg<'tcx>(
) {
let (ret_temp_place, return_ptr) = match ret_arg_abi.mode {
PassMode::Ignore => (None, None),
PassMode::Indirect { attrs: _, meta_attrs: None, address_space: _, mode: _ } => {
PassMode::Indirect { attrs: _, address_space: _, mode: _ } => {
if let Some(ret_ptr) = ret_place.try_to_ptr() {
// This is an optimization to prevent unnecessary copies of the return value when
// the return place is already a memory place as opposed to a register.
Expand All @@ -61,7 +61,7 @@ pub(super) fn codegen_with_call_return_arg<'tcx>(
(Some(place), Some(place.to_ptr().get_addr(fx)))
}
}
PassMode::Indirect { attrs: _, meta_attrs: Some(_), address_space: _, mode: _ } => {
PassMode::IndirectUnsized { attrs: _, meta_attrs: _ } => {
unreachable!("unsized return value")
}
PassMode::Direct(_) | PassMode::Pair(_, _) | PassMode::Cast { .. } => (None, None),
Expand All @@ -86,14 +86,14 @@ pub(super) fn codegen_with_call_return_arg<'tcx>(
super::pass_mode::from_casted_value(fx, &results, ret_place.layout(), cast);
ret_place.write_cvalue(fx, result);
}
PassMode::Indirect { attrs: _, meta_attrs: None, address_space: _, mode: _ } => {
PassMode::Indirect { attrs: _, address_space: _, mode: _ } => {
if let Some(ret_temp_place) = ret_temp_place {
// If ret_temp_place is None, it is not necessary to copy the return value.
let ret_temp_value = ret_temp_place.to_cvalue(fx);
ret_place.write_cvalue(fx, ret_temp_value);
}
}
PassMode::Indirect { attrs: _, meta_attrs: Some(_), address_space: _, mode: _ } => {
PassMode::IndirectUnsized { attrs: _, meta_attrs: _ } => {
unreachable!("unsized return value")
}
}
Expand All @@ -102,11 +102,10 @@ pub(super) fn codegen_with_call_return_arg<'tcx>(
/// Codegen a return instruction with the right return value(s) if any.
pub(crate) fn codegen_return(fx: &mut FunctionCx<'_, '_, '_>) {
match fx.fn_abi.ret.mode {
PassMode::Ignore
| PassMode::Indirect { attrs: _, meta_attrs: None, address_space: _, mode: _ } => {
PassMode::Ignore | PassMode::Indirect { attrs: _, address_space: _, mode: _ } => {
fx.bcx.ins().return_(&[]);
}
PassMode::Indirect { attrs: _, meta_attrs: Some(_), address_space: _, mode: _ } => {
PassMode::IndirectUnsized { attrs: _, meta_attrs: _ } => {
unreachable!("unsized return value")
}
PassMode::Direct(_) => {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_cranelift/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ fn codegen_fn_body(fx: &mut FunctionCx<'_, '_, '_>, start_block: Block) {
crate::PrintOnPanic(|| format!("terminator {:?}", bb_data.terminator().kind));

match &bb_data.terminator().kind {
TerminatorKind::Goto { target } => {
TerminatorKind::Goto { target, loop_hint_attrs: _ } => {
if let TerminatorKind::Return = fx.mir[*target].terminator().kind {
let mut can_immediately_return = true;
for stmt in &fx.mir[*target].statements {
Expand Down
24 changes: 4 additions & 20 deletions compiler/rustc_codegen_gcc/src/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ impl<'gcc, 'tcx> FnAbiGccExt<'gcc, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
argument_tys.push(cx.type_ptr_to(self.ret.layout.gcc_type(cx)));
cx.type_void()
}
PassMode::IndirectUnsized { .. } => bug!("unsized returns are not supported"),
};
#[cfg(feature = "master")]
let mut non_null_args = Vec::new();
Expand Down Expand Up @@ -190,12 +191,7 @@ impl<'gcc, 'tcx> FnAbiGccExt<'gcc, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
let ty = cast.gcc_type(cx);
apply_attrs(ty, &cast.attrs, argument_tys.len())
}
PassMode::Indirect {
attrs: _,
meta_attrs: None,
address_space: _,
mode: IndirectMode::OnStack,
} => {
PassMode::Indirect { attrs: _, address_space: _, mode: IndirectMode::OnStack } => {
let x86_interrupt_first_arg = {
#[cfg(feature = "master")]
{
Expand Down Expand Up @@ -224,7 +220,6 @@ impl<'gcc, 'tcx> FnAbiGccExt<'gcc, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
}
PassMode::Indirect {
attrs: _,
meta_attrs: None,
address_space: _,
mode: IndirectMode::AmdgpuKernelArg,
} => {
Expand All @@ -233,21 +228,10 @@ impl<'gcc, 'tcx> FnAbiGccExt<'gcc, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
PassMode::Direct(attrs) => {
apply_attrs(arg.layout.immediate_gcc_type(cx), &attrs, argument_tys.len())
}
PassMode::Indirect {
attrs,
meta_attrs: None,
address_space: _,
mode: IndirectMode::Pointer,
} => {
PassMode::Indirect { attrs, address_space: _, mode: IndirectMode::Pointer } => {
apply_attrs(cx.type_ptr_to(arg.layout.gcc_type(cx)), &attrs, argument_tys.len())
}
PassMode::Indirect {
attrs,
meta_attrs: Some(meta_attrs),
address_space: _,
mode,
} => {
assert!(mode == IndirectMode::Pointer);
PassMode::IndirectUnsized { attrs, meta_attrs } => {
// Construct the type of a (wide) pointer to `ty`, and pass its two fields.
// Any two ABI-compatible unsized types have the same metadata type and
// moreover the same metadata value leads to the same dynamic size and
Expand Down
12 changes: 7 additions & 5 deletions compiler/rustc_codegen_gcc/src/intrinsic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tc
sym::cttz_nonzero => {
self.count_trailing_zeroes_nonzero(width, args[0].immediate())
}
sym::ctpop => self.pop_count(args[0].immediate()),
sym::ctpop => self.ctpop(args[0].immediate()),
sym::bswap => {
if width == 8 {
args[0].immediate() // byte swap a u8/i8 is just a no-op
Expand Down Expand Up @@ -689,6 +689,10 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tc
cond
}

fn ctpop(&mut self, val: Self::Value) -> Self::Value {
self.pop_count(val)
}

fn type_checked_load(
&mut self,
_vtable: Self::Value,
Expand Down Expand Up @@ -841,12 +845,10 @@ impl<'gcc, 'tcx> ArgAbiExt<'gcc, 'tcx> for ArgAbi<'tcx, Ty<'tcx>> {
PassMode::Pair(..) => {
OperandValue::Pair(next(), next()).store(bx, dst);
}
PassMode::Indirect { meta_attrs: Some(_), .. } => {
PassMode::IndirectUnsized { .. } => {
bug!("unsized `ArgAbi` cannot be stored");
}
PassMode::Direct(_)
| PassMode::Indirect { meta_attrs: None, .. }
| PassMode::Cast { .. } => {
PassMode::Direct(_) | PassMode::Indirect { .. } | PassMode::Cast { .. } => {
let next_arg = next();
self.store(bx, next_arg, dst);
}
Expand Down
Loading
Loading