]> git.lizzy.rs Git - rust.git/blob - src/test/ui/dep-graph/dep-graph-assoc-type-codegen.rs
Rollup merge of #101388 - compiler-errors:issue-101376, r=fee1-dead
[rust.git] / src / test / ui / dep-graph / dep-graph-assoc-type-codegen.rs
1 // Test that when a trait impl changes, fns whose body uses that trait
2 // must also be recompiled.
3
4 // incremental
5 // compile-flags: -Z query-dep-graph
6
7 #![feature(rustc_attrs)]
8 #![allow(warnings)]
9
10 fn main() { }
11
12 pub trait Foo: Sized {
13     type T;
14     fn method(self) { }
15 }
16
17 mod x {
18     use Foo;
19
20     #[rustc_if_this_changed]
21     impl Foo for char { type T = char; }
22
23     impl Foo for u32 { type T = u32; }
24 }
25
26 mod y {
27     use Foo;
28
29     #[rustc_then_this_would_need(typeck)] //~ ERROR OK
30     pub fn use_char_assoc() {
31         // Careful here: in the representation, <char as Foo>::T gets
32         // normalized away, so at a certain point we had no edge to
33         // codegen.  (But now codegen just depends on typeck.)
34         let x: <char as Foo>::T = 'a';
35     }
36
37     pub fn take_foo<T:Foo>(t: T) { }
38 }