Skip to content

Commit d2df620

Browse files
committed
Auto merge of #85110 - RalfJung:no-rustc_args_required_const, r=oli-obk
Remove rustc_args_required_const attribute Now that stdarch no longer needs it (thanks `@Amanieu!),` we can kill the `rustc_args_required_const` attribute. This means that lifetime extension of references to temporaries is the only remaining job that promotion is performing. :-) r? `@oli-obk` Fixes #69493
2 parents 17b60b8 + c61e8fa commit d2df620

33 files changed

+107
-609
lines changed

compiler/rustc_codegen_ssa/src/mir/rvalue.rs

-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ use rustc_middle::ty::cast::{CastTy, IntTy};
1414
use rustc_middle::ty::layout::HasTyCtxt;
1515
use rustc_middle::ty::{self, adjustment::PointerCast, Instance, Ty, TyCtxt};
1616
use rustc_span::source_map::{Span, DUMMY_SP};
17-
use rustc_span::symbol::sym;
1817
use rustc_target::abi::{Abi, Int, LayoutOf, Variants};
1918

2019
impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
@@ -187,9 +186,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
187186
mir::CastKind::Pointer(PointerCast::ReifyFnPointer) => {
188187
match *operand.layout.ty.kind() {
189188
ty::FnDef(def_id, substs) => {
190-
if bx.cx().tcx().has_attr(def_id, sym::rustc_args_required_const) {
191-
bug!("reifying a fn ptr that requires const arguments");
192-
}
193189
let instance = ty::Instance::resolve_for_fn_ptr(
194190
bx.tcx(),
195191
ty::ParamEnv::reveal_all(),

compiler/rustc_feature/src/builtin_attrs.rs

-1
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,6 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
469469
// ==========================================================================
470470

471471
rustc_attr!(rustc_promotable, AssumedUsed, template!(Word), IMPL_DETAIL),
472-
rustc_attr!(rustc_args_required_const, AssumedUsed, template!(List: "N"), INTERNAL_UNSTABLE),
473472
rustc_attr!(rustc_legacy_const_generics, AssumedUsed, template!(List: "N"), INTERNAL_UNSTABLE),
474473

475474
// ==========================================================================

compiler/rustc_mir/src/interpret/cast.rs

-8
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use rustc_middle::mir::CastKind;
77
use rustc_middle::ty::adjustment::PointerCast;
88
use rustc_middle::ty::layout::{IntegerExt, TyAndLayout};
99
use rustc_middle::ty::{self, FloatTy, Ty, TypeAndMut};
10-
use rustc_span::symbol::sym;
1110
use rustc_target::abi::{Integer, LayoutOf, Variants};
1211

1312
use super::{
@@ -49,13 +48,6 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
4948
// All reifications must be monomorphic, bail out otherwise.
5049
ensure_monomorphic_enough(*self.tcx, src.layout.ty)?;
5150

52-
if self.tcx.has_attr(def_id, sym::rustc_args_required_const) {
53-
span_bug!(
54-
self.cur_span(),
55-
"reifying a fn ptr that requires const arguments"
56-
);
57-
}
58-
5951
let instance = ty::Instance::resolve_for_fn_ptr(
6052
*self.tcx,
6153
self.param_env,

compiler/rustc_mir/src/interpret/intern.rs

-1
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,6 @@ where
305305
let base_intern_mode = match intern_kind {
306306
InternKind::Static(mutbl) => InternMode::Static(mutbl),
307307
// `Constant` includes array lengths.
308-
// `Promoted` includes non-`Copy` array initializers and `rustc_args_required_const` arguments.
309308
InternKind::Constant | InternKind::Promoted => InternMode::Const,
310309
};
311310

compiler/rustc_mir/src/transform/lower_intrinsics.rs

+15-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use rustc_middle::mir::*;
55
use rustc_middle::ty::subst::SubstsRef;
66
use rustc_middle::ty::{self, Ty, TyCtxt};
77
use rustc_span::symbol::{sym, Symbol};
8+
use rustc_span::Span;
89
use rustc_target::spec::abi::Abi;
910

1011
pub struct LowerIntrinsics;
@@ -119,6 +120,9 @@ impl<'tcx> MirPass<'tcx> for LowerIntrinsics {
119120
terminator.kind = TerminatorKind::Goto { target };
120121
}
121122
}
123+
_ if intrinsic_name.as_str().starts_with("simd_shuffle") => {
124+
validate_simd_shuffle(tcx, args, terminator.source_info.span);
125+
}
122126
_ => {}
123127
}
124128
}
@@ -132,9 +136,19 @@ fn resolve_rust_intrinsic(
132136
) -> Option<(Symbol, SubstsRef<'tcx>)> {
133137
if let ty::FnDef(def_id, substs) = *func_ty.kind() {
134138
let fn_sig = func_ty.fn_sig(tcx);
135-
if fn_sig.abi() == Abi::RustIntrinsic {
139+
if let Abi::RustIntrinsic | Abi::PlatformIntrinsic = fn_sig.abi() {
136140
return Some((tcx.item_name(def_id), substs));
137141
}
138142
}
139143
None
140144
}
145+
146+
fn validate_simd_shuffle(tcx: TyCtxt<'tcx>, args: &[Operand<'tcx>], span: Span) {
147+
match &args[2] {
148+
Operand::Constant(_) => {} // all good
149+
_ => {
150+
let msg = format!("last argument of `simd_shuffle` is required to be a `const` item");
151+
tcx.sess.span_err(span, &msg);
152+
}
153+
}
154+
}

0 commit comments

Comments
 (0)