Skip to content

Commit e187f88

Browse files
committed
Auto merge of rust-lang#107314 - matthiaskrgr:rollup-j40lnlj, r=matthiaskrgr
Rollup of 11 pull requests Successful merges: - rust-lang#106407 (Improve proc macro attribute diagnostics) - rust-lang#106960 (Teach parser to understand fake anonymous enum syntax) - rust-lang#107085 (Custom MIR: Support binary and unary operations) - rust-lang#107086 (Print PID holding bootstrap build lock on Linux) - rust-lang#107175 (Fix escaping inference var ICE in `point_at_expr_source_of_inferred_type`) - rust-lang#107204 (suggest qualifying bare associated constants) - rust-lang#107248 (abi: add AddressSpace field to Primitive::Pointer ) - rust-lang#107272 (Implement ObjectSafe and WF in the new solver) - rust-lang#107285 (Implement `Generator` and `Future` in the new solver) - rust-lang#107286 (ICE in new solver if we see an inference variable) - rust-lang#107313 (Add Style Team Triagebot config) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 885bf62 + 267d626 commit e187f88

File tree

77 files changed

+1676
-337
lines changed

Some content is hidden

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

77 files changed

+1676
-337
lines changed

Cargo.lock

+7-7
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ dependencies = [
351351
"cargo-test-macro",
352352
"cargo-test-support",
353353
"cargo-util",
354-
"clap 4.1.3",
354+
"clap 4.1.4",
355355
"crates-io",
356356
"curl",
357357
"curl-sys",
@@ -655,9 +655,9 @@ dependencies = [
655655

656656
[[package]]
657657
name = "clap"
658-
version = "4.1.3"
658+
version = "4.1.4"
659659
source = "registry+https://github.com/rust-lang/crates.io-index"
660-
checksum = "d8d93d855ce6a0aa87b8473ef9169482f40abaa2e9e0993024c35c902cbd5920"
660+
checksum = "f13b9c79b5d1dd500d20ef541215a6423c75829ef43117e1b4d17fd8af0b5d76"
661661
dependencies = [
662662
"bitflags",
663663
"clap_derive 4.1.0",
@@ -675,7 +675,7 @@ version = "4.0.7"
675675
source = "registry+https://github.com/rust-lang/crates.io-index"
676676
checksum = "10861370d2ba66b0f5989f83ebf35db6421713fd92351790e7fdd6c36774c56b"
677677
dependencies = [
678-
"clap 4.1.3",
678+
"clap 4.1.4",
679679
]
680680

681681
[[package]]
@@ -2294,7 +2294,7 @@ name = "jsondoclint"
22942294
version = "0.1.0"
22952295
dependencies = [
22962296
"anyhow",
2297-
"clap 4.1.3",
2297+
"clap 4.1.4",
22982298
"fs-err",
22992299
"rustdoc-json-types",
23002300
"serde",
@@ -2557,7 +2557,7 @@ dependencies = [
25572557
"ammonia",
25582558
"anyhow",
25592559
"chrono",
2560-
"clap 4.1.3",
2560+
"clap 4.1.4",
25612561
"clap_complete",
25622562
"elasticlunr-rs",
25632563
"env_logger 0.10.0",
@@ -3528,7 +3528,7 @@ dependencies = [
35283528
name = "rustbook"
35293529
version = "0.1.0"
35303530
dependencies = [
3531-
"clap 4.1.3",
3531+
"clap 4.1.4",
35323532
"env_logger 0.7.1",
35333533
"mdbook",
35343534
]

compiler/rustc_abi/src/lib.rs

+14-22
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,9 @@ impl TargetDataLayout {
267267
["a", ref a @ ..] => dl.aggregate_align = align(a, "a")?,
268268
["f32", ref a @ ..] => dl.f32_align = align(a, "f32")?,
269269
["f64", ref a @ ..] => dl.f64_align = align(a, "f64")?,
270+
// FIXME(erikdesjardins): we should be parsing nonzero address spaces
271+
// this will require replacing TargetDataLayout::{pointer_size,pointer_align}
272+
// with e.g. `fn pointer_size_in(AddressSpace)`
270273
[p @ "p", s, ref a @ ..] | [p @ "p0", s, ref a @ ..] => {
271274
dl.pointer_size = size(s, p)?;
272275
dl.pointer_align = align(a, p)?;
@@ -861,7 +864,7 @@ pub enum Primitive {
861864
Int(Integer, bool),
862865
F32,
863866
F64,
864-
Pointer,
867+
Pointer(AddressSpace),
865868
}
866869

867870
impl Primitive {
@@ -872,7 +875,10 @@ impl Primitive {
872875
Int(i, _) => i.size(),
873876
F32 => Size::from_bits(32),
874877
F64 => Size::from_bits(64),
875-
Pointer => dl.pointer_size,
878+
// FIXME(erikdesjardins): ignoring address space is technically wrong, pointers in
879+
// different address spaces can have different sizes
880+
// (but TargetDataLayout doesn't currently parse that part of the DL string)
881+
Pointer(_) => dl.pointer_size,
876882
}
877883
}
878884

@@ -883,26 +889,12 @@ impl Primitive {
883889
Int(i, _) => i.align(dl),
884890
F32 => dl.f32_align,
885891
F64 => dl.f64_align,
886-
Pointer => dl.pointer_align,
892+
// FIXME(erikdesjardins): ignoring address space is technically wrong, pointers in
893+
// different address spaces can have different alignments
894+
// (but TargetDataLayout doesn't currently parse that part of the DL string)
895+
Pointer(_) => dl.pointer_align,
887896
}
888897
}
889-
890-
// FIXME(eddyb) remove, it's trivial thanks to `matches!`.
891-
#[inline]
892-
pub fn is_float(self) -> bool {
893-
matches!(self, F32 | F64)
894-
}
895-
896-
// FIXME(eddyb) remove, it's completely unused.
897-
#[inline]
898-
pub fn is_int(self) -> bool {
899-
matches!(self, Int(..))
900-
}
901-
902-
#[inline]
903-
pub fn is_ptr(self) -> bool {
904-
matches!(self, Pointer)
905-
}
906898
}
907899

908900
/// Inclusive wrap-around range of valid values, that is, if
@@ -1188,7 +1180,8 @@ impl FieldsShape {
11881180
/// An identifier that specifies the address space that some operation
11891181
/// should operate on. Special address spaces have an effect on code generation,
11901182
/// depending on the target and the address spaces it implements.
1191-
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
1183+
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
1184+
#[cfg_attr(feature = "nightly", derive(HashStable_Generic))]
11921185
pub struct AddressSpace(pub u32);
11931186

11941187
impl AddressSpace {
@@ -1468,7 +1461,6 @@ pub struct PointeeInfo {
14681461
pub size: Size,
14691462
pub align: Align,
14701463
pub safe: Option<PointerKind>,
1471-
pub address_space: AddressSpace,
14721464
}
14731465

14741466
/// Used in `might_permit_raw_init` to indicate the kind of initialisation

compiler/rustc_ast/src/visit.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -400,8 +400,8 @@ pub fn walk_ty<'a, V: Visitor<'a>>(visitor: &mut V, typ: &'a Ty) {
400400
walk_list!(visitor, visit_lifetime, opt_lifetime, LifetimeCtxt::Ref);
401401
visitor.visit_ty(&mutable_type.ty)
402402
}
403-
TyKind::Tup(tuple_element_types) => {
404-
walk_list!(visitor, visit_ty, tuple_element_types);
403+
TyKind::Tup(tys) => {
404+
walk_list!(visitor, visit_ty, tys);
405405
}
406406
TyKind::BareFn(function_declaration) => {
407407
walk_list!(visitor, visit_generic_param, &function_declaration.generic_params);

compiler/rustc_codegen_cranelift/src/common.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ pub(crate) fn scalar_to_clif_type(tcx: TyCtxt<'_>, scalar: Scalar) -> Type {
3535
},
3636
Primitive::F32 => types::F32,
3737
Primitive::F64 => types::F64,
38-
Primitive::Pointer => pointer_ty(tcx),
38+
// FIXME(erikdesjardins): handle non-default addrspace ptr sizes
39+
Primitive::Pointer(_) => pointer_ty(tcx),
3940
}
4041
}
4142

compiler/rustc_codegen_gcc/src/builder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,7 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
709709
bx.range_metadata(load, vr);
710710
}
711711
}
712-
abi::Pointer if vr.start < vr.end && !vr.contains(0) => {
712+
abi::Pointer(_) if vr.start < vr.end && !vr.contains(0) => {
713713
bx.nonnull_metadata(load);
714714
}
715715
_ => {}

compiler/rustc_codegen_gcc/src/common.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ impl<'gcc, 'tcx> ConstMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
211211
let base_addr = self.const_bitcast(base_addr, self.usize_type);
212212
let offset = self.context.new_rvalue_from_long(self.usize_type, offset.bytes() as i64);
213213
let ptr = self.const_bitcast(base_addr + offset, ptr_type);
214-
if layout.primitive() != Pointer {
214+
if !matches!(layout.primitive(), Pointer(_)) {
215215
self.const_bitcast(ptr.dereference(None).to_rvalue(), ty)
216216
}
217217
else {

compiler/rustc_codegen_gcc/src/consts.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -322,13 +322,16 @@ pub fn const_alloc_to_gcc<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, alloc: ConstAl
322322
)
323323
.expect("const_alloc_to_llvm: could not read relocation pointer")
324324
as u64;
325+
326+
let address_space = cx.tcx.global_alloc(alloc_id).address_space(cx);
327+
325328
llvals.push(cx.scalar_to_backend(
326329
InterpScalar::from_pointer(
327330
interpret::Pointer::new(alloc_id, Size::from_bytes(ptr_offset)),
328331
&cx.tcx,
329332
),
330-
abi::Scalar::Initialized { value: Primitive::Pointer, valid_range: WrappingRange::full(dl.pointer_size) },
331-
cx.type_i8p(),
333+
abi::Scalar::Initialized { value: Primitive::Pointer(address_space), valid_range: WrappingRange::full(dl.pointer_size) },
334+
cx.type_i8p_ext(address_space),
332335
));
333336
next_offset = offset + pointer_size;
334337
}

compiler/rustc_codegen_gcc/src/type_of.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ impl<'tcx> LayoutGccExt<'tcx> for TyAndLayout<'tcx> {
253253
Int(i, false) => cx.type_from_unsigned_integer(i),
254254
F32 => cx.type_f32(),
255255
F64 => cx.type_f64(),
256-
Pointer => {
256+
Pointer(address_space) => {
257257
// If we know the alignment, pick something better than i8.
258258
let pointee =
259259
if let Some(pointee) = self.pointee_info_at(cx, offset) {
@@ -262,7 +262,7 @@ impl<'tcx> LayoutGccExt<'tcx> for TyAndLayout<'tcx> {
262262
else {
263263
cx.type_i8()
264264
};
265-
cx.type_ptr_to(pointee)
265+
cx.type_ptr_to_ext(pointee, address_space)
266266
}
267267
}
268268
}

compiler/rustc_codegen_llvm/src/asm.rs

+9-4
Original file line numberDiff line numberDiff line change
@@ -849,14 +849,16 @@ fn dummy_output_type<'ll>(cx: &CodegenCx<'ll, '_>, reg: InlineAsmRegClass) -> &'
849849
/// Helper function to get the LLVM type for a Scalar. Pointers are returned as
850850
/// the equivalent integer type.
851851
fn llvm_asm_scalar_type<'ll>(cx: &CodegenCx<'ll, '_>, scalar: Scalar) -> &'ll Type {
852+
let dl = &cx.tcx.data_layout;
852853
match scalar.primitive() {
853854
Primitive::Int(Integer::I8, _) => cx.type_i8(),
854855
Primitive::Int(Integer::I16, _) => cx.type_i16(),
855856
Primitive::Int(Integer::I32, _) => cx.type_i32(),
856857
Primitive::Int(Integer::I64, _) => cx.type_i64(),
857858
Primitive::F32 => cx.type_f32(),
858859
Primitive::F64 => cx.type_f64(),
859-
Primitive::Pointer => cx.type_isize(),
860+
// FIXME(erikdesjardins): handle non-default addrspace ptr sizes
861+
Primitive::Pointer(_) => cx.type_from_integer(dl.ptr_sized_integer()),
860862
_ => unreachable!(),
861863
}
862864
}
@@ -868,6 +870,7 @@ fn llvm_fixup_input<'ll, 'tcx>(
868870
reg: InlineAsmRegClass,
869871
layout: &TyAndLayout<'tcx>,
870872
) -> &'ll Value {
873+
let dl = &bx.tcx.data_layout;
871874
match (reg, layout.abi) {
872875
(InlineAsmRegClass::AArch64(AArch64InlineAsmRegClass::vreg), Abi::Scalar(s)) => {
873876
if let Primitive::Int(Integer::I8, _) = s.primitive() {
@@ -881,8 +884,10 @@ fn llvm_fixup_input<'ll, 'tcx>(
881884
let elem_ty = llvm_asm_scalar_type(bx.cx, s);
882885
let count = 16 / layout.size.bytes();
883886
let vec_ty = bx.cx.type_vector(elem_ty, count);
884-
if let Primitive::Pointer = s.primitive() {
885-
value = bx.ptrtoint(value, bx.cx.type_isize());
887+
// FIXME(erikdesjardins): handle non-default addrspace ptr sizes
888+
if let Primitive::Pointer(_) = s.primitive() {
889+
let t = bx.type_from_integer(dl.ptr_sized_integer());
890+
value = bx.ptrtoint(value, t);
886891
}
887892
bx.insert_element(bx.const_undef(vec_ty), value, bx.const_i32(0))
888893
}
@@ -958,7 +963,7 @@ fn llvm_fixup_output<'ll, 'tcx>(
958963
}
959964
(InlineAsmRegClass::AArch64(AArch64InlineAsmRegClass::vreg_low16), Abi::Scalar(s)) => {
960965
value = bx.extract_element(value, bx.const_i32(0));
961-
if let Primitive::Pointer = s.primitive() {
966+
if let Primitive::Pointer(_) = s.primitive() {
962967
value = bx.inttoptr(value, layout.llvm_type(bx.cx));
963968
}
964969
value

compiler/rustc_codegen_llvm/src/builder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
511511
bx.range_metadata(load, scalar.valid_range(bx));
512512
}
513513
}
514-
abi::Pointer => {
514+
abi::Pointer(_) => {
515515
if !scalar.valid_range(bx).contains(0) {
516516
bx.nonnull_metadata(load);
517517
}

compiler/rustc_codegen_llvm/src/common.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ impl<'ll, 'tcx> ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> {
236236
Scalar::Int(int) => {
237237
let data = int.assert_bits(layout.size(self));
238238
let llval = self.const_uint_big(self.type_ix(bitsize), data);
239-
if layout.primitive() == Pointer {
239+
if matches!(layout.primitive(), Pointer(_)) {
240240
unsafe { llvm::LLVMConstIntToPtr(llval, llty) }
241241
} else {
242242
self.const_bitcast(llval, llty)
@@ -284,7 +284,7 @@ impl<'ll, 'tcx> ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> {
284284
1,
285285
)
286286
};
287-
if layout.primitive() != Pointer {
287+
if !matches!(layout.primitive(), Pointer(_)) {
288288
unsafe { llvm::LLVMConstPtrToInt(llval, llty) }
289289
} else {
290290
self.const_bitcast(llval, llty)

compiler/rustc_codegen_llvm/src/consts.rs

+4-11
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,15 @@ use rustc_codegen_ssa::traits::*;
1313
use rustc_hir::def_id::DefId;
1414
use rustc_middle::middle::codegen_fn_attrs::{CodegenFnAttrFlags, CodegenFnAttrs};
1515
use rustc_middle::mir::interpret::{
16-
read_target_uint, Allocation, ConstAllocation, ErrorHandled, GlobalAlloc, InitChunk, Pointer,
16+
read_target_uint, Allocation, ConstAllocation, ErrorHandled, InitChunk, Pointer,
1717
Scalar as InterpScalar,
1818
};
1919
use rustc_middle::mir::mono::MonoItem;
2020
use rustc_middle::ty::layout::LayoutOf;
2121
use rustc_middle::ty::{self, Instance, Ty};
2222
use rustc_middle::{bug, span_bug};
2323
use rustc_session::config::Lto;
24-
use rustc_target::abi::{
25-
AddressSpace, Align, HasDataLayout, Primitive, Scalar, Size, WrappingRange,
26-
};
24+
use rustc_target::abi::{Align, HasDataLayout, Primitive, Scalar, Size, WrappingRange};
2725
use std::ops::Range;
2826

2927
pub fn const_alloc_to_llvm<'ll>(cx: &CodegenCx<'ll, '_>, alloc: ConstAllocation<'_>) -> &'ll Value {
@@ -98,20 +96,15 @@ pub fn const_alloc_to_llvm<'ll>(cx: &CodegenCx<'ll, '_>, alloc: ConstAllocation<
9896
.expect("const_alloc_to_llvm: could not read relocation pointer")
9997
as u64;
10098

101-
let address_space = match cx.tcx.global_alloc(alloc_id) {
102-
GlobalAlloc::Function(..) => cx.data_layout().instruction_address_space,
103-
GlobalAlloc::Static(..) | GlobalAlloc::Memory(..) | GlobalAlloc::VTable(..) => {
104-
AddressSpace::DATA
105-
}
106-
};
99+
let address_space = cx.tcx.global_alloc(alloc_id).address_space(cx);
107100

108101
llvals.push(cx.scalar_to_backend(
109102
InterpScalar::from_pointer(
110103
Pointer::new(alloc_id, Size::from_bytes(ptr_offset)),
111104
&cx.tcx,
112105
),
113106
Scalar::Initialized {
114-
value: Primitive::Pointer,
107+
value: Primitive::Pointer(address_space),
115108
valid_range: WrappingRange::full(dl.pointer_size),
116109
},
117110
cx.type_i8p_ext(address_space),

compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@ fn tag_base_type<'ll, 'tcx>(
122122
Primitive::Int(t, _) => t,
123123
Primitive::F32 => Integer::I32,
124124
Primitive::F64 => Integer::I64,
125-
Primitive::Pointer => {
125+
// FIXME(erikdesjardins): handle non-default addrspace ptr sizes
126+
Primitive::Pointer(_) => {
126127
// If the niche is the NULL value of a reference, then `discr_enum_ty` will be
127128
// a RawPtr. CodeView doesn't know what to do with enums whose base type is a
128129
// pointer so we fix this up to just be `usize`.

compiler/rustc_codegen_llvm/src/intrinsic.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ impl<'ll, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'_, 'll, 'tcx> {
149149
emit_va_arg(self, args[0], ret_ty)
150150
}
151151
}
152-
Primitive::F64 | Primitive::Pointer => {
152+
Primitive::F64 | Primitive::Pointer(_) => {
153153
emit_va_arg(self, args[0], ret_ty)
154154
}
155155
// `va_arg` should never be used with the return type f32.

compiler/rustc_codegen_llvm/src/type_of.rs

+7-8
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use rustc_middle::bug;
77
use rustc_middle::ty::layout::{FnAbiOf, LayoutOf, TyAndLayout};
88
use rustc_middle::ty::print::{with_no_trimmed_paths, with_no_visible_paths};
99
use rustc_middle::ty::{self, Ty, TypeVisitable};
10-
use rustc_target::abi::{Abi, AddressSpace, Align, FieldsShape};
10+
use rustc_target::abi::{Abi, Align, FieldsShape};
1111
use rustc_target::abi::{Int, Pointer, F32, F64};
1212
use rustc_target::abi::{PointeeInfo, Scalar, Size, TyAbiInterface, Variants};
1313
use smallvec::{smallvec, SmallVec};
@@ -312,14 +312,13 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyAndLayout<'tcx> {
312312
Int(i, _) => cx.type_from_integer(i),
313313
F32 => cx.type_f32(),
314314
F64 => cx.type_f64(),
315-
Pointer => {
315+
Pointer(address_space) => {
316316
// If we know the alignment, pick something better than i8.
317-
let (pointee, address_space) =
318-
if let Some(pointee) = self.pointee_info_at(cx, offset) {
319-
(cx.type_pointee_for_align(pointee.align), pointee.address_space)
320-
} else {
321-
(cx.type_i8(), AddressSpace::DATA)
322-
};
317+
let pointee = if let Some(pointee) = self.pointee_info_at(cx, offset) {
318+
cx.type_pointee_for_align(pointee.align)
319+
} else {
320+
cx.type_i8()
321+
};
323322
cx.type_ptr_to_ext(pointee, address_space)
324323
}
325324
}

compiler/rustc_codegen_ssa/src/mir/block.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1801,8 +1801,8 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
18011801
match (src.layout.abi, dst.layout.abi) {
18021802
(abi::Abi::Scalar(src_scalar), abi::Abi::Scalar(dst_scalar)) => {
18031803
// HACK(eddyb) LLVM doesn't like `bitcast`s between pointers and non-pointers.
1804-
let src_is_ptr = src_scalar.primitive() == abi::Pointer;
1805-
let dst_is_ptr = dst_scalar.primitive() == abi::Pointer;
1804+
let src_is_ptr = matches!(src_scalar.primitive(), abi::Pointer(_));
1805+
let dst_is_ptr = matches!(dst_scalar.primitive(), abi::Pointer(_));
18061806
if src_is_ptr == dst_is_ptr {
18071807
assert_eq!(src.layout.size, dst.layout.size);
18081808

0 commit comments

Comments
 (0)