Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
8ecda4b
interpret: fix overlapping aggregate initialization
RalfJung Sep 10, 2025
7222506
clarify current MIR semantics re: overlapping assignment
RalfJung Sep 10, 2025
0e5281c
remove unused macro
klensy Sep 11, 2025
acb3503
remove unused getLongestEntryLength
klensy Sep 11, 2025
dbfa01b
remove outdated jsbackend leftovers
klensy Sep 12, 2025
96f8dbe
compiletest: Enable new-output-capture by default
Zalathar Sep 15, 2025
b919a5f
Remove UnsizedConstParamTy trait and make it into an unstable impl
tiif Sep 15, 2025
1a02cd5
Add check to make sure ConstParamTy impls of certain types are gated …
tiif Sep 15, 2025
0bd2ee3
Fix the testcases to not use UnsizedConstParamTy
tiif Sep 15, 2025
1c30399
Add documentation for select_where_possible and select_all_or_error
tiif Sep 15, 2025
7299e8f
Fix feature gate tests
tiif Sep 15, 2025
9cbf1a5
Split `FnCtxt::report_args_error` into subfunctions
scrabsha Aug 23, 2025
2d76bb1
replace some `#[const_trait]` with `const trait`
npmccallum Sep 12, 2025
bf73aac
compiletest: Make `./x test --test-args ...` work again
Enselic Sep 15, 2025
b8cb80c
improve internal bootstrap docs
lolbinarycat Sep 15, 2025
29ca09b
bootstrap: lower verbosity of cargo to one less than bootstrap's
lolbinarycat Sep 15, 2025
edd6721
Rollup merge of #145095 - tiif:unstable_const_param, r=BoxyUwU
Zalathar Sep 16, 2025
85249d5
Rollup merge of #145960 - scrabsha:push-kskuprrtmnky, r=jdonszelmann
Zalathar Sep 16, 2025
f162d11
Rollup merge of #146402 - RalfJung:aggregate-init, r=saethlin
Zalathar Sep 16, 2025
9eaf3c8
Rollup merge of #146466 - klensy:llvm-wrapper-c, r=cuviper
Zalathar Sep 16, 2025
336e45e
Rollup merge of #146574 - Zalathar:capture, r=jieyouxu
Zalathar Sep 16, 2025
f3c395b
Rollup merge of #146599 - npmccallum:cleanup, r=fmease
Zalathar Sep 16, 2025
7cad097
Rollup merge of #146601 - Enselic:fix-test-args, r=Mark-Simulacrum
Zalathar Sep 16, 2025
cc315a8
Rollup merge of #146608 - lolbinarycat:bootstrap-readme, r=Kobzol
Zalathar Sep 16, 2025
f0e8c2f
Rollup merge of #146609 - lolbinarycat:bootstrap-less-verbose-cargo, …
Zalathar Sep 16, 2025
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
39 changes: 0 additions & 39 deletions compiler/rustc_builtin_macros/src/deriving/bounds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,43 +51,4 @@ pub(crate) fn expand_deriving_const_param_ty(
};

trait_def.expand(cx, mitem, item, push);

let trait_def = TraitDef {
span,
path: path_std!(marker::UnsizedConstParamTy),
skip_path_as_bound: false,
needs_copy_as_bound_if_packed: false,
additional_bounds: vec![ty::Ty::Path(path_std!(cmp::Eq))],
supports_unions: false,
methods: Vec::new(),
associated_types: Vec::new(),
is_const,
is_staged_api_crate: cx.ecfg.features.staged_api(),
};

trait_def.expand(cx, mitem, item, push);
}

