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 15 pull requests #52958

Merged
merged 32 commits into from
Aug 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
8e88d64
Added test for #49579.
davidtwco Jul 28, 2018
6d5694a
fix memrchr in miri
RalfJung Jul 30, 2018
d5f1f70
Fix Alias intra doc ICE
GuillaumeGomez Jul 29, 2018
f985e6c
tests/ui: Add missing mips{64} ignores
Jul 31, 2018
38e311e
Use SetLenOnDrop in Vec::truncate()
lnicola Jul 31, 2018
d94bdf8
Put back original field discovery
GuillaumeGomez Jul 31, 2018
84dc485
Allow borrow conflicts for promoted length 0 arrays
matthewjasper Jul 31, 2018
0babbf1
Don't count MIR locals as borrowed after StorageDead when finding loc…
Zoxc Jul 31, 2018
dbc0cd9
rustc_resolve: record single-segment extern crate import resolutions.
eddyb Aug 1, 2018
e462c06
Another SmallVec.extend optimization
llogiq Aug 1, 2018
b5ed39f
Implement custom read_to_end for io::Take
ljedrz Aug 1, 2018
1d64b24
Switch syntax attribute tracking to BitVector
Mark-Simulacrum Jul 30, 2018
9bc4fbb
Split out growth functionality into BitVector type
Mark-Simulacrum Jul 30, 2018
27b3cb5
rustc: Trim down the `rust_2018_idioms` lint group
alexcrichton Jul 31, 2018
c2d57db
1.27 actually added the `armv5te-unknown-linux-musleabi` target
Susurrus Aug 1, 2018
8bbf042
Added test for #49824.
davidtwco Jul 27, 2018
f685142
async can begin expressions
cramertj Aug 1, 2018
334da29
Rollup merge of #52793 - davidtwco:issue-49824, r=pnkfelix
pietroalbini Aug 1, 2018
42243f8
Rollup merge of #52799 - Mark-Simulacrum:attr-id-bitvecs, r=michaelwo…
pietroalbini Aug 1, 2018
4d1ddfe
Rollup merge of #52809 - davidtwco:issue-49579, r=pnkfelix
pietroalbini Aug 1, 2018
d5fcd27
Rollup merge of #52834 - matthewjasper:allow-zst-conflicts, r=pnkfelix
pietroalbini Aug 1, 2018
f52ef3b
Rollup merge of #52835 - GuillaumeGomez:ice-rustdoc-links, r=eddyb
pietroalbini Aug 1, 2018
e3928cc
Rollup merge of #52854 - RalfJung:memrchr, r=Kimundi
pietroalbini Aug 1, 2018
3ae03e9
Rollup merge of #52899 - draganmladjenovic:ui_tests64, r=alexcrichton
pietroalbini Aug 1, 2018
1997c70
Rollup merge of #52908 - lnicola:vec-truncate-opt, r=alexcrichton
pietroalbini Aug 1, 2018
b40b899
Rollup merge of #52915 - Zoxc:refine-gen-borrow-analysis, r=eddyb
pietroalbini Aug 1, 2018
110b71a
Rollup merge of #52926 - alexcrichton:trim-idioms-lints, r=oli-obk
pietroalbini Aug 1, 2018
2893bd0
Rollup merge of #52930 - eddyb:issue-52489, r=cramertj
pietroalbini Aug 1, 2018
eeb7b6a
Rollup merge of #52939 - ljedrz:fix_51746, r=kennytm
pietroalbini Aug 1, 2018
6e7e385
Rollup merge of #52942 - llogiq:smallvec-opt, r=Mark-Simulacrum
pietroalbini Aug 1, 2018
b2392fa
Rollup merge of #52947 - Susurrus:patch-1, r=alexcrichton
pietroalbini Aug 1, 2018
3e7897f
Rollup merge of #52954 - cramertj:async-parse, r=petrochenkov
pietroalbini Aug 1, 2018
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
2 changes: 1 addition & 1 deletion RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ Language

Compiler
--------
- [Added the `armv5te-unknown-linux-musl` target.][50423]
- [Added the `armv5te-unknown-linux-musleabi` target.][50423]

