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 12 pull requests #70085

Closed
wants to merge 56 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
14bcf0a
Fix Peekable::next_back
timvermeulen Feb 4, 2020
16a23e7
Fuse FlattenCompat's inner iterator
timvermeulen Feb 4, 2020
cdc7304
Compute the correct layout for variants of uninhabited enums and read…
oli-obk Mar 6, 2020
ec88ffa
Comment nits
oli-obk Mar 11, 2020
74608c7
Rustfmt and adjust capitalization
oli-obk Mar 11, 2020
f5efb68
miri: categorize errors into "unsupported" and "UB"
RalfJung Mar 8, 2020
d02543a
fmt, tweak messages and bless
RalfJung Mar 8, 2020
9a95b01
generalize InvalidNullPointerUsage to InvalidIntPointerUsage
RalfJung Mar 8, 2020
3ebcd78
fmt, and fix rustfmt-induced rebase hickup
RalfJung Mar 8, 2020
2764d3d
start Miri messages lower-case
RalfJung Mar 9, 2020
3e61442
explain why we catch PointerUseAfterFree
RalfJung Mar 9, 2020
d8f8168
avoid boolean inversion
RalfJung Mar 9, 2020
9681422
we are on 2018 edition, use try block
RalfJung Mar 9, 2020
93436d8
make error message less confusing
RalfJung Mar 9, 2020
e219dd4
fmt
RalfJung Mar 11, 2020
349fcb9
tidy: Use cargo_metadata for license checks.
ehuss Feb 24, 2020
3f45da0
tidy: Check if exceptions are no longer used.
ehuss Feb 24, 2020
be10f14
tidy: check the licenses don't change
ehuss Feb 24, 2020
bc738f2
tidy: Verify the runtime crates don't have license exceptions.
ehuss Feb 24, 2020
3c48c89
tidy: Add some clarifying comments in license checks.
ehuss Feb 24, 2020
2e46faa
tidy: Add `test` to RUNTIME_CRATES.
ehuss Feb 25, 2020
9a53cf3
tidy: Sort WHITELIST.
ehuss Feb 25, 2020
ed0158d
tidy: Remove chalk-engine/chalk-macros.
ehuss Mar 13, 2020
76c7144
Properly handle Spans that reference imported SourceFiles
Aaron1011 Feb 7, 2020
51ea260
rustc: don't resolve Instances which would produce malformed shims.
eddyb Feb 9, 2020
bc8ff3f
rustc: tweak comments on InstanceDef.
anyska Mar 11, 2020
b9167e6
Support type search for arguments and returned types
GuillaumeGomez Feb 23, 2020
2f44857
Update JS results tester
GuillaumeGomez Feb 23, 2020
e78c451
Add tests for new of variables
GuillaumeGomez Feb 23, 2020
5654cde
formatting
GuillaumeGomez Feb 23, 2020
d964e60
Rename render::Type to improve naming
GuillaumeGomez Mar 3, 2020
496256c
Update src/librustdoc/html/static/main.js
GuillaumeGomez Mar 9, 2020
9b85213
Add missing variable to load in non-std tester as well
GuillaumeGomez Mar 16, 2020
cff1182
Fix FlattenCompat::{next, next_back}
timvermeulen Feb 6, 2020
8cf33b0
Add tests
timvermeulen Feb 4, 2020
5a9ccc9
Remove `free_region_map` from `TypeckTables`
matthewjasper Nov 30, 2019
cefd030
Don't use `TypeckTables` in NiceRegionError
matthewjasper Feb 15, 2020
0a7f16e
Erase regions in writeback
matthewjasper Feb 15, 2020
1ee5829
Update tests for erasing regions in typeck
matthewjasper Feb 15, 2020
a4cbcb2
Fix abort-on-eprintln during process shutdown
alexcrichton Mar 12, 2020
773c04c
std: Don't abort process when printing panics in tests
alexcrichton Mar 12, 2020
3314a34
Don't unwind when hitting the macro expansion recursion limit
Zoxc Feb 26, 2020
bdaf9e4
Update test
Zoxc Feb 29, 2020
37bee6d
Allow `hir().find` to return `None`
Zoxc Mar 16, 2020
9825d5c
Rollup merge of #68915 - timvermeulen:non_fused_iter, r=Amanieu
Manishearth Mar 17, 2020
af55daf
Rollup merge of #68941 - Aaron1011:fix/imported-span, r=petrochenkov
Manishearth Mar 17, 2020
60f7aa1
Rollup merge of #69036 - eddyb:monoshim, r=nikomatsakis
Manishearth Mar 17, 2020
59e1a3d
Rollup merge of #69189 - matthewjasper:erase-the-world, r=nikomatsakis
Manishearth Mar 17, 2020
b960a1b
Rollup merge of #69402 - GuillaumeGomez:extend-search, r=kinnison
Manishearth Mar 17, 2020
f4090a6
Rollup merge of #69443 - ehuss:tidy-license, r=skade,Mark-Simulacrum
Manishearth Mar 17, 2020
e80c8ad
Rollup merge of #69497 - Zoxc:ast-fragment-error, r=petrochenkov
Manishearth Mar 17, 2020
45ed7e1
Rollup merge of #69768 - oli-obk:union_field_ice, r=eddyb,RalfJung
Manishearth Mar 17, 2020
c74d524
Rollup merge of #69839 - RalfJung:miri-error-cleanup, r=oli-obk
Manishearth Mar 17, 2020
d6f4e39
Rollup merge of #69955 - alexcrichton:stderr-infallible, r=sfackler
Manishearth Mar 17, 2020
63e67ce
Rollup merge of #69959 - alexcrichton:fix-panic-in-print, r=Mark-Simu…
Manishearth Mar 17, 2020
c0f826a
Rollup merge of #70051 - Zoxc:opt-find, r=eddyb
Manishearth Mar 17, 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
13 changes: 6 additions & 7 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -386,9 +386,9 @@ dependencies = [

[[package]]
name = "cargo_metadata"
version = "0.9.0"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8d2d1617e838936c0d2323a65cc151e03ae19a7678dd24f72bccf27119b90a5d"
checksum = "46e3374c604fb39d1a2f35ed5e4a4e30e60d01fab49446e08f1b3e9a90aef202"
dependencies = [
"semver",
"serde",
Expand Down Expand Up @@ -450,7 +450,7 @@ dependencies = [
name = "clippy"
version = "0.0.212"
dependencies = [
"cargo_metadata 0.9.0",
"cargo_metadata 0.9.1",
"clippy-mini-macro-test",
"clippy_lints",
"compiletest_rs",
Expand All @@ -474,7 +474,7 @@ version = "0.2.0"
name = "clippy_lints"
version = "0.0.212"
dependencies = [
"cargo_metadata 0.9.0",
"cargo_metadata 0.9.1",
"if_chain",
"itertools 0.9.0",
"lazy_static 1.4.0",
Expand Down Expand Up @@ -2133,7 +2133,7 @@ name = "miri"
version = "0.1.0"
dependencies = [
"byteorder",
"cargo_metadata 0.9.0",
"cargo_metadata 0.9.1",
"colored",
"compiletest_rs",
"directories",
Expand Down Expand Up @@ -4851,10 +4851,9 @@ dependencies = [
name = "tidy"
version = "0.1.0"
dependencies = [
"cargo_metadata 0.9.1",
"lazy_static 1.4.0",
"regex",
"serde",
"serde_json",
"walkdir",
]

Expand Down
3 changes: 0 additions & 3 deletions src/bootstrap/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -728,9 +728,6 @@ impl Step for Tidy {
let mut cmd = builder.tool_cmd(Tool::Tidy);
cmd.arg(builder.src.join("src"));
cmd.arg(&builder.initial_cargo);
if !builder.config.vendor {
cmd.arg("--no-vendor");
}
if builder.is_verbose() {
cmd.arg("--verbose");
}
Expand Down
21 changes: 13 additions & 8 deletions src/libcore/iter/adapters/flatten.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::fmt;
use crate::ops::Try;

use super::super::{DoubleEndedIterator, FusedIterator, Iterator};
use super::super::{DoubleEndedIterator, Fuse, FusedIterator, Iterator};
use super::Map;

/// An iterator that maps each element to an iterator, and yields the elements
Expand Down Expand Up @@ -239,14 +239,17 @@ where
/// this type.
#[derive(Clone, Debug)]
struct FlattenCompat<I, U> {
iter: I,
iter: Fuse<I>,
frontiter: Option<U>,
backiter: Option<U>,
}
impl<I, U> FlattenCompat<I, U> {
impl<I, U> FlattenCompat<I, U>
where
I: Iterator,
{
/// Adapts an iterator by flattening it, for use in `flatten()` and `flat_map()`.
fn new(iter: I) -> FlattenCompat<I, U> {
FlattenCompat { iter, frontiter: None, backiter: None }
FlattenCompat { iter: iter.fuse(), frontiter: None, backiter: None }
}
}

Expand All @@ -261,8 +264,9 @@ where
fn next(&mut self) -> Option<U::Item> {
loop {
if let Some(ref mut inner) = self.frontiter {
if let elt @ Some(_) = inner.next() {
return elt;
match inner.next() {
None => self.frontiter = None,
elt @ Some(_) => return elt,
}
}
match self.iter.next() {
Expand Down Expand Up @@ -348,8 +352,9 @@ where
fn next_back(&mut self) -> Option<U::Item> {
loop {
if let Some(ref mut inner) = self.backiter {
if let elt @ Some(_) = inner.next_back() {
return elt;
match inner.next_back() {
None => self.backiter = None,
elt @ Some(_) => return elt,
}
}
match self.iter.next_back() {
Expand Down
6 changes: 5 additions & 1 deletion src/libcore/iter/adapters/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1480,7 +1480,11 @@ where
{
#[inline]
fn next_back(&mut self) -> Option<Self::Item> {
self.iter.next_back().or_else(|| self.peeked.take().and_then(|x| x))
match self.peeked.as_mut() {
Some(v @ Some(_)) => self.iter.next_back().or_else(|| v.take()),
Some(None) => None,
None => self.iter.next_back(),
}
}

#[inline]
Expand Down
72 changes: 72 additions & 0 deletions src/libcore/tests/iter.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// ignore-tidy-filelength

use core::cell::Cell;
use core::convert::TryFrom;
use core::iter::*;
Expand Down Expand Up @@ -2940,3 +2942,73 @@ fn test_partition() {
check(xs, |&x| x < 3, 3); // small
check(xs, |&x| x > 6, 3); // large
}

/// An iterator that panics whenever `next` or next_back` is called
/// after `None` has already been returned. This does not violate
/// `Iterator`'s contract. Used to test that iterator adaptors don't
/// poll their inner iterators after exhausting them.
struct NonFused<I> {
iter: I,
done: bool,
}

impl<I> NonFused<I> {
fn new(iter: I) -> Self {
Self { iter, done: false }
}
}

impl<I> Iterator for NonFused<I>
where
I: Iterator,
{
type Item = I::Item;

fn next(&mut self) -> Option<Self::Item> {
assert!(!self.done, "this iterator has already returned None");
self.iter.next().or_else(|| {
self.done = true;
None
})
}
}

impl<I> DoubleEndedIterator for NonFused<I>
where
I: DoubleEndedIterator,
{
fn next_back(&mut self) -> Option<Self::Item> {
assert!(!self.done, "this iterator has already returned None");
self.iter.next_back().or_else(|| {
self.done = true;
None
})
}
}

#[test]
fn test_peekable_non_fused() {
let mut iter = NonFused::new(empty::<i32>()).peekable();

assert_eq!(iter.peek(), None);
assert_eq!(iter.next_back(), None);
}

#[test]
fn test_flatten_non_fused_outer() {
let mut iter = NonFused::new(once(0..2)).flatten();

assert_eq!(iter.next_back(), Some(1));
assert_eq!(iter.next(), Some(0));
assert_eq!(iter.next(), None);
}

#[test]
fn test_flatten_non_fused_inner() {
let mut iter = once(0..1).chain(once(1..3)).flat_map(NonFused::new);

assert_eq!(iter.next_back(), Some(2));
assert_eq!(iter.next(), Some(0));
assert_eq!(iter.next(), Some(1));
assert_eq!(iter.next(), None);
}
4 changes: 2 additions & 2 deletions src/librustc/hir/map/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_data_structures::svh::Svh;
use rustc_hir as hir;
use rustc_hir::def_id::CRATE_DEF_INDEX;
use rustc_hir::def_id::{CrateNum, DefIndex, LOCAL_CRATE};
use rustc_hir::def_id::{DefIndex, LOCAL_CRATE};
use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor};
use rustc_hir::*;
use rustc_index::vec::{Idx, IndexVec};
Expand Down Expand Up @@ -175,7 +175,7 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
.source_map
.files()
.iter()
.filter(|source_file| CrateNum::from_u32(source_file.crate_of_origin) == LOCAL_CRATE)
.filter(|source_file| source_file.cnum == LOCAL_CRATE)
.map(|source_file| source_file.name_hash)
.collect();

Expand Down
25 changes: 16 additions & 9 deletions src/librustc/hir/map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,20 +342,25 @@ impl<'hir> Map<'hir> {
}

fn find_entry(&self, id: HirId) -> Option<Entry<'hir>> {
Some(self.get_entry(id))
}

fn get_entry(&self, id: HirId) -> Entry<'hir> {
if id.local_id == ItemLocalId::from_u32_const(0) {
let owner = self.tcx.hir_owner(id.owner_def_id());
Entry { parent: owner.parent, node: owner.node }
owner.map(|owner| Entry { parent: owner.parent, node: owner.node })
} else {
let owner = self.tcx.hir_owner_items(id.owner_def_id());
let item = owner.items[id.local_id].as_ref().unwrap();
Entry { parent: HirId { owner: id.owner, local_id: item.parent }, node: item.node }
owner.and_then(|owner| {
let item = owner.items[id.local_id].as_ref();
item.map(|item| Entry {
parent: HirId { owner: id.owner, local_id: item.parent },
node: item.node,
})
})
}
}

fn get_entry(&self, id: HirId) -> Entry<'hir> {
self.find_entry(id).unwrap()
}

pub fn item(&self, id: HirId) -> &'hir Item<'hir> {
match self.find(id).unwrap() {
Node::Item(item) => item,
Expand All @@ -380,6 +385,7 @@ impl<'hir> Map<'hir> {
pub fn body(&self, id: BodyId) -> &'hir Body<'hir> {
self.tcx
.hir_owner_items(DefId::local(id.hir_id.owner))
.unwrap()
.bodies
.get(&id.hir_id.local_id)
.unwrap()
Expand Down Expand Up @@ -541,8 +547,9 @@ impl<'hir> Map<'hir> {

/// Retrieves the `Node` corresponding to `id`, returning `None` if cannot be found.
pub fn find(&self, hir_id: HirId) -> Option<Node<'hir>> {
let node = self.get_entry(hir_id).node;
if let Node::Crate(..) = node { None } else { Some(node) }
self.find_entry(hir_id).and_then(|entry| {
if let Node::Crate(..) = entry.node { None } else { Some(entry.node) }
})
}

/// Similar to `get_parent`; returns the parent HIR Id, or just `hir_id` if there
Expand Down
7 changes: 3 additions & 4 deletions src/librustc/hir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,8 @@ pub fn provide(providers: &mut Providers<'_>) {
let module = hir.as_local_hir_id(id).unwrap();
&tcx.untracked_crate.modules[&module]
};
providers.hir_owner = |tcx, id| tcx.index_hir(id.krate).map[id.index].signature.unwrap();
providers.hir_owner_items = |tcx, id| {
tcx.index_hir(id.krate).map[id.index].with_bodies.as_ref().map(|items| &**items).unwrap()
};
providers.hir_owner = |tcx, id| tcx.index_hir(id.krate).map[id.index].signature;
providers.hir_owner_items =
|tcx, id| tcx.index_hir(id.krate).map[id.index].with_bodies.as_ref().map(|items| &**items);
map::provide(providers);
}
8 changes: 3 additions & 5 deletions src/librustc/ich/impls_syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use crate::ich::StableHashingContext;

use rustc_ast::ast;
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_hir::def_id::{CrateNum, DefId, CRATE_DEF_INDEX};
use rustc_span::SourceFile;

use smallvec::SmallVec;
Expand Down Expand Up @@ -59,7 +58,7 @@ impl<'a> HashStable<StableHashingContext<'a>> for SourceFile {
name_hash,
name_was_remapped,
unmapped_path: _,
crate_of_origin,
cnum,
// Do not hash the source as it is not encoded
src: _,
src_hash,
Expand All @@ -75,9 +74,6 @@ impl<'a> HashStable<StableHashingContext<'a>> for SourceFile {
(name_hash as u64).hash_stable(hcx, hasher);
name_was_remapped.hash_stable(hcx, hasher);

DefId { krate: CrateNum::from_u32(crate_of_origin), index: CRATE_DEF_INDEX }
.hash_stable(hcx, hasher);

src_hash.hash_stable(hcx, hasher);

// We only hash the relative position within this source_file
Expand All @@ -101,6 +97,8 @@ impl<'a> HashStable<StableHashingContext<'a>> for SourceFile {
for &char_pos in normalized_pos.iter() {
stable_normalized_pos(char_pos, start_pos).hash_stable(hcx, hasher);
}

cnum.hash_stable(hcx, hasher);
}
}

Expand Down
5 changes: 3 additions & 2 deletions src/librustc/mir/interpret/allocation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ pub struct Allocation<Tag = (), Extra = ()> {
/// The size of the allocation. Currently, must always equal `bytes.len()`.
pub size: Size,
/// The alignment of the allocation to detect unaligned reads.
/// (`Align` guarantees that this is a power of two.)
pub align: Align,
/// `true` if the allocation is mutable.
/// Also used by codegen to determine if a static should be put into mutable memory,
Expand Down Expand Up @@ -314,7 +315,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
&self.get_bytes(cx, ptr, size_with_null)?[..size]
}
// This includes the case where `offset` is out-of-bounds to begin with.
None => throw_unsup!(UnterminatedCString(ptr.erase_tag())),
None => throw_ub!(UnterminatedCString(ptr.erase_tag())),
})
}

Expand Down Expand Up @@ -573,7 +574,7 @@ impl<'tcx, Tag, Extra> Allocation<Tag, Extra> {
fn check_defined(&self, ptr: Pointer<Tag>, size: Size) -> InterpResult<'tcx> {
self.undef_mask
.is_range_defined(ptr.offset, ptr.offset + size)
.or_else(|idx| throw_unsup!(ReadUndefBytes(idx)))
.or_else(|idx| throw_ub!(InvalidUndefBytes(Some(Pointer::new(ptr.alloc_id, idx)))))
}

pub fn mark_definedness(&mut self, ptr: Pointer<Tag>, size: Size, new_state: bool) {
Expand Down
Loading