Skip to content

Rollup of 5 pull requests #62561

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

Merged
merged 40 commits into from
Jul 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
f6e5ac6
rustc_mir: treat DropAndReplace as Drop + Assign in qualify_consts.
eddyb Jul 1, 2019
8918881
Give index temporaries a drop scope
matthewjasper Jul 7, 2019
163c059
Only omit StorageLive/Dead for variable that are never initialized
matthewjasper Jul 7, 2019
bc322af
doc(ptr): add example for {read,write}_unaligned
Freyskeyd Jul 8, 2019
76a8bc2
Use fold in Iterator::last
czipperz Jul 7, 2019
9b0ebfa
Move literal_to_string to fmt::Display
Mark-Simulacrum Jun 26, 2019
0f10d11
Remove duplicate attr_to_string
Mark-Simulacrum Jul 5, 2019
a440337
Remove unused arm_to_string
Mark-Simulacrum Jul 5, 2019
11d5216
Move lifetime_to_string to Display impl
Mark-Simulacrum Jul 5, 2019
ae5ed9b
Don't re-collect tokenstream twice to pretty print
Mark-Simulacrum Jul 5, 2019
4483980
Privatize and remove unused functions
Mark-Simulacrum Jul 5, 2019
a573d14
Remove unused boxes vector
Mark-Simulacrum Jul 5, 2019
59b161c
Stop Option-wrapping comments
Mark-Simulacrum Jul 5, 2019
9b5e397
Inline State::new
Mark-Simulacrum Jul 5, 2019
0eb2e56
Combine comment-handling logic into struct
Mark-Simulacrum Jul 5, 2019
7e37914
Replace src: &mut dyn Read with String
Mark-Simulacrum Jul 5, 2019
e0db2e6
print_crate returns String instead of taking an out pointer
Mark-Simulacrum Jul 5, 2019
e0ffa7c
Inline State::new_from_input in pprust
Mark-Simulacrum Jul 5, 2019
00ca508
Move pp::Printer out field to owned String
Mark-Simulacrum Jul 5, 2019
4c58fc3
Fully privatize (vs. crate visibility) functions
Mark-Simulacrum Jul 6, 2019
ccf279d
Remove useless call to indent
Mark-Simulacrum Jul 6, 2019
cd2d832
Move BufEntry assignment into scan_push
Mark-Simulacrum Jul 6, 2019
55a6a76
Simplify check_stack implementation
Mark-Simulacrum Jul 7, 2019
57cf7a2
Simplify print_end
Mark-Simulacrum Jul 7, 2019
4783d9e
Remove is_begin/is_end functions from PrintState
Mark-Simulacrum Jul 7, 2019
5879146
Rename pretty_print_* to scan_* to follow naming in the paper
Mark-Simulacrum Jul 8, 2019
04b80a5
Drop length from Token::String
Mark-Simulacrum Jul 5, 2019
39aa9bf
Remove needless indirection in bclose
Mark-Simulacrum Jul 9, 2019
e91dbc5
Rename is_bol -> is_beginning_of_line
Mark-Simulacrum Jul 9, 2019
cab4532
Move pp::Printer helpers to direct impl
Mark-Simulacrum Jul 9, 2019
daf1b29
Properly case indent_unit constant
Mark-Simulacrum Jul 9, 2019
63fdf1a
Remove needless indent arguments
Mark-Simulacrum Jul 9, 2019
73c1752
Use constant instead of magic number
Mark-Simulacrum Jul 9, 2019
096cb41
Remove writer function from PrintState
Mark-Simulacrum Jul 9, 2019
56a9237
File is now short enough for tidy
Mark-Simulacrum Jul 9, 2019
a2cbae8
Rollup merge of #62275 - eddyb:const-drop-replace, r=pnkfelix
Centril Jul 10, 2019
5760bc6
Rollup merge of #62465 - matthewjasper:never-type-storage, r=pnkfelix
Centril Jul 10, 2019
ad21558
Rollup merge of #62481 - czipperz:iterator-last-nth-use-for_each, r=s…
Centril Jul 10, 2019
d0cec04
Rollup merge of #62493 - Freyskeyd:valid_example_read-write_unaligned…
Centril Jul 10, 2019
3c299a9
Rollup merge of #62532 - Mark-Simulacrum:syntax-print-cleanup, r=petr…
Centril Jul 10, 2019
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
4 changes: 1 addition & 3 deletions src/libcore/iter/traits/iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,7 @@ pub trait Iterator {
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
fn last(self) -> Option<Self::Item> where Self: Sized {
let mut last = None;
for x in self { last = Some(x); }
last
self.fold(None, |_, x| Some(x))
}

/// Returns the `n`th element of the iterator.
Expand Down
32 changes: 32 additions & 0 deletions src/libcore/ptr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,22 @@ pub unsafe fn read<T>(src: *const T) -> T {
///
/// Accessing unaligned fields directly with e.g. `packed.unaligned` is safe however.
// FIXME: Update docs based on outcome of RFC #2582 and friends.
///
/// # Examples
///
/// Read an usize value from a byte buffer:
///
/// ```
/// use std::mem;
///
/// fn read_usize(x: &[u8]) -> usize {
/// assert!(x.len() >= mem::size_of::<usize>());
///
/// let ptr = x.as_ptr() as *const usize;
///
/// unsafe { ptr.read_unaligned() }
/// }
/// ```
#[inline]
#[stable(feature = "ptr_unaligned", since = "1.17.0")]
pub unsafe fn read_unaligned<T>(src: *const T) -> T {
Expand Down Expand Up @@ -839,6 +855,22 @@ pub unsafe fn write<T>(dst: *mut T, src: T) {
///
/// Accessing unaligned fields directly with e.g. `packed.unaligned` is safe however.
// FIXME: Update docs based on outcome of RFC #2582 and friends.
///
/// # Examples
///
/// Write an usize value to a byte buffer:
///
/// ```
/// use std::mem;
///
/// fn write_usize(x: &mut [u8], val: usize) {
/// assert!(x.len() >= mem::size_of::<usize>());
///
/// let ptr = x.as_mut_ptr() as *mut usize;
///
/// unsafe { ptr.write_unaligned(val) }
/// }
/// ```
#[inline]
#[stable(feature = "ptr_unaligned", since = "1.17.0")]
pub unsafe fn write_unaligned<T>(dst: *mut T, src: T) {
Expand Down
4 changes: 1 addition & 3 deletions src/librustc/hir/map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1212,10 +1212,8 @@ impl<'a> print::State<'a> {
Node::Pat(a) => self.print_pat(&a),
Node::Arm(a) => self.print_arm(&a),
Node::Block(a) => {
use syntax::print::pprust::PrintState;

// containing cbox, will be closed by print-block at }
self.cbox(print::indent_unit);
self.cbox(print::INDENT_UNIT);
// head-ibox, will be closed by print-block after {
self.ibox(0);
self.print_block(&a)
Expand Down
Loading