Skip to content

Commit 4d4c5d0

Browse files
committed
Auto merge of rust-lang#116025 - GuillaumeGomez:rollup-4z7tlho, r=GuillaumeGomez
Rollup of 5 pull requests Successful merges: - rust-lang#104385 (Raise minimum supported Apple OS versions) - rust-lang#115936 (Prevent promotion of const fn calls in inline consts) - rust-lang#115972 (rename mir::Constant -> mir::ConstOperand, mir::ConstKind -> mir::Const) - rust-lang#116007 (Call panic_display directly in const_panic_fmt.) - rust-lang#116019 (Delete obsolete `--disable-per-crate-search` rustdoc flag) r? `@ghost` `@rustbot` modify labels: rollup
2 parents e4a361a + 9e683f7 commit 4d4c5d0

File tree

111 files changed

+573
-625
lines changed

Some content is hidden

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

111 files changed

+573
-625
lines changed

.github/workflows/ci.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ jobs:
305305
SCRIPT: "./x.py dist bootstrap --include-default-paths --host=x86_64-apple-darwin --target=x86_64-apple-darwin"
306306
RUST_CONFIGURE_ARGS: "--enable-full-tools --enable-sanitizers --enable-profiler --set rust.jemalloc --set llvm.ninja=false --set rust.lto=thin"
307307
RUSTC_RETRY_LINKER_ON_SEGFAULT: 1
308-
MACOSX_DEPLOYMENT_TARGET: 10.7
308+
MACOSX_DEPLOYMENT_TARGET: 10.12
309309
SELECT_XCODE: /Applications/Xcode_13.4.1.app
310310
NO_LLVM_ASSERTIONS: 1
311311
NO_DEBUG_ASSERTIONS: 1
@@ -317,7 +317,7 @@ jobs:
317317
SCRIPT: "./x.py dist bootstrap --include-default-paths --host='' --target=aarch64-apple-ios,x86_64-apple-ios,aarch64-apple-ios-sim"
318318
RUST_CONFIGURE_ARGS: "--enable-sanitizers --enable-profiler --set rust.jemalloc --set llvm.ninja=false"
319319
RUSTC_RETRY_LINKER_ON_SEGFAULT: 1
320-
MACOSX_DEPLOYMENT_TARGET: 10.7
320+
MACOSX_DEPLOYMENT_TARGET: 10.12
321321
SELECT_XCODE: /Applications/Xcode_13.4.1.app
322322
NO_LLVM_ASSERTIONS: 1
323323
NO_DEBUG_ASSERTIONS: 1
@@ -328,8 +328,8 @@ jobs:
328328
SCRIPT: "./x.py --stage 2 test --skip tests/ui --skip tests/rustdoc --skip tests/run-make-fulldeps"
329329
RUST_CONFIGURE_ARGS: "--build=x86_64-apple-darwin --enable-sanitizers --enable-profiler --set rust.jemalloc --set llvm.ninja=false"
330330
RUSTC_RETRY_LINKER_ON_SEGFAULT: 1
331-
MACOSX_DEPLOYMENT_TARGET: 10.8
332-
MACOSX_STD_DEPLOYMENT_TARGET: 10.7
331+
MACOSX_DEPLOYMENT_TARGET: 10.12
332+
MACOSX_STD_DEPLOYMENT_TARGET: 10.12
333333
NO_LLVM_ASSERTIONS: 1
334334
NO_DEBUG_ASSERTIONS: 1
335335
NO_OVERFLOW_CHECKS: 1
@@ -339,8 +339,8 @@ jobs:
339339
SCRIPT: "./x.py --stage 2 test tests/ui tests/rustdoc tests/run-make-fulldeps"
340340
RUST_CONFIGURE_ARGS: "--build=x86_64-apple-darwin --enable-sanitizers --enable-profiler --set rust.jemalloc --set llvm.ninja=false"
341341
RUSTC_RETRY_LINKER_ON_SEGFAULT: 1
342-
MACOSX_DEPLOYMENT_TARGET: 10.8
343-
MACOSX_STD_DEPLOYMENT_TARGET: 10.7
342+
MACOSX_DEPLOYMENT_TARGET: 10.12
343+
MACOSX_STD_DEPLOYMENT_TARGET: 10.12
344344
NO_LLVM_ASSERTIONS: 1
345345
NO_DEBUG_ASSERTIONS: 1
346346
NO_OVERFLOW_CHECKS: 1

