Skip to content

Commit fddff47

Browse files
authored
Merge pull request #4101 from RalfJung/rustup
Rustup
2 parents db960a2 + 9659fbc commit fddff47

Some content is hidden

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

64 files changed

+947
-809
lines changed

Diff for: compiler/rustc_const_eval/src/check_consts/resolver.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use std::fmt;
66
use std::marker::PhantomData;
77

8-
use rustc_index::bit_set::BitSet;
8+
use rustc_index::bit_set::MixedBitSet;
99
use rustc_middle::mir::visit::Visitor;
1010
use rustc_middle::mir::{
1111
self, BasicBlock, CallReturnPlaces, Local, Location, Statement, StatementKind, TerminatorEdges,
@@ -246,12 +246,14 @@ where
246246
}
247247

248248
#[derive(Debug, PartialEq, Eq)]
249+
/// The state for the `FlowSensitiveAnalysis` dataflow analysis. This domain is likely homogeneous,
250+
/// and has a big size, so we use a bitset that can be sparse (c.f. issue #134404).
249251
pub(super) struct State {
250252
/// Describes whether a local contains qualif.
251-
pub qualif: BitSet<Local>,
253+
pub qualif: MixedBitSet<Local>,
252254
/// Describes whether a local's address escaped and it might become qualified as a result an
253255
/// indirect mutation.
254-
pub borrow: BitSet<Local>,
256+
pub borrow: MixedBitSet<Local>,
255257
}
256258

