Skip to content

Commit 6828cf9

Browse files
committed
Auto merge of #47235 - kennytm:rollup, r=kennytm
Rollup of 7 pull requests - Successful merges: #46947, #47170, #47190, #47205, #47217, #47220, #47230 - Failed merges: #47233
2 parents 72176cf + ce70106 commit 6828cf9

File tree

54 files changed

+278
-192
lines changed

Some content is hidden

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

54 files changed

+278
-192
lines changed

src/liballoc/btree/set.rs

+33
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,16 @@ impl<T: Ord> BTreeSet<T> {
415415
/// The value may be any borrowed form of the set's value type,
416416
/// but the ordering on the borrowed form *must* match the
417417
/// ordering on the value type.
418+
///
419+
/// # Examples
420+
///
421+
/// ```
422+
/// use std::collections::BTreeSet;
423+
///
424+
/// let set: BTreeSet<_> = [1, 2, 3].iter().cloned().collect();
425+
/// assert_eq!(set.get(&2), Some(&2));
426+
/// assert_eq!(set.get(&4), None);
427+
/// ```
418428
#[stable(feature = "set_recovery", since = "1.9.0")]
419429
pub fn get<Q: ?Sized>(&self, value: &Q) -> Option<&T>
420430
where T: Borrow<Q>,
@@ -540,6 +550,19 @@ impl<T: Ord> BTreeSet<T> {
540550

541551
/// Adds a value to the set, replacing the existing value, if any, that is equal to the given
542552
/// one. Returns the replaced value.
553+
///
554+
/// # Examples
555+
///
556+
/// ```
557+
/// use std::collections::BTreeSet;
558+
///
559+
/// let mut set = BTreeSet::new();
560+
/// set.insert(Vec::<i32>::new());
561+
///
562+
/// assert_eq!(set.get(&[][..]).unwrap().capacity(), 0);
563+
/// set.replace(Vec::with_capacity(10));
564+
/// assert_eq!(set.get(&[][..]).unwrap().capacity(), 10);
565+
/// ```
543566
#[stable(feature = "set_recovery", since = "1.9.0")]
544567
pub fn replace(&mut self, value: T) -> Option<T> {
545568
Recover::replace(&mut self.map, value)
@@ -576,6 +599,16 @@ impl<T: Ord> BTreeSet<T> {
576599
/// The value may be any borrowed form of the set's value type,
577600
/// but the ordering on the borrowed form *must* match the
578601
/// ordering on the value type.
602+
///
603+
/// # Examples
604+
///
605+
/// ```
606+
/// use std::collections::BTreeSet;
607+
///
608+
/// let mut set: BTreeSet<_> = [1, 2, 3].iter().cloned().collect();
609+
/// assert_eq!(set.take(&2), Some(2));
610+
/// assert_eq!(set.take(&2), None);
611+
/// ```
579612
#[stable(feature = "set_recovery", since = "1.9.0")]
580613
pub fn take<Q: ?Sized>(&mut self, value: &Q) -> Option<T>
581614
where T: Borrow<Q>,

src/libcore/num/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ macro_rules! int_impl {
439439
}
440440

441441
/// Checked integer division. Computes `self / rhs`, returning `None`
442-
/// if `rhs == 0` or the operation results in overflow.
442+
/// if `rhs == 0` or the division results in overflow.
443443
///
444444
/// # Examples
445445
///
@@ -461,7 +461,7 @@ macro_rules! int_impl {
461461
}
462462

463463
/// Checked integer remainder. Computes `self % rhs`, returning `None`
464-
/// if `rhs == 0` or the operation results in overflow.
464+
/// if `rhs == 0` or the division results in overflow.
465465
///
466466
/// # Examples
467467
///
@@ -1607,7 +1607,7 @@ macro_rules! uint_impl {
16071607
}
16081608

16091609
/// Checked integer division. Computes `self / rhs`, returning `None`
1610-
/// if `rhs == 0` or the operation results in overflow.
1610+
/// if `rhs == 0`.
16111611
///
16121612
/// # Examples
16131613
///
@@ -1627,7 +1627,7 @@ macro_rules! uint_impl {
16271627
}
16281628

16291629
/// Checked integer remainder. Computes `self % rhs`, returning `None`
1630-
/// if `rhs == 0` or the operation results in overflow.
1630+
/// if `rhs == 0`.
16311631
///
16321632
/// # Examples
16331633
///

src/libpanic_abort/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ pub unsafe extern fn __rust_maybe_catch_panic(f: fn(*mut u8),
5353
pub unsafe extern fn __rust_start_panic(_data: usize, _vtable: usize) -> u32 {
5454
abort();
5555

56-
#[cfg(unix)]
56+
#[cfg(any(unix, target_os = "cloudabi"))]
5757
unsafe fn abort() -> ! {
5858
extern crate libc;
5959
libc::abort();

src/libpanic_unwind/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ mod imp;
6868

6969
// i686-pc-windows-gnu and all others
7070
#[cfg(any(all(unix, not(target_os = "emscripten")),
71+
target_os = "cloudabi",
7172
target_os = "redox",
7273
all(windows, target_arch = "x86", target_env = "gnu")))]
7374
#[path = "gcc.rs"]

src/librustc/ich/impls_syntax.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,8 @@ impl_stable_hash_for!(enum ::syntax::ast::LitKind {
155155
Bool(value)
156156
});
157157

158-
impl_stable_hash_for!(enum ::syntax::ast::IntTy { Is, I8, I16, I32, I64, I128 });
159-
impl_stable_hash_for!(enum ::syntax::ast::UintTy { Us, U8, U16, U32, U64, U128 });
158+
impl_stable_hash_for!(enum ::syntax::ast::IntTy { Isize, I8, I16, I32, I64, I128 });
159+
impl_stable_hash_for!(enum ::syntax::ast::UintTy { Usize, U8, U16, U32, U64, U128 });
160160
impl_stable_hash_for!(enum ::syntax::ast::FloatTy { F32, F64 });
161161
impl_stable_hash_for!(enum ::syntax::ast::Unsafety { Unsafe, Normal });
162162
impl_stable_hash_for!(enum ::syntax::ast::Constness { Const, NotConst });

src/librustc/mir/interpret/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ impl<'tcx> MemoryPointer {
145145
}
146146

147147

148-
#[derive(Copy, Clone, Eq, Hash, Ord, PartialEq, PartialOrd, Debug)]
148+
#[derive(Copy, Clone, Default, Eq, Hash, Ord, PartialEq, PartialOrd, Debug)]
149149
pub struct AllocId(pub u64);
150150

151151
impl fmt::Display for AllocId {

src/librustc/session/config.rs

+6
Original file line numberDiff line numberDiff line change
@@ -1082,6 +1082,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
10821082
"gather borrowck statistics"),
10831083
no_landing_pads: bool = (false, parse_bool, [TRACKED],
10841084
"omit landing pads for unwinding"),
1085+
fewer_names: bool = (false, parse_bool, [TRACKED],
1086+
"reduce memory use by retaining fewer names within compilation artifacts (LLVM-IR)"),
10851087
debug_llvm: bool = (false, parse_bool, [UNTRACKED],
10861088
"enable debug output from LLVM"),
10871089
meta_stats: bool = (false, parse_bool, [UNTRACKED],
@@ -2811,6 +2813,10 @@ mod tests {
28112813
opts.debugging_opts.no_landing_pads = true;
28122814
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
28132815

2816+
opts = reference.clone();
2817+
opts.debugging_opts.fewer_names = true;
2818+
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
2819+
28142820
opts = reference.clone();
28152821
opts.debugging_opts.no_trans = true;
28162822
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());

src/librustc/session/mod.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use lint;
1818
use middle::allocator::AllocatorKind;
1919
use middle::dependency_format;
2020
use session::search_paths::PathKind;
21-
use session::config::{BorrowckMode, DebugInfoLevel};
21+
use session::config::{BorrowckMode, DebugInfoLevel, OutputType};
2222
use ty::tls;
2323
use util::nodemap::{FxHashMap, FxHashSet};
2424
use util::common::{duration_to_secs_str, ErrorReported};
@@ -504,6 +504,13 @@ impl Session {
504504
pub fn linker_flavor(&self) -> LinkerFlavor {
505505
self.opts.debugging_opts.linker_flavor.unwrap_or(self.target.target.linker_flavor)
506506
}
507+
508+
pub fn fewer_names(&self) -> bool {
509+
let more_names = self.opts.output_types.contains_key(&OutputType::LlvmAssembly) ||
510+
self.opts.output_types.contains_key(&OutputType::Bitcode);
511+
self.opts.debugging_opts.fewer_names || !more_names
512+
}
513+
507514
pub fn no_landing_pads(&self) -> bool {
508515
self.opts.debugging_opts.no_landing_pads || self.panic_strategy() == PanicStrategy::Abort
509516
}

src/librustc/ty/context.rs

+19-21
Original file line numberDiff line numberDiff line change
@@ -754,13 +754,13 @@ impl<'tcx> CommonTypes<'tcx> {
754754
char: mk(TyChar),
755755
never: mk(TyNever),
756756
err: mk(TyError),
757-
isize: mk(TyInt(ast::IntTy::Is)),
757+
isize: mk(TyInt(ast::IntTy::Isize)),
758758
i8: mk(TyInt(ast::IntTy::I8)),
759759
i16: mk(TyInt(ast::IntTy::I16)),
760760
i32: mk(TyInt(ast::IntTy::I32)),
761761
i64: mk(TyInt(ast::IntTy::I64)),
762762
i128: mk(TyInt(ast::IntTy::I128)),
763-
usize: mk(TyUint(ast::UintTy::Us)),
763+
usize: mk(TyUint(ast::UintTy::Usize)),
764764
u8: mk(TyUint(ast::UintTy::U8)),
765765
u16: mk(TyUint(ast::UintTy::U16)),
766766
u32: mk(TyUint(ast::UintTy::U32)),
@@ -895,31 +895,29 @@ pub struct InterpretInterner<'tcx> {
895895
allocs: FxHashSet<&'tcx interpret::Allocation>,
896896

897897
/// Allows obtaining function instance handles via a unique identifier
898-
functions: FxHashMap<u64, Instance<'tcx>>,
898+
functions: FxHashMap<interpret::AllocId, Instance<'tcx>>,
899899

900900
/// Inverse map of `interpret_functions`.
901901
/// Used so we don't allocate a new pointer every time we need one
902-
function_cache: FxHashMap<Instance<'tcx>, u64>,
902+
function_cache: FxHashMap<Instance<'tcx>, interpret::AllocId>,
903903

904904
/// Allows obtaining const allocs via a unique identifier
905-
alloc_by_id: FxHashMap<u64, &'tcx interpret::Allocation>,
905+
alloc_by_id: FxHashMap<interpret::AllocId, &'tcx interpret::Allocation>,
906906

907907
/// The AllocId to assign to the next new regular allocation.
908908
/// Always incremented, never gets smaller.
909-
next_id: u64,
909+
next_id: interpret::AllocId,
910910

911911
/// Allows checking whether a constant already has an allocation
912-
///
913-
/// The pointers are to the beginning of an `alloc_by_id` allocation
914-
alloc_cache: FxHashMap<interpret::GlobalId<'tcx>, interpret::Pointer>,
912+
alloc_cache: FxHashMap<interpret::GlobalId<'tcx>, interpret::AllocId>,
915913

916914
/// A cache for basic byte allocations keyed by their contents. This is used to deduplicate
917915
/// allocations for string and bytestring literals.
918-
literal_alloc_cache: FxHashMap<Vec<u8>, u64>,
916+
literal_alloc_cache: FxHashMap<Vec<u8>, interpret::AllocId>,
919917
}
920918

921919
impl<'tcx> InterpretInterner<'tcx> {
922-
pub fn create_fn_alloc(&mut self, instance: Instance<'tcx>) -> u64 {
920+
pub fn create_fn_alloc(&mut self, instance: Instance<'tcx>) -> interpret::AllocId {
923921
if let Some(&alloc_id) = self.function_cache.get(&instance) {
924922
return alloc_id;
925923
}
@@ -932,29 +930,29 @@ impl<'tcx> InterpretInterner<'tcx> {
932930

933931
pub fn get_fn(
934932
&self,
935-
id: u64,
933+
id: interpret::AllocId,
936934
) -> Option<Instance<'tcx>> {
937935
self.functions.get(&id).cloned()
938936
}
939937

940938
pub fn get_alloc(
941939
&self,
942-
id: u64,
940+
id: interpret::AllocId,
943941
) -> Option<&'tcx interpret::Allocation> {
944942
self.alloc_by_id.get(&id).cloned()
945943
}
946944

947945
pub fn get_cached(
948946
&self,
949947
global_id: interpret::GlobalId<'tcx>,
950-
) -> Option<interpret::Pointer> {
948+
) -> Option<interpret::AllocId> {
951949
self.alloc_cache.get(&global_id).cloned()
952950
}
953951

954952
pub fn cache(
955953
&mut self,
956954
global_id: interpret::GlobalId<'tcx>,
957-
ptr: interpret::Pointer,
955+
ptr: interpret::AllocId,
958956
) {
959957
if let Some(old) = self.alloc_cache.insert(global_id, ptr) {
960958
bug!("tried to cache {:?}, but was already existing as {:#?}", global_id, old);
@@ -963,7 +961,7 @@ impl<'tcx> InterpretInterner<'tcx> {
963961

964962
pub fn intern_at_reserved(
965963
&mut self,
966-
id: u64,
964+
id: interpret::AllocId,
967965
alloc: &'tcx interpret::Allocation,
968966
) {
969967
if let Some(old) = self.alloc_by_id.insert(id, alloc) {
@@ -975,9 +973,9 @@ impl<'tcx> InterpretInterner<'tcx> {
975973
/// yet have an allocation backing it.
976974
pub fn reserve(
977975
&mut self,
978-
) -> u64 {
976+
) -> interpret::AllocId {
979977
let next = self.next_id;
980-
self.next_id = self.next_id
978+
self.next_id.0 = self.next_id.0
981979
.checked_add(1)
982980
.expect("You overflowed a u64 by incrementing by 1... \
983981
You've just earned yourself a free drink if we ever meet. \
@@ -1069,7 +1067,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
10691067
}
10701068

10711069
/// Allocates a byte or string literal for `mir::interpret`
1072-
pub fn allocate_cached(self, bytes: &[u8]) -> u64 {
1070+
pub fn allocate_cached(self, bytes: &[u8]) -> interpret::AllocId {
10731071
// check whether we already allocated this literal or a constant with the same memory
10741072
if let Some(&alloc_id) = self.interpret_interner.borrow().literal_alloc_cache.get(bytes) {
10751073
return alloc_id;
@@ -1912,7 +1910,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
19121910

19131911
pub fn mk_mach_int(self, tm: ast::IntTy) -> Ty<'tcx> {
19141912
match tm {
1915-
ast::IntTy::Is => self.types.isize,
1913+
ast::IntTy::Isize => self.types.isize,
19161914
ast::IntTy::I8 => self.types.i8,
19171915
ast::IntTy::I16 => self.types.i16,
19181916
ast::IntTy::I32 => self.types.i32,
@@ -1923,7 +1921,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
19231921

19241922
pub fn mk_mach_uint(self, tm: ast::UintTy) -> Ty<'tcx> {
19251923
match tm {
1926-
ast::UintTy::Us => self.types.usize,
1924+
ast::UintTy::Usize => self.types.usize,
19271925
ast::UintTy::U8 => self.types.u8,
19281926
ast::UintTy::U16 => self.types.u16,
19291927
ast::UintTy::U32 => self.types.u32,

src/librustc/ty/layout.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ impl<'a, 'tcx> Integer {
520520
attr::SignedInt(IntTy::I32) | attr::UnsignedInt(UintTy::U32) => I32,
521521
attr::SignedInt(IntTy::I64) | attr::UnsignedInt(UintTy::U64) => I64,
522522
attr::SignedInt(IntTy::I128) | attr::UnsignedInt(UintTy::U128) => I128,
523-
attr::SignedInt(IntTy::Is) | attr::UnsignedInt(UintTy::Us) => {
523+
attr::SignedInt(IntTy::Isize) | attr::UnsignedInt(UintTy::Usize) => {
524524
dl.ptr_sized_integer()
525525
}
526526
}

src/librustc/ty/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1575,7 +1575,7 @@ impl ReprOptions {
15751575
pub fn linear(&self) -> bool { self.flags.contains(ReprFlags::IS_LINEAR) }
15761576

15771577
pub fn discr_type(&self) -> attr::IntType {
1578-
self.int.unwrap_or(attr::SignedInt(ast::IntTy::Is))
1578+
self.int.unwrap_or(attr::SignedInt(ast::IntTy::Isize))
15791579
}
15801580

15811581
/// Returns true if this `#[repr()]` should inhabit "smart enum

src/librustc/ty/sty.rs

+1-8
Original file line numberDiff line numberDiff line change
@@ -1478,13 +1478,6 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
14781478
}
14791479
}
14801480

1481-
pub fn is_uint(&self) -> bool {
1482-
match self.sty {
1483-
TyInfer(IntVar(_)) | TyUint(ast::UintTy::Us) => true,
1484-
_ => false
1485-
}
1486-
}
1487-
14881481
pub fn is_char(&self) -> bool {
14891482
match self.sty {
14901483
TyChar => true,
@@ -1512,7 +1505,7 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
15121505

15131506
pub fn is_machine(&self) -> bool {
15141507
match self.sty {
1515-
TyInt(ast::IntTy::Is) | TyUint(ast::UintTy::Us) => false,
1508+
TyInt(ast::IntTy::Isize) | TyUint(ast::UintTy::Usize) => false,
15161509
TyInt(..) | TyUint(..) | TyFloat(..) => true,
15171510
_ => false,
15181511
}

src/librustc/ty/util.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ macro_rules! typed_literal {
5555
SignedInt(ast::IntTy::I32) => ConstInt::I32($lit),
5656
SignedInt(ast::IntTy::I64) => ConstInt::I64($lit),
5757
SignedInt(ast::IntTy::I128) => ConstInt::I128($lit),
58-
SignedInt(ast::IntTy::Is) => match $tcx.sess.target.isize_ty {
58+
SignedInt(ast::IntTy::Isize) => match $tcx.sess.target.isize_ty {
5959
ast::IntTy::I16 => ConstInt::Isize(ConstIsize::Is16($lit)),
6060
ast::IntTy::I32 => ConstInt::Isize(ConstIsize::Is32($lit)),
6161
ast::IntTy::I64 => ConstInt::Isize(ConstIsize::Is64($lit)),
@@ -66,7 +66,7 @@ macro_rules! typed_literal {
6666
UnsignedInt(ast::UintTy::U32) => ConstInt::U32($lit),
6767
UnsignedInt(ast::UintTy::U64) => ConstInt::U64($lit),
6868
UnsignedInt(ast::UintTy::U128) => ConstInt::U128($lit),
69-
UnsignedInt(ast::UintTy::Us) => match $tcx.sess.target.usize_ty {
69+
UnsignedInt(ast::UintTy::Usize) => match $tcx.sess.target.usize_ty {
7070
ast::UintTy::U16 => ConstInt::Usize(ConstUsize::Us16($lit)),
7171
ast::UintTy::U32 => ConstInt::Usize(ConstUsize::Us32($lit)),
7272
ast::UintTy::U64 => ConstInt::Usize(ConstUsize::Us64($lit)),
@@ -84,13 +84,13 @@ impl IntTypeExt for attr::IntType {
8484
SignedInt(ast::IntTy::I32) => tcx.types.i32,
8585
SignedInt(ast::IntTy::I64) => tcx.types.i64,
8686
SignedInt(ast::IntTy::I128) => tcx.types.i128,
87-
SignedInt(ast::IntTy::Is) => tcx.types.isize,
87+
SignedInt(ast::IntTy::Isize) => tcx.types.isize,
8888
UnsignedInt(ast::UintTy::U8) => tcx.types.u8,
8989
UnsignedInt(ast::UintTy::U16) => tcx.types.u16,
9090
UnsignedInt(ast::UintTy::U32) => tcx.types.u32,
9191
UnsignedInt(ast::UintTy::U64) => tcx.types.u64,
9292
UnsignedInt(ast::UintTy::U128) => tcx.types.u128,
93-
UnsignedInt(ast::UintTy::Us) => tcx.types.usize,
93+
UnsignedInt(ast::UintTy::Usize) => tcx.types.usize,
9494
}
9595
}
9696

@@ -105,13 +105,13 @@ impl IntTypeExt for attr::IntType {
105105
(SignedInt(ast::IntTy::I32), ConstInt::I32(_)) => {},
106106
(SignedInt(ast::IntTy::I64), ConstInt::I64(_)) => {},
107107
(SignedInt(ast::IntTy::I128), ConstInt::I128(_)) => {},
108-
(SignedInt(ast::IntTy::Is), ConstInt::Isize(_)) => {},
108+
(SignedInt(ast::IntTy::Isize), ConstInt::Isize(_)) => {},
109109
(UnsignedInt(ast::UintTy::U8), ConstInt::U8(_)) => {},
110110
(UnsignedInt(ast::UintTy::U16), ConstInt::U16(_)) => {},
111111
(UnsignedInt(ast::UintTy::U32), ConstInt::U32(_)) => {},
112112
(UnsignedInt(ast::UintTy::U64), ConstInt::U64(_)) => {},
113113
(UnsignedInt(ast::UintTy::U128), ConstInt::U128(_)) => {},
114-
(UnsignedInt(ast::UintTy::Us), ConstInt::Usize(_)) => {},
114+
(UnsignedInt(ast::UintTy::Usize), ConstInt::Usize(_)) => {},
115115
_ => bug!("disr type mismatch: {:?} vs {:?}", self, val),
116116
}
117117
}

0 commit comments

Comments
 (0)