pub(crate) fn expand_deriving_unsized_const_param_ty(
cx: &ExtCtxt<'_>,
span: Span,
mitem: &MetaItem,
item: &Annotatable,
push: &mut dyn FnMut(Annotatable),
is_const: bool,
) {
let trait_def = TraitDef {
span,
path: path_std!(marker::UnsizedConstParamTy),
skip_path_as_bound: false,
needs_copy_as_bound_if_packed: false,
additional_bounds: vec![ty::Ty::Path(path_std!(cmp::Eq))],
supports_unions: false,
methods: Vec::new(),
associated_types: Vec::new(),
is_const,
is_staged_api_crate: cx.ecfg.features.staged_api(),
};

trait_def.expand(cx, mitem, item, push);
}
1 change: 0 additions & 1 deletion compiler/rustc_builtin_macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ pub fn register_builtin_macros(resolver: &mut dyn ResolverExpand) {
Clone: clone::expand_deriving_clone,
Copy: bounds::expand_deriving_copy,
ConstParamTy: bounds::expand_deriving_const_param_ty,
UnsizedConstParamTy: bounds::expand_deriving_unsized_const_param_ty,
Debug: debug::expand_deriving_debug,
Default: default::expand_deriving_default,
Eq: eq::expand_deriving_eq,
Expand Down
11 changes: 10 additions & 1 deletion compiler/rustc_codegen_ssa/src/mir/rvalue.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use itertools::Itertools as _;
use rustc_abi::{self as abi, FIRST_VARIANT};
use rustc_abi::{self as abi, BackendRepr, FIRST_VARIANT};
use rustc_middle::ty::adjustment::PointerCoercion;
use rustc_middle::ty::layout::{HasTyCtxt, HasTypingEnv, LayoutOf, TyAndLayout};
use rustc_middle::ty::{self, Instance, Ty, TyCtxt};
Expand All @@ -25,6 +25,15 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
match *rvalue {
mir::Rvalue::Use(ref operand) => {
let cg_operand = self.codegen_operand(bx, operand);
// Crucially, we do *not* use `OperandValue::Ref` for types with
// `BackendRepr::Scalar | BackendRepr::ScalarPair`. This ensures we match the MIR
// semantics regarding when assignment operators allow overlap of LHS and RHS.
if matches!(
cg_operand.layout.backend_repr,
BackendRepr::Scalar(..) | BackendRepr::ScalarPair(..),
) {
debug_assert!(!matches!(cg_operand.val, OperandValue::Ref(..)));
}
// FIXME: consider not copying constants through stack. (Fixable by codegen'ing
// constants into `OperandValue::Ref`; why don’t we do that yet if we don’t?)
cg_operand.val.store(bx, dest);
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_const_eval/src/interpret/place.rs
Original file line number Diff line number Diff line change
Expand Up @@ -858,7 +858,7 @@ where
/// Also, if you use this you are responsible for validating that things get copied at the
/// right type.
#[instrument(skip(self), level = "trace")]
fn copy_op_no_validate(
pub(super) fn copy_op_no_validate(
&mut self,
src: &impl Projectable<'tcx, M::Provenance>,
dest: &impl Writeable<'tcx, M::Provenance>,
Expand Down
16 changes: 13 additions & 3 deletions compiler/rustc_const_eval/src/interpret/step.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,6 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
operands: &IndexSlice<FieldIdx, mir::Operand<'tcx>>,
dest: &PlaceTy<'tcx, M::Provenance>,
) -> InterpResult<'tcx> {
self.write_uninit(dest)?; // make sure all the padding ends up as uninit
let (variant_index, variant_dest, active_field_index) = match *kind {
mir::AggregateKind::Adt(_, variant_index, _, _, active_field_index) => {
let variant_dest = self.project_downcast(dest, variant_index)?;
Expand Down Expand Up @@ -346,9 +345,20 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
let field_index = active_field_index.unwrap_or(field_index);
let field_dest = self.project_field(&variant_dest, field_index)?;
let op = self.eval_operand(operand, Some(field_dest.layout))?;
self.copy_op(&op, &field_dest)?;
// We validate manually below so we don't have to do it here.
self.copy_op_no_validate(&op, &field_dest, /*allow_transmute*/ false)?;
}
self.write_discriminant(variant_index, dest)
self.write_discriminant(variant_index, dest)?;
// Validate that the entire thing is valid, and reset padding that might be in between the
// fields.
if M::enforce_validity(self, dest.layout()) {
self.validate_operand(
dest,
M::enforce_validity_recursively(self, dest.layout()),
/*reset_provenance_and_padding*/ true,
)?;
}
interp_ok(())
}

/// Repeats `operand` into the destination. `dest` must have array type, and that type
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_hir/src/lang_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,6 @@ language_item_table! {
CoercePointeeValidated, sym::coerce_pointee_validated, coerce_pointee_validated_trait, Target::Trait, GenericRequirement::Exact(0);

ConstParamTy, sym::const_param_ty, const_param_ty_trait, Target::Trait, GenericRequirement::Exact(0);
UnsizedConstParamTy, sym::unsized_const_param_ty, unsized_const_param_ty_trait, Target::Trait, GenericRequirement::Exact(0);

Poll, sym::Poll, poll, Target::Enum, GenericRequirement::None;
PollReady, sym::Ready, poll_ready_variant, Target::Variant, GenericRequirement::None;
Expand Down
13 changes: 1 addition & 12 deletions compiler/rustc_hir_analysis/src/check/wfcheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -819,17 +819,7 @@ fn check_param_wf(tcx: TyCtxt<'_>, param: &ty::GenericParamDef) -> Result<(), Er
let span = tcx.def_span(param.def_id);
let def_id = param.def_id.expect_local();

if tcx.features().unsized_const_params() {
enter_wf_checking_ctxt(tcx, tcx.local_parent(def_id), |wfcx| {
wfcx.register_bound(
ObligationCause::new(span, def_id, ObligationCauseCode::ConstParam(ty)),
wfcx.param_env,
ty,
tcx.require_lang_item(LangItem::UnsizedConstParamTy, span),
);
Ok(())
})
} else if tcx.features().adt_const_params() {
if tcx.features().adt_const_params() {
enter_wf_checking_ctxt(tcx, tcx.local_parent(def_id), |wfcx| {
wfcx.register_bound(
ObligationCause::new(span, def_id, ObligationCauseCode::ConstParam(ty)),
Expand Down Expand Up @@ -880,7 +870,6 @@ fn check_param_wf(tcx: TyCtxt<'_>, param: &ty::GenericParamDef) -> Result<(), Er
tcx,
tcx.param_env(param.def_id),
ty,
LangItem::ConstParamTy,
cause,
) {
// Can never implement `ConstParamTy`, don't suggest anything.
Expand Down
15 changes: 3 additions & 12 deletions compiler/rustc_hir_analysis/src/coherence/builtin.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//! Check properties that are required by built-in traits and set
//! up data structures required by type-checking/codegen.

use std::assert_matches::assert_matches;
use std::collections::BTreeMap;

use rustc_data_structures::fx::FxHashSet;
Expand Down Expand Up @@ -40,10 +39,7 @@ pub(super) fn check_trait<'tcx>(
checker.check(lang_items.async_drop_trait(), visit_implementation_of_drop)?;
checker.check(lang_items.copy_trait(), visit_implementation_of_copy)?;
checker.check(lang_items.const_param_ty_trait(), |checker| {
visit_implementation_of_const_param_ty(checker, LangItem::ConstParamTy)
})?;
checker.check(lang_items.unsized_const_param_ty_trait(), |checker| {
visit_implementation_of_const_param_ty(checker, LangItem::UnsizedConstParamTy)
visit_implementation_of_const_param_ty(checker)
})?;
checker.check(lang_items.coerce_unsized_trait(), visit_implementation_of_coerce_unsized)?;
checker
Expand Down Expand Up @@ -138,12 +134,7 @@ fn visit_implementation_of_copy(checker: &Checker<'_>) -> Result<(), ErrorGuaran
}
}

fn visit_implementation_of_const_param_ty(
checker: &Checker<'_>,
kind: LangItem,
) -> Result<(), ErrorGuaranteed> {
assert_matches!(kind, LangItem::ConstParamTy | LangItem::UnsizedConstParamTy);

fn visit_implementation_of_const_param_ty(checker: &Checker<'_>) -> Result<(), ErrorGuaranteed> {
let tcx = checker.tcx;
let header = checker.impl_header;
let impl_did = checker.impl_def_id;
Expand All @@ -157,7 +148,7 @@ fn visit_implementation_of_const_param_ty(
}

let cause = traits::ObligationCause::misc(DUMMY_SP, impl_did);
match type_allowed_to_implement_const_param_ty(tcx, param_env, self_type, kind, cause) {
match type_allowed_to_implement_const_param_ty(tcx, param_env, self_type, cause) {
Ok(()) => Ok(()),
Err(ConstParamTyImplementationError::InfrigingFields(fields)) => {
let span = tcx.hir_expect_item(impl_did).expect_impl().self_ty.span;
Expand Down
Loading
Loading