]> git.lizzy.rs Git - rust.git/blob - src/test/ui/dep-graph/dep-graph-assoc-type-codegen.rs
Auto merge of #55519 - fhartwig:hashmap-index-example, r=Centril
[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 // compile-flags: -Z query-dep-graph
5
6 #![feature(rustc_attrs)]
7 #![allow(warnings)]
8
9 fn main() { }
10
11 pub trait Foo: Sized {
12     type T;
13     fn method(self) { }
14 }
15
16 mod x {
17     use Foo;
18
19     #[rustc_if_this_changed]
20     impl Foo for char { type T = char; }
21
22     impl Foo for u32 { type T = u32; }
23 }
24
25 mod y {
26     use Foo;
27
28     #[rustc_then_this_would_need(TypeckTables)] //~ ERROR OK
29     pub fn use_char_assoc() {
30         // Careful here: in the representation, <char as Foo>::T gets
31         // normalized away, so at a certain point we had no edge to
32         // codegen.  (But now codegen just depends on typeck.)
33         let x: <char as Foo>::T = 'a';
34     }
35
36     pub fn take_foo<T:Foo>(t: T) { }
37 }