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 7 pull requests #62580

Merged
merged 44 commits into from
Jul 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
30b27f3
core: check for pointer equality when comparing Eq slices
aschampion Jun 8, 2019
d482589
core: use iterators for slice equality comparison
aschampion Jun 8, 2019
45dda93
Move async-await tests from run-pass to ui
agnxy Jul 1, 2019
b14a2ec
Remove duplicated arc_wake.rs
agnxy Jul 3, 2019
73aee89
Move the test async-fn-size-moved-locals to ui
agnxy Jul 3, 2019
f115147
Add missing aux-build directive
agnxy Jul 4, 2019
70e8ba3
Fix typo in libcore/intrinsics.rs
taiki-e Jul 10, 2019
128143c
Ignore async-fn-size-moved-locals test on wasm
agnxy Jul 10, 2019
6031a07
filedesc: don't use ioctl(FIOCLEX) on Linux
cyphar Jul 5, 2019
fa0809d
Regression test for issue 30786.
pnkfelix Jul 9, 2019
4863522
Remove `MacroKind::ProcMacroStub`
petrochenkov Jun 18, 2019
ec376c7
Move `MacroKind` into `libsyntax_pos`
petrochenkov Jun 18, 2019
16918a8
Rename some things in `syntax_pos/hygiene`
petrochenkov Jun 18, 2019
f1d4ebf
Remove unnecessary expansions created by `#[test_case/test/bench]`
petrochenkov Jun 19, 2019
62a1f5d
hygiene: Remove some dead code
petrochenkov Jun 20, 2019
a138e9d
expand: Get rid of `resolve_macro_path`
petrochenkov Jun 28, 2019
3eafaae
syntax: Make def-site span mandatory in ExpnInfo/MacroBacktrace/Diagn…
petrochenkov Jun 30, 2019
4dcf9b1
hygiene: Remove some unused impls
petrochenkov Jun 30, 2019
aff9738
hygiene: Reuse `MacroKind` in `ExpnKind`
petrochenkov Jun 30, 2019
e272946
def_collector: Simplify tracking of macro invocation parents
petrochenkov Jul 2, 2019
b392781
def_collector: `parent_def` is no longer optional
petrochenkov Jul 2, 2019
cd0fd63
resolve: Make proc macro stubs less stubby
petrochenkov Jul 2, 2019
f16993d
resolve/expand: `resolve_macro_invocation` no longer returns determin…
petrochenkov Jul 3, 2019
3041ec6
resolve/expand: Catch macro kind mismatches early in resolve
petrochenkov Jul 3, 2019
8bc187d
resolve: Include stdlib prelude into name lookup in macro namespace
petrochenkov Jul 3, 2019
f923942
resolve: Divide macro path resolution into speculative and error repo…
petrochenkov Jul 3, 2019
0ec6ea7
resolve: Fix access to extern and stdlib prelude from opaque macros
petrochenkov Jul 6, 2019
d1949b1
expand: Do not overwrite existing `ExpnInfo` when injecting derive ma…
petrochenkov Jul 6, 2019
99c7432
hygiene: Introduce a helper method for creating new expansions
petrochenkov Jul 6, 2019
dcd30a4
hygiene: Fix wording of desugaring descriptions
petrochenkov Jul 7, 2019
eac900a
hygiene: Make sure each `Mark` has an associated expansion info
petrochenkov Jul 7, 2019
374a80a
expand: It's always possible to create a dummy AST fragment
petrochenkov Jul 7, 2019
b003dd6
expand: Merge `expand_{bang,attr,derive}_invoc` into a single function
petrochenkov Jul 7, 2019
baddce5
expand: Move "derive containers" into a separate `InvocationKind` var…
petrochenkov Jul 7, 2019
7b74d72
Fix failing tests
petrochenkov Jul 7, 2019
e86e5cb
Add a regression test for #44692
petrochenkov Jul 8, 2019
29e7bfd
Refactor diagnostic emission for green nodes
Zoxc Apr 19, 2019
ea62f9b
Rollup merge of #61665 - aschampion:slice-eq-ptr, r=sfackler
Centril Jul 11, 2019
618fc02
Rollup merge of #61923 - Zoxc:dep-stream-prefix-2, r=pnkfelix
Centril Jul 11, 2019
8fe7ed0
Rollup merge of #62270 - agnxy:move-async-test, r=Centril,tmandry
Centril Jul 11, 2019
e07df9c
Rollup merge of #62425 - cyphar:linux-cloexec-use-fcntl, r=alexcrichton
Centril Jul 11, 2019
7697b29
Rollup merge of #62476 - petrochenkov:expref, r=matthewjasper
Centril Jul 11, 2019
03c26f9
Rollup merge of #62519 - pnkfelix:add-test-for-30786, r=pnkfelix
Centril Jul 11, 2019
f9034ce
Rollup merge of #62557 - taiki-e:typo, r=Centril
Centril Jul 11, 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
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ application of these fields based on a variety of attributes when using
`crate_local`) or matching against a particular method. Currently used
for `try`.
- `from_desugaring`: usable both as boolean (whether the flag is present)
or matching against a particular desugaring.
or matching against a particular desugaring. The desugaring is identified
with its variant name in the `DesugaringKind` enum.

