Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit fdad98d

Browse files
committed
Auto merge of #143254 - matthiaskrgr:rollup-7x8bxek, r=matthiaskrgr
Rollup of 9 pull requests Successful merges: - #143019 (Ensure -V --verbose processes both codegen_backend and codegen-backend) - #143140 (give Pointer::into_parts a more scary name and offer a safer alternative) - #143175 (Make combining LLD with external LLVM config a hard error) - #143180 (Use `tracing-forest` instead of `tracing-tree` for bootstrap tracing) - #143223 (Improve macro stats printing) - #143228 (Handle build scripts better in `-Zmacro-stats` output.) - #143229 ([COMPILETEST-UNTANGLE 1/N] Move some some early config checks to the lib and move the compiletest binary) - #143246 (Subtree update of `rust-analyzer`) - #143248 (Update books) r? `@ghost` `@rustbot` modify labels: rollup
2 parents f26e580 + 3f6dc54 commit fdad98d

File tree

188 files changed

+2458
-983
lines changed

Some content is hidden

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

188 files changed

+2458
-983
lines changed

‎compiler/rustc_codegen_cranelift/src/constant.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ pub(crate) fn codegen_const_value<'tcx>(
133133
}
134134
}
135135
Scalar::Ptr(ptr, _size) => {
136-
let (prov, offset) = ptr.into_parts();// we know the `offset` is relative
136+
let (prov, offset) = ptr.prov_and_relative_offset();
137137
let alloc_id = prov.alloc_id();
138138
let base_addr = match fx.tcx.global_alloc(alloc_id) {
139139
GlobalAlloc::Memory(alloc) => {

‎compiler/rustc_codegen_gcc/src/common.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ impl<'gcc, 'tcx> ConstCodegenMethods for CodegenCx<'gcc, 'tcx> {
240240
}
241241
}
242242
Scalar::Ptr(ptr, _size) => {
243-
let (prov, offset) = ptr.into_parts();// we know the `offset` is relative
243+
let (prov, offset) = ptr.prov_and_relative_offset();
244244
let alloc_id = prov.alloc_id();
245245
let base_addr = match self.tcx.global_alloc(alloc_id) {
246246
GlobalAlloc::Memory(alloc) => {

‎compiler/rustc_codegen_llvm/src/common.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ impl<'ll, 'tcx> ConstCodegenMethods for CodegenCx<'ll, 'tcx> {
268268
}
269269
}
270270
Scalar::Ptr(ptr, _size) => {
271-
let (prov, offset) = ptr.into_parts();
271+
let (prov, offset) = ptr.prov_and_relative_offset();
272272
let global_alloc = self.tcx.global_alloc(prov.alloc_id());
273273
let base_addr = match global_alloc {
274274
GlobalAlloc::Memory(alloc) => {

‎compiler/rustc_const_eval/src/const_eval/eval_queries.rs‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -209,9 +209,9 @@ pub(super) fn op_to_const<'tcx>(
209209

210210
match immediate {
211211
Left(ref mplace) => {
212-
// We know `offset` is relative to the allocation, so we can use `into_parts`.
213-
let(prov, offset) = mplace.ptr().into_parts();
214-
let alloc_id = prov.expect("cannot have `fake` place for non-ZST type").alloc_id();
212+
let(prov,offset) =
213+
mplace.ptr().into_pointer_or_addr().unwrap().prov_and_relative_offset();
214+
let alloc_id = prov.alloc_id();
215215
ConstValue::Indirect { alloc_id, offset }
216216
}
217217
// see comment on `let force_as_immediate` above
@@ -232,9 +232,10 @@ pub(super) fn op_to_const<'tcx>(
232232
imm.layout.ty,
233233
);
234234
let msg = "`op_to_const` on an immediate scalar pair must only be used on slice references to the beginning of an actual allocation";
235-
// We know `offset` is relative to the allocation, so we can use `into_parts`.
236-
let (prov, offset) = a.to_pointer(ecx).expect(msg).into_parts();
237-
let alloc_id = prov.expect(msg).alloc_id();
235+
let ptr = a.to_pointer(ecx).expect(msg);
236+
let (prov, offset) =
237+
ptr.into_pointer_or_addr().expect(msg).prov_and_relative_offset();
238+
let alloc_id = prov.alloc_id();
238239
let data = ecx.tcx.global_alloc(alloc_id).unwrap_memory();
239240
assert!(offset == abi::Size::ZERO, "{}", msg);
240241
let meta = b.to_target_usize(ecx).expect(msg);

‎compiler/rustc_const_eval/src/errors.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ impl<'a> ReportErrorExt for UndefinedBehaviorInfo<'a> {
574574
if addr != 0 {
575575
diag.arg(
576576
"pointer",
577-
Pointer::<Option<CtfeProvenance>>::from_addr_invalid(addr).to_string(),
577+
Pointer::<Option<CtfeProvenance>>::without_provenance(addr).to_string(),
578578
);
579579
}
580580

‎compiler/rustc_const_eval/src/interpret/machine.rs‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,7 @@ pub macro compile_time_machine(<$tcx: lifetime>) {
747747
// Allow these casts, but make the pointer not dereferenceable.
748748
// (I.e., they behave like transmutation.)
749749
// This is correct because no pointers can ever be exposed in compile-time evaluation.
750-
interp_ok(Pointer::from_addr_invalid(addr))
750+
interp_ok(Pointer::without_provenance(addr))
751751
}
752752

753753
#[inline(always)]
@@ -756,8 +756,7 @@ pub macro compile_time_machine(<$tcx: lifetime>) {
756756
ptr: Pointer<CtfeProvenance>,
757757
_size: i64,
758758
) -> Option<(AllocId, Size, Self::ProvenanceExtra)> {
759-
// We know `offset` is relative to the allocation, so we can use `into_parts`.
760-
let (prov, offset) = ptr.into_parts();
759+
let (prov, offset) = ptr.prov_and_relative_offset();
761760
Some((prov.alloc_id(), offset, prov.immutable()))
762761
}
763762

‎compiler/rustc_const_eval/src/interpret/memory.rs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1596,7 +1596,8 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
15961596
Some((alloc_id, offset, extra)) => Ok((alloc_id, offset, extra)),
15971597
None => {
15981598
assert!(M::Provenance::OFFSET_IS_ADDR);
1599-
let (_, addr) = ptr.into_parts();
1599+
// Offset is absolute, as we just asserted.
1600+
let (_, addr) = ptr.into_raw_parts();
16001601
Err(addr.bytes())
16011602
}
16021603
},

‎compiler/rustc_const_eval/src/interpret/place.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ impl<'tcx, Prov: Provenance> MPlaceTy<'tcx, Prov> {
118118
pub fn fake_alloc_zst(layout: TyAndLayout<'tcx>) -> Self {
119119
assert!(layout.is_zst());
120120
let align = layout.align.abi;
121-
let ptr = Pointer::from_addr_invalid(align.bytes()); // no provenance, absolute address
121+
let ptr = Pointer::without_provenance(align.bytes()); // no provenance, absolute address
122122
MPlaceTy { mplace: MemPlace { ptr, meta: MemPlaceMeta::None, misaligned: None }, layout }
123123
}
124124

‎compiler/rustc_const_eval/src/interpret/validity.rs‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ impl<'rt, 'tcx, M: Machine<'tcx>> ValidityVisitor<'rt, 'tcx, M> {
518518
Ub(DanglingIntPointer { addr: i, .. }) => DanglingPtrNoProvenance {
519519
ptr_kind,
520520
// FIXME this says "null pointer" when null but we need translate
521-
pointer: format!("{}", Pointer::<Option<AllocId>>::from_addr_invalid(i))
521+
pointer: format!("{}", Pointer::<Option<AllocId>>::without_provenance(i))
522522
},
523523
Ub(PointerOutOfBounds { .. }) => DanglingPtrOutOfBounds {
524524
ptr_kind
@@ -868,7 +868,9 @@ impl<'rt, 'tcx, M: Machine<'tcx>> ValidityVisitor<'rt, 'tcx, M> {
868868
fn add_data_range(&mut self, ptr: Pointer<Option<M::Provenance>>, size: Size) {
869869
if let Some(data_bytes) = self.data_bytes.as_mut() {
870870
// We only have to store the offset, the rest is the same for all pointers here.
871-
let (_prov, offset) = ptr.into_parts();
871+
// The logic is agnostic to wether the offset is relative or absolute as long as
872+
// it is consistent.
873+
let (_prov, offset) = ptr.into_raw_parts();
872874
// Add this.
873875
data_bytes.add_range(offset, size);
874876
};
@@ -894,7 +896,7 @@ impl<'rt, 'tcx, M: Machine<'tcx>> ValidityVisitor<'rt, 'tcx, M> {
894896
.as_mplace_or_imm()
895897
.expect_left("place must be in memory")
896898
.ptr();
897-
let (_prov, offset) = ptr.into_parts();
899+
let (_prov, offset) = ptr.into_raw_parts();
898900
offset
899901
}
900902

@@ -903,7 +905,7 @@ impl<'rt, 'tcx, M: Machine<'tcx>> ValidityVisitor<'rt, 'tcx, M> {
903905
// Our value must be in memory, otherwise we would not have set up `data_bytes`.
904906
let mplace = self.ecx.force_allocation(place)?;
905907
// Determine starting offset and size.
906-
let (_prov, start_offset) = mplace.ptr().into_parts();
908+
let (_prov, start_offset) = mplace.ptr().into_raw_parts();
907909
let (size, _align) = self
908910
.ecx
909911
.size_and_align_of_val(&mplace)?

‎compiler/rustc_driver_impl/src/lib.rs‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1112,7 +1112,9 @@ fn get_backend_from_raw_matches(
11121112
matches: &Matches,
11131113
) -> Box<dyn CodegenBackend> {
11141114
let debug_flags = matches.opt_strs("Z");
1115-
let backend_name = debug_flags.iter().find_map(|x| x.strip_prefix("codegen-backend="));
1115+
let backend_name = debug_flags
1116+
.iter()
1117+
.find_map(|x| x.strip_prefix("codegen-backend=").or(x.strip_prefix("codegen_backend=")));
11161118
let target = parse_target_triple(early_dcx, matches);
11171119
let sysroot = Sysroot::new(matches.opt_str("sysroot").map(PathBuf::from));
11181120
let target = config::build_target_config(early_dcx, &target, sysroot.path());

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /