Skip to content

Commit b5a3ab2

Browse files
committed
Auto merge of #45915 - michaelwoerister:removed-nodes-in-try-mark-green, r=alexcrichton
incr.comp.: Don't crash in DepGraph::try_mark_green() when encountering a removed input node. Fixes a small regression that was introduced in #45867. r? @nikomatsakis
2 parents 9b53f0a + 67d2b1b commit b5a3ab2

File tree

4 files changed

+60
-5
lines changed

4 files changed

+60
-5
lines changed

src/librustc/dep_graph/graph.rs

+12-4
Original file line numberDiff line numberDiff line change
@@ -524,14 +524,22 @@ impl DepGraph {
524524
current_deps.push(node_index);
525525
continue;
526526
}
527-
} else if cfg!(debug_assertions) {
527+
} else {
528528
match dep_dep_node.kind {
529529
DepKind::Hir |
530530
DepKind::HirBody |
531531
DepKind::CrateMetadata => {
532-
assert!(dep_dep_node.extract_def_id(tcx).is_none(),
533-
"Input {:?} should have been pre-allocated but wasn't.",
534-
dep_dep_node);
532+
if dep_node.extract_def_id(tcx).is_none() {
533+
// If the node does not exist anymore, we
534+
// just fail to mark green.
535+
return None
536+
} else {
537+
// If the node does exist, it should have
538+
// been pre-allocated.
539+
bug!("DepNode {:?} should have been \
540+
pre-allocated but wasn't.",
541+
dep_dep_node)
542+
}
535543
}
536544
_ => {
537545
// For other kinds of inputs it's OK to be

src/librustc/ty/maps/plumbing.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,7 @@ pub fn force_from_dep_node<'a, 'gcx, 'lcx>(tcx: TyCtxt<'a, 'gcx, 'lcx>,
723723

724724
// This one should never occur in this context
725725
DepKind::Null => {
726-
bug!("force_from_dep_node() - Encountered {:?}", dep_node.kind)
726+
bug!("force_from_dep_node() - Encountered {:?}", dep_node)
727727
}
728728

729729
// These are not queries
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
pub fn foo(_: u8) {
12+
13+
}
+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// Test that removing an upstream crate does not cause any trouble.
12+
13+
// revisions:rpass1 rpass2
14+
// aux-build:extern_crate.rs
15+
16+
#[cfg(rpass1)]
17+
extern crate extern_crate;
18+
19+
pub fn main() {
20+
#[cfg(rpass1)]
21+
{
22+
extern_crate::foo(1);
23+
}
24+
25+
#[cfg(rpass2)]
26+
{
27+
foo(1);
28+
}
29+
}
30+
31+
#[cfg(rpass2)]
32+
pub fn foo(_: u8) {
33+
34+
}

0 commit comments

Comments
 (0)