For example, the `Iterator` trait can be annotated in the following way:

Expand Down
3 changes: 2 additions & 1 deletion src/libcore/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,8 @@ extern "rust-intrinsic" {
they should be used through stabilized interfaces \
in the rest of the standard library",
issue = "0")]
#[rustc_deprecated(reason = "no longer used by rustc, will be removed - use MaybeUnint instead",
#[rustc_deprecated(reason = "no longer used by rustc, will be removed - use MaybeUninit \
instead",
since = "1.38.0")]
pub fn init<T>() -> T;

Expand Down
3 changes: 3 additions & 0 deletions src/libcore/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1244,19 +1244,22 @@ mod builtin {

/// Attribute macro applied to a function to turn it into a unit test.
#[stable(feature = "rust1", since = "1.0.0")]
#[allow_internal_unstable(test, rustc_attrs)]
#[rustc_builtin_macro]
#[rustc_macro_transparency = "semitransparent"]
pub macro test($item:item) { /* compiler built-in */ }

/// Attribute macro applied to a function to turn it into a benchmark test.
#[stable(feature = "rust1", since = "1.0.0")]
#[allow_internal_unstable(test, rustc_attrs)]
#[rustc_builtin_macro]
#[rustc_macro_transparency = "semitransparent"]
pub macro bench($item:item) { /* compiler built-in */ }

/// An implementation detail of the `#[test]` and `#[bench]` macros.
#[unstable(feature = "custom_test_frameworks", issue = "50297",
reason = "custom test frameworks are an unstable feature")]
#[allow_internal_unstable(test, rustc_attrs)]
#[rustc_builtin_macro]
#[rustc_macro_transparency = "semitransparent"]
pub macro test_case($item:item) { /* compiler built-in */ }
Expand Down
4 changes: 2 additions & 2 deletions src/libcore/ops/try.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
#[rustc_on_unimplemented(
on(all(
any(from_method="from_error", from_method="from_ok"),
from_desugaring="?"),
from_desugaring="QuestionMark"),
message="the `?` operator can only be used in a \
function that returns `Result` or `Option` \
(or another type that implements `{Try}`)",
label="cannot use the `?` operator in a function that returns `{Self}`"),
on(all(from_method="into_result", from_desugaring="?"),
on(all(from_method="into_result", from_desugaring="QuestionMark"),
message="the `?` operator can only be applied to values \
that implement `{Try}`",
label="the `?` operator cannot be applied to type `{Self}`")
Expand Down
23 changes: 17 additions & 6 deletions src/libcore/slice/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5342,13 +5342,24 @@ impl<A, B> SlicePartialEq<B> for [A]
return false;
}

for i in 0..self.len() {
if !self[i].eq(&other[i]) {
return false;
}
self.iter().zip(other.iter()).all(|(x, y)| x == y)
}
}

