]> git.lizzy.rs Git - rust.git/blob - src/test/ui/dep-graph/dep-graph-trait-impl.rs
Rollup merge of #101388 - compiler-errors:issue-101376, r=fee1-dead
[rust.git] / src / test / ui / dep-graph / dep-graph-trait-impl.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     fn method(self) { }
14 }
15
16 mod x {
17     use Foo;
18
19     #[rustc_if_this_changed]
20     impl Foo for char { }
21
22     impl Foo for u32 { }
23 }
24
25 mod y {
26     use Foo;
27
28     #[rustc_then_this_would_need(typeck)] //~ ERROR OK
29     pub fn with_char() {
30         char::method('a');
31     }
32
33     #[rustc_then_this_would_need(typeck)] //~ ERROR OK
34     pub fn take_foo_with_char() {
35         take_foo::<char>('a');
36     }
37
38     #[rustc_then_this_would_need(typeck)] //~ ERROR OK
39     pub fn with_u32() {
40         u32::method(22);
41     }
42
43     #[rustc_then_this_would_need(typeck)] //~ ERROR OK
44     pub fn take_foo_with_u32() {
45         take_foo::<u32>(22);
46     }
47
48     pub fn take_foo<T:Foo>(t: T) { }
49 }
50
51 mod z {
52     use y;
53
54     // These are expected to yield errors, because changes to `x`
55     // affect the BODY of `y`, but not its signature.
56     #[rustc_then_this_would_need(typeck)] //~ ERROR no path
57     pub fn z() {
58         y::with_char();
59         y::with_u32();
60     }
61 }