Skip to content

Commit 8a1b399

Browse files
committed
Auto merge of #146614 - Zalathar:rollup-hcxvdi1, r=Zalathar
Rollup of 9 pull requests Successful merges: - #145095 (Migrate `UnsizedConstParamTy` to unstable impl of `ConstParamTy_`) - #145960 (Split `FnCtxt::report_args_error` into subfunctions) - #146402 (interpret: fix overlapping aggregate initialization) - #146466 (llvm-wrapper: other cleanup) - #146574 (compiletest: Enable new-output-capture by default) - #146599 (replace some `#[const_trait]` with `const trait`) - #146601 (compiletest: Make `./x test --test-args ...` work again) - #146608 (improve internal bootstrap docs) - #146609 (bootstrap: lower verbosity of cargo to one less than bootstrap's) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 9d82de1 + f0e8c2f commit 8a1b399

File tree

81 files changed

+2676
-2494
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+2676
-2494
lines changed

compiler/rustc_builtin_macros/src/deriving/bounds.rs

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -51,43 +51,4 @@ pub(crate) fn expand_deriving_const_param_ty(
5151
};
5252

5353
trait_def.expand(cx, mitem, item, push);
54-
55-
let trait_def = TraitDef {
56-
span,
57-
path: path_std!(marker::UnsizedConstParamTy),
58-
skip_path_as_bound: false,
59-
needs_copy_as_bound_if_packed: false,
60-
additional_bounds: vec![ty::Ty::Path(path_std!(cmp::Eq))],
61-
supports_unions: false,
62-
methods: Vec::new(),
63-
associated_types: Vec::new(),
64-
is_const,
65-
is_staged_api_crate: cx.ecfg.features.staged_api(),
66-
};
67-
68-
trait_def.expand(cx, mitem, item, push);
69-
}
70-
71-
pub(crate) fn expand_deriving_unsized_const_param_ty(
72-
cx: &ExtCtxt<'_>,
73-
span: Span,
74-
mitem: &MetaItem,
75-
item: &Annotatable,
76-
push: &mut dyn FnMut(Annotatable),
77-
is_const: bool,
78-
) {
79-
let trait_def = TraitDef {
80-
span,
81-
path: path_std!(marker::UnsizedConstParamTy),
82-
skip_path_as_bound: false,
83-
needs_copy_as_bound_if_packed: false,
84-
additional_bounds: vec![ty::Ty::Path(path_std!(cmp::Eq))],
85-
supports_unions: false,
86-
methods: Vec::new(),
87-
associated_types: Vec::new(),
88-
is_const,
89-
is_staged_api_crate: cx.ecfg.features.staged_api(),
90-
};
91-
92-
trait_def.expand(cx, mitem, item, push);
9354
}

