Skip to content

Commit ca1e68b

Browse files
committed
Auto merge of #98730 - matthiaskrgr:rollup-2c4d4x5, r=matthiaskrgr
Rollup of 10 pull requests Successful merges: - #97629 ([core] add `Exclusive` to sync) - #98503 (fix data race in thread::scope) - #98670 (llvm-wrapper: adapt for LLVMConstExtractValue removal) - #98671 (Fix source sidebar bugs) - #98677 (For diagnostic information of Boolean, remind it as use the type: 'bool') - #98684 (add test for 72793) - #98688 (interpret: add From<&MplaceTy> for PlaceTy) - #98695 (use "or pattern") - #98709 (Remove unneeded methods declaration for old web browsers) - #98717 (get rid of tidy 'unnecessarily ignored' warnings) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 7e2733b + 6e918b4 commit ca1e68b

File tree

26 files changed

+364
-79
lines changed

26 files changed

+364
-79
lines changed

compiler/rustc_codegen_llvm/src/common.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,7 @@ impl<'ll> CodegenCx<'ll, '_> {
109109
pub fn const_get_elt(&self, v: &'ll Value, idx: u64) -> &'ll Value {
110110
unsafe {
111111
assert_eq!(idx as c_uint as u64, idx);
112-
let us = &[idx as c_uint];
113-
let r = llvm::LLVMConstExtractValue(v, us.as_ptr(), us.len() as c_uint);
112+
let r = llvm::LLVMGetAggregateElement(v, idx as c_uint).unwrap();
114113

115114
debug!("const_get_elt(v={:?}, idx={}, r={:?})", v, idx, r);
116115

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,11 +1134,7 @@ extern "C" {
11341134
pub fn LLVMConstIntToPtr<'a>(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
11351135
pub fn LLVMConstBitCast<'a>(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
11361136
pub fn LLVMConstPointerCast<'a>(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
1137-
pub fn LLVMConstExtractValue(
1138-
AggConstant: &Value,
1139-
IdxList: *const c_uint,
1140-
NumIdx: c_uint,
1141-
) -> &Value;
1137+
pub fn LLVMGetAggregateElement(ConstantVal: &Value, Idx: c_uint) -> Option<&Value>;
11421138

11431139
// Operations on global variables, functions, and aliases (globals)
11441140
pub fn LLVMIsDeclaration(Global: &Value) -> Bool;

compiler/rustc_const_eval/src/const_eval/valtrees.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ fn valtree_into_mplace<'tcx>(
346346
ty::FnDef(_, _) => {
347347
ecx.write_immediate(
348348
Immediate::Scalar(ScalarMaybeUninit::Scalar(Scalar::ZST)),
349-
&(*place).into(),
349+
&place.into(),
350350
)
351351
.unwrap();
352352
}
@@ -355,7 +355,7 @@ fn valtree_into_mplace<'tcx>(
355355
debug!("writing trivial valtree {:?} to place {:?}", scalar_int, place);
356356
ecx.write_immediate(
357357
Immediate::Scalar(ScalarMaybeUninit::Scalar(scalar_int.into())),
358-
&(*place).into(),
358+
&place.into(),
359359
)
360360
.unwrap();
361361
}
@@ -382,7 +382,7 @@ fn valtree_into_mplace<'tcx>(
382382
};
383383
debug!(?imm);
384384

385-
ecx.write_immediate(imm, &(*place).into()).unwrap();
385+
ecx.write_immediate(imm, &place.into()).unwrap();
386386
}
387387
ty::Adt(_, _) | ty::Tuple(_) | ty::Array(_, _) | ty::Str | ty::Slice(_) => {
388388
let branches = valtree.unwrap_branch();
@@ -464,11 +464,11 @@ fn valtree_into_mplace<'tcx>(
464464

465465
if let Some(variant_idx) = variant_idx {
466466
// don't forget filling the place with the discriminant of the enum
467-
ecx.write_discriminant(variant_idx, &(*place).into()).unwrap();
467+
ecx.write_discriminant(variant_idx, &place.into()).unwrap();
468468
}
469469

470470
debug!("dump of place after writing discriminant:");
471-
dump_place(ecx, (*place).into());
471+
dump_place(ecx, place.into());
472472
}
473473
_ => bug!("shouldn't have created a ValTree for {:?}", ty),
474474
}

compiler/rustc_const_eval/src/interpret/intern.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: CompileTimeMachine<'mir, 'tcx, const_eval::Memory
195195
let tcx = self.ecx.tcx;
196196
let ty = mplace.layout.ty;
197197
if let ty::Ref(_, referenced_ty, ref_mutability) = *ty.kind() {
198-
let value = self.ecx.read_immediate(&(*mplace).into())?;
198+
let value = self.ecx.read_immediate(&mplace.into())?;
199199
let mplace = self.ecx.ref_to_mplace(&value)?;
200200
assert_eq!(mplace.layout.ty, referenced_ty);
201201
// Handle trait object vtables.

compiler/rustc_const_eval/src/interpret/operand.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,13 @@ impl<'tcx, Tag: Provenance> From<&'_ MPlaceTy<'tcx, Tag>> for OpTy<'tcx, Tag> {
204204
}
205205
}
206206

