Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
193a6df
Test: ICE in valtree due SizeOverflow of const array
Suryansh-Dey Oct 9, 2026
b1d5a71
Fix: Construct byte string valtree array type using literal length
Suryansh-Dey Oct 10, 2026
b065242
refine: respect recursion limit in RPITIT collector to prevent stack …
Vara715 Oct 12, 2026
15158df
handle trait solver overflow during monomorphization
amirHdev Oct 13, 2026
dcce5ba
Update LoongArch64 Linux dist builder to LLVM 23
heiher Oct 15, 2026
432a29b
Make the `documentation` scope a sub-scope of the `object` scope
Urgau Oct 13, 2026
2f751d2
Add regression test for lifetime extension
lsunsi Oct 15, 2026
05582c9
Add next-solver revisions to lifetime extension test
lsunsi Oct 15, 2026
4402999
Avoid erasing regions on is_transmutable check
lsunsi Oct 15, 2026
19b4d85
cargotest: update xsv libc for RISC-V
HNO3Miracle Oct 16, 2026
a48e904
Add missing ignore-windows due to path sep differences
Urgau Oct 16, 2026
7c7a46c
Implement after-stack-frame-init-hook
Oct 16, 2026
a0aea04
Rollup merge of #162467 - amirHdev:impossible-impl-mono-items, r=adwi…
JonathanBrouwer Oct 16, 2026
686a116
Rollup merge of #164111 - Suryansh-Dey:ice, r=khyperia
JonathanBrouwer Oct 16, 2026
6b688f0
Rollup merge of #164227 - Vara715:fix-rpitit-refine-cycle, r=oli-obk
JonathanBrouwer Oct 16, 2026
3f0afc0
Rollup merge of #164279 - Urgau:documentation-scope-as-sub-scope-of-o…
JonathanBrouwer Oct 16, 2026
ef9981f
Rollup merge of #164353 - heiher:loong64-llvm-23, r=jieyouxu
JonathanBrouwer Oct 16, 2026
e23a3da
Rollup merge of #164365 - lsunsi:avoid-erased-region-on-transmutabili…
JonathanBrouwer Oct 16, 2026
04167e0
Rollup merge of #164419 - HNO3Miracle:fix/cargotest-xsv-riscv-libc, r…
JonathanBrouwer Oct 16, 2026
5006510
Rollup merge of #164422 - muellernilsb:feature/after-stack-frame-init…
JonathanBrouwer Oct 16, 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
3 changes: 3 additions & 0 deletions compiler/rustc_const_eval/src/interpret/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,9 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
throw_ub_format!("calling a function with more arguments than it expected");
}

// All function arguments have gotten initialized, call corresponding hook.
M::after_stack_frame_init(self)?;

// Done!
self.push_stack_frame_done()
}
Expand Down
5 changes: 5 additions & 0 deletions compiler/rustc_const_eval/src/interpret/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,11 @@ pub trait Machine<'tcx>: Sized {
interp_ok(())
}

