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 17 pull requests #48350

Closed
wants to merge 46 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
bd10ef7
rustc_typeck/check/closure: rustfmt
nikomatsakis Feb 10, 2018
cc05561
detect wrong number of args when type-checking a closure
nikomatsakis Feb 12, 2018
3118cbe
Allow two-phase borrows of &mut self in ops
sapphire-arches Feb 14, 2018
75f72c0
Make nested impl Trait a hard error
cramertj Feb 8, 2018
70e1f4f
Disallow projections from impl Trait types
cramertj Feb 9, 2018
f1fbf79
Amend nested impl Trait error message
cramertj Feb 14, 2018
dbacf0c
Test err on impl Trait projection within dyn Trait
cramertj Feb 14, 2018
20dcc72
inform type annotations
csmoe Feb 14, 2018
d4b8475
incr.comp.: Store DepNode colors in a dense array instead of a hashmap.
michaelwoerister Feb 13, 2018
9e9c55f
Update E0657 stderr to match changed test
cramertj Feb 14, 2018
7062955
Fix arguments specified by lxl in two-phase-bin-ops test
sapphire-arches Feb 15, 2018
f787bdd
Turn features() into a query.
michaelwoerister Feb 14, 2018
c0517a3
incr.comp.: Add regression test for detecting feature gate changes.
michaelwoerister Feb 14, 2018
d691c46
Fix procedural_mbe_matching test case after libsyntax change.
michaelwoerister Feb 15, 2018
1f0e1a0
Convert compile-fail/lint-ctypes.rs to ui test
Feb 14, 2018
7ac5e96
[improper_ctypes] Use a 'help:' line for possible fixes
Feb 11, 2018
ae92dfa
[improper_ctypes] Stop complaining about repr(usize) and repr(isize) …
Feb 11, 2018
9b5f47e
[improper_ctypes] Overhaul primary label
Feb 12, 2018
22a1716
[improper_ctypes] Suggest repr(transparent) for structs
Feb 14, 2018
9d493c8
[improper_ctypes] Point at definition of non-FFI-safe type if possible
Feb 14, 2018
051ea5c
[improper_ctypes] Don't suggest raw pointers when encountering trait …
Feb 14, 2018
0be2dc8
fix stderr
csmoe Feb 17, 2018
2cf683e
Merge branch 'master' into inform_type_annotations
csmoe Feb 17, 2018
01a70c6
Add a closing parenthesis to the span of Visibility::Crate
topecongiro Jan 27, 2018
0bddba9
Add a span field to Visibility::Restricted
topecongiro Jan 27, 2018
d6bdf29
Change ast::Visibility to Spanned type
topecongiro Jan 29, 2018
b5099a7
Replace dummy spans with empty spans
topecongiro Feb 4, 2018
291c51b
Fix up tests and typos
topecongiro Feb 14, 2018
8e9fa57
Revert unintentional submodule updates
topecongiro Feb 17, 2018
472dcdb
Fix broken documentation link.
frewsxcv Feb 18, 2018
4370a58
fix tyvar_behind_raw_pointer error code
csmoe Feb 18, 2018
6818551
bump pulldown
Manishearth Feb 18, 2018
f60aeec
Include shortcut links in markdown_links
Manishearth Feb 18, 2018
1d0ae9f
Generate shortcut links
Manishearth Feb 18, 2018
a04c124
Add test
Manishearth Feb 18, 2018
5fdc10c
Filter out non-macros in resolve_macro
Manishearth Feb 18, 2018
894707a
Rollup merge of #48084 - cramertj:impl-trait-errors, r=nikomatsakis
Manishearth Feb 20, 2018
fa17dac
Rollup merge of #48123 - nikomatsakis:issue-47244-expected-num-args, …
Manishearth Feb 20, 2018
7d3251c
Rollup merge of #48197 - bobtwinkles:two_phase_borrow_on_ops, r=nikom…
Manishearth Feb 20, 2018
e9f5e2b
Rollup merge of #48206 - michaelwoerister:colors-array, r=nikomatsakis
Manishearth Feb 20, 2018
852f7f1
Rollup merge of #48208 - michaelwoerister:track-features, r=petrochenkov
Manishearth Feb 20, 2018
0527a9a
Rollup merge of #48221 - rkruppe:improve-ctypes-lint, r=estebank
Manishearth Feb 20, 2018
f8b640c
Rollup merge of #48335 - Manishearth:shortcut-links, r=QuietMisdreavus
Manishearth Feb 20, 2018
df186aa
Rollup merge of #48198 - csmoe:inform_type_annotations, r=estebank
Manishearth Feb 20, 2018
587c42f
Rollup merge of #48314 - frewsxcv:frewsxcv-broken-link, r=GuillaumeGomez
Manishearth Feb 20, 2018
bbea863
Rollup merge of #47799 - topecongiro:fix-span-of-visibility, r=petroc…
Manishearth Feb 20, 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
8 changes: 4 additions & 4 deletions src/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 6 additions & 4 deletions src/librustc/dep_graph/dep_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,9 @@ impl DepKind {
}