257259
impl Clone for State {
@@ -320,8 +322,8 @@ where
320322

321323
fn bottom_value(&self, body: &mir::Body<'tcx>) -> Self::Domain {
322324
State {
323-
qualif: BitSet::new_empty(body.local_decls.len()),
324-
borrow: BitSet::new_empty(body.local_decls.len()),
325+
qualif: MixedBitSet::new_empty(body.local_decls.len()),
326+
borrow: MixedBitSet::new_empty(body.local_decls.len()),
325327
}
326328
}
327329

Diff for: compiler/rustc_const_eval/src/const_eval/dummy_machine.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
use rustc_middle::mir::interpret::{AllocId, ConstAllocation, InterpResult};
22
use rustc_middle::mir::*;
33
use rustc_middle::query::TyCtxtAt;
4+
use rustc_middle::ty::Ty;
45
use rustc_middle::ty::layout::TyAndLayout;
56
use rustc_middle::{bug, span_bug, ty};
67
use rustc_span::def_id::DefId;
8+
use rustc_target::callconv::FnAbi;
79

810
use crate::interpret::{
911
self, HasStaticRootDefId, ImmTy, Immediate, InterpCx, PointerArithmetic, interp_ok,
@@ -86,7 +88,7 @@ impl<'tcx> interpret::Machine<'tcx> for DummyMachine {
8688
fn find_mir_or_eval_fn(
8789
_ecx: &mut InterpCx<'tcx, Self>,
8890
_instance: ty::Instance<'tcx>,
89-
_abi: rustc_abi::ExternAbi,
91+
_abi: &FnAbi<'tcx, Ty<'tcx>>,
9092
_args: &[interpret::FnArg<'tcx, Self::Provenance>],
9193
_destination: &interpret::MPlaceTy<'tcx, Self::Provenance>,
9294
_target: Option<BasicBlock>,

Diff for: compiler/rustc_const_eval/src/const_eval/machine.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::borrow::{Borrow, Cow};
22
use std::fmt;
33
use std::hash::Hash;
44

5-
use rustc_abi::{Align, ExternAbi, Size};
5+
use rustc_abi::{Align, Size};
66
use rustc_ast::Mutability;
77
use rustc_data_structures::fx::{FxHashMap, FxIndexMap, IndexEntry};
88
use rustc_hir::def_id::{DefId, LocalDefId};
@@ -14,6 +14,7 @@ use rustc_middle::ty::layout::{HasTypingEnv, TyAndLayout};
1414
use rustc_middle::ty::{self, Ty, TyCtxt};
1515
use rustc_middle::{bug, mir};
1616
use rustc_span::{Span, Symbol, sym};
17+
use rustc_target::callconv::FnAbi;
1718
use tracing::debug;
1819

1920
use super::error::*;
@@ -339,7 +340,7 @@ impl<'tcx> interpret::Machine<'tcx> for CompileTimeMachine<'tcx> {
339340
fn find_mir_or_eval_fn(
340341
ecx: &mut InterpCx<'tcx, Self>,
341342
orig_instance: ty::Instance<'tcx>,
342-
_abi: ExternAbi,
343+
_abi: &FnAbi<'tcx, Ty<'tcx>>,
343344
args: &[FnArg<'tcx>],
344345
dest: &MPlaceTy<'tcx>,
345346
ret: Option<mir::BasicBlock>,

Diff for: compiler/rustc_const_eval/src/interpret/call.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
519519
return M::call_extra_fn(
520520
self,
521521
extra,
522-
caller_abi,
522+
caller_fn_abi,
523523
args,
524524
destination,
525525
target,
@@ -570,7 +570,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
570570
let Some((body, instance)) = M::find_mir_or_eval_fn(
571571
self,
572572
instance,
573-
caller_abi,
573+
caller_fn_abi,
574574
args,
575575
destination,
576576
target,

Diff for: compiler/rustc_const_eval/src/interpret/machine.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::borrow::{Borrow, Cow};
66
use std::fmt::Debug;
77
use std::hash::Hash;
88

9-
use rustc_abi::{Align, ExternAbi, Size};
9+
use rustc_abi::{Align, Size};
1010
use rustc_apfloat::{Float, FloatConvert};
1111
use rustc_ast::{InlineAsmOptions, InlineAsmTemplatePiece};
1212
use rustc_middle::query::TyCtxtAt;
@@ -15,6 +15,7 @@ use rustc_middle::ty::layout::TyAndLayout;
1515
use rustc_middle::{mir, ty};
1616
use rustc_span::Span;
1717
use rustc_span::def_id::DefId;
18+
use rustc_target::callconv::FnAbi;
1819

1920
use super::{
2021
AllocBytes, AllocId, AllocKind, AllocRange, Allocation, CTFE_ALLOC_SALT, ConstAllocation,
@@ -201,7 +202,7 @@ pub trait Machine<'tcx>: Sized {
201202
fn find_mir_or_eval_fn(
202203
ecx: &mut InterpCx<'tcx, Self>,
203204
instance: ty::Instance<'tcx>,
204-
abi: ExternAbi,
205+
abi: &FnAbi<'tcx, Ty<'tcx>>,
205206
args: &[FnArg<'tcx, Self::Provenance>],
206207
destination: &MPlaceTy<'tcx, Self::Provenance>,
207208
target: Option<mir::BasicBlock>,
@@ -213,7 +214,7 @@ pub trait Machine<'tcx>: Sized {
213214
fn call_extra_fn(
214215
ecx: &mut InterpCx<'tcx, Self>,
215216
fn_val: Self::ExtraFnVal,
216-
abi: ExternAbi,
217+
abi: &FnAbi<'tcx, Ty<'tcx>>,
217218
args: &[FnArg<'tcx, Self::Provenance>],
218219
destination: &MPlaceTy<'tcx, Self::Provenance>,
219220
target: Option<mir::BasicBlock>,
@@ -656,7 +657,7 @@ pub macro compile_time_machine(<$tcx: lifetime>) {
656657
fn call_extra_fn(
657658
_ecx: &mut InterpCx<$tcx, Self>,
658659
fn_val: !,
659-
_abi: ExternAbi,
660+
_abi: &FnAbi<$tcx, Ty<$tcx>>,
660661
_args: &[FnArg<$tcx>],
661662
_destination: &MPlaceTy<$tcx, Self::Provenance>,
662663
_target: Option<mir::BasicBlock>,

Diff for: compiler/rustc_hir_typeck/src/method/probe.rs

+10-17
Original file line numberDiff line numberDiff line change
@@ -1229,23 +1229,16 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
12291229
if let Some(by_value_pick) = by_value_pick {
12301230
if let Ok(by_value_pick) = by_value_pick.as_ref() {
12311231
if by_value_pick.kind == PickKind::InherentImplPick {
1232-
if let Err(e) = self.check_for_shadowed_autorefd_method(
1233-
by_value_pick,
1234-
step,
1235-
self_ty,
1236-
hir::Mutability::Not,
1237-
track_unstable_candidates,
1238-
) {
1239-
return Some(Err(e));
1240-
}
1241-
if let Err(e) = self.check_for_shadowed_autorefd_method(
1242-
by_value_pick,
1243-
step,
1244-
self_ty,
1245-
hir::Mutability::Mut,
1246-
track_unstable_candidates,
1247-
) {
1248-
return Some(Err(e));
1232+
for mutbl in [hir::Mutability::Not, hir::Mutability::Mut] {
1233+
if let Err(e) = self.check_for_shadowed_autorefd_method(
1234+
by_value_pick,
1235+
step,
1236+
self_ty,
1237+
mutbl,
1238+
track_unstable_candidates,
1239+
) {
1240+
return Some(Err(e));
1241+
}
12491242
}
12501243
}
12511244
}

Diff for: compiler/rustc_index/src/bit_set.rs

+8
Original file line numberDiff line numberDiff line change
@@ -1191,6 +1191,14 @@ impl<T: Idx> MixedBitSet<T> {
11911191
}
11921192
}
11931193

1194+
#[inline]
1195+
pub fn clear(&mut self) {
1196+
match self {
1197+
MixedBitSet::Small(set) => set.clear(),
1198+
MixedBitSet::Large(set) => set.clear(),
1199+
}
1200+
}
1201+
11941202
bit_relations_inherent_impls! {}
11951203
}
11961204

Diff for: library/alloc/src/vec/mod.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -1824,7 +1824,10 @@ impl<T, A: Allocator> Vec<T, A> {
18241824
///
18251825
/// # Examples
18261826
///
1827-
/// This method can be useful for situations in which the vector
1827+
/// See [`spare_capacity_mut()`] for an example with safe
1828+
/// initialization of capacity elements and use of this method.
1829+
///
1830+
/// `set_len()` can be useful for situations in which the vector
18281831
/// is serving as a buffer for other code, particularly over FFI:
18291832
///
18301833
/// ```no_run
@@ -1884,6 +1887,8 @@ impl<T, A: Allocator> Vec<T, A> {
18841887
///
18851888
/// Normally, here, one would use [`clear`] instead to correctly drop
18861889
/// the contents and thus not leak memory.
1890+
///
1891+
/// [`spare_capacity_mut()`]: Vec::spare_capacity_mut
18871892
#[inline]
18881893
#[stable(feature = "rust1", since = "1.0.0")]
18891894
pub unsafe fn set_len(&mut self, new_len: usize) {

Diff for: library/core/src/net/ip_addr.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ impl Ipv4Addr {
527527
/// ```
528528
/// use std::net::Ipv4Addr;
529529
///
530-
/// let addr = Ipv4Addr::from(0x12345678);
530+
/// let addr = Ipv4Addr::from_bits(0x12345678);
531531
/// assert_eq!(Ipv4Addr::new(0x12, 0x34, 0x56, 0x78), addr);
532532
/// ```
533533
#[rustc_const_stable(feature = "ip_bits", since = "1.80.0")]
@@ -1294,7 +1294,7 @@ impl Ipv6Addr {
12941294
/// 0x1020, 0x3040, 0x5060, 0x7080,
12951295
/// 0x90A0, 0xB0C0, 0xD0E0, 0xF00D,
12961296
/// );
1297-
/// assert_eq!(0x102030405060708090A0B0C0D0E0F00D_u128, u128::from(addr));
1297+
/// assert_eq!(0x102030405060708090A0B0C0D0E0F00D_u128, addr.to_bits());
12981298
/// ```
12991299
///
13001300
/// ```
@@ -1330,7 +1330,7 @@ impl Ipv6Addr {
13301330
/// ```
13311331
/// use std::net::Ipv6Addr;
13321332
///
1333-
/// let addr = Ipv6Addr::from(0x102030405060708090A0B0C0D0E0F00D_u128);
1333+
/// let addr = Ipv6Addr::from_bits(0x102030405060708090A0B0C0D0E0F00D_u128);
13341334
/// assert_eq!(
13351335
/// Ipv6Addr::new(
13361336
/// 0x1020, 0x3040, 0x5060, 0x7080,

Diff for: library/core/src/slice/mod.rs

+8-7
Original file line numberDiff line numberDiff line change
@@ -4641,7 +4641,7 @@ impl<T> [T] {
46414641

46424642
/// Returns the index that an element reference points to.
46434643
///
4644-
/// Returns `None` if `element` does not point within the slice or if it points between elements.
4644+
/// Returns `None` if `element` does not point to the start of an element within the slice.
46454645
///
46464646
/// This method is useful for extending slice iterators like [`slice::split`].
46474647
///
@@ -4661,9 +4661,9 @@ impl<T> [T] {
46614661
/// let num = &nums[2];
46624662
///
46634663
/// assert_eq!(num, &1);
4664-
/// assert_eq!(nums.elem_offset(num), Some(2));
4664+
/// assert_eq!(nums.element_offset(num), Some(2));
46654665
/// ```
4666-
/// Returning `None` with an in-between element:
4666+
/// Returning `None` with an unaligned element:
46674667
/// ```
46684668
/// #![feature(substr_range)]
46694669
///
@@ -4676,12 +4676,12 @@ impl<T> [T] {
46764676
/// assert_eq!(ok_elm, &[0, 1]);
46774677
/// assert_eq!(weird_elm, &[1, 2]);
46784678
///
4679-
/// assert_eq!(arr.elem_offset(ok_elm), Some(0)); // Points to element 0
4680-
/// assert_eq!(arr.elem_offset(weird_elm), None); // Points between element 0 and 1
4679+
/// assert_eq!(arr.element_offset(ok_elm), Some(0)); // Points to element 0
4680+
/// assert_eq!(arr.element_offset(weird_elm), None); // Points between element 0 and 1
46814681
/// ```
46824682
#[must_use]
46834683
#[unstable(feature = "substr_range", issue = "126769")]
4684-
pub fn elem_offset(&self, element: &T) -> Option<usize> {
4684+
pub fn element_offset(&self, element: &T) -> Option<usize> {
46854685
if T::IS_ZST {
46864686
panic!("elements are zero-sized");
46874687
}
@@ -4702,7 +4702,8 @@ impl<T> [T] {
47024702

47034703
/// Returns the range of indices that a subslice points to.
47044704
///
4705-
/// Returns `None` if `subslice` does not point within the slice or if it points between elements.
4705+
/// Returns `None` if `subslice` does not point within the slice or if it is not aligned with the
4706+
/// elements in the slice.
47064707
///
47074708
/// This method **does not compare elements**. Instead, this method finds the location in the slice that
47084709
/// `subslice` was obtained from. To find the index of a subslice via comparison, instead use

0 commit comments

Comments
 (0)