Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 9 pull requests #69652

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
6f568e7
miri engine: turn some debug_assert into assert
RalfJung Feb 28, 2020
5982e9d
downgrade some assertions to debug_ again
RalfJung Feb 29, 2020
275dac7
doc(librustc_error_codes): add long error explanation for E0719
thekuom Mar 1, 2020
99a595e
Fix a leak in `DiagnosticBuilder::into_diagnostic`.
nnethercote Mar 2, 2020
4643b12
Update my mailmap entry
XAMPPRocky Mar 2, 2020
ba49ed0
clean up E0378 explanation
GuillaumeGomez Mar 2, 2020
0ec1408
Don't convert Results to Options just for matching.
matthiaskrgr Mar 1, 2020
fdc14cb
Toolstate: don't duplicate nightly tool list.
ehuss Mar 2, 2020
4281fe0
Update books
ehuss Mar 2, 2020
d8e3557
Remove `usable_size` APIs
TimDiekmann Mar 2, 2020
f53764a
Rollup merge of #69565 - RalfJung:assert, r=eddyb
Dylan-DPC Mar 3, 2020
d198d60
Rollup merge of #69609 - TimDiekmann:excess, r=Amanieu
Dylan-DPC Mar 3, 2020
1eb9857
Rollup merge of #69620 - thekuom:doc/61137-add-long-error-code-e0719,…
Dylan-DPC Mar 3, 2020
28e4c7a
Rollup merge of #69626 - ehuss:toolstate-nightly-cleanup, r=Mark-Simu…
Dylan-DPC Mar 3, 2020
6a07f16
Rollup merge of #69628 - nnethercote:fix-DiagnosticBuilder-into_diagn…
Dylan-DPC Mar 3, 2020
473c7a8
Rollup merge of #69633 - XAMPPRocky:master, r=Dylan-DPC
Dylan-DPC Mar 3, 2020
11ff6dd
Rollup merge of #69634 - GuillaumeGomez:clean-up-e0378, r=Dylan-DPC
Dylan-DPC Mar 3, 2020
917ecab
Rollup merge of #69637 - matthiaskrgr:if_let_some_result, r=ecstatic-…
Dylan-DPC Mar 3, 2020
284cd89
Rollup merge of #69641 - ehuss:update-books, r=ehuss
Dylan-DPC Mar 3, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
# email addresses.
#

