Skip to content

Commit

Permalink
Auto merge of rust-lang#3303 - rust-lang:rustup-2024-02-17, r=saethlin
Browse files Browse the repository at this point in the history
Automatic Rustup
  • Loading branch information
bors committed Feb 17, 2024
2 parents 454f054 + f9c8ad5 commit f856ddd
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion rust-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0f806a9812b62c36bdab08d33c14cf2d3ecf4355
4316d0c6252cb1f833e582dfa68adb98efd5ddfb
5 changes: 3 additions & 2 deletions src/bin/miri.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![feature(generic_nonzero)]
#![feature(rustc_private, stmt_expr_attributes)]
#![allow(
clippy::manual_range_contains,
Expand All @@ -19,7 +20,7 @@ extern crate rustc_session;
extern crate tracing;

use std::env::{self, VarError};
use std::num::NonZeroU64;
use std::num::NonZero;
use std::path::PathBuf;
use std::str::FromStr;

Expand Down Expand Up @@ -524,7 +525,7 @@ fn main() {
}
}
} else if let Some(param) = arg.strip_prefix("-Zmiri-track-alloc-id=") {
let ids: Vec<miri::AllocId> = match parse_comma_list::<NonZeroU64>(param) {
let ids: Vec<miri::AllocId> = match parse_comma_list::<NonZero<u64>>(param) {
Ok(ids) => ids.into_iter().map(miri::AllocId).collect(),
Err(err) =>
show_error!(
Expand Down
14 changes: 7 additions & 7 deletions src/borrow_tracker/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::cell::RefCell;
use std::fmt;
use std::num::NonZeroU64;
use std::num::NonZero;

use smallvec::SmallVec;

Expand All @@ -12,22 +12,22 @@ use crate::*;
pub mod stacked_borrows;
pub mod tree_borrows;

pub type CallId = NonZeroU64;
pub type CallId = NonZero<u64>;

/// Tracking pointer provenance
#[derive(Copy, Clone, Hash, PartialEq, Eq, PartialOrd, Ord)]
pub struct BorTag(NonZeroU64);
pub struct BorTag(NonZero<u64>);

impl BorTag {
pub fn new(i: u64) -> Option<Self> {
NonZeroU64::new(i).map(BorTag)
NonZero::new(i).map(BorTag)
}

pub fn get(&self) -> u64 {
self.0.get()
}

pub fn inner(&self) -> NonZeroU64 {
pub fn inner(&self) -> NonZero<u64> {
self.0
}

Expand Down Expand Up @@ -183,7 +183,7 @@ impl GlobalStateInner {
borrow_tracker_method,
next_ptr_tag: BorTag::one(),
base_ptr_tags: FxHashMap::default(),
next_call_id: NonZeroU64::new(1).unwrap(),
next_call_id: NonZero::new(1).unwrap(),
protected_tags: FxHashMap::default(),
tracked_pointer_tags,
tracked_call_ids,
Expand All @@ -205,7 +205,7 @@ impl GlobalStateInner {
if self.tracked_call_ids.contains(&call_id) {
machine.emit_diagnostic(NonHaltingDiagnostic::CreatedCallId(call_id));
}
self.next_call_id = NonZeroU64::new(call_id.get() + 1).unwrap();
self.next_call_id = NonZero::new(call_id.get() + 1).unwrap();
FrameState { call_id, protected_tags: SmallVec::new() }
}

Expand Down
1 change: 0 additions & 1 deletion src/concurrency/init_once.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::collections::VecDeque;
use std::num::NonZeroU32;

use rustc_index::Idx;
use rustc_middle::ty::layout::TyAndLayout;
Expand Down
9 changes: 4 additions & 5 deletions src/concurrency/sync.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::collections::{hash_map::Entry, VecDeque};
use std::num::NonZeroU32;
use std::ops::Not;

use rustc_data_structures::fx::FxHashMap;
Expand All @@ -24,12 +23,12 @@ macro_rules! declare_id {
/// 0 is used to indicate that the id was not yet assigned and,
/// therefore, is not a valid identifier.
#[derive(Clone, Copy, Debug, PartialOrd, Ord, PartialEq, Eq, Hash)]
pub struct $name(NonZeroU32);
pub struct $name(std::num::NonZero<u32>);

impl SyncId for $name {
// Panics if `id == 0`.
fn from_u32(id: u32) -> Self {
Self(NonZeroU32::new(id).unwrap())
Self(std::num::NonZero::new(id).unwrap())
}
fn to_u32(&self) -> u32 {
self.0.get()
Expand All @@ -42,11 +41,11 @@ macro_rules! declare_id {
// therefore, need to shift by one when converting from an index
// into a vector.
let shifted_idx = u32::try_from(idx).unwrap().checked_add(1).unwrap();
$name(NonZeroU32::new(shifted_idx).unwrap())
$name(std::num::NonZero::new(shifted_idx).unwrap())
}
fn index(self) -> usize {
// See the comment in `Self::new`.
// (This cannot underflow because self is NonZeroU32.)
// (This cannot underflow because `self.0` is `NonZero<u32>`.)
usize::try_from(self.0.get() - 1).unwrap()
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/diagnostics.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::fmt::{self, Write};
use std::num::NonZeroU64;
use std::num::NonZero;

use rustc_errors::{DiagnosticBuilder, DiagnosticMessage, Level};
use rustc_span::{SpanData, Symbol, DUMMY_SP};
Expand Down Expand Up @@ -110,7 +110,7 @@ pub enum NonHaltingDiagnostic {
/// (new_tag, new_perm, (alloc_id, base_offset, orig_tag))
///
/// new_perm is `None` for base tags.
CreatedPointerTag(NonZeroU64, Option<String>, Option<(AllocId, AllocRange, ProvenanceExtra)>),
CreatedPointerTag(NonZero<u64>, Option<String>, Option<(AllocId, AllocRange, ProvenanceExtra)>),
/// This `Item` was popped from the borrow stack. The string explains the reason.
PoppedPointerTag(Item, String),
CreatedCallId(CallId),
Expand Down
4 changes: 2 additions & 2 deletions src/helpers.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::cmp;
use std::iter;
use std::num::NonZeroUsize;
use std::num::NonZero;
use std::time::Duration;

use rustc_apfloat::ieee::{Double, Single};
Expand Down Expand Up @@ -572,7 +572,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
fn visit_union(
&mut self,
_v: &MPlaceTy<'tcx, Provenance>,
_fields: NonZeroUsize,
_fields: NonZero<usize>,
) -> InterpResult<'tcx> {
bug!("we should have already handled unions in `visit_value`")
}
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#![feature(rustc_private)]
#![feature(cell_update)]
#![feature(float_gamma)]
#![feature(generic_nonzero)]
#![feature(map_try_insert)]
#![feature(never_type)]
#![feature(try_blocks)]
Expand Down
2 changes: 1 addition & 1 deletion src/shims/foreign_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ trait EvalContextExtPriv<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
let [id, show_unnamed] = this.check_shim(abi, Abi::Rust, link_name, args)?;
let id = this.read_scalar(id)?.to_u64()?;
let show_unnamed = this.read_scalar(show_unnamed)?.to_bool()?;
if let Some(id) = std::num::NonZeroU64::new(id) {
if let Some(id) = std::num::NonZero::new(id) {
this.print_borrow_state(AllocId(id), show_unnamed)?;
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/pass/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ fn main() {
let mut saw_false = false;

for _ in 0..50 {
if unsafe { intrinsics::is_val_statically_known(0) } {
if intrinsics::is_val_statically_known(0) {
saw_true = true;
} else {
saw_false = true;
Expand Down

0 comments on commit f856ddd

Please sign in to comment.