// Use an equal-pointer optimization when types are `Eq`
impl<A> SlicePartialEq<A> for [A]
where A: PartialEq<A> + Eq
{
default fn equal(&self, other: &[A]) -> bool {
if self.len() != other.len() {
return false;
}

if self.as_ptr() == other.as_ptr() {
return true;
}

true
self.iter().zip(other.iter()).all(|(x, y)| x == y)
}
}

Expand Down Expand Up @@ -5457,7 +5468,7 @@ impl SliceOrd<u8> for [u8] {
#[doc(hidden)]
/// Trait implemented for types that can be compared for equality using
/// their bytewise representation
trait BytewiseEquality { }
trait BytewiseEquality: Eq + Copy { }

macro_rules! impl_marker_for {
($traitname:ident, $($ty:ty)*) => {
Expand Down
86 changes: 51 additions & 35 deletions src/librustc/dep_graph/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use rustc_data_structures::sync::{Lrc, Lock, AtomicU32, Ordering};
use std::env;
use std::hash::Hash;
use std::collections::hash_map::Entry;
use std::mem;
use crate::ty::{self, TyCtxt};
use crate::util::common::{ProfileQueriesMsg, profq_msg};
use parking_lot::{Mutex, Condvar};
Expand Down Expand Up @@ -61,11 +62,11 @@ struct DepGraphData {

colors: DepNodeColorMap,

/// A set of loaded diagnostics that have been emitted.
emitted_diagnostics: Mutex<FxHashSet<DepNodeIndex>>,
/// A set of loaded diagnostics that is in the progress of being emitted.
emitting_diagnostics: Mutex<FxHashSet<DepNodeIndex>>,

/// Used to wait for diagnostics to be emitted.
emitted_diagnostics_cond_var: Condvar,
emitting_diagnostics_cond_var: Condvar,

/// When we load, there may be `.o` files, cached MIR, or other such
/// things available to us. If we find that they are not dirty, we
Expand Down Expand Up @@ -99,8 +100,8 @@ impl DepGraph {
previous_work_products: prev_work_products,
dep_node_debug: Default::default(),
current: Lock::new(CurrentDepGraph::new(prev_graph_node_count)),
emitted_diagnostics: Default::default(),
emitted_diagnostics_cond_var: Condvar::new(),
emitting_diagnostics: Default::default(),
emitting_diagnostics_cond_var: Condvar::new(),
previous: prev_graph,
colors: DepNodeColorMap::new(prev_graph_node_count),
loaded_from_cache: Default::default(),
Expand Down Expand Up @@ -744,7 +745,7 @@ impl DepGraph {

// There may be multiple threads trying to mark the same dep node green concurrently

let (dep_node_index, did_allocation) = {
let dep_node_index = {
let mut current = data.current.borrow_mut();

// Copy the fingerprint from the previous graph,
Expand All @@ -758,71 +759,86 @@ impl DepGraph {

// ... emitting any stored diagnostic ...

// FIXME: Store the fact that a node has diagnostics in a bit in the dep graph somewhere
// Maybe store a list on disk and encode this fact in the DepNodeState
let diagnostics = tcx.queries.on_disk_cache
.load_diagnostics(tcx, prev_dep_node_index);
.load_diagnostics(tcx, prev_dep_node_index);

#[cfg(not(parallel_compiler))]
debug_assert!(data.colors.get(prev_dep_node_index).is_none(),
"DepGraph::try_mark_previous_green() - Duplicate DepNodeColor \
insertion for {:?}", dep_node);

if unlikely!(diagnostics.len() > 0) {
self.emit_diagnostics(
tcx,
data,
dep_node_index,
did_allocation,
prev_dep_node_index,
diagnostics
);
}

// ... and finally storing a "Green" entry in the color map.
// Multiple threads can all write the same color here
#[cfg(not(parallel_compiler))]
debug_assert!(data.colors.get(prev_dep_node_index).is_none(),
"DepGraph::try_mark_previous_green() - Duplicate DepNodeColor \
insertion for {:?}", dep_node);

data.colors.insert(prev_dep_node_index, DepNodeColor::Green(dep_node_index));

debug!("try_mark_previous_green({:?}) - END - successfully marked as green", dep_node);
Some(dep_node_index)
}

/// Atomically emits some loaded diagnotics, assuming that this only gets called with
/// `did_allocation` set to `true` on a single thread.
/// Atomically emits some loaded diagnostics.
/// This may be called concurrently on multiple threads for the same dep node.
#[cold]
#[inline(never)]
fn emit_diagnostics<'tcx>(
&self,
tcx: TyCtxt<'tcx>,
data: &DepGraphData,
dep_node_index: DepNodeIndex,
did_allocation: bool,
prev_dep_node_index: SerializedDepNodeIndex,
diagnostics: Vec<Diagnostic>,
) {
if did_allocation || !cfg!(parallel_compiler) {
// Only the thread which did the allocation emits the error messages
let handle = tcx.sess.diagnostic();
let mut emitting = data.emitting_diagnostics.lock();

if data.colors.get(prev_dep_node_index) == Some(DepNodeColor::Green(dep_node_index)) {
// The node is already green so diagnostics must have been emitted already
return;
}

if emitting.insert(dep_node_index) {
// We were the first to insert the node in the set so this thread
// must emit the diagnostics and signal other potentially waiting
// threads after.
mem::drop(emitting);

// Promote the previous diagnostics to the current session.
tcx.queries.on_disk_cache
.store_diagnostics(dep_node_index, diagnostics.clone().into());
.store_diagnostics(dep_node_index, diagnostics.clone().into());

let handle = tcx.sess.diagnostic();

for diagnostic in diagnostics {
DiagnosticBuilder::new_diagnostic(handle, diagnostic).emit();
}

#[cfg(parallel_compiler)]
{
// Mark the diagnostics and emitted and wake up waiters
data.emitted_diagnostics.lock().insert(dep_node_index);
data.emitted_diagnostics_cond_var.notify_all();
}
// Mark the node as green now that diagnostics are emitted
data.colors.insert(prev_dep_node_index, DepNodeColor::Green(dep_node_index));

// Remove the node from the set
data.emitting_diagnostics.lock().remove(&dep_node_index);

// Wake up waiters
data.emitting_diagnostics_cond_var.notify_all();
} else {
// The other threads will wait for the diagnostics to be emitted
// We must wait for the other thread to finish emitting the diagnostic

let mut emitted_diagnostics = data.emitted_diagnostics.lock();
loop {
if emitted_diagnostics.contains(&dep_node_index) {
data.emitting_diagnostics_cond_var.wait(&mut emitting);
if data.colors
.get(prev_dep_node_index) == Some(DepNodeColor::Green(dep_node_index)) {
break;
}
data.emitted_diagnostics_cond_var.wait(&mut emitted_diagnostics);
}
}
}
Expand Down Expand Up @@ -1027,7 +1043,7 @@ impl CurrentDepGraph {
hash: self.anon_id_seed.combine(hasher.finish()),
};

self.intern_node(target_dep_node, task_deps.reads, Fingerprint::ZERO).0
self.intern_node(target_dep_node, task_deps.reads, Fingerprint::ZERO)
}

fn alloc_node(
Expand All @@ -1037,19 +1053,19 @@ impl CurrentDepGraph {
fingerprint: Fingerprint
) -> DepNodeIndex {
debug_assert!(!self.node_to_node_index.contains_key(&dep_node));
self.intern_node(dep_node, edges, fingerprint).0
self.intern_node(dep_node, edges, fingerprint)
}

fn intern_node(
&mut self,
dep_node: DepNode,
edges: SmallVec<[DepNodeIndex; 8]>,
fingerprint: Fingerprint
) -> (DepNodeIndex, bool) {
) -> DepNodeIndex {
debug_assert_eq!(self.node_to_node_index.len(), self.data.len());

match self.node_to_node_index.entry(dep_node) {
Entry::Occupied(entry) => (*entry.get(), false),
Entry::Occupied(entry) => *entry.get(),
Entry::Vacant(entry) => {
let dep_node_index = DepNodeIndex::new(self.data.len());
self.data.push(DepNodeData {
Expand All @@ -1058,7 +1074,7 @@ impl CurrentDepGraph {
fingerprint
});
entry.insert(dep_node_index);
(dep_node_index, true)
dep_node_index
}
}
}
Expand Down
Loading