define_dep_nodes!( <'tcx>
// We use this for most things when incr. comp. is turned off.
[] Null,

// Represents the `Krate` as a whole (the `hir::Krate` value) (as
// distinct from the krate module). This is basically a hash of
// the entire krate, so if you read from `Krate` (e.g., by calling
Expand Down Expand Up @@ -605,8 +608,8 @@ define_dep_nodes!( <'tcx>
[input] MissingExternCrateItem(CrateNum),
[input] UsedCrateSource(CrateNum),
[input] PostorderCnums,
[input] HasCloneClosures(CrateNum),
[input] HasCopyClosures(CrateNum),
[] HasCloneClosures(CrateNum),
[] HasCopyClosures(CrateNum),

// This query is not expected to have inputs -- as a result, it's
// not a good candidate for "replay" because it's essentially a
Expand All @@ -630,8 +633,6 @@ define_dep_nodes!( <'tcx>
[] CompileCodegenUnit(InternedString),
[input] OutputFilenames,
[anon] NormalizeTy,
// We use this for most things when incr. comp. is turned off.
[] Null,

[] SubstituteNormalizeAndTestPredicates { key: (DefId, &'tcx Substs<'tcx>) },

Expand All @@ -642,6 +643,7 @@ define_dep_nodes!( <'tcx>

[] GetSymbolExportLevel(DefId),

[input] Features,
);

trait DepNodeParams<'a, 'gcx: 'tcx + 'a, 'tcx: 'a> : fmt::Debug {
Expand Down
148 changes: 104 additions & 44 deletions src/librustc/dep_graph/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ struct DepGraphData {
/// nodes and edges as well as all fingerprints of nodes that have them.
previous: PreviousDepGraph,

colors: RefCell<FxHashMap<DepNode, DepNodeColor>>,
colors: RefCell<DepNodeColorMap>,

/// 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 All @@ -97,16 +97,18 @@ impl DepGraph {
// Pre-allocate the fingerprints array. We over-allocate a little so
// that we hopefully don't have to re-allocate during this compilation
// session.
let prev_graph_node_count = prev_graph.node_count();

let fingerprints = IndexVec::from_elem_n(Fingerprint::ZERO,
(prev_graph.node_count() * 115) / 100);
(prev_graph_node_count * 115) / 100);
DepGraph {
data: Some(Rc::new(DepGraphData {
previous_work_products: RefCell::new(FxHashMap()),
work_products: RefCell::new(FxHashMap()),
dep_node_debug: RefCell::new(FxHashMap()),
current: RefCell::new(CurrentDepGraph::new()),
previous: prev_graph,
colors: RefCell::new(FxHashMap()),
colors: RefCell::new(DepNodeColorMap::new(prev_graph_node_count)),
loaded_from_cache: RefCell::new(FxHashMap()),
})),
fingerprints: Rc::new(RefCell::new(fingerprints)),
Expand Down Expand Up @@ -213,8 +215,6 @@ impl DepGraph {
R: HashStable<HCX>,
{
if let Some(ref data) = self.data {
debug_assert!(!data.colors.borrow().contains_key(&key));

push(&data.current, key);
if cfg!(debug_assertions) {
profq_msg(ProfileQueriesMsg::TaskBegin(key.clone()))
Expand Down Expand Up @@ -254,19 +254,21 @@ impl DepGraph {
}

// Determine the color of the new DepNode.
{
let prev_fingerprint = data.previous.fingerprint_of(&key);
if let Some(prev_index) = data.previous.node_to_index_opt(&key) {
let prev_fingerprint = data.previous.fingerprint_by_index(prev_index);

let color = if Some(current_fingerprint) == prev_fingerprint {
let color = if current_fingerprint == prev_fingerprint {
DepNodeColor::Green(dep_node_index)
} else {
DepNodeColor::Red
};

let old_value = data.colors.borrow_mut().insert(key, color);
debug_assert!(old_value.is_none(),
let mut colors = data.colors.borrow_mut();
debug_assert!(colors.get(prev_index).is_none(),
"DepGraph::with_task() - Duplicate DepNodeColor \
insertion for {:?}", key);

colors.insert(prev_index, color);
}

(result, dep_node_index)
Expand All @@ -281,9 +283,11 @@ impl DepGraph {
let mut fingerprints = self.fingerprints.borrow_mut();
let dep_node_index = DepNodeIndex::new(fingerprints.len());
fingerprints.push(fingerprint);

debug_assert!(fingerprints[dep_node_index] == fingerprint,
"DepGraph::with_task() - Assigned fingerprint to \
unexpected index for {:?}", key);

(result, dep_node_index)
} else {
(task(cx, arg), DepNodeIndex::INVALID)
Expand Down Expand Up @@ -356,6 +360,15 @@ impl DepGraph {
.unwrap()
}

#[inline]
pub fn dep_node_exists(&self, dep_node: &DepNode) -> bool {
if let Some(ref data) = self.data {
data.current.borrow_mut().node_to_node_index.contains_key(dep_node)
} else {
false
}
}

#[inline]
pub fn fingerprint_of(&self, dep_node_index: DepNodeIndex) -> Fingerprint {
match self.fingerprints.borrow().get(dep_node_index) {
Expand Down Expand Up @@ -495,7 +508,17 @@ impl DepGraph {
}

pub fn node_color(&self, dep_node: &DepNode) -> Option<DepNodeColor> {
self.data.as_ref().and_then(|data| data.colors.borrow().get(dep_node).cloned())
if let Some(ref data) = self.data {
if let Some(prev_index) = data.previous.node_to_index_opt(dep_node) {
return data.colors.borrow().get(prev_index)
} else {
// This is a node that did not exist in the previous compilation
// session, so we consider it to be red.
return Some(DepNodeColor::Red)
}
}

None
}

pub fn try_mark_green<'tcx>(&self,
Expand All @@ -505,7 +528,6 @@ impl DepGraph {
debug!("try_mark_green({:?}) - BEGIN", dep_node);
let data = self.data.as_ref().unwrap();

debug_assert!(!data.colors.borrow().contains_key(dep_node));
debug_assert!(!data.current.borrow().node_to_node_index.contains_key(dep_node));

if dep_node.kind.is_input() {
Expand Down Expand Up @@ -535,19 +557,22 @@ impl DepGraph {
}
};

debug_assert!(data.colors.borrow().get(prev_dep_node_index).is_none());

let mut current_deps = Vec::new();

for &dep_dep_node_index in prev_deps {
let dep_dep_node = &data.previous.index_to_node(dep_dep_node_index);
let dep_dep_node_color = data.colors.borrow().get(dep_dep_node_index);

let dep_dep_node_color = data.colors.borrow().get(dep_dep_node).cloned();
match dep_dep_node_color {
Some(DepNodeColor::Green(node_index)) => {
// This dependency has been marked as green before, we are
// still fine and can continue with checking the other
// dependencies.
debug!("try_mark_green({:?}) --- found dependency {:?} to \
be immediately green", dep_node, dep_dep_node);
be immediately green",
dep_node,
data.previous.index_to_node(dep_dep_node_index));
current_deps.push(node_index);
}
Some(DepNodeColor::Red) => {
Expand All @@ -556,10 +581,14 @@ impl DepGraph {
// mark the DepNode as green and also don't need to bother
// with checking any of the other dependencies.
debug!("try_mark_green({:?}) - END - dependency {:?} was \
immediately red", dep_node, dep_dep_node);
immediately red",
dep_node,
data.previous.index_to_node(dep_dep_node_index));
return None
}
None => {
let dep_dep_node = &data.previous.index_to_node(dep_dep_node_index);

// We don't know the state of this dependency. If it isn't
// an input node, let's try to mark it green recursively.
if !dep_dep_node.kind.is_input() {
Expand Down Expand Up @@ -601,10 +630,8 @@ impl DepGraph {
debug!("try_mark_green({:?}) --- trying to force \
dependency {:?}", dep_node, dep_dep_node);
if ::ty::maps::force_from_dep_node(tcx, dep_dep_node) {
let dep_dep_node_color = data.colors
.borrow()
.get(dep_dep_node)
.cloned();
let dep_dep_node_color = data.colors.borrow().get(dep_dep_node_index);

match dep_dep_node_color {
Some(DepNodeColor::Green(node_index)) => {
debug!("try_mark_green({:?}) --- managed to \
Expand Down Expand Up @@ -681,26 +708,21 @@ impl DepGraph {
}

// ... and finally storing a "Green" entry in the color map.
let old_color = data.colors
.borrow_mut()
.insert(*dep_node, DepNodeColor::Green(dep_node_index));
debug_assert!(old_color.is_none(),
let mut colors = data.colors.borrow_mut();
debug_assert!(colors.get(prev_dep_node_index).is_none(),
"DepGraph::try_mark_green() - Duplicate DepNodeColor \
insertion for {:?}", dep_node);

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

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

// Used in various assertions
pub fn is_green(&self, dep_node_index: DepNodeIndex) -> bool {
let dep_node = self.data.as_ref().unwrap().current.borrow().nodes[dep_node_index];
self.data.as_ref().unwrap().colors.borrow().get(&dep_node).map(|&color| {
match color {
DepNodeColor::Red => false,
DepNodeColor::Green(_) => true,
}
}).unwrap_or(false)
// Returns true if the given node has been marked as green during the
// current compilation session. Used in various assertions
pub fn is_green(&self, dep_node: &DepNode) -> bool {
self.node_color(dep_node).map(|c| c.is_green()).unwrap_or(false)
}

// This method loads all on-disk cacheable query results into memory, so
Expand All @@ -714,20 +736,25 @@ impl DepGraph {
pub fn exec_cache_promotions<'a, 'tcx>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) {
let green_nodes: Vec<DepNode> = {
let data = self.data.as_ref().unwrap();
data.colors.borrow().iter().filter_map(|(dep_node, color)| match color {
DepNodeColor::Green(_) => {
if dep_node.cache_on_disk(tcx) {
Some(*dep_node)
} else {
let colors = data.colors.borrow();
colors.values.indices().filter_map(|prev_index| {
match colors.get(prev_index) {
Some(DepNodeColor::Green(_)) => {
let dep_node = data.previous.index_to_node(prev_index);
if dep_node.cache_on_disk(tcx) {
Some(dep_node)
} else {
None
}
}
None |
Some(DepNodeColor::Red) => {
// We can skip red nodes because a node can only be marked
// as red if the query result was recomputed and thus is
// already in memory.
None
}
}
DepNodeColor::Red => {
// We can skip red nodes because a node can only be marked
// as red if the query result was recomputed and thus is
// already in memory.
None
}
}).collect()
};

Expand Down Expand Up @@ -1052,3 +1079,36 @@ enum OpenTask {
node: DepNode,
},
}

// A data structure that stores Option<DepNodeColor> values as a contiguous
// array, using one u32 per entry.
struct DepNodeColorMap {
values: IndexVec<SerializedDepNodeIndex, u32>,
}

const COMPRESSED_NONE: u32 = 0;
const COMPRESSED_RED: u32 = 1;
const COMPRESSED_FIRST_GREEN: u32 = 2;

impl DepNodeColorMap {
fn new(size: usize) -> DepNodeColorMap {
DepNodeColorMap {
values: IndexVec::from_elem_n(COMPRESSED_NONE, size)
}
}

fn get(&self, index: SerializedDepNodeIndex) -> Option<DepNodeColor> {
match self.values[index] {
COMPRESSED_NONE => None,
COMPRESSED_RED => Some(DepNodeColor::Red),
value => Some(DepNodeColor::Green(DepNodeIndex(value - COMPRESSED_FIRST_GREEN)))
}
}

fn insert(&mut self, index: SerializedDepNodeIndex, color: DepNodeColor) {
self.values[index] = match color {
DepNodeColor::Red => COMPRESSED_RED,
DepNodeColor::Green(index) => index.0 + COMPRESSED_FIRST_GREEN,
}
}
}
5 changes: 5 additions & 0 deletions src/librustc/dep_graph/prev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ impl PreviousDepGraph {
self.index[dep_node]
}

#[inline]
pub fn node_to_index_opt(&self, dep_node: &DepNode) -> Option<SerializedDepNodeIndex> {
self.index.get(dep_node).cloned()
}

#[inline]
pub fn fingerprint_of(&self, dep_node: &DepNode) -> Option<Fingerprint> {
self.index
Expand Down
Loading