Skip to content

Commit a024d65

Browse files
author
The rustc-josh-sync Cronjob Bot
committed
Merge ref '425a9c0a0e36' from rust-lang/rust
Pull recent changes from https://github.com/rust-lang/rust via Josh. Upstream ref: 425a9c0a0e365c0b8c6cfd00c2ded83a73bed9a0 Filtered ref: 26b9fd24259f4fc5fd7634a99dd6dda2821fb2d0 This merge was created using https://github.com/rust-lang/josh-sync.
2 parents 8bb92ce + 7e955d5 commit a024d65

Some content is hidden

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

56 files changed

+223
-184
lines changed

src/bin/miri.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ impl rustc_driver::Callbacks for MiriBeRustCompilerCalls {
279279
return None;
280280
}
281281
let codegen_fn_attrs = tcx.codegen_fn_attrs(local_def_id);
282-
if codegen_fn_attrs.contains_extern_indicator()
282+
if codegen_fn_attrs.contains_extern_indicator(tcx, local_def_id.into())
283283
|| codegen_fn_attrs
284284
.flags
285285
.contains(CodegenFnAttrFlags::USED_COMPILER)

src/borrow_tracker/mod.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ impl GlobalStateInner {
260260
kind: MemoryKind,
261261
machine: &MiriMachine<'_>,
262262
) -> AllocState {
263-
let _span = enter_trace_span!(borrow_tracker::new_allocation, ?id, ?alloc_size, ?kind);
263+
let _trace = enter_trace_span!(borrow_tracker::new_allocation, ?id, ?alloc_size, ?kind);
264264
match self.borrow_tracker_method {
265265
BorrowTrackerMethod::StackedBorrows =>
266266
AllocState::StackedBorrows(Box::new(RefCell::new(Stacks::new_allocation(
@@ -281,7 +281,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
281281
kind: RetagKind,
282282
val: &ImmTy<'tcx>,
283283
) -> InterpResult<'tcx, ImmTy<'tcx>> {
284-
let _span = enter_trace_span!(borrow_tracker::retag_ptr_value, ?kind, ?val.layout);
284+
let _trace = enter_trace_span!(borrow_tracker::retag_ptr_value, ?kind, ?val.layout);
285285
let this = self.eval_context_mut();
286286
let method = this.machine.borrow_tracker.as_ref().unwrap().borrow().borrow_tracker_method;
287287
match method {
@@ -295,7 +295,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
295295
kind: RetagKind,
296296
place: &PlaceTy<'tcx>,
297297
) -> InterpResult<'tcx> {
298-
let _span = enter_trace_span!(borrow_tracker::retag_place_contents, ?kind, ?place);
298+
let _trace = enter_trace_span!(borrow_tracker::retag_place_contents, ?kind, ?place);
299299
let this = self.eval_context_mut();
300300
let method = this.machine.borrow_tracker.as_ref().unwrap().borrow().borrow_tracker_method;
301301
match method {
@@ -305,7 +305,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
305305
}
306306

307307
fn protect_place(&mut self, place: &MPlaceTy<'tcx>) -> InterpResult<'tcx, MPlaceTy<'tcx>> {
308-
let _span = enter_trace_span!(borrow_tracker::protect_place, ?place);
308+
let _trace = enter_trace_span!(borrow_tracker::protect_place, ?place);
309309
let this = self.eval_context_mut();
310310
let method = this.machine.borrow_tracker.as_ref().unwrap().borrow().borrow_tracker_method;
311311
match method {
@@ -315,7 +315,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
315315
}
316316

317317
fn expose_tag(&self, alloc_id: AllocId, tag: BorTag) -> InterpResult<'tcx> {
318-
let _span =
318+
let _trace =
319319
enter_trace_span!(borrow_tracker::expose_tag, alloc_id = alloc_id.0, tag = tag.0);
320320
let this = self.eval_context_ref();
321321
let method = this.machine.borrow_tracker.as_ref().unwrap().borrow().borrow_tracker_method;
@@ -360,7 +360,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
360360
&self,
361361
frame: &Frame<'tcx, Provenance, FrameExtra<'tcx>>,
362362
) -> InterpResult<'tcx> {
363-
let _span = enter_trace_span!(borrow_tracker::on_stack_pop);
363+
let _trace = enter_trace_span!(borrow_tracker::on_stack_pop);
364364
let this = self.eval_context_ref();
365365
let borrow_tracker = this.machine.borrow_tracker.as_ref().unwrap();
366366
// The body of this loop needs `borrow_tracker` immutably
@@ -438,7 +438,7 @@ impl AllocState {
438438
range: AllocRange,
439439
machine: &MiriMachine<'tcx>,
440440
) -> InterpResult<'tcx> {
441-
let _span = enter_trace_span!(borrow_tracker::before_memory_read, alloc_id = alloc_id.0);
441+
let _trace = enter_trace_span!(borrow_tracker::before_memory_read, alloc_id = alloc_id.0);
442442
match self {
443443
AllocState::StackedBorrows(sb) =>
444444
sb.borrow_mut().before_memory_read(alloc_id, prov_extra, range, machine),
@@ -460,7 +460,7 @@ impl AllocState {
460460
range: AllocRange,
461461
machine: &MiriMachine<'tcx>,
462462
) -> InterpResult<'tcx> {
463-
let _span = enter_trace_span!(borrow_tracker::before_memory_write, alloc_id = alloc_id.0);
463+
let _trace = enter_trace_span!(borrow_tracker::before_memory_write, alloc_id = alloc_id.0);
464464
match self {
465465
AllocState::StackedBorrows(sb) =>
466466
sb.get_mut().before_memory_write(alloc_id, prov_extra, range, machine),
@@ -482,7 +482,7 @@ impl AllocState {
482482
size: Size,
483483
machine: &MiriMachine<'tcx>,
484484
) -> InterpResult<'tcx> {
485-
let _span =
485+
let _trace =
486486
enter_trace_span!(borrow_tracker::before_memory_deallocation, alloc_id = alloc_id.0);
487487
match self {
488488
AllocState::StackedBorrows(sb) =>
@@ -493,7 +493,7 @@ impl AllocState {
493493
}
494494

495495
pub fn remove_unreachable_tags(&self, tags: &FxHashSet<BorTag>) {
496-
let _span = enter_trace_span!(borrow_tracker::remove_unreachable_tags);
496+
let _trace = enter_trace_span!(borrow_tracker::remove_unreachable_tags);
497497
match self {
498498
AllocState::StackedBorrows(sb) => sb.borrow_mut().remove_unreachable_tags(tags),
499499
AllocState::TreeBorrows(tb) => tb.borrow_mut().remove_unreachable_tags(tags),
@@ -508,7 +508,7 @@ impl AllocState {
508508
tag: BorTag,
509509
alloc_id: AllocId, // diagnostics
510510
) -> InterpResult<'tcx> {
511-
let _span = enter_trace_span!(
511+
let _trace = enter_trace_span!(
512512
borrow_tracker::release_protector,
513513
alloc_id = alloc_id.0,
514514
tag = tag.0
@@ -523,7 +523,7 @@ impl AllocState {
523523

524524
impl VisitProvenance for AllocState {
525525
fn visit_provenance(&self, visit: &mut VisitWith<'_>) {
526-
let _span = enter_trace_span!(borrow_tracker::visit_provenance);
526+
let _trace = enter_trace_span!(borrow_tracker::visit_provenance);
527527
match self {
528528
AllocState::StackedBorrows(sb) => sb.visit_provenance(visit),
529529
AllocState::TreeBorrows(tb) => tb.visit_provenance(visit),

src/helpers.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ pub enum AccessKind {
3232
///
3333
/// A `None` namespace indicates we are looking for a module.
3434
fn try_resolve_did(tcx: TyCtxt<'_>, path: &[&str], namespace: Option<Namespace>) -> Option<DefId> {
35+
let _trace = enter_trace_span!("try_resolve_did", ?path);
36+
3537
/// Yield all children of the given item, that have the given name.
3638
fn find_children<'tcx: 'a, 'a>(
3739
tcx: TyCtxt<'tcx>,
@@ -132,7 +134,7 @@ pub fn iter_exported_symbols<'tcx>(
132134
for def_id in crate_items.definitions() {
133135
let exported = tcx.def_kind(def_id).has_codegen_attrs() && {
134136
let codegen_attrs = tcx.codegen_fn_attrs(def_id);
135-
codegen_attrs.contains_extern_indicator()
137+
codegen_attrs.contains_extern_indicator(tcx, def_id.into())
136138
|| codegen_attrs.flags.contains(CodegenFnAttrFlags::RUSTC_STD_INTERNAL_SYMBOL)
137139
|| codegen_attrs.flags.contains(CodegenFnAttrFlags::USED_COMPILER)
138140
|| codegen_attrs.flags.contains(CodegenFnAttrFlags::USED_LINKER)

src/intrinsics/atomic.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -105,27 +105,27 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
105105
}
106106

107107
"or" => {
108-
let ord = get_ord_at(1);
108+
let ord = get_ord_at(2);
109109
this.atomic_rmw_op(args, dest, AtomicOp::MirOp(BinOp::BitOr, false), rw_ord(ord))?;
110110
}
111111
"xor" => {
112-
let ord = get_ord_at(1);
112+
let ord = get_ord_at(2);
113113
this.atomic_rmw_op(args, dest, AtomicOp::MirOp(BinOp::BitXor, false), rw_ord(ord))?;
114114
}
115115
"and" => {
116-
let ord = get_ord_at(1);
116+
let ord = get_ord_at(2);
117117
this.atomic_rmw_op(args, dest, AtomicOp::MirOp(BinOp::BitAnd, false), rw_ord(ord))?;
118118
}
119119
"nand" => {
120-
let ord = get_ord_at(1);
120+
let ord = get_ord_at(2);
121121
this.atomic_rmw_op(args, dest, AtomicOp::MirOp(BinOp::BitAnd, true), rw_ord(ord))?;
122122
}
123123
"xadd" => {
124-
let ord = get_ord_at(1);
124+
let ord = get_ord_at(2);
125125
this.atomic_rmw_op(args, dest, AtomicOp::MirOp(BinOp::Add, false), rw_ord(ord))?;
126126
}
127127
"xsub" => {
128-
let ord = get_ord_at(1);
128+
let ord = get_ord_at(2);
129129
this.atomic_rmw_op(args, dest, AtomicOp::MirOp(BinOp::Sub, false), rw_ord(ord))?;
130130
}
131131
"min" => {
@@ -231,15 +231,14 @@ trait EvalContextPrivExt<'tcx>: MiriInterpCxExt<'tcx> {
231231
let place = this.deref_pointer(place)?;
232232
let rhs = this.read_immediate(rhs)?;
233233

234-
if !place.layout.ty.is_integral() && !place.layout.ty.is_raw_ptr() {
234+
if !(place.layout.ty.is_integral() || place.layout.ty.is_raw_ptr())
235+
|| !(rhs.layout.ty.is_integral() || rhs.layout.ty.is_raw_ptr())
236+
{
235237
span_bug!(
236238
this.cur_span(),
237239
"atomic arithmetic operations only work on integer and raw pointer types",
238240
);
239241
}
240-
if rhs.layout.ty != place.layout.ty {
241-
span_bug!(this.cur_span(), "atomic arithmetic operation type mismatch");
242-
}
243242

244243
let old = match atomic_op {
245244
AtomicOp::Min =>

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![cfg_attr(bootstrap, feature(strict_overflow_ops))]
12
#![feature(abort_unwind)]
23
#![feature(cfg_select)]
34
#![feature(rustc_private)]
@@ -11,7 +12,6 @@
1112
#![feature(variant_count)]
1213
#![feature(yeet_expr)]
1314
#![feature(nonzero_ops)]
14-
#![feature(strict_overflow_ops)]
1515
#![feature(pointer_is_aligned_to)]
1616
#![feature(ptr_metadata)]
1717
#![feature(unqualified_local_imports)]

src/machine.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -280,16 +280,16 @@ impl interpret::Provenance for Provenance {
280280
Ok(())
281281
}
282282

283-
fn join(left: Option<Self>, right: Option<Self>) -> Option<Self> {
283+
fn join(left: Self, right: Self) -> Option<Self> {
284284
match (left, right) {
285285
// If both are the *same* concrete tag, that is the result.
286286
(
287-
Some(Provenance::Concrete { alloc_id: left_alloc, tag: left_tag }),
288-
Some(Provenance::Concrete { alloc_id: right_alloc, tag: right_tag }),
289-
) if left_alloc == right_alloc && left_tag == right_tag => left,
287+
Provenance::Concrete { alloc_id: left_alloc, tag: left_tag },
288+
Provenance::Concrete { alloc_id: right_alloc, tag: right_tag },
289+
) if left_alloc == right_alloc && left_tag == right_tag => Some(left),
290290
// If one side is a wildcard, the best possible outcome is that it is equal to the other
291291
// one, and we use that.
292-
(Some(Provenance::Wildcard), o) | (o, Some(Provenance::Wildcard)) => o,
292+
(Provenance::Wildcard, o) | (o, Provenance::Wildcard) => Some(o),
293293
// Otherwise, fall back to `None`.
294294
_ => None,
295295
}

src/operator.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,13 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
5050
}
5151

5252
// Some more operations are possible with atomics.
53-
// The return value always has the provenance of the *left* operand.
53+
// The RHS must be `usize`.
5454
Add | Sub | BitOr | BitAnd | BitXor => {
5555
assert!(left.layout.ty.is_raw_ptr());
56-
assert!(right.layout.ty.is_raw_ptr());
56+
assert_eq!(right.layout.ty, this.tcx.types.usize);
5757
let ptr = left.to_scalar().to_pointer(this)?;
5858
// We do the actual operation with usize-typed scalars.
5959
let left = ImmTy::from_uint(ptr.addr().bytes(), this.machine.layouts.usize);
60-
let right = ImmTy::from_uint(
61-
right.to_scalar().to_target_usize(this)?,
62-
this.machine.layouts.usize,
63-
);
6460
let result = this.binary_op(bin_op, &left, &right)?;
6561
// Construct a new pointer with the provenance of `ptr` (the LHS).
6662
let result_ptr = Pointer::new(

src/shims/native_lib/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
246246
let p_map = alloc.provenance();
247247
for idx in overlap {
248248
// If a provenance was read by the foreign code, expose it.
249-
if let Some(prov) = p_map.get(Size::from_bytes(idx), this) {
249+
if let Some((prov, _idx)) = p_map.get_byte(Size::from_bytes(idx), this) {
250250
this.expose_provenance(prov)?;
251251
}
252252
}

src/shims/time.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,8 +322,8 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
322322

323323
// Since our emulated ticks in `mach_absolute_time` *are* nanoseconds,
324324
// no scaling needs to happen.
325-
let (numer, denom) = (1, 1);
326-
this.write_int_fields(&[numer.into(), denom.into()], &info)?;
325+
let (numerator, denom) = (1, 1);
326+
this.write_int_fields(&[numerator.into(), denom.into()], &info)?;
327327

328328
interp_ok(Scalar::from_i32(0)) // KERN_SUCCESS
329329
}

tests/fail/alloc/alloc_error_handler_custom.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ note: inside `_::__rg_oom`
1111
--> tests/fail/alloc/alloc_error_handler_custom.rs:LL:CC
1212
|
1313
LL | #[alloc_error_handler]
14-
| ---------------------- in this procedural macro expansion
14+
| ---------------------- in this attribute macro expansion
1515
LL | fn alloc_error_handler(layout: Layout) -> ! {
1616
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1717
= note: inside `alloc::alloc::handle_alloc_error::rt_error` at RUSTLIB/alloc/src/alloc.rs:LL:CC

0 commit comments

Comments
 (0)