Skip to content

Commit 56c73e5

Browse files
committed
Indicate that trans is always dependent on typeck
1 parent 0bdefd7 commit 56c73e5

File tree

3 files changed

+58
-4
lines changed

3 files changed

+58
-4
lines changed

src/librustc_trans/trans/base.rs

+8
Original file line numberDiff line numberDiff line change
@@ -3323,6 +3323,14 @@ impl<'a, 'tcx, 'v> Visitor<'v> for TransItemsWithinModVisitor<'a, 'tcx> {
33233323
// giving `trans_item` access to this item, so also record a read.
33243324
tcx.dep_graph.with_task(DepNode::TransCrateItem(def_id), || {
33253325
tcx.dep_graph.read(DepNode::Hir(def_id));
3326+
3327+
// We are going to be accessing various tables
3328+
// generated by TypeckItemBody; we also assume
3329+
// that the body passes type check. These tables
3330+
// are not individually tracked, so just register
3331+
// a read here.
3332+
tcx.dep_graph.read(DepNode::TypeckItemBody(def_id));
3333+
33263334
trans_item(self.ccx, i);
33273335
});
33283336

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// Copyright 2012-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 when a trait impl changes, fns whose body uses that trait
12+
// must also be recompiled.
13+
14+
// compile-flags: -Z incr-comp
15+
16+
#![feature(rustc_attrs)]
17+
#![allow(warnings)]
18+
19+
fn main() { }
20+
21+
pub trait Foo: Sized {
22+
type T;
23+
fn method(self) { }
24+
}
25+
26+
mod x {
27+
use Foo;
28+
29+
#[rustc_if_this_changed]
30+
impl Foo for char { type T = char; }
31+
32+
impl Foo for u32 { type T = u32; }
33+
}
34+
35+
mod y {
36+
use Foo;
37+
38+
#[rustc_then_this_would_need(TypeckItemBody)] //~ ERROR OK
39+
#[rustc_then_this_would_need(TransCrateItem)] //~ ERROR OK
40+
pub fn use_char_assoc() {
41+
// Careful here: in the representation, <char as Foo>::T gets
42+
// normalized away, so at a certain point we had no edge to
43+
// trans. (But now trans just depends on typeck.)
44+
let x: <char as Foo>::T = 'a';
45+
}
46+
47+
pub fn take_foo<T:Foo>(t: T) { }
48+
}

src/test/compile-fail/dep-graph-trait-impl.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,8 @@ mod y {
4040
char::method('a');
4141
}
4242

43-
// FIXME(#30741) tcx fulfillment cache not tracked
4443
#[rustc_then_this_would_need(TypeckItemBody)] //~ ERROR OK
45-
#[rustc_then_this_would_need(TransCrateItem)] //~ ERROR no path
44+
#[rustc_then_this_would_need(TransCrateItem)] //~ ERROR OK
4645
pub fn take_foo_with_char() {
4746
take_foo::<char>('a');
4847
}
@@ -53,9 +52,8 @@ mod y {
5352
u32::method(22);
5453
}
5554

56-
// FIXME(#30741) tcx fulfillment cache not tracked
5755
#[rustc_then_this_would_need(TypeckItemBody)] //~ ERROR OK
58-
#[rustc_then_this_would_need(TransCrateItem)] //~ ERROR no path
56+
#[rustc_then_this_would_need(TransCrateItem)] //~ ERROR OK
5957
pub fn take_foo_with_u32() {
6058
take_foo::<u32>(22);
6159
}

0 commit comments

Comments
 (0)