Skip to content

Commit

Permalink
Auto merge of #55502 - kennytm:rollup, r=kennytm
Browse files Browse the repository at this point in the history
Rollup of 12 pull requests

Successful merges:

 - #54885 (Don't lint 'unused_parens` on `if (break _) { .. }`)
 - #55205 (Improve a few cases of collecting to an FxHash(Map/Set))
 - #55450 (msp430: remove the whole Atomic* API)
 - #55459 (Add UI test for #49296)
 - #55472 (Use opt.take() instead of mem::replace(opt, None))
 - #55473 (Take advantage of impl Iterator in (transitive/elaborate)_bounds)
 - #55474 (Fix validation false positive)
 - #55476 (Change a flat_map with 0/1-element vecs to a filter_map)
 - #55487 (Adjust Ids of path segments in visibility modifiers)
 - #55493 (Doc fixes)
 - #55494 (borrowck=migrate must look at parents of closures)
 - #55496 (Update clippy)

Failed merges:

r? @ghost
  • Loading branch information
bors committed Oct 30, 2018
2 parents b1ca390 + c16ff6e commit e8aef7c
Show file tree
Hide file tree
Showing 38 changed files with 444 additions and 139 deletions.
9 changes: 5 additions & 4 deletions src/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ dependencies = [
"clippy-mini-macro-test 0.2.0",
"clippy_dev 0.0.1",
"clippy_lints 0.0.212",
"compiletest_rs 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)",
"compiletest_rs 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
"derive-new 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
Expand Down Expand Up @@ -443,7 +443,7 @@ dependencies = [

[[package]]
name = "compiletest_rs"
version = "0.3.13"
version = "0.3.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"diff 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
Expand All @@ -452,6 +452,7 @@ dependencies = [
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
"miow 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.75 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 1.0.75 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.31 (registry+https://github.com/rust-lang/crates.io-index)",
Expand Down Expand Up @@ -1289,7 +1290,7 @@ dependencies = [
"byteorder 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"cargo_metadata 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"colored 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"compiletest_rs 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)",
"compiletest_rs 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
"env_logger 0.5.12 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
"vergen 3.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
Expand Down Expand Up @@ -3202,7 +3203,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum colored 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b0aa3473e85a3161b59845d6096b289bb577874cafeaf75ea1b1beaa6572c7fc"
"checksum commoncrypto 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d056a8586ba25a1e4d61cb090900e495952c7886786fc55f909ab2f819b69007"
"checksum commoncrypto-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1fed34f46747aa73dfaa578069fd8279d2818ade2b55f38f22a9401c7f4083e2"
"checksum compiletest_rs 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)" = "d3064bc712922596dd5ab449fca9261d411893356581fe5297b96aa8f53bb1b8"
"checksum compiletest_rs 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)" = "75e809f56d6aa9575b67924b0af686c4f4c1380314f47947e235e9ff7fa94bed"
"checksum core-foundation 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cc3532ec724375c7cb7ff0a097b714fde180bb1f6ed2ab27cfcd99ffca873cd2"
"checksum core-foundation-sys 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a3fb15cdbdd9cf8b82d97d0296bb5cd3631bba58d6e31650a002a8e7fb5721f9"
"checksum crossbeam 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "24ce9782d4d5c53674646a6a4c1863a21a8fc0cb649b3c94dfc16e45071dea19"
Expand Down
2 changes: 2 additions & 0 deletions src/liballoc/collections/vec_deque.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ use vec::Vec;

const INITIAL_CAPACITY: usize = 7; // 2^3 - 1
const MINIMUM_CAPACITY: usize = 1; // 2 - 1
#[cfg(target_pointer_width = "16")]
const MAXIMUM_ZST_CAPACITY: usize = 1 << (16 - 1); // Largest possible power of two
#[cfg(target_pointer_width = "32")]
const MAXIMUM_ZST_CAPACITY: usize = 1 << (32 - 1); // Largest possible power of two
#[cfg(target_pointer_width = "64")]
Expand Down
8 changes: 7 additions & 1 deletion src/librustc/hir/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3022,8 +3022,14 @@ impl<'a> LoweringContext<'a> {
hir::VisibilityKind::Inherited => hir::VisibilityKind::Inherited,
hir::VisibilityKind::Restricted { ref path, id: _, hir_id: _ } => {
let id = this.next_id();
let mut path = path.clone();
for seg in path.segments.iter_mut() {
if seg.id.is_some() {
seg.id = Some(this.next_id().node_id);
}
}
hir::VisibilityKind::Restricted {
path: path.clone(),
path,
id: id.node_id,
hir_id: id.hir_id,
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/hir/map/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
};

bug!("inconsistent DepNode for `{}`: \
current_dep_node_owner={} ({:?}), hir_id.owner={} ({:?}) {}",
current_dep_node_owner={} ({:?}), hir_id.owner={} ({:?}){}",
node_str,
self.definitions
.def_path(self.current_dep_node_owner)
Expand Down
5 changes: 1 addition & 4 deletions src/librustc/infer/lexical_region_resolve/graphviz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,7 @@ impl<'a, 'gcx, 'tcx> dot::GraphWalk<'a> for ConstraintGraph<'a, 'gcx, 'tcx> {
type Node = Node;
type Edge = Edge<'tcx>;
fn nodes(&self) -> dot::Nodes<'_, Node> {
let mut set = FxHashSet::default();
for node in self.node_ids.keys() {
set.insert(*node);
}
let set = self.node_ids.keys().cloned().collect::<FxHashSet<_>>();
debug!("constraint graph has {} nodes", set.len());
set.into_iter().collect()
}
Expand Down
7 changes: 3 additions & 4 deletions src/librustc/middle/dependency_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,11 @@ pub enum Linkage {

pub fn calculate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
let sess = &tcx.sess;
let mut fmts = FxHashMap::default();
for &ty in sess.crate_types.borrow().iter() {
let fmts = sess.crate_types.borrow().iter().map(|&ty| {
let linkage = calculate_type(tcx, ty);
verify_ok(tcx, &linkage);
fmts.insert(ty, linkage);
}
(ty, linkage)
}).collect::<FxHashMap<_, _>>();
sess.abort_if_errors();
sess.dependency_formats.set(fmts);
}
Expand Down
7 changes: 3 additions & 4 deletions src/librustc/traits/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,10 @@ pub fn elaborate_trait_ref<'cx, 'gcx, 'tcx>(

pub fn elaborate_trait_refs<'cx, 'gcx, 'tcx>(
tcx: TyCtxt<'cx, 'gcx, 'tcx>,
trait_refs: &[ty::PolyTraitRef<'tcx>])
trait_refs: impl Iterator<Item = ty::PolyTraitRef<'tcx>>)
-> Elaborator<'cx, 'gcx, 'tcx>
{
let predicates = trait_refs.iter()
.map(|trait_ref| trait_ref.to_predicate())
let predicates = trait_refs.map(|trait_ref| trait_ref.to_predicate())
.collect();
elaborate_predicates(tcx, predicates)
}
Expand Down Expand Up @@ -271,7 +270,7 @@ pub fn supertraits<'cx, 'gcx, 'tcx>(tcx: TyCtxt<'cx, 'gcx, 'tcx>,
}

pub fn transitive_bounds<'cx, 'gcx, 'tcx>(tcx: TyCtxt<'cx, 'gcx, 'tcx>,
bounds: &[ty::PolyTraitRef<'tcx>])
bounds: impl Iterator<Item = ty::PolyTraitRef<'tcx>>)
-> Supertraits<'cx, 'gcx, 'tcx>
{
elaborate_trait_refs(tcx, bounds).filter_to_traits()
Expand Down
9 changes: 6 additions & 3 deletions src/librustc/ty/query/on_disk_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,13 @@ impl<'sess> OnDiskCache<'sess> {
tcx.dep_graph.with_ignore(|| {
// Allocate SourceFileIndices
let (file_to_file_index, file_index_to_stable_id) = {
let mut file_to_file_index = FxHashMap::default();
let mut file_index_to_stable_id = FxHashMap::default();
let files = tcx.sess.source_map().files();
let mut file_to_file_index = FxHashMap::with_capacity_and_hasher(
files.len(), Default::default());
let mut file_index_to_stable_id = FxHashMap::with_capacity_and_hasher(
files.len(), Default::default());

for (index, file) in tcx.sess.source_map().files().iter().enumerate() {
for (index, file) in files.iter().enumerate() {
let index = SourceFileIndex(index as u32);
let file_ptr: *const SourceFile = &**file as *const _;
file_to_file_index.insert(file_ptr, index);
Expand Down
3 changes: 1 addition & 2 deletions src/librustc/ty/steal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
// except according to those terms.

use rustc_data_structures::sync::{RwLock, ReadGuard, MappedReadGuard};
use std::mem;

/// The `Steal` struct is intended to used as the value for a query.
/// Specifically, we sometimes have queries (*cough* MIR *cough*)
Expand Down Expand Up @@ -51,7 +50,7 @@ impl<T> Steal<T> {

pub fn steal(&self) -> T {
let value_ref = &mut *self.value.try_write().expect("stealing value which is locked");
let value = mem::replace(value_ref, None);
let value = value_ref.take();
value.expect("attempt to read from stolen value")
}
}
8 changes: 3 additions & 5 deletions src/librustc_data_structures/tiny_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
//! If you expect to store more than 1 element in the common case, steer clear
//! and use a `Vec<T>`, `Box<[T]>`, or a `SmallVec<T>`.
use std::mem;

#[derive(Clone, Hash, Debug, PartialEq)]
pub struct TinyList<T: PartialEq> {
head: Option<Element<T>>
Expand Down Expand Up @@ -52,15 +50,15 @@ impl<T: PartialEq> TinyList<T> {
pub fn insert(&mut self, data: T) {
self.head = Some(Element {
data,
next: mem::replace(&mut self.head, None).map(Box::new),
next: self.head.take().map(Box::new)
});
}

#[inline]
pub fn remove(&mut self, data: &T) -> bool {
self.head = match self.head {
Some(ref mut head) if head.data == *data => {
mem::replace(&mut head.next, None).map(|x| *x)
head.next.take().map(|x| *x)
}
Some(ref mut head) => return head.remove_next(data),
None => return false,
Expand Down Expand Up @@ -100,7 +98,7 @@ impl<T: PartialEq> Element<T> {
if next.data != *data {
return next.remove_next(data)
} else {
mem::replace(&mut next.next, None)
next.next.take()
}
} else {
return false
Expand Down
7 changes: 3 additions & 4 deletions src/librustc_lint/unused.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,10 +278,9 @@ impl UnusedParens {
msg: &str,
followed_by_block: bool) {
if let ast::ExprKind::Paren(ref inner) = value.node {
let necessary = followed_by_block && if let ast::ExprKind::Ret(_) = inner.node {
true
} else {
parser::contains_exterior_struct_lit(&inner)
let necessary = followed_by_block && match inner.node {
ast::ExprKind::Ret(_) | ast::ExprKind::Break(..) => true,
_ => parser::contains_exterior_struct_lit(&inner),
};
if !necessary {
let expr_text = if let Ok(snippet) = cx.sess().source_map()
Expand Down
28 changes: 27 additions & 1 deletion src/librustc_mir/borrow_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,33 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
mbcx.errors_buffer.sort_by_key(|diag| diag.span.primary_span());

if tcx.migrate_borrowck() {
match tcx.borrowck(def_id).signalled_any_error {
// When borrowck=migrate, check if AST-borrowck would
// error on the given code.

// rust-lang/rust#55492: loop over parents to ensure that
// errors that AST-borrowck only detects in some parent of
// a closure still allows NLL to signal an error.
let mut curr_def_id = def_id;
let signalled_any_error = loop {
match tcx.borrowck(curr_def_id).signalled_any_error {
SignalledError::NoErrorsSeen => {
// keep traversing (and borrow-checking) parents
}
SignalledError::SawSomeError => {
// stop search here
break SignalledError::SawSomeError;
}
}

if tcx.is_closure(curr_def_id) {
curr_def_id = tcx.parent_def_id(curr_def_id)
.expect("a closure must have a parent_def_id");
} else {
break SignalledError::NoErrorsSeen;
}
};

match signalled_any_error {
SignalledError::NoErrorsSeen => {
// if AST-borrowck signalled no errors, then
// downgrade all the buffered MIR-borrowck errors
Expand Down
6 changes: 5 additions & 1 deletion src/librustc_mir/const_eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,11 @@ pub fn const_eval_provider<'a, 'tcx>(
key.param_env.reveal = Reveal::UserFacing;
match tcx.const_eval(key) {
// try again with reveal all as requested
Err(ErrorHandled::TooGeneric) => {},
Err(ErrorHandled::TooGeneric) => {
// Promoteds should never be "too generic" when getting evaluated.
// They either don't get evaluated, or we are in a monomorphic context
assert!(key.value.promoted.is_none());
},
// dedupliate calls
other => return other,
}
Expand Down
3 changes: 2 additions & 1 deletion src/librustc_mir/interpret/validity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,8 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M>
let (lo, hi) = layout.valid_range.clone().into_inner();
let max_hi = u128::max_value() >> (128 - size.bits()); // as big as the size fits
assert!(hi <= max_hi);
if lo == 0 && hi == max_hi {
// We could also write `(hi + 1) % (max_hi + 1) == lo` but `max_hi + 1` overflows for `u128`
if (lo == 0 && hi == max_hi) || (hi + 1 == lo) {
// Nothing to check
return Ok(());
}
Expand Down
9 changes: 7 additions & 2 deletions src/librustc_target/spec/msp430_none_elf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,14 @@ pub fn target() -> TargetResult {
no_integrated_as: true,

// There are no atomic CAS instructions available in the MSP430
// instruction set
max_atomic_width: Some(16),
// instruction set, and the LLVM backend doesn't currently support
// compiler fences so the Atomic* API is missing on this target.
// When the LLVM backend gains support for compile fences uncomment
// the `singlethread: true` line and set `max_atomic_width` to
// `Some(16)`.
max_atomic_width: Some(0),
atomic_cas: false,
// singlethread: true,

// Because these devices have very little resources having an
// unwinder is too onerous so we default to "abort" because the
Expand Down
12 changes: 6 additions & 6 deletions src/librustc_traits/implied_outlives_bounds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,14 @@ fn implied_bounds_from_components(
) -> Vec<OutlivesBound<'tcx>> {
sup_components
.into_iter()
.flat_map(|component| {
.filter_map(|component| {
match component {
Component::Region(r) =>
vec![OutlivesBound::RegionSubRegion(sub_region, r)],
Some(OutlivesBound::RegionSubRegion(sub_region, r)),
Component::Param(p) =>
vec![OutlivesBound::RegionSubParam(sub_region, p)],
Some(OutlivesBound::RegionSubParam(sub_region, p)),
Component::Projection(p) =>
vec![OutlivesBound::RegionSubProjection(sub_region, p)],
Some(OutlivesBound::RegionSubProjection(sub_region, p)),
Component::EscapingProjection(_) =>
// If the projection has escaping regions, don't
// try to infer any implied bounds even for its
Expand All @@ -176,9 +176,9 @@ fn implied_bounds_from_components(
// idea is that the WAY that the caller proves
// that may change in the future and we want to
// give ourselves room to get smarter here.
vec![],
None,
Component::UnresolvedInferenceVariable(..) =>
vec![],
None,
}
})
.collect()
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_typeck/astconv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1112,12 +1112,12 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx>+'o {
{
let tcx = self.tcx();

let bounds: Vec<_> = self.get_type_parameter_bounds(span, ty_param_def_id)
.predicates.into_iter().filter_map(|(p, _)| p.to_opt_poly_trait_ref()).collect();
let bounds = self.get_type_parameter_bounds(span, ty_param_def_id)
.predicates.into_iter().filter_map(|(p, _)| p.to_opt_poly_trait_ref());

// Check that there is exactly one way to find an associated type with the
// correct name.
let suitable_bounds = traits::transitive_bounds(tcx, &bounds)
let suitable_bounds = traits::transitive_bounds(tcx, bounds)
.filter(|b| self.trait_defines_associated_type_named(b.def_id(), assoc_name));

let param_node_id = tcx.hir.as_local_node_id(ty_param_def_id).unwrap();
Expand Down
Loading

0 comments on commit e8aef7c

Please sign in to comment.