compiler/rustc_builtin_macros/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ pub fn register_builtin_macros(resolver: &mut dyn ResolverExpand) {
129129
Clone: clone::expand_deriving_clone,
130130
Copy: bounds::expand_deriving_copy,
131131
ConstParamTy: bounds::expand_deriving_const_param_ty,
132-
UnsizedConstParamTy: bounds::expand_deriving_unsized_const_param_ty,
133132
Debug: debug::expand_deriving_debug,
134133
Default: default::expand_deriving_default,
135134
Eq: eq::expand_deriving_eq,

compiler/rustc_codegen_ssa/src/mir/rvalue.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use itertools::Itertools as _;
2-
use rustc_abi::{self as abi, FIRST_VARIANT};
2+
use rustc_abi::{self as abi, BackendRepr, FIRST_VARIANT};
33
use rustc_middle::ty::adjustment::PointerCoercion;
44
use rustc_middle::ty::layout::{HasTyCtxt, HasTypingEnv, LayoutOf, TyAndLayout};
55
use rustc_middle::ty::{self, Instance, Ty, TyCtxt};
@@ -25,6 +25,15 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
2525
match *rvalue {
2626
mir::Rvalue::Use(ref operand) => {
2727
let cg_operand = self.codegen_operand(bx, operand);
28+
// Crucially, we do *not* use `OperandValue::Ref` for types with
29+
// `BackendRepr::Scalar | BackendRepr::ScalarPair`. This ensures we match the MIR
30+
// semantics regarding when assignment operators allow overlap of LHS and RHS.
31+
if matches!(
32+
cg_operand.layout.backend_repr,
33+
BackendRepr::Scalar(..) | BackendRepr::ScalarPair(..),
34+
) {
35+
debug_assert!(!matches!(cg_operand.val, OperandValue::Ref(..)));
36+
}
2837
// FIXME: consider not copying constants through stack. (Fixable by codegen'ing
2938
// constants into `OperandValue::Ref`; why don’t we do that yet if we don’t?)
3039
cg_operand.val.store(bx, dest);

compiler/rustc_const_eval/src/interpret/place.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -858,7 +858,7 @@ where
858858
/// Also, if you use this you are responsible for validating that things get copied at the
859859
/// right type.
860860
#[instrument(skip(self), level = "trace")]
861-
fn copy_op_no_validate(
861+
pub(super) fn copy_op_no_validate(
862862
&mut self,
863863
src: &impl Projectable<'tcx, M::Provenance>,
864864
dest: &impl Writeable<'tcx, M::Provenance>,

compiler/rustc_const_eval/src/interpret/step.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,6 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
310310
operands: &IndexSlice<FieldIdx, mir::Operand<'tcx>>,
311311
dest: &PlaceTy<'tcx, M::Provenance>,
312312
) -> InterpResult<'tcx> {
313-
self.write_uninit(dest)?; // make sure all the padding ends up as uninit
314313
let (variant_index, variant_dest, active_field_index) = match *kind {
315314
mir::AggregateKind::Adt(_, variant_index, _, _, active_field_index) => {
316315
let variant_dest = self.project_downcast(dest, variant_index)?;
@@ -346,9 +345,20 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
346345
let field_index = active_field_index.unwrap_or(field_index);
347346
let field_dest = self.project_field(&variant_dest, field_index)?;
348347
let op = self.eval_operand(operand, Some(field_dest.layout))?;
349-
self.copy_op(&op, &field_dest)?;
348+
// We validate manually below so we don't have to do it here.
349+
self.copy_op_no_validate(&op, &field_dest, /*allow_transmute*/ false)?;
350350
}
351-
self.write_discriminant(variant_index, dest)
351+
self.write_discriminant(variant_index, dest)?;
352+
// Validate that the entire thing is valid, and reset padding that might be in between the
353+
// fields.
354+
if M::enforce_validity(self, dest.layout()) {
355+
self.validate_operand(
356+
dest,
357+
M::enforce_validity_recursively(self, dest.layout()),
358+
/*reset_provenance_and_padding*/ true,
359+
)?;
360+
}
361+
interp_ok(())
352362
}
353363

354364
/// Repeats `operand` into the destination. `dest` must have array type, and that type

compiler/rustc_hir/src/lang_items.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,6 @@ language_item_table! {
370370
CoercePointeeValidated, sym::coerce_pointee_validated, coerce_pointee_validated_trait, Target::Trait, GenericRequirement::Exact(0);
371371

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

375374
Poll, sym::Poll, poll, Target::Enum, GenericRequirement::None;
376375
PollReady, sym::Ready, poll_ready_variant, Target::Variant, GenericRequirement::None;

compiler/rustc_hir_analysis/src/check/wfcheck.rs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -819,17 +819,7 @@ fn check_param_wf(tcx: TyCtxt<'_>, param: &ty::GenericParamDef) -> Result<(), Er
819819
let span = tcx.def_span(param.def_id);
820820
let def_id = param.def_id.expect_local();
821821

822-
if tcx.features().unsized_const_params() {
823-
enter_wf_checking_ctxt(tcx, tcx.local_parent(def_id), |wfcx| {
824-
wfcx.register_bound(
825-
ObligationCause::new(span, def_id, ObligationCauseCode::ConstParam(ty)),
826-
wfcx.param_env,
827-
ty,
828-
tcx.require_lang_item(LangItem::UnsizedConstParamTy, span),
829-
);
830-
Ok(())
831-
})
832-
} else if tcx.features().adt_const_params() {
822+
if tcx.features().adt_const_params() {
833823
enter_wf_checking_ctxt(tcx, tcx.local_parent(def_id), |wfcx| {
834824
wfcx.register_bound(
835825
ObligationCause::new(span, def_id, ObligationCauseCode::ConstParam(ty)),
@@ -880,7 +870,6 @@ fn check_param_wf(tcx: TyCtxt<'_>, param: &ty::GenericParamDef) -> Result<(), Er
880870
tcx,
881871
tcx.param_env(param.def_id),
882872
ty,
883-
LangItem::ConstParamTy,
884873
cause,
885874
) {
886875
// Can never implement `ConstParamTy`, don't suggest anything.

compiler/rustc_hir_analysis/src/coherence/builtin.rs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//! Check properties that are required by built-in traits and set
22
//! up data structures required by type-checking/codegen.
33
4-
use std::assert_matches::assert_matches;
54
use std::collections::BTreeMap;
65

76
use rustc_data_structures::fx::FxHashSet;
@@ -40,10 +39,7 @@ pub(super) fn check_trait<'tcx>(
4039
checker.check(lang_items.async_drop_trait(), visit_implementation_of_drop)?;
4140
checker.check(lang_items.copy_trait(), visit_implementation_of_copy)?;
4241
checker.check(lang_items.const_param_ty_trait(), |checker| {
43-
visit_implementation_of_const_param_ty(checker, LangItem::ConstParamTy)
44-
})?;
45-
checker.check(lang_items.unsized_const_param_ty_trait(), |checker| {
46-
visit_implementation_of_const_param_ty(checker, LangItem::UnsizedConstParamTy)
42+
visit_implementation_of_const_param_ty(checker)
4743
})?;
4844
checker.check(lang_items.coerce_unsized_trait(), visit_implementation_of_coerce_unsized)?;
4945
checker
@@ -138,12 +134,7 @@ fn visit_implementation_of_copy(checker: &Checker<'_>) -> Result<(), ErrorGuaran
138134
}
139135
}
140136

141-
fn visit_implementation_of_const_param_ty(
142-
checker: &Checker<'_>,
143-
kind: LangItem,
144-
) -> Result<(), ErrorGuaranteed> {
145-
assert_matches!(kind, LangItem::ConstParamTy | LangItem::UnsizedConstParamTy);
146-
137+
fn visit_implementation_of_const_param_ty(checker: &Checker<'_>) -> Result<(), ErrorGuaranteed> {
147138
let tcx = checker.tcx;
148139
let header = checker.impl_header;
149140
let impl_did = checker.impl_def_id;
@@ -157,7 +148,7 @@ fn visit_implementation_of_const_param_ty(
157148
}
158149

159150
let cause = traits::ObligationCause::misc(DUMMY_SP, impl_did);
160-
match type_allowed_to_implement_const_param_ty(tcx, param_env, self_type, kind, cause) {
151+
match type_allowed_to_implement_const_param_ty(tcx, param_env, self_type, cause) {
161152
Ok(()) => Ok(()),
162153
Err(ConstParamTyImplementationError::InfrigingFields(fields)) => {
163154
let span = tcx.hir_expect_item(impl_did).expect_impl().self_ty.span;

0 commit comments

Comments
 (0)