207+
impl<'tcx, Tag: Provenance> From<&'_ mut MPlaceTy<'tcx, Tag>> for OpTy<'tcx, Tag> {
208+
#[inline(always)]
209+
fn from(mplace: &mut MPlaceTy<'tcx, Tag>) -> Self {
210+
OpTy { op: Operand::Indirect(**mplace), layout: mplace.layout }
211+
}
212+
}
213+
207214
impl<'tcx, Tag: Provenance> From<ImmTy<'tcx, Tag>> for OpTy<'tcx, Tag> {
208215
#[inline(always)]
209216
fn from(val: ImmTy<'tcx, Tag>) -> Self {

compiler/rustc_const_eval/src/interpret/place.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,21 @@ impl<'tcx, Tag: Provenance> std::ops::Deref for MPlaceTy<'tcx, Tag> {
118118
impl<'tcx, Tag: Provenance> From<MPlaceTy<'tcx, Tag>> for PlaceTy<'tcx, Tag> {
119119
#[inline(always)]
120120
fn from(mplace: MPlaceTy<'tcx, Tag>) -> Self {
121-
PlaceTy { place: Place::Ptr(mplace.mplace), layout: mplace.layout }
121+
PlaceTy { place: Place::Ptr(*mplace), layout: mplace.layout }
122+
}
123+
}
124+
125+
impl<'tcx, Tag: Provenance> From<&'_ MPlaceTy<'tcx, Tag>> for PlaceTy<'tcx, Tag> {
126+
#[inline(always)]
127+
fn from(mplace: &MPlaceTy<'tcx, Tag>) -> Self {
128+
PlaceTy { place: Place::Ptr(**mplace), layout: mplace.layout }
129+
}
130+
}
131+
132+
impl<'tcx, Tag: Provenance> From<&'_ mut MPlaceTy<'tcx, Tag>> for PlaceTy<'tcx, Tag> {
133+
#[inline(always)]
134+
fn from(mplace: &mut MPlaceTy<'tcx, Tag>) -> Self {
135+
PlaceTy { place: Place::Ptr(**mplace), layout: mplace.layout }
122136
}
123137
}
124138

compiler/rustc_const_eval/src/interpret/visitor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> Value<'mir, 'tcx, M>
9292
&self,
9393
_ecx: &InterpCx<'mir, 'tcx, M>,
9494
) -> InterpResult<'tcx, OpTy<'tcx, M::PointerTag>> {
95-
Ok((*self).into())
95+
Ok(self.into())
9696
}
9797

9898
#[inline(always)]

compiler/rustc_errors/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1447,7 +1447,7 @@ impl HandlerInner {
14471447
self.flags.treat_err_as_bug.map(|c| c.get()).unwrap_or(0),
14481448
) {
14491449
(1, 1) => panic!("aborting due to `-Z treat-err-as-bug=1`"),
1450-
(0, _) | (1, _) => {}
1450+
(0 | 1, _) => {}
14511451
(count, as_bug) => panic!(
14521452
"aborting after {} errors due to `-Z treat-err-as-bug={}`",
14531453
count, as_bug,

compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1865,3 +1865,11 @@ extern "C" void LLVMRustGetMangledName(LLVMValueRef V, RustStringRef Str) {
18651865
GlobalValue *GV = unwrap<GlobalValue>(V);
18661866
Mangler().getNameWithPrefix(OS, GV, true);
18671867
}
1868+
1869+
// LLVMGetAggregateElement was added in LLVM 15. For earlier LLVM versions just
1870+
// use its implementation.
1871+
#if LLVM_VERSION_LT(15, 0)
1872+
extern "C" LLVMValueRef LLVMGetAggregateElement(LLVMValueRef C, unsigned Idx) {
1873+
return wrap(unwrap<Constant>(C)->getAggregateElement(Idx));
1874+
}
1875+
#endif

compiler/rustc_resolve/src/late/diagnostics.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1503,6 +1503,8 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
15031503
Some(match name {
15041504
"byte" => sym::u8, // In Java, bytes are signed, but in practice one almost always wants unsigned bytes.
15051505
"short" => sym::i16,
1506+
"Bool" => sym::bool,
1507+
"Boolean" => sym::bool,
15061508
"boolean" => sym::bool,
15071509
"int" => sym::i32,
15081510
"long" => sym::i64,

0 commit comments

Comments
 (0)