/// Called immediately after a stack frame has its function arguments initialized.
fn after_stack_frame_init(_ecx: &mut InterpCx<'tcx, Self>) -> InterpResult<'tcx> {
interp_ok(())
}

/// Called just before the frame is removed from the stack (followed by return value copy and
/// local cleanup).
fn before_stack_pop(_ecx: &mut InterpCx<'tcx, Self>) -> InterpResult<'tcx> {
Expand Down
29 changes: 24 additions & 5 deletions compiler/rustc_hir_analysis/src/check/compare_impl_item/refine.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::ops::ControlFlow;

use itertools::Itertools as _;
use rustc_data_structures::fx::FxIndexSet;
use rustc_hir as hir;
Expand Down Expand Up @@ -71,8 +73,10 @@ pub(crate) fn check_refining_return_position_impl_trait_in_trait<'tcx>(
return;
}

let mut collector = ImplTraitInTraitCollector { tcx, types: FxIndexSet::default() };
trait_m_sig.visit_with(&mut collector);
let mut collector = ImplTraitInTraitCollector { tcx, depth: 0, types: FxIndexSet::default() };
if trait_m_sig.visit_with(&mut collector).is_break() {
return;
}

// Bound that we find on RPITITs in the trait signature.
let mut trait_bounds = vec![];
Expand Down Expand Up @@ -264,28 +268,43 @@ pub(crate) fn check_refining_return_position_impl_trait_in_trait<'tcx>(

struct ImplTraitInTraitCollector<'tcx> {
tcx: TyCtxt<'tcx>,
depth: usize,
types: FxIndexSet<ty::ProjectionAliasTy<'tcx>>,
}

/// Once depth exceeds `tcx.recursion_limit()`, the visitor immediately breaks
/// the entire traversal using `ControlFlow::Break(())`.
impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for ImplTraitInTraitCollector<'tcx> {
fn visit_ty(&mut self, ty: Ty<'tcx>) {
type Result = ControlFlow<()>;

fn visit_ty(&mut self, ty: Ty<'tcx>) -> Self::Result {
if let ty::Alias(_, alias) = *ty.kind()
&& let Some(proj) = alias.try_to_projection()
&& self.tcx.is_impl_trait_in_trait(proj.kind)
{
if !self.tcx.recursion_limit().value_within_limit(self.depth) {
self.tcx.dcx().span_delayed_bug(
self.tcx.def_span(proj.kind),
"recursion limit exceeded while collecting implied RPITIT bounds",
);
return ControlFlow::Break(());
}
if self.types.insert(proj) {
self.depth += 1;
for (pred, _) in self
.tcx
.explicit_item_bounds(proj.kind)
.iter_instantiated_copied(self.tcx, proj.args)
.map(Unnormalized::skip_norm_wip)
{
pred.visit_with(self);
pred.visit_with(self)?;
}
self.depth -= 1;
}
} else {
ty.super_visit_with(self);
ty.super_visit_with(self)?;
}
ControlFlow::Continue(())
}
}

Expand Down
18 changes: 15 additions & 3 deletions compiler/rustc_mir_build/src/thir/constant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,18 @@ pub(crate) fn lit_to_const<'tcx>(
let valtree_ty = Ty::new_imm_ref(tcx, tcx.lifetimes.re_static, tcx.types.str_);
(ty::ValTree::from_raw_bytes(tcx, str_bytes), valtree_ty)
}
(ast::LitKind::ByteStr(byte_sym, _), Some(ty::Ref(_, inner_ty, _)))
(ast::LitKind::ByteStr(byte_sym, _), Some(ty::Ref(region, inner_ty, mutbl)))
if let ty::Slice(ty) | ty::Array(ty, _) = inner_ty.kind()
&& let ty::Uint(UintTy::U8) = ty.kind() =>
{
(ty::ValTree::from_raw_bytes(tcx, byte_sym.as_byte_str()), expected_ty.unwrap())
let valtree_ty = if inner_ty.is_slice() {
expected_ty.unwrap()
} else {
let array_ty =
Ty::new_array(tcx, tcx.types.u8, byte_sym.as_byte_str().len() as u64);
Ty::new_ref(tcx, *region, array_ty, *mutbl)
};
(ty::ValTree::from_raw_bytes(tcx, byte_sym.as_byte_str()), valtree_ty)
}
(
ast::LitKind::ByteStr(byte_sym, _),
Expand All @@ -51,7 +58,12 @@ pub(crate) fn lit_to_const<'tcx>(
{
// Byte string literal patterns may have type `[u8]` or `[u8; N]` if `deref_patterns` is
// enabled, in order to allow, e.g., `deref!(b"..."): Vec<u8>`.
(ty::ValTree::from_raw_bytes(tcx, byte_sym.as_byte_str()), expected_ty.unwrap())
let valtree_ty = if expected_ty.unwrap().is_slice() {
expected_ty.unwrap()
} else {
Ty::new_array(tcx, tcx.types.u8, byte_sym.as_byte_str().len() as u64)
};
(ty::ValTree::from_raw_bytes(tcx, byte_sym.as_byte_str()), valtree_ty)
}
(ast::LitKind::ByteStr(byte_sym, _), _) => {
let valtree = ty::ValTree::from_raw_bytes(tcx, byte_sym.as_byte_str());
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_span/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,9 @@ bitflags::bitflags! {
/// Apply remappings to documentation information
const DOCUMENTATION = 1 << 5;

/// An alias for `macro`, `debuginfo` and `coverage`. This ensures all paths in compiled
/// executables, libraries and objects are remapped but not elsewhere.
const OBJECT = Self::MACRO.bits() | Self::DEBUGINFO.bits() | Self::COVERAGE.bits();
/// An alias for `macro`, `documentation`, `debuginfo` and `coverage`. This ensures all paths in compiled
/// executables, libraries, objects and documentation outputs are remapped but not elsewhere.
const OBJECT = Self::MACRO.bits() | Self::DOCUMENTATION.bits() | Self::DEBUGINFO.bits() | Self::COVERAGE.bits();
}
}

Expand Down
4 changes: 0 additions & 4 deletions compiler/rustc_trait_selection/src/solve/delegate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -494,10 +494,6 @@ impl<'tcx> rustc_next_trait_solver::delegate::SolverDelegate for SolverDelegate<
dst: Ty<'tcx>,
assume: ty::Const<'tcx>,
) -> Result<Answer<Region<'tcx>, Ty<'tcx>>, NoSolution> {
// Erase regions because we compute layouts in `rustc_transmute`,
// which will ICE for region vars.
let (dst, src) = self.tcx.erase_and_anonymize_regions((dst, src));

rustc_transmute::Assume::from_const(self.tcx, assume)
.map(|assume| TransmuteTypeEnv::new(self.0.tcx).is_transmutable(src, dst, assume))
.ok_or(NoSolution)
Expand Down
34 changes: 26 additions & 8 deletions compiler/rustc_traits/src/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use rustc_middle::ty::{self, PseudoCanonicalInput, TyCtxt, TypeVisitableExt};
use rustc_span::bug;
use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
use rustc_trait_selection::traits::{
ImplSource, Obligation, ObligationCause, ObligationCtxt, ScrubbedTraitError, SelectionContext,
SelectionError,
FulfillmentErrorCode, ImplSource, Obligation, ObligationCause, ObligationCtxt,
SelectionContext, SelectionError,
};
use tracing::debug;

Expand Down Expand Up @@ -51,22 +51,40 @@ pub(crate) fn codegen_select_candidate<'tcx>(
// Currently, we use a fulfillment context to completely resolve
// all nested obligations. This is because they can inform the
// inference of the impl's type parameters.
let ocx = ObligationCtxt::new(&infcx);
let ocx = ObligationCtxt::new_with_diagnostics(&infcx);
let impl_source = selection.map(|obligation| {
ocx.register_obligation(obligation);
});

let impl_span = match &impl_source {
ImplSource::UserDefined(source) => Some(tcx.def_span(source.impl_def_id)),
_ => None,
};

// In principle, we only need to do this so long as `impl_source`
// contains unbound type parameters. It could be a slight
// optimization to stop iterating early.
let errors = ocx.evaluate_obligations_error_on_ambiguity();
if !errors.no_errors() {
// `rustc_monomorphize::collector` assumes there are no type errors.
// Cycle errors are the only post-monomorphization errors possible; emit them now so
// `rustc_ty_utils::resolve_associated_item` doesn't return `None` post-monomorphization.
for err in errors {
if let ScrubbedTraitError::Cycle(cycle) = err {
infcx.err_ctxt().report_overflow_obligation_cycle(&cycle);
// Report post-monomorphization overflows here so that `Instance::expect_resolve` doesn't ICE later.
for mut err in errors {
match err.code {
FulfillmentErrorCode::Ambiguity { overflow: Some(suggest_increasing_limit) } => {
if err.obligation.cause.span.is_dummy() {
if let Some(span) = impl_span {
err.obligation.cause.span = span;
}
}

infcx
.err_ctxt()
.report_overflow_obligation(&err.obligation, suggest_increasing_limit);
}
FulfillmentErrorCode::Cycle(cycle) => {
infcx.err_ctxt().report_overflow_obligation_cycle(&cycle);
}
_ => {}
}
}
return Err(CodegenObligationError::Unimplemented);
Expand Down
11 changes: 7 additions & 4 deletions src/ci/docker/host-x86_64/dist-loongarch64-linux/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@ FROM ubuntu:26.04
COPY scripts/cross-apt-packages.sh /scripts/
RUN sh /scripts/cross-apt-packages.sh

RUN curl https://apt.llvm.org/llvm-snapshot.gpg.key | tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc && \
echo 'deb http://apt.llvm.org/resolute/ llvm-toolchain-resolute-23 main' | tee -a /etc/apt/sources.list

RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
clang-22 \
llvm-22 \
lld-22
clang-23 \
llvm-23 \
lld-23

COPY scripts/crosstool-ng-git.sh /scripts/
COPY scripts/crosstool-ng-sha256-20260705.diff /scripts/
Expand All @@ -24,7 +27,7 @@ RUN /scripts/crosstool-ng-build.sh
COPY scripts/sccache.sh /scripts/
RUN sh /scripts/sccache.sh

ENV PATH=/usr/lib/llvm-22/bin:$PATH:/x-tools/loongarch64-unknown-linux-gnu/bin
ENV PATH=/usr/lib/llvm-23/bin:$PATH:/x-tools/loongarch64-unknown-linux-gnu/bin

# --no-rosegment keeps read-only code in the first LOAD segment, matching the
# segment layout produced by GNU ld. This allows Linux to make better use of
Expand Down
11 changes: 7 additions & 4 deletions src/ci/docker/host-x86_64/dist-loongarch64-musl/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@ FROM ubuntu:26.04
COPY scripts/cross-apt-packages.sh /scripts/
RUN sh /scripts/cross-apt-packages.sh

RUN curl https://apt.llvm.org/llvm-snapshot.gpg.key | tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc && \
echo 'deb http://apt.llvm.org/resolute/ llvm-toolchain-resolute-23 main' | tee -a /etc/apt/sources.list

RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
clang-22 \
llvm-22 \
lld-22
clang-23 \
llvm-23 \
lld-23

COPY scripts/crosstool-ng-git.sh /scripts/
COPY scripts/crosstool-ng-sha256-20260705.diff /scripts/
Expand All @@ -24,7 +27,7 @@ RUN /scripts/crosstool-ng-build.sh
COPY scripts/sccache.sh /scripts/
RUN sh /scripts/sccache.sh

ENV PATH=/usr/lib/llvm-22/bin:$PATH:/x-tools/loongarch64-unknown-linux-musl/bin
ENV PATH=/usr/lib/llvm-23/bin:$PATH:/x-tools/loongarch64-unknown-linux-musl/bin

# --no-rosegment keeps read-only code in the first LOAD segment, matching the
# segment layout produced by GNU ld. This allows Linux to make better use of
Expand Down
Loading
Loading