]> git.lizzy.rs Git - rust.git/blob - src/test/ui/dep-graph/dep-graph-type-alias.rs
Rollup merge of #105843 - compiler-errors:sugg-const, r=lcnr
[rust.git] / src / test / ui / dep-graph / dep-graph-type-alias.rs
1 // Test that changing what a `type` points to does not go unnoticed.
2
3 // incremental
4 // compile-flags: -Z query-dep-graph
5
6 #![feature(rustc_attrs)]
7 #![allow(dead_code)]
8 #![allow(unused_variables)]
9
10 fn main() { }
11
12
13 #[rustc_if_this_changed]
14 type TypeAlias = u32;
15
16 // The type alias directly affects the type of the field,
17 // not the enclosing struct:
18 #[rustc_then_this_would_need(type_of)] //~ ERROR no path
19 struct Struct {
20     #[rustc_then_this_would_need(type_of)] //~ ERROR OK
21     x: TypeAlias,
22     y: u32
23 }
24
25 #[rustc_then_this_would_need(type_of)] //~ ERROR no path
26 enum Enum {
27     Variant1 {
28         #[rustc_then_this_would_need(type_of)] //~ ERROR OK
29         t: TypeAlias
30     },
31     Variant2(i32)
32 }
33
34 #[rustc_then_this_would_need(type_of)] //~ ERROR no path
35 trait Trait {
36     #[rustc_then_this_would_need(fn_sig)] //~ ERROR OK
37     fn method(&self, _: TypeAlias);
38 }
39
40 struct SomeType;
41
42 #[rustc_then_this_would_need(type_of)] //~ ERROR no path
43 impl SomeType {
44     #[rustc_then_this_would_need(fn_sig)] //~ ERROR OK
45     #[rustc_then_this_would_need(typeck)] //~ ERROR OK
46     fn method(&self, _: TypeAlias) {}
47 }
48
49 #[rustc_then_this_would_need(type_of)] //~ ERROR OK
50 type TypeAlias2 = TypeAlias;
51
52 #[rustc_then_this_would_need(fn_sig)] //~ ERROR OK
53 #[rustc_then_this_would_need(typeck)] //~ ERROR OK
54 fn function(_: TypeAlias) {
55
56 }