Libraries
---------
Expand Down
23 changes: 17 additions & 6 deletions src/liballoc/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -690,14 +690,20 @@ impl<T> Vec<T> {
/// [`drain`]: #method.drain
#[stable(feature = "rust1", since = "1.0.0")]
pub fn truncate(&mut self, len: usize) {
let current_len = self.len;
unsafe {
let mut ptr = self.as_mut_ptr().offset(self.len as isize);
// Set the final length at the end, keeping in mind that
// dropping an element might panic. Works around a missed
// optimization, as seen in the following issue:
// https://github.com/rust-lang/rust/issues/51802
let mut local_len = SetLenOnDrop::new(&mut self.len);

// drop any extra elements
while len < self.len {
// decrement len before the drop_in_place(), so a panic on Drop
// doesn't re-drop the just-failed value.
self.len -= 1;
let len = self.len;
ptr::drop_in_place(self.get_unchecked_mut(len));
for _ in len..current_len {
local_len.decrement_len(1);
ptr = ptr.offset(-1);
ptr::drop_in_place(ptr);
}
}
}
Expand Down Expand Up @@ -1512,6 +1518,11 @@ impl<'a> SetLenOnDrop<'a> {
fn increment_len(&mut self, increment: usize) {
self.local_len += increment;
}

#[inline]
fn decrement_len(&mut self, decrement: usize) {
self.local_len -= decrement;
}
}

impl<'a> Drop for SetLenOnDrop<'a> {
Expand Down
26 changes: 16 additions & 10 deletions src/libcore/slice/memchr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,24 +100,30 @@ pub fn memrchr(x: u8, text: &[u8]) -> Option<usize> {
// - the first remaining bytes, < 2 word size
let len = text.len();
let ptr = text.as_ptr();
let usize_bytes = mem::size_of::<usize>();
type Chunk = usize;

let mut offset = {
// We call this just to obtain the length of the suffix
let (_, _, suffix) = unsafe { text.align_to::<usize>() };
len - suffix.len()
let (min_aligned_offset, max_aligned_offset) = {
// We call this just to obtain the length of the prefix and suffix.
// In the middle we always process two chunks at once.
let (prefix, _, suffix) = unsafe { text.align_to::<(Chunk, Chunk)>() };
(prefix.len(), len - suffix.len())
};

let mut offset = max_aligned_offset;
if let Some(index) = text[offset..].iter().rposition(|elt| *elt == x) {
return Some(offset + index);
}

// search the body of the text
// search the body of the text, make sure we don't cross min_aligned_offset.
// offset is always aligned, so just testing `>` is sufficient and avoids possible
// overflow.
let repeated_x = repeat_byte(x);
let chunk_bytes = mem::size_of::<Chunk>();

while offset >= 2 * usize_bytes {
while offset > min_aligned_offset {
unsafe {
let u = *(ptr.offset(offset as isize - 2 * usize_bytes as isize) as *const usize);
let v = *(ptr.offset(offset as isize - usize_bytes as isize) as *const usize);
let u = *(ptr.offset(offset as isize - 2 * chunk_bytes as isize) as *const Chunk);
let v = *(ptr.offset(offset as isize - chunk_bytes as isize) as *const Chunk);

// break if there is a matching byte
let zu = contains_zero_byte(u ^ repeated_x);
Expand All @@ -126,7 +132,7 @@ pub fn memrchr(x: u8, text: &[u8]) -> Option<usize> {
break;
}
}
offset -= 2 * usize_bytes;
offset -= 2 * chunk_bytes;
}

// find the byte before the point the body loop stopped
Expand Down
10 changes: 5 additions & 5 deletions src/librustc/mir/traversal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use rustc_data_structures::bitvec::BitVector;
use rustc_data_structures::bitvec::BitArray;

use super::*;

Expand All @@ -32,7 +32,7 @@ use super::*;
#[derive(Clone)]
pub struct Preorder<'a, 'tcx: 'a> {
mir: &'a Mir<'tcx>,
visited: BitVector<BasicBlock>,
visited: BitArray<BasicBlock>,
worklist: Vec<BasicBlock>,
}

Expand All @@ -42,7 +42,7 @@ impl<'a, 'tcx> Preorder<'a, 'tcx> {

Preorder {
mir,
visited: BitVector::new(mir.basic_blocks().len()),
visited: BitArray::new(mir.basic_blocks().len()),
worklist,
}
}
Expand Down Expand Up @@ -104,15 +104,15 @@ impl<'a, 'tcx> ExactSizeIterator for Preorder<'a, 'tcx> {}
/// A Postorder traversal of this graph is `D B C A` or `D C B A`
pub struct Postorder<'a, 'tcx: 'a> {
mir: &'a Mir<'tcx>,
visited: BitVector<BasicBlock>,
visited: BitArray<BasicBlock>,
visit_stack: Vec<(BasicBlock, Successors<'a>)>
}

impl<'a, 'tcx> Postorder<'a, 'tcx> {
pub fn new(mir: &'a Mir<'tcx>, root: BasicBlock) -> Postorder<'a, 'tcx> {
let mut po = Postorder {
mir,
visited: BitVector::new(mir.basic_blocks().len()),
visited: BitArray::new(mir.basic_blocks().len()),
visit_stack: Vec::new()
};

Expand Down
4 changes: 2 additions & 2 deletions src/librustc/traits/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ use middle::lang_items;
use mir::interpret::{GlobalId};

use rustc_data_structures::sync::Lock;
use rustc_data_structures::bitvec::BitVector;
use rustc_data_structures::bitvec::BitArray;
use std::iter;
use std::cmp;
use std::fmt;
Expand Down Expand Up @@ -3056,7 +3056,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
} else {
return Err(Unimplemented);
};
let mut ty_params = BitVector::new(substs_a.types().count());
let mut ty_params = BitArray::new(substs_a.types().count());
let mut found = false;
for ty in field.walk() {
if let ty::TyParam(p) = ty.sty {
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_codegen_llvm/debuginfo/create_scope_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use libc::c_uint;

use syntax_pos::Pos;

use rustc_data_structures::bitvec::BitVector;
use rustc_data_structures::bitvec::BitArray;
use rustc_data_structures::indexed_vec::{Idx, IndexVec};

use syntax_pos::BytePos;
Expand Down Expand Up @@ -64,7 +64,7 @@ pub fn create_mir_scopes(
};

// Find all the scopes with variables defined in them.
let mut has_variables = BitVector::new(mir.source_scopes.len());
let mut has_variables = BitArray::new(mir.source_scopes.len());
for var in mir.vars_iter() {
let decl = &mir.local_decls[var];
has_variables.insert(decl.visibility_scope);
Expand All @@ -81,7 +81,7 @@ pub fn create_mir_scopes(

fn make_mir_scope(cx: &CodegenCx<'ll, '_>,
mir: &Mir,
has_variables: &BitVector<SourceScope>,
has_variables: &BitArray<SourceScope>,
debug_context: &FunctionDebugContextData<'ll>,
scope: SourceScope,
scopes: &mut IndexVec<SourceScope, MirDebugScope<'ll>>) {
Expand Down
8 changes: 4 additions & 4 deletions src/librustc_codegen_llvm/mir/analyze.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
//! An analysis to determine which locals require allocas and
//! which do not.

use rustc_data_structures::bitvec::BitVector;
use rustc_data_structures::bitvec::BitArray;
use rustc_data_structures::graph::dominators::Dominators;
use rustc_data_structures::indexed_vec::{Idx, IndexVec};
use rustc::mir::{self, Location, TerminatorKind};
Expand All @@ -22,7 +22,7 @@ use rustc::ty::layout::LayoutOf;
use type_of::LayoutLlvmExt;
use super::FunctionCx;

pub fn non_ssa_locals(fx: &FunctionCx<'a, 'll, 'tcx>) -> BitVector<mir::Local> {
pub fn non_ssa_locals(fx: &FunctionCx<'a, 'll, 'tcx>) -> BitArray<mir::Local> {
let mir = fx.mir;
let mut analyzer = LocalAnalyzer::new(fx);

Expand Down Expand Up @@ -54,7 +54,7 @@ pub fn non_ssa_locals(fx: &FunctionCx<'a, 'll, 'tcx>) -> BitVector<mir::Local> {
struct LocalAnalyzer<'mir, 'a: 'mir, 'll: 'a, 'tcx: 'll> {
fx: &'mir FunctionCx<'a, 'll, 'tcx>,
dominators: Dominators<mir::BasicBlock>,
non_ssa_locals: BitVector<mir::Local>,
non_ssa_locals: BitArray<mir::Local>,
// The location of the first visited direct assignment to each
// local, or an invalid location (out of bounds `block` index).
first_assignment: IndexVec<mir::Local, Location>
Expand All @@ -67,7 +67,7 @@ impl LocalAnalyzer<'mir, 'a, 'll, 'tcx> {
let mut analyzer = LocalAnalyzer {
fx,
dominators: fx.mir.dominators(),
non_ssa_locals: BitVector::new(fx.mir.local_decls.len()),
non_ssa_locals: BitArray::new(fx.mir.local_decls.len()),
first_assignment: IndexVec::from_elem(invalid_location, &fx.mir.local_decls)
};

Expand Down
6 changes: 3 additions & 3 deletions src/librustc_codegen_llvm/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use syntax::symbol::keywords;

use std::iter;

use rustc_data_structures::bitvec::BitVector;
use rustc_data_structures::bitvec::BitArray;
use rustc_data_structures::indexed_vec::{IndexVec, Idx};

pub use self::constant::codegen_static_initializer;
Expand Down Expand Up @@ -323,7 +323,7 @@ pub fn codegen_mir(
debuginfo::start_emitting_source_locations(&fx.debug_context);

let rpo = traversal::reverse_postorder(&mir);
let mut visited = BitVector::new(mir.basic_blocks().len());
let mut visited = BitArray::new(mir.basic_blocks().len());

// Codegen the body of each block using reverse postorder
for (bb, _) in rpo {
Expand Down Expand Up @@ -417,7 +417,7 @@ fn arg_local_refs(
bx: &Builder<'a, 'll, 'tcx>,
fx: &FunctionCx<'a, 'll, 'tcx>,
scopes: &IndexVec<mir::SourceScope, debuginfo::MirDebugScope<'ll>>,
memory_locals: &BitVector<mir::Local>,
memory_locals: &BitArray<mir::Local>,
) -> Vec<LocalRef<'ll, 'tcx>> {
let mir = fx.mir;
let tcx = bx.tcx();
Expand Down
Loading