Skip to content

Rollup of 10 pull requests #78127

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 32 commits into from
Oct 20, 2020
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
bd13567
Allow setting up git hooks from other worktrees
jyn514 Oct 10, 2020
0ec3ea9
const keyword: brief paragraph on 'const fn'
RalfJung Oct 11, 2020
c8405d2
fix markdown reference
RalfJung Oct 12, 2020
058699d
[net] clippy: needless_update
wcampbell0x2a Oct 13, 2020
e6dc604
[net] clippy: match_like_matches_macro
wcampbell0x2a Oct 13, 2020
7a75f44
[net] clippy: identity_op
wcampbell0x2a Oct 13, 2020
39867f3
Fixed false positive for `unused_parens` lint
aticu Oct 13, 2020
7da0e58
use matches! in library/std/src/net/ip.rs
wcampbell0x2a Oct 13, 2020
ce04836
fmt
wcampbell0x2a Oct 14, 2020
608f260
Rename some RFC dirs to be sorted alphabetically
JohnTitor Oct 15, 2020
d87c17d
Migrate from `associated-const` to `associated-consts`
JohnTitor Oct 15, 2020
3113c07
Migrate from `associated-type` to `associated-types`
JohnTitor Oct 15, 2020
72b3807
Clarify the `mod` dir name not to make confusion with the `modules`
JohnTitor Oct 15, 2020
3156310
Migrate from `generic` to `generics`
JohnTitor Oct 15, 2020
488b999
BTreeMap: test invariants more thoroughly and more readably
ssomers Oct 5, 2020
736c27e
Revert "[net] clippy: needless_update"
wcampbell0x2a Oct 19, 2020
34c80aa
change name in mailmap
lcnr Oct 19, 2020
71ca239
don't assume trait ambiguity happens in `Self`
SNCPlay42 Oct 19, 2020
c146e8c
revert workaround #73027
SNCPlay42 Oct 19, 2020
66ac5a2
Do not ICE on pattern that uses a binding multiple times in generator
LeSeulArtichaut Oct 19, 2020
334c6c5
Add regression test
LeSeulArtichaut Oct 19, 2020
21c29b1
Check that pthread mutex initialization succeeded
tmiasko Oct 20, 2020
c5b0a88
Rollup merge of #77612 - ssomers:btree_cleanup_2, r=Mark-Simulacrum
JohnTitor Oct 20, 2020
b09ef11
Rollup merge of #77761 - tmiasko:pthread-mutex, r=cuviper
JohnTitor Oct 20, 2020
24907f3
Rollup merge of #77778 - jyn514:git-hook, r=mark-simulacrum
JohnTitor Oct 20, 2020
f9db008
Rollup merge of #77838 - RalfJung:const-fn, r=kennytm
JohnTitor Oct 20, 2020
6df79bf
Rollup merge of #77923 - wcampbell0x2a:cleanup-net-module, r=scottmcm
JohnTitor Oct 20, 2020
378ca5e
Rollup merge of #77931 - aticu:fix_60336, r=petrochenkov
JohnTitor Oct 20, 2020
587cf84
Rollup merge of #77959 - JohnTitor:tweak-test-structure, r=petrochenkov
JohnTitor Oct 20, 2020
aebeec7
Rollup merge of #78105 - lcnr:namesNstuff, r=Mark-Simulacrum
JohnTitor Oct 20, 2020
3f1c637
Rollup merge of #78111 - SNCPlay42:not-always-self, r=lcnr
JohnTitor Oct 20, 2020
21df410
Rollup merge of #78121 - LeSeulArtichaut:issue-78115, r=tmandry
JohnTitor Oct 20, 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
2 changes: 1 addition & 1 deletion .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ Ariel Ben-Yehuda <arielb1@mail.tau.ac.il> arielb1 <arielb1@mail.tau.ac.il>
Austin Seipp <mad.one@gmail.com> <as@hacks.yi.org>
Aydin Kim <ladinjin@hanmail.net> aydin.kim <aydin.kim@samsung.com>
Barosl Lee <vcs@barosl.com> Barosl LEE <github@barosl.com>
Bastian Kauschke <bastian_kauschke@hotmail.de>
Ben Alpert <ben@benalpert.com> <spicyjalapeno@gmail.com>
Ben Sago <ogham@users.noreply.github.com> Ben S <ogham@bsago.me>
Ben Sago <ogham@users.noreply.github.com> Ben S <ogham@users.noreply.github.com>
Expand Down Expand Up @@ -161,6 +160,7 @@ Kyle J Strand <batmanaod@gmail.com> <kyle.j.strand@gmail.com>
Kyle J Strand <batmanaod@gmail.com> <kyle.strand@pieinsurance.com>
Kyle J Strand <batmanaod@gmail.com> <kyle.strand@rms.com>
Laurențiu Nicola <lnicola@dend.ro>
lcnr <bastian_kauschke@hotmail.de>
Lee Jeffery <leejeffery@gmail.com> Lee Jeffery <lee@leejeffery.co.uk>
Lee Wondong <wdlee91@gmail.com>
Lennart Kudling <github@kudling.de>
Expand Down
17 changes: 2 additions & 15 deletions compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,17 +91,6 @@ impl<'a, 'tcx> Visitor<'tcx> for FindHirNodeVisitor<'a, 'tcx> {
if let (None, Some(ty)) =
(self.found_local_pattern, self.node_ty_contains_target(local.hir_id))
{
// FIXME: There's a trade-off here - we can either check that our target span
// is contained in `local.span` or not. If we choose to check containment
// we can avoid some spurious suggestions (see #72690), but we lose
// the ability to report on things like:
//
// ```
// let x = vec![];
// ```
//
// because the target span will be in the macro expansion of `vec![]`.
// At present we choose not to check containment.
self.found_local_pattern = Some(&*local.pat);
self.found_node_ty = Some(ty);
}
Expand All @@ -113,10 +102,8 @@ impl<'a, 'tcx> Visitor<'tcx> for FindHirNodeVisitor<'a, 'tcx> {
if let (None, Some(ty)) =
(self.found_arg_pattern, self.node_ty_contains_target(param.hir_id))
{
if self.target_span.contains(param.pat.span) {
self.found_arg_pattern = Some(&*param.pat);
self.found_node_ty = Some(ty);
}
self.found_arg_pattern = Some(&*param.pat);
self.found_node_ty = Some(ty);
}
}
intravisit::walk_body(self, body);
Expand Down
11 changes: 9 additions & 2 deletions compiler/rustc_lint/src/unused.rs
Original file line number Diff line number Diff line change
Expand Up @@ -751,13 +751,20 @@ impl UnusedDelimLint for UnusedParens {
if !Self::is_expr_delims_necessary(inner, followed_by_block)
&& value.attrs.is_empty()
&& !value.span.from_expansion()
&& (ctx != UnusedDelimsCtx::LetScrutineeExpr
|| match inner.kind {
ast::ExprKind::Binary(
rustc_span::source_map::Spanned { node, .. },
_,
_,
) if node.lazy() => false,
_ => true,
})
{
self.emit_unused_delims_expr(cx, value, ctx, left_pos, right_pos)
}
}
ast::ExprKind::Let(_, ref expr) => {
// FIXME(#60336): Properly handle `let true = (false && true)`
// actually needing the parenthesis.
self.check_unused_delims_expr(
cx,
expr,
Expand Down
30 changes: 15 additions & 15 deletions compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1462,9 +1462,8 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
let bound_predicate = predicate.bound_atom();
let mut err = match bound_predicate.skip_binder() {
ty::PredicateAtom::Trait(data, _) => {
let self_ty = data.trait_ref.self_ty();
let trait_ref = bound_predicate.rebind(data.trait_ref);
debug!("self_ty {:?} {:?} trait_ref {:?}", self_ty, self_ty.kind(), trait_ref);
debug!("trait_ref {:?}", trait_ref);

if predicate.references_error() {
return;
Expand All @@ -1479,6 +1478,17 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
// known, since we don't dispatch based on region
// relationships.

// Pick the first substitution that still contains inference variables as the one
// we're going to emit an error for. If there are none (see above), fall back to
// the substitution for `Self`.
let subst = {
let substs = data.trait_ref.substs;
substs
.iter()
.find(|s| s.has_infer_types_or_consts())
.unwrap_or_else(|| substs[0])
};

// This is kind of a hack: it frequently happens that some earlier
// error prevents types from being fully inferred, and then we get
// a bunch of uninteresting errors saying something like "<generic
Expand All @@ -1495,21 +1505,11 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
// check upstream for type errors and don't add the obligations to
// begin with in those cases.
if self.tcx.lang_items().sized_trait() == Some(trait_ref.def_id()) {
self.emit_inference_failure_err(
body_id,
span,
self_ty.into(),
ErrorCode::E0282,
)
.emit();
self.emit_inference_failure_err(body_id, span, subst, ErrorCode::E0282).emit();
return;
}
let mut err = self.emit_inference_failure_err(
body_id,
span,
self_ty.into(),
ErrorCode::E0283,
);
let mut err =
self.emit_inference_failure_err(body_id, span, subst, ErrorCode::E0283);
err.note(&format!("cannot satisfy `{}`", predicate));
if let ObligationCauseCode::ItemObligation(def_id) = obligation.cause.code {
self.suggest_fully_qualified_path(&mut err, def_id, span, trait_ref.def_id());
Expand Down
5 changes: 1 addition & 4 deletions compiler/rustc_typeck/src/check/generator_interior.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,7 @@ impl<'a, 'tcx> Visitor<'tcx> for InteriorVisitor<'a, 'tcx> {
let mut scope_var_ids =
self.guard_bindings.pop().expect("should have pushed at least one earlier");
for var_id in scope_var_ids.drain(..) {
assert!(
self.guard_bindings_set.remove(&var_id),
"variable should be placed in scope earlier"
);
self.guard_bindings_set.remove(&var_id);
}
}
self.visit_expr(body);
Expand Down
89 changes: 10 additions & 79 deletions library/alloc/src/collections/btree/map/tests.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use super::super::{navigate::Position, node, DeterministicRng};
use super::super::{node, DeterministicRng};
use super::Entry::{Occupied, Vacant};
use super::*;
use crate::boxed::Box;
Expand All @@ -7,7 +7,7 @@ use crate::rc::Rc;
use crate::string::{String, ToString};
use crate::vec::Vec;
use std::convert::TryFrom;
use std::iter::FromIterator;
use std::iter::{self, FromIterator};
use std::mem;
use std::ops::Bound::{self, Excluded, Included, Unbounded};
use std::ops::RangeBounds;
Expand Down Expand Up @@ -42,19 +42,6 @@ fn test_all_refs<'a, T: 'a>(dummy: &mut T, iter: impl Iterator<Item = &'a mut T>
}
}

struct SeriesChecker<T> {
previous: Option<T>,
}

impl<T: Copy + Debug + Ord> SeriesChecker<T> {
fn is_ascending(&mut self, next: T) {
if let Some(previous) = self.previous {
assert!(previous < next, "{:?} >= {:?}", previous, next);
}
self.previous = Some(next);
}
}

impl<'a, K: 'a, V: 'a> BTreeMap<K, V> {
/// Panics if the map (or the code navigating it) is corrupted.
fn check(&self)
Expand All @@ -63,44 +50,10 @@ impl<'a, K: 'a, V: 'a> BTreeMap<K, V> {
{
if let Some(root) = &self.root {
let root_node = root.node_as_ref();
let mut checker = SeriesChecker { previous: None };
let mut internal_length = 0;
let mut internal_kv_count = 0;
let mut leaf_length = 0;
root_node.visit_nodes_in_order(|pos| match pos {
Position::Leaf(node) => {
let is_root = root_node.height() == 0;
let min_len = if is_root { 0 } else { node::MIN_LEN };
assert!(node.len() >= min_len, "{} < {}", node.len(), min_len);

for idx in 0..node.len() {
let key = *unsafe { node.key_at(idx) };
checker.is_ascending(key);
}
leaf_length += node.len();
}
Position::Internal(node) => {
let is_root = root_node.height() == node.height();
let min_len = if is_root { 1 } else { node::MIN_LEN };
assert!(node.len() >= min_len, "{} < {}", node.len(), min_len);

for idx in 0..=node.len() {
let edge = unsafe { node::Handle::new_edge(node, idx) };
assert!(edge.descend().ascend().ok().unwrap() == edge);
}

internal_length += node.len();
}
Position::InternalKV(kv) => {
let key = *kv.into_kv().0;
checker.is_ascending(key);

internal_kv_count += 1;
}
});
assert_eq!(internal_length, internal_kv_count);
assert_eq!(root_node.calc_length(), internal_length + leaf_length);
assert_eq!(self.length, internal_length + leaf_length);
assert!(root_node.ascend().is_err());
root_node.assert_back_pointers();
root_node.assert_ascending();
assert_eq!(self.length, root_node.assert_and_add_lengths());
} else {
assert_eq!(self.length, 0);
}
Expand All @@ -116,28 +69,7 @@ impl<'a, K: 'a, V: 'a> BTreeMap<K, V> {
K: Debug,
{
if let Some(root) = self.root.as_ref() {
let mut result = String::new();
let root_node = root.node_as_ref();
root_node.visit_nodes_in_order(|pos| match pos {
Position::Leaf(leaf) => {
let depth = root_node.height();
let indent = " ".repeat(depth);
result += &format!("\n{}", indent);
for idx in 0..leaf.len() {
if idx > 0 {
result += ", ";
}
result += &format!("{:?}", unsafe { leaf.key_at(idx) });
}
}
Position::Internal(_) => {}
Position::InternalKV(kv) => {
let depth = root_node.height() - kv.into_node().height();
let indent = " ".repeat(depth);
result += &format!("\n{}{:?}", indent, kv.into_kv().0);
}
});
result
root.node_as_ref().dump_keys()
} else {
String::from("not yet allocated")
}
Expand Down Expand Up @@ -170,7 +102,6 @@ fn test_levels() {
let last_key = *map.last_key_value().unwrap().0;
map.insert(last_key + 1, ());
}
println!("{}", map.dump_keys());
map.check();
// Structure:
// - 1 element in internal root node with 2 children
Expand Down Expand Up @@ -372,7 +303,7 @@ fn test_iter_rev() {
fn do_test_iter_mut_mutation<T>(size: usize)
where
T: Copy + Debug + Ord + TryFrom<usize>,
<T as std::convert::TryFrom<usize>>::Error: std::fmt::Debug,
<T as TryFrom<usize>>::Error: Debug,
{
let zero = T::try_from(0).unwrap();
let mut map: BTreeMap<T, T> = (0..size).map(|i| (T::try_from(i).unwrap(), zero)).collect();
Expand Down Expand Up @@ -857,7 +788,7 @@ mod test_drain_filter {
fn consuming_nothing() {
let pairs = (0..3).map(|i| (i, i));
let mut map: BTreeMap<_, _> = pairs.collect();
assert!(map.drain_filter(|_, _| false).eq(std::iter::empty()));
assert!(map.drain_filter(|_, _| false).eq(iter::empty()));
map.check();
}

Expand All @@ -878,7 +809,7 @@ mod test_drain_filter {
*v += 6;
false
})
.eq(std::iter::empty())
.eq(iter::empty())
);
assert!(map.keys().copied().eq(0..3));
assert!(map.values().copied().eq(6..9));
Expand Down
105 changes: 105 additions & 0 deletions library/alloc/src/collections/btree/node/tests.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,111 @@
use super::super::navigate;
use super::*;
use crate::fmt::Debug;
use crate::string::String;
use core::cmp::Ordering::*;

impl<'a, K: 'a, V: 'a> NodeRef<marker::Immut<'a>, K, V, marker::LeafOrInternal> {
pub fn assert_back_pointers(self) {
match self.force() {
ForceResult::Leaf(_) => {}
ForceResult::Internal(node) => {
for idx in 0..=node.len() {
let edge = unsafe { Handle::new_edge(node, idx) };
let child = edge.descend();
assert!(child.ascend().ok() == Some(edge));
child.assert_back_pointers();
}
}
}
}

pub fn assert_ascending(self)
where
K: Copy + Debug + Ord,
{
struct SeriesChecker<T> {
previous: Option<T>,
}
impl<T: Copy + Debug + Ord> SeriesChecker<T> {
fn is_ascending(&mut self, next: T) {
if let Some(previous) = self.previous {
assert!(previous < next, "{:?} >= {:?}", previous, next);
}
self.previous = Some(next);
}
}

let mut checker = SeriesChecker { previous: None };
self.visit_nodes_in_order(|pos| match pos {
navigate::Position::Leaf(node) => {
for idx in 0..node.len() {
let key = *unsafe { node.key_at(idx) };
checker.is_ascending(key);
}
}
navigate::Position::InternalKV(kv) => {
let key = *kv.into_kv().0;
checker.is_ascending(key);
}
navigate::Position::Internal(_) => {}
});
}

pub fn assert_and_add_lengths(self) -> usize {
let mut internal_length = 0;
let mut internal_kv_count = 0;
let mut leaf_length = 0;
self.visit_nodes_in_order(|pos| match pos {
navigate::Position::Leaf(node) => {
let is_root = self.height() == 0;
let min_len = if is_root { 0 } else { MIN_LEN };
assert!(node.len() >= min_len, "{} < {}", node.len(), min_len);
leaf_length += node.len();
}
navigate::Position::Internal(node) => {
let is_root = self.height() == node.height();
let min_len = if is_root { 1 } else { MIN_LEN };
assert!(node.len() >= min_len, "{} < {}", node.len(), min_len);
internal_length += node.len();
}
navigate::Position::InternalKV(_) => {
internal_kv_count += 1;
}
});
assert_eq!(internal_length, internal_kv_count);
let total = internal_length + leaf_length;
assert_eq!(self.calc_length(), total);
total
}

pub fn dump_keys(self) -> String
where
K: Debug,
{
let mut result = String::new();
self.visit_nodes_in_order(|pos| match pos {
navigate::Position::Leaf(leaf) => {
let depth = self.height();
let indent = " ".repeat(depth);
result += &format!("\n{}", indent);
for idx in 0..leaf.len() {
if idx > 0 {
result += ", ";
}
result += &format!("{:?}", unsafe { leaf.key_at(idx) });
}
}
navigate::Position::Internal(_) => {}
navigate::Position::InternalKV(kv) => {
let depth = self.height() - kv.into_node().height();
let indent = " ".repeat(depth);
result += &format!("\n{}{:?}", indent, kv.into_kv().0);
}
});
result
}
}

#[test]
fn test_splitpoint() {
for idx in 0..=CAPACITY {
Expand Down
Loading