compiler/rustc_borrowck/src/diagnostics/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use rustc_index::IndexSlice;
1313
use rustc_infer::infer::LateBoundRegionConversionTime;
1414
use rustc_middle::mir::tcx::PlaceTy;
1515
use rustc_middle::mir::{
16-
AggregateKind, CallSource, Constant, FakeReadCause, Local, LocalInfo, LocalKind, Location,
16+
AggregateKind, CallSource, ConstOperand, FakeReadCause, Local, LocalInfo, LocalKind, Location,
1717
Operand, Place, PlaceRef, ProjectionElem, Rvalue, Statement, StatementKind, Terminator,
1818
TerminatorKind,
1919
};
@@ -101,12 +101,12 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
101101
let terminator = self.body[location.block].terminator();
102102
debug!("add_moved_or_invoked_closure_note: terminator={:?}", terminator);
103103
if let TerminatorKind::Call {
104-
func: Operand::Constant(box Constant { literal, .. }),
104+
func: Operand::Constant(box ConstOperand { const_, .. }),
105105
args,
106106
..
107107
} = &terminator.kind
108108
{
109-
if let ty::FnDef(id, _) = *literal.ty().kind() {
109+
if let ty::FnDef(id, _) = *const_.ty().kind() {
110110
debug!("add_moved_or_invoked_closure_note: id={:?}", id);
111111
if Some(self.infcx.tcx.parent(id)) == self.infcx.tcx.lang_items().fn_once_trait() {
112112
let closure = match args.first() {

compiler/rustc_borrowck/src/renumber.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ use crate::BorrowckInferCtxt;
44
use rustc_index::IndexSlice;
55
use rustc_infer::infer::NllRegionVariableOrigin;
66
use rustc_middle::mir::visit::{MutVisitor, TyContext};
7-
use rustc_middle::mir::Constant;
8-
use rustc_middle::mir::{Body, Location, Promoted};
7+
use rustc_middle::mir::{Body, ConstOperand, Location, Promoted};
98
use rustc_middle::ty::GenericArgsRef;
109
use rustc_middle::ty::{self, Ty, TyCtxt, TypeFoldable};
1110
use rustc_span::{Span, Symbol};
@@ -117,9 +116,9 @@ impl<'a, 'tcx> MutVisitor<'tcx> for RegionRenumberer<'a, 'tcx> {
117116
}
118117

119118
#[instrument(skip(self), level = "debug")]
120-
fn visit_constant(&mut self, constant: &mut Constant<'tcx>, location: Location) {
121-
let literal = constant.literal;
122-
constant.literal = self.renumber_regions(literal, || RegionCtxt::Location(location));
119+
fn visit_constant(&mut self, constant: &mut ConstOperand<'tcx>, location: Location) {
120+
let const_ = constant.const_;
121+
constant.const_ = self.renumber_regions(const_, || RegionCtxt::Location(location));
123122
debug!("constant: {:#?}", constant);
124123
}
125124
}

compiler/rustc_borrowck/src/type_check/mod.rs

+14-14
Original file line numberDiff line numberDiff line change
@@ -302,11 +302,11 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
302302
self.sanitize_place(place, location, context);
303303
}
304304

305-
fn visit_constant(&mut self, constant: &Constant<'tcx>, location: Location) {
305+
fn visit_constant(&mut self, constant: &ConstOperand<'tcx>, location: Location) {
306306
debug!(?constant, ?location, "visit_constant");
307307

308308
self.super_constant(constant, location);
309-
let ty = self.sanitize_type(constant, constant.literal.ty());
309+
let ty = self.sanitize_type(constant, constant.const_.ty());
310310

311311
self.cx.infcx.tcx.for_each_free_region(&ty, |live_region| {
312312
let live_region_vid =
@@ -328,7 +328,7 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
328328

329329
if let Some(annotation_index) = constant.user_ty {
330330
if let Err(terr) = self.cx.relate_type_and_user_type(
331-
constant.literal.ty(),
331+
constant.const_.ty(),
332332
ty::Variance::Invariant,
333333
&UserTypeProjection { base: annotation_index, projs: vec![] },
334334
locations,
@@ -340,20 +340,20 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
340340
constant,
341341
"bad constant user type {:?} vs {:?}: {:?}",
342342
annotation,
343-
constant.literal.ty(),
343+
constant.const_.ty(),
344344
terr,
345345
);
346346
}
347347
} else {
348348
let tcx = self.tcx();
349-
let maybe_uneval = match constant.literal {
350-
ConstantKind::Ty(ct) => match ct.kind() {
349+
let maybe_uneval = match constant.const_ {
350+
Const::Ty(ct) => match ct.kind() {
351351
ty::ConstKind::Unevaluated(_) => {
352-
bug!("should not encounter unevaluated ConstantKind::Ty here, got {:?}", ct)
352+
bug!("should not encounter unevaluated Const::Ty here, got {:?}", ct)
353353
}
354354
_ => None,
355355
},
356-
ConstantKind::Unevaluated(uv, _) => Some(uv),
356+
Const::Unevaluated(uv, _) => Some(uv),
357357
_ => None,
358358
};
359359

@@ -384,15 +384,15 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
384384
check_err(self, promoted_body, ty, promoted_ty);
385385
} else {
386386
self.cx.ascribe_user_type(
387-
constant.literal.ty(),
387+
constant.const_.ty(),
388388
UserType::TypeOf(uv.def, UserArgs { args: uv.args, user_self_ty: None }),
389389
locations.span(&self.cx.body),
390390
);
391391
}
392392
} else if let Some(static_def_id) = constant.check_static_ptr(tcx) {
393393
let unnormalized_ty = tcx.type_of(static_def_id).instantiate_identity();
394394
let normalized_ty = self.cx.normalize(unnormalized_ty, locations);
395-
let literal_ty = constant.literal.ty().builtin_deref(true).unwrap().ty;
395+
let literal_ty = constant.const_.ty().builtin_deref(true).unwrap().ty;
396396

397397
if let Err(terr) = self.cx.eq_types(
398398
literal_ty,
@@ -404,7 +404,7 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
404404
}
405405
}
406406

407-
if let ty::FnDef(def_id, args) = *constant.literal.ty().kind() {
407+
if let ty::FnDef(def_id, args) = *constant.const_.ty().kind() {
408408
let instantiated_predicates = tcx.predicates_of(def_id).instantiate(tcx, args);
409409
self.cx.normalize_and_prove_instantiated_predicates(
410410
def_id,
@@ -1801,9 +1801,9 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
18011801
debug!(?op, ?location, "check_operand");
18021802

18031803
if let Operand::Constant(constant) = op {
1804-
let maybe_uneval = match constant.literal {
1805-
ConstantKind::Val(..) | ConstantKind::Ty(_) => None,
1806-
ConstantKind::Unevaluated(uv, _) => Some(uv),
1804+
let maybe_uneval = match constant.const_ {
1805+
Const::Val(..) | Const::Ty(_) => None,
1806+
Const::Unevaluated(uv, _) => Some(uv),
18071807
};
18081808

18091809
if let Some(uv) = maybe_uneval {

compiler/rustc_borrowck/src/universal_regions.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
580580
}
581581
}
582582

583-
BodyOwnerKind::Const | BodyOwnerKind::Static(..) => {
583+
BodyOwnerKind::Const { .. } | BodyOwnerKind::Static(..) => {
584584
let identity_args = GenericArgs::identity_for_item(tcx, typeck_root_def_id);
585585
if self.mir_def.to_def_id() == typeck_root_def_id {
586586
let args =

compiler/rustc_codegen_cranelift/src/constant.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ pub(crate) fn codegen_tls_ref<'tcx>(
6464

6565
pub(crate) fn eval_mir_constant<'tcx>(
6666
fx: &FunctionCx<'_, '_, 'tcx>,
67-
constant: &Constant<'tcx>,
67+
constant: &ConstOperand<'tcx>,
6868
) -> (ConstValue<'tcx>, Ty<'tcx>) {
69-
let cv = fx.monomorphize(constant.literal);
69+
let cv = fx.monomorphize(constant.const_);
7070
// This cannot fail because we checked all required_consts in advance.
7171
let val = cv
7272
.eval(fx.tcx, ty::ParamEnv::reveal_all(), Some(constant.span))
@@ -76,7 +76,7 @@ pub(crate) fn eval_mir_constant<'tcx>(
7676

7777
pub(crate) fn codegen_constant_operand<'tcx>(
7878
fx: &mut FunctionCx<'_, '_, 'tcx>,
79-
constant: &Constant<'tcx>,
79+
constant: &ConstOperand<'tcx>,
8080
) -> CValue<'tcx> {
8181
let (const_val, ty) = eval_mir_constant(fx, constant);
8282
codegen_const_value(fx, const_val, ty)

compiler/rustc_codegen_cranelift/src/inline_asm.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,8 @@ pub(crate) fn codegen_inline_asm<'tcx>(
252252
CInlineAsmOperand::Const { value }
253253
}
254254
InlineAsmOperand::SymFn { ref value } => {
255-
let literal = fx.monomorphize(value.literal);
256-
if let ty::FnDef(def_id, args) = *literal.ty().kind() {
255+
let const_ = fx.monomorphize(value.const_);
256+
if let ty::FnDef(def_id, args) = *const_.ty().kind() {
257257
let instance = ty::Instance::resolve_for_fn_ptr(
258258
fx.tcx,
259259
ty::ParamEnv::reveal_all(),

compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -660,12 +660,12 @@ fn push_const_param<'tcx>(tcx: TyCtxt<'tcx>, ct: ty::Const<'tcx>, output: &mut S
660660
}
661661
_ => match ct.ty().kind() {
662662
ty::Int(ity) => {
663-
let bits = ct.eval_bits(tcx, ty::ParamEnv::reveal_all(), ct.ty());
663+
let bits = ct.eval_bits(tcx, ty::ParamEnv::reveal_all());
664664
let val = Integer::from_int_ty(&tcx, *ity).size().sign_extend(bits) as i128;
665665
write!(output, "{val}")
666666
}
667667
ty::Uint(_) => {
668-
let val = ct.eval_bits(tcx, ty::ParamEnv::reveal_all(), ct.ty());
668+
let val = ct.eval_bits(tcx, ty::ParamEnv::reveal_all());
669669
write!(output, "{val}")
670670
}
671671
ty::Bool => {

compiler/rustc_codegen_ssa/src/mir/block.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1098,8 +1098,8 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
10981098
InlineAsmOperandRef::Const { string }
10991099
}
11001100
mir::InlineAsmOperand::SymFn { ref value } => {
1101-
let literal = self.monomorphize(value.literal);
1102-
if let ty::FnDef(def_id, args) = *literal.ty().kind() {
1101+
let const_ = self.monomorphize(value.const_);
1102+
if let ty::FnDef(def_id, args) = *const_.ty().kind() {
11031103
let instance = ty::Instance::resolve_for_fn_ptr(
11041104
bx.tcx(),
11051105
ty::ParamEnv::reveal_all(),

compiler/rustc_codegen_ssa/src/mir/constant.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -13,37 +13,37 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
1313
pub fn eval_mir_constant_to_operand(
1414
&self,
1515
bx: &mut Bx,
16-
constant: &mir::Constant<'tcx>,
16+
constant: &mir::ConstOperand<'tcx>,
1717
) -> OperandRef<'tcx, Bx::Value> {
1818
let val = self.eval_mir_constant(constant);
1919
let ty = self.monomorphize(constant.ty());
2020
OperandRef::from_const(bx, val, ty)
2121
}
2222

23-
pub fn eval_mir_constant(&self, constant: &mir::Constant<'tcx>) -> mir::ConstValue<'tcx> {
24-
self.monomorphize(constant.literal)
23+
pub fn eval_mir_constant(&self, constant: &mir::ConstOperand<'tcx>) -> mir::ConstValue<'tcx> {
24+
self.monomorphize(constant.const_)
2525
.eval(self.cx.tcx(), ty::ParamEnv::reveal_all(), Some(constant.span))
2626
.expect("erroneous constant not captured by required_consts")
2727
}
2828

2929
/// This is a convenience helper for `simd_shuffle_indices`. It has the precondition
30-
/// that the given `constant` is an `ConstantKind::Unevaluated` and must be convertible to
30+
/// that the given `constant` is an `Const::Unevaluated` and must be convertible to
3131
/// a `ValTree`. If you want a more general version of this, talk to `wg-const-eval` on zulip.
3232
///
3333
/// Note that this function is cursed, since usually MIR consts should not be evaluated to valtrees!
3434
pub fn eval_unevaluated_mir_constant_to_valtree(
3535
&self,
36-
constant: &mir::Constant<'tcx>,
36+
constant: &mir::ConstOperand<'tcx>,
3737
) -> Result<Option<ty::ValTree<'tcx>>, ErrorHandled> {
38-
let uv = match self.monomorphize(constant.literal) {
39-
mir::ConstantKind::Unevaluated(uv, _) => uv.shrink(),
40-
mir::ConstantKind::Ty(c) => match c.kind() {
38+
let uv = match self.monomorphize(constant.const_) {
39+
mir::Const::Unevaluated(uv, _) => uv.shrink(),
40+
mir::Const::Ty(c) => match c.kind() {
4141
// A constant that came from a const generic but was then used as an argument to old-style
4242
// simd_shuffle (passing as argument instead of as a generic param).
4343
rustc_type_ir::ConstKind::Value(valtree) => return Ok(Some(valtree)),
4444
other => span_bug!(constant.span, "{other:#?}"),
4545
},
46-
// We should never encounter `ConstantKind::Val` unless MIR opts (like const prop) evaluate
46+
// We should never encounter `Const::Val` unless MIR opts (like const prop) evaluate
4747
// a constant and write that value back into `Operand`s. This could happen, but is unlikely.
4848
// Also: all users of `simd_shuffle` are on unstable and already need to take a lot of care
4949
// around intrinsics. For an issue to happen here, it would require a macro expanding to a
@@ -65,7 +65,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
6565
pub fn simd_shuffle_indices(
6666
&mut self,
6767
bx: &Bx,
68-
constant: &mir::Constant<'tcx>,
68+
constant: &mir::ConstOperand<'tcx>,
6969
) -> (Bx::Value, Ty<'tcx>) {
7070
let ty = self.monomorphize(constant.ty());
7171
let val = self

compiler/rustc_const_eval/src/interpret/eval_context.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1089,7 +1089,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
10891089

10901090
pub fn eval_mir_constant(
10911091
&self,
1092-
val: &mir::ConstantKind<'tcx>,
1092+
val: &mir::Const<'tcx>,
10931093
span: Option<Span>,
10941094
layout: Option<TyAndLayout<'tcx>>,
10951095
) -> InterpResult<'tcx, OpTy<'tcx, M::Provenance>> {

compiler/rustc_const_eval/src/interpret/operand.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
692692

693693
Constant(constant) => {
694694
let c =
695-
self.subst_from_current_frame_and_normalize_erasing_regions(constant.literal)?;
695+
self.subst_from_current_frame_and_normalize_erasing_regions(constant.const_)?;
696696

697697
// This can still fail:
698698
// * During ConstProp, with `TooGeneric` or since the `required_consts` were not all

compiler/rustc_const_eval/src/transform/check_consts/check.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ impl<'mir, 'tcx> Qualifs<'mir, 'tcx> {
167167
false
168168
}
169169

170-
hir::ConstContext::Const | hir::ConstContext::Static(_) => {
170+
hir::ConstContext::Const { .. } | hir::ConstContext::Static(_) => {
171171
let mut cursor = FlowSensitiveAnalysis::new(CustomEq, ccx)
172172
.into_engine(ccx.tcx, &ccx.body)
173173
.iterate_to_fixpoint()

compiler/rustc_const_eval/src/transform/check_consts/qualifs.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -346,20 +346,20 @@ where
346346
};
347347

348348
// Check the qualifs of the value of `const` items.
349-
let uneval = match constant.literal {
350-
ConstantKind::Ty(ct)
349+
let uneval = match constant.const_ {
350+
Const::Ty(ct)
351351
if matches!(
352352
ct.kind(),
353353
ty::ConstKind::Param(_) | ty::ConstKind::Error(_) | ty::ConstKind::Value(_)
354354
) =>
355355
{
356356
None
357357
}
358-
ConstantKind::Ty(c) => {
358+
Const::Ty(c) => {
359359
bug!("expected ConstKind::Param or ConstKind::Value here, found {:?}", c)
360360
}
361-
ConstantKind::Unevaluated(uv, _) => Some(uv),
362-
ConstantKind::Val(..) => None,
361+
Const::Unevaluated(uv, _) => Some(uv),
362+
Const::Val(..) => None,
363363
};
364364

365365
if let Some(mir::UnevaluatedConst { def, args: _, promoted }) = uneval {
@@ -383,5 +383,5 @@ where
383383
}
384384

385385
// Otherwise use the qualifs of the type.
386-
Q::in_any_value_of_ty(cx, constant.literal.ty())
386+
Q::in_any_value_of_ty(cx, constant.const_.ty())
387387
}

0 commit comments

Comments
 (0)