Aaron Power <theaaronepower@gmail.com> Erin Power <xampprocky@gmail.com>
Aaron Todd <github@opprobrio.us>
Abhishek Chanda <abhishek.becs@gmail.com> Abhishek Chanda <abhishek@cloudscaling.com>
Adolfo Ochagavía <aochagavia92@gmail.com>
Expand Down Expand Up @@ -84,6 +83,8 @@ Eric Holk <eric.holk@gmail.com> <eholk@mozilla.com>
Eric Holmes <eric@ejholmes.net>
Eric Reed <ecreed@cs.washington.edu> <ereed@mozilla.com>
Erick Tryzelaar <erick.tryzelaar@gmail.com> <etryzelaar@iqt.org>
Erin Power <xampprocky@gmail.com> <theaaronepower@gmail.com>
Erin Power <xampprocky@gmail.com> <Aaronepower@users.noreply.github.com>
Esteban Küber <esteban@kuber.com.ar> <esteban@commure.com>
Esteban Küber <esteban@kuber.com.ar> <estebank@users.noreply.github.com>
Esteban Küber <esteban@kuber.com.ar> <github@kuber.com.ar>
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/toolstate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ fn change_toolstate(
if new_state != state {
eprintln!("The state of `{}` has changed from `{}` to `{}`", tool, state, new_state);
if new_state < state {
if !["rustc-guide", "miri", "embedded-book"].contains(&tool.as_str()) {
if !NIGHTLY_TOOLS.iter().any(|(name, _path)| name == tool) {
regressed = true;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/doc/embedded-book
14 changes: 7 additions & 7 deletions src/liballoc/alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ pub unsafe fn alloc_zeroed(layout: Layout) -> *mut u8 {
#[unstable(feature = "allocator_api", issue = "32838")]
unsafe impl AllocRef for Global {
#[inline]
unsafe fn alloc(&mut self, layout: Layout) -> Result<NonNull<u8>, AllocErr> {
NonNull::new(alloc(layout)).ok_or(AllocErr)
unsafe fn alloc(&mut self, layout: Layout) -> Result<(NonNull<u8>, usize), AllocErr> {
NonNull::new(alloc(layout)).ok_or(AllocErr).map(|p| (p, layout.size()))
}

#[inline]
Expand All @@ -180,13 +180,13 @@ unsafe impl AllocRef for Global {
ptr: NonNull<u8>,
layout: Layout,
new_size: usize,
) -> Result<NonNull<u8>, AllocErr> {
NonNull::new(realloc(ptr.as_ptr(), layout, new_size)).ok_or(AllocErr)
) -> Result<(NonNull<u8>, usize), AllocErr> {
NonNull::new(realloc(ptr.as_ptr(), layout, new_size)).ok_or(AllocErr).map(|p| (p, new_size))
}

#[inline]
unsafe fn alloc_zeroed(&mut self, layout: Layout) -> Result<NonNull<u8>, AllocErr> {
NonNull::new(alloc_zeroed(layout)).ok_or(AllocErr)
unsafe fn alloc_zeroed(&mut self, layout: Layout) -> Result<(NonNull<u8>, usize), AllocErr> {
NonNull::new(alloc_zeroed(layout)).ok_or(AllocErr).map(|p| (p, layout.size()))
}
}

Expand All @@ -201,7 +201,7 @@ unsafe fn exchange_malloc(size: usize, align: usize) -> *mut u8 {
} else {
let layout = Layout::from_size_align_unchecked(size, align);
match Global.alloc(layout) {
Ok(ptr) => ptr.as_ptr(),
Ok((ptr, _)) => ptr.as_ptr(),
Err(_) => handle_alloc_error(layout),
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/liballoc/alloc/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use test::Bencher;
fn allocate_zeroed() {
unsafe {
let layout = Layout::from_size_align(1024, 1).unwrap();
let ptr =
let (ptr, _) =
Global.alloc_zeroed(layout.clone()).unwrap_or_else(|_| handle_alloc_error(layout));

let mut i = ptr.cast::<u8>().as_ptr();
Expand Down
4 changes: 2 additions & 2 deletions src/liballoc/boxed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ impl<T> Box<T> {
let ptr = if layout.size() == 0 {
NonNull::dangling()
} else {
Global.alloc(layout).unwrap_or_else(|_| alloc::handle_alloc_error(layout)).cast()
Global.alloc(layout).unwrap_or_else(|_| alloc::handle_alloc_error(layout)).0.cast()
};
Box::from_raw(ptr.as_ptr())
}
Expand Down Expand Up @@ -270,7 +270,7 @@ impl<T> Box<[T]> {
let ptr = if layout.size() == 0 {
NonNull::dangling()
} else {
Global.alloc(layout).unwrap_or_else(|_| alloc::handle_alloc_error(layout)).cast()
Global.alloc(layout).unwrap_or_else(|_| alloc::handle_alloc_error(layout)).0.cast()
};
Box::from_raw(slice::from_raw_parts_mut(ptr.as_ptr(), len))
}
Expand Down
21 changes: 13 additions & 8 deletions src/liballoc/raw_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ impl<T, A: AllocRef> RawVec<T, A> {
RawVec::allocate_in(capacity, true, a)
}

fn allocate_in(capacity: usize, zeroed: bool, mut a: A) -> Self {
fn allocate_in(mut capacity: usize, zeroed: bool, mut a: A) -> Self {
unsafe {
let elem_size = mem::size_of::<T>();

Expand All @@ -87,7 +87,10 @@ impl<T, A: AllocRef> RawVec<T, A> {
let layout = Layout::from_size_align(alloc_size, align).unwrap();
let result = if zeroed { a.alloc_zeroed(layout) } else { a.alloc(layout) };
match result {
Ok(ptr) => ptr.cast(),
Ok((ptr, size)) => {
capacity = size / elem_size;
ptr.cast()
}
Err(_) => handle_alloc_error(layout),
}
};
Expand Down Expand Up @@ -280,7 +283,7 @@ impl<T, A: AllocRef> RawVec<T, A> {
// 0, getting to here necessarily means the `RawVec` is overfull.
assert!(elem_size != 0, "capacity overflow");

let (new_cap, ptr) = match self.current_layout() {
let (ptr, new_cap) = match self.current_layout() {
Some(cur) => {
// Since we guarantee that we never allocate more than
// `isize::MAX` bytes, `elem_size * self.cap <= isize::MAX` as
Expand All @@ -297,7 +300,7 @@ impl<T, A: AllocRef> RawVec<T, A> {
alloc_guard(new_size).unwrap_or_else(|_| capacity_overflow());
let ptr_res = self.a.realloc(NonNull::from(self.ptr).cast(), cur, new_size);
match ptr_res {
Ok(ptr) => (new_cap, ptr),
Ok((ptr, new_size)) => (ptr, new_size / elem_size),
Err(_) => handle_alloc_error(Layout::from_size_align_unchecked(
new_size,
cur.align(),
Expand All @@ -310,7 +313,7 @@ impl<T, A: AllocRef> RawVec<T, A> {
let new_cap = if elem_size > (!0) / 8 { 1 } else { 4 };
let layout = Layout::array::<T>(new_cap).unwrap();
match self.a.alloc(layout) {
Ok(ptr) => (new_cap, ptr),
Ok((ptr, new_size)) => (ptr, new_size / elem_size),
Err(_) => handle_alloc_error(layout),
}
}
Expand Down Expand Up @@ -598,7 +601,7 @@ impl<T, A: AllocRef> RawVec<T, A> {
let align = mem::align_of::<T>();
let old_layout = Layout::from_size_align_unchecked(old_size, align);
match self.a.realloc(NonNull::from(self.ptr).cast(), old_layout, new_size) {
Ok(p) => self.ptr = p.cast().into(),
Ok((ptr, _)) => self.ptr = ptr.cast().into(),
Err(_) => {
handle_alloc_error(Layout::from_size_align_unchecked(new_size, align))
}
Expand Down Expand Up @@ -631,6 +634,8 @@ impl<T, A: AllocRef> RawVec<T, A> {
fallibility: Fallibility,
strategy: ReserveStrategy,
) -> Result<(), TryReserveError> {
let elem_size = mem::size_of::<T>();

unsafe {
// NOTE: we don't early branch on ZSTs here because we want this
// to actually catch "asking for more than usize::MAX" in that case.
Expand Down Expand Up @@ -662,15 +667,15 @@ impl<T, A: AllocRef> RawVec<T, A> {
None => self.a.alloc(new_layout),
};

let ptr = match (res, fallibility) {
let (ptr, new_cap) = match (res, fallibility) {
(Err(AllocErr), Infallible) => handle_alloc_error(new_layout),
(Err(AllocErr), Fallible) => {
return Err(TryReserveError::AllocError {
layout: new_layout,
non_exhaustive: (),
});
}
(Ok(ptr), _) => ptr,
(Ok((ptr, new_size)), _) => (ptr, new_size / elem_size),
};

self.ptr = ptr.cast().into();
Expand Down
2 changes: 1 addition & 1 deletion src/liballoc/raw_vec/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ fn allocator_param() {
fuel: usize,
}
unsafe impl AllocRef for BoundedAlloc {
unsafe fn alloc(&mut self, layout: Layout) -> Result<NonNull<u8>, AllocErr> {
unsafe fn alloc(&mut self, layout: Layout) -> Result<(NonNull<u8>, usize), AllocErr> {
let size = layout.size();
if size > self.fuel {
return Err(AllocErr);
Expand Down
2 changes: 1 addition & 1 deletion src/liballoc/rc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -923,7 +923,7 @@ impl<T: ?Sized> Rc<T> {
let layout = Layout::new::<RcBox<()>>().extend(value_layout).unwrap().0.pad_to_align();

// Allocate for the layout.
let mem = Global.alloc(layout).unwrap_or_else(|_| handle_alloc_error(layout));
let (mem, _) = Global.alloc(layout).unwrap_or_else(|_| handle_alloc_error(layout));

// Initialize the RcBox
let inner = mem_to_rcbox(mem.as_ptr());
Expand Down
2 changes: 1 addition & 1 deletion src/liballoc/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,7 @@ impl<T: ?Sized> Arc<T> {
// reference (see #54908).
let layout = Layout::new::<ArcInner<()>>().extend(value_layout).unwrap().0.pad_to_align();

let mem = Global.alloc(layout).unwrap_or_else(|_| handle_alloc_error(layout));
let (mem, _) = Global.alloc(layout).unwrap_or_else(|_| handle_alloc_error(layout));

// Initialize the ArcInner
let inner = mem_to_arcinner(mem.as_ptr());
Expand Down
2 changes: 1 addition & 1 deletion src/liballoc/tests/heap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ fn check_overalign_requests<T: AllocRef>(mut allocator: T) {
unsafe {
let pointers: Vec<_> = (0..iterations)
.map(|_| {
allocator.alloc(Layout::from_size_align(size, align).unwrap()).unwrap()
allocator.alloc(Layout::from_size_align(size, align).unwrap()).unwrap().0
})
.collect();
for &ptr in &pointers {
Expand Down
Loading