From 64d98f8ee037282c35007b64c2649055c56af1db Mon Sep 17 00:00:00 2001
From: Daniel Baumann <daniel.baumann@progress-linux.org>
Date: Wed, 17 Apr 2024 14:19:03 +0200
Subject: Merging upstream version 1.68.2+dfsg1.

Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
---
 tests/ui/dep-graph/dep-graph-assoc-type-codegen.rs |  38 ++++++
 .../dep-graph/dep-graph-assoc-type-codegen.stderr  |   8 ++
 tests/ui/dep-graph/dep-graph-caller-callee.rs      |  36 ++++++
 tests/ui/dep-graph/dep-graph-caller-callee.stderr  |  14 +++
 tests/ui/dep-graph/dep-graph-check-attr.rs         |  20 +++
 tests/ui/dep-graph/dep-graph-check-attr.stderr     |  26 ++++
 tests/ui/dep-graph/dep-graph-dump.rs               |   6 +
 tests/ui/dep-graph/dep-graph-dump.stderr           |   2 +
 tests/ui/dep-graph/dep-graph-struct-signature.rs   |  87 +++++++++++++
 .../ui/dep-graph/dep-graph-struct-signature.stderr | 134 +++++++++++++++++++++
 .../dep-graph-trait-impl-two-traits-same-method.rs |  46 +++++++
 ...-graph-trait-impl-two-traits-same-method.stderr |  14 +++
 .../dep-graph/dep-graph-trait-impl-two-traits.rs   |  45 +++++++
 .../dep-graph-trait-impl-two-traits.stderr         |  14 +++
 tests/ui/dep-graph/dep-graph-trait-impl.rs         |  61 ++++++++++
 tests/ui/dep-graph/dep-graph-trait-impl.stderr     |  32 +++++
 tests/ui/dep-graph/dep-graph-type-alias.rs         |  56 +++++++++
 tests/ui/dep-graph/dep-graph-type-alias.stderr     |  74 ++++++++++++
 tests/ui/dep-graph/dep-graph-variance-alias.rs     |  22 ++++
 tests/ui/dep-graph/dep-graph-variance-alias.stderr |   8 ++
 20 files changed, 743 insertions(+)
 create mode 100644 tests/ui/dep-graph/dep-graph-assoc-type-codegen.rs
 create mode 100644 tests/ui/dep-graph/dep-graph-assoc-type-codegen.stderr
 create mode 100644 tests/ui/dep-graph/dep-graph-caller-callee.rs
 create mode 100644 tests/ui/dep-graph/dep-graph-caller-callee.stderr
 create mode 100644 tests/ui/dep-graph/dep-graph-check-attr.rs
 create mode 100644 tests/ui/dep-graph/dep-graph-check-attr.stderr
 create mode 100644 tests/ui/dep-graph/dep-graph-dump.rs
 create mode 100644 tests/ui/dep-graph/dep-graph-dump.stderr
 create mode 100644 tests/ui/dep-graph/dep-graph-struct-signature.rs
 create mode 100644 tests/ui/dep-graph/dep-graph-struct-signature.stderr
 create mode 100644 tests/ui/dep-graph/dep-graph-trait-impl-two-traits-same-method.rs
 create mode 100644 tests/ui/dep-graph/dep-graph-trait-impl-two-traits-same-method.stderr
 create mode 100644 tests/ui/dep-graph/dep-graph-trait-impl-two-traits.rs
 create mode 100644 tests/ui/dep-graph/dep-graph-trait-impl-two-traits.stderr
 create mode 100644 tests/ui/dep-graph/dep-graph-trait-impl.rs
 create mode 100644 tests/ui/dep-graph/dep-graph-trait-impl.stderr
 create mode 100644 tests/ui/dep-graph/dep-graph-type-alias.rs
 create mode 100644 tests/ui/dep-graph/dep-graph-type-alias.stderr
 create mode 100644 tests/ui/dep-graph/dep-graph-variance-alias.rs
 create mode 100644 tests/ui/dep-graph/dep-graph-variance-alias.stderr

(limited to 'tests/ui/dep-graph')

diff --git a/tests/ui/dep-graph/dep-graph-assoc-type-codegen.rs b/tests/ui/dep-graph/dep-graph-assoc-type-codegen.rs
new file mode 100644
index 000000000..978c19948
--- /dev/null
+++ b/tests/ui/dep-graph/dep-graph-assoc-type-codegen.rs
@@ -0,0 +1,38 @@
+// Test that when a trait impl changes, fns whose body uses that trait
+// must also be recompiled.
+
+// incremental
+// compile-flags: -Z query-dep-graph
+
+#![feature(rustc_attrs)]
+#![allow(warnings)]
+
+fn main() { }
+
+pub trait Foo: Sized {
+    type T;
+    fn method(self) { }
+}
+
+mod x {
+    use Foo;
+
+    #[rustc_if_this_changed]
+    impl Foo for char { type T = char; }
+
+    impl Foo for u32 { type T = u32; }
+}
+
+mod y {
+    use Foo;
+
+    #[rustc_then_this_would_need(typeck)] //~ ERROR OK
+    pub fn use_char_assoc() {
+        // Careful here: in the representation, <char as Foo>::T gets
+        // normalized away, so at a certain point we had no edge to
+        // codegen.  (But now codegen just depends on typeck.)
+        let x: <char as Foo>::T = 'a';
+    }
+
+    pub fn take_foo<T:Foo>(t: T) { }
+}
diff --git a/tests/ui/dep-graph/dep-graph-assoc-type-codegen.stderr b/tests/ui/dep-graph/dep-graph-assoc-type-codegen.stderr
new file mode 100644
index 000000000..cdc268cff
--- /dev/null
+++ b/tests/ui/dep-graph/dep-graph-assoc-type-codegen.stderr
@@ -0,0 +1,8 @@
+error: OK
+  --> $DIR/dep-graph-assoc-type-codegen.rs:29:5
+   |
+LL |     #[rustc_then_this_would_need(typeck)]
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
diff --git a/tests/ui/dep-graph/dep-graph-caller-callee.rs b/tests/ui/dep-graph/dep-graph-caller-callee.rs
new file mode 100644
index 000000000..4a3a8bb6b
--- /dev/null
+++ b/tests/ui/dep-graph/dep-graph-caller-callee.rs
@@ -0,0 +1,36 @@
+// Test that immediate callers have to change when callee changes, but
+// not callers' callers.
+
+// incremental
+// compile-flags: -Z query-dep-graph
+
+#![feature(rustc_attrs)]
+#![allow(dead_code)]
+
+fn main() { }
+
+mod x {
+    #[rustc_if_this_changed]
+    pub fn x() { }
+}
+
+mod y {
+    use x;
+
+    // These dependencies SHOULD exist:
+    #[rustc_then_this_would_need(typeck)] //~ ERROR OK
+    pub fn y() {
+        x::x();
+    }
+}
+
+mod z {
+    use y;
+
+    // These are expected to yield errors, because changes to `x`
+    // affect the BODY of `y`, but not its signature.
+    #[rustc_then_this_would_need(typeck)] //~ ERROR no path
+    pub fn z() {
+        y::y();
+    }
+}
diff --git a/tests/ui/dep-graph/dep-graph-caller-callee.stderr b/tests/ui/dep-graph/dep-graph-caller-callee.stderr
new file mode 100644
index 000000000..4d06dc7f3
--- /dev/null
+++ b/tests/ui/dep-graph/dep-graph-caller-callee.stderr
@@ -0,0 +1,14 @@
+error: OK
+  --> $DIR/dep-graph-caller-callee.rs:21:5
+   |
+LL |     #[rustc_then_this_would_need(typeck)]
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: no path from `x` to `typeck`
+  --> $DIR/dep-graph-caller-callee.rs:32:5
+   |
+LL |     #[rustc_then_this_would_need(typeck)]
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 2 previous errors
+
diff --git a/tests/ui/dep-graph/dep-graph-check-attr.rs b/tests/ui/dep-graph/dep-graph-check-attr.rs
new file mode 100644
index 000000000..a45bf24f8
--- /dev/null
+++ b/tests/ui/dep-graph/dep-graph-check-attr.rs
@@ -0,0 +1,20 @@
+// Test that using rustc_clean/dirty/if_this_changed/then_this_would_need
+// are forbidden when `-Z query-dep-graph` is not enabled.
+
+#![feature(rustc_attrs)]
+#![allow(dead_code)]
+#![allow(unused_variables)]
+
+#[rustc_clean(hir_owner)] //~ ERROR attribute requires -Z query-dep-graph
+fn main() {}
+
+#[rustc_if_this_changed(hir_owner)] //~ ERROR attribute requires -Z query-dep-graph
+struct Foo<T> {
+    f: T,
+}
+
+#[rustc_clean(hir_owner)] //~ ERROR attribute requires -Z query-dep-graph
+type TypeAlias<T> = Foo<T>;
+
+#[rustc_then_this_would_need(variances_of)] //~ ERROR attribute requires -Z query-dep-graph
+trait Use<T> {}
diff --git a/tests/ui/dep-graph/dep-graph-check-attr.stderr b/tests/ui/dep-graph/dep-graph-check-attr.stderr
new file mode 100644
index 000000000..46f4e4358
--- /dev/null
+++ b/tests/ui/dep-graph/dep-graph-check-attr.stderr
@@ -0,0 +1,26 @@
+error: attribute requires -Z query-dep-graph to be enabled
+  --> $DIR/dep-graph-check-attr.rs:8:1
+   |
+LL | #[rustc_clean(hir_owner)]
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: attribute requires -Z query-dep-graph to be enabled
+  --> $DIR/dep-graph-check-attr.rs:11:1
+   |
+LL | #[rustc_if_this_changed(hir_owner)]
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: attribute requires -Z query-dep-graph to be enabled
+  --> $DIR/dep-graph-check-attr.rs:16:1
+   |
+LL | #[rustc_clean(hir_owner)]
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: attribute requires -Z query-dep-graph to be enabled
+  --> $DIR/dep-graph-check-attr.rs:19:1
+   |
+LL | #[rustc_then_this_would_need(variances_of)]
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 4 previous errors
+
diff --git a/tests/ui/dep-graph/dep-graph-dump.rs b/tests/ui/dep-graph/dep-graph-dump.rs
new file mode 100644
index 000000000..cbc4def0e
--- /dev/null
+++ b/tests/ui/dep-graph/dep-graph-dump.rs
@@ -0,0 +1,6 @@
+// Test dump-dep-graph requires query-dep-graph enabled
+
+// incremental
+// compile-flags: -Z dump-dep-graph
+
+fn main() {}
diff --git a/tests/ui/dep-graph/dep-graph-dump.stderr b/tests/ui/dep-graph/dep-graph-dump.stderr
new file mode 100644
index 000000000..ea44b8bb0
--- /dev/null
+++ b/tests/ui/dep-graph/dep-graph-dump.stderr
@@ -0,0 +1,2 @@
+error: can't dump dependency graph without `-Z query-dep-graph`
+
diff --git a/tests/ui/dep-graph/dep-graph-struct-signature.rs b/tests/ui/dep-graph/dep-graph-struct-signature.rs
new file mode 100644
index 000000000..fcf9f6387
--- /dev/null
+++ b/tests/ui/dep-graph/dep-graph-struct-signature.rs
@@ -0,0 +1,87 @@
+// Test cases where a changing struct appears in the signature of fns
+// and methods.
+
+// incremental
+// compile-flags: -Z query-dep-graph
+
+#![feature(rustc_attrs)]
+#![allow(dead_code)]
+#![allow(unused_variables)]
+
+fn main() { }
+
+#[rustc_if_this_changed]
+struct WillChange {
+    x: u32,
+    y: u32
+}
+
+struct WontChange {
+    x: u32,
+    y: u32
+}
+
+// these are valid dependencies
+mod signatures {
+    use WillChange;
+
+    #[rustc_then_this_would_need(type_of)] //~ ERROR no path
+    #[rustc_then_this_would_need(associated_item)] //~ ERROR no path
+    #[rustc_then_this_would_need(trait_def)] //~ ERROR no path
+    trait Bar {
+        #[rustc_then_this_would_need(fn_sig)] //~ ERROR OK
+        fn do_something(x: WillChange);
+    }
+
+    #[rustc_then_this_would_need(fn_sig)] //~ ERROR OK
+    #[rustc_then_this_would_need(typeck)] //~ ERROR OK
+    fn some_fn(x: WillChange) { }
+
+    #[rustc_then_this_would_need(fn_sig)] //~ ERROR OK
+    #[rustc_then_this_would_need(typeck)] //~ ERROR OK
+    fn new_foo(x: u32, y: u32) -> WillChange {
+        WillChange { x: x, y: y }
+    }
+
+    #[rustc_then_this_would_need(type_of)] //~ ERROR OK
+    impl WillChange {
+        #[rustc_then_this_would_need(fn_sig)] //~ ERROR OK
+        #[rustc_then_this_would_need(typeck)] //~ ERROR OK
+        fn new(x: u32, y: u32) -> WillChange { loop { } }
+    }
+
+    #[rustc_then_this_would_need(type_of)] //~ ERROR OK
+    impl WillChange {
+        #[rustc_then_this_would_need(fn_sig)] //~ ERROR OK
+        #[rustc_then_this_would_need(typeck)] //~ ERROR OK
+        fn method(&self, x: u32) { }
+    }
+
+    struct WillChanges {
+        #[rustc_then_this_would_need(type_of)] //~ ERROR OK
+        x: WillChange,
+        #[rustc_then_this_would_need(type_of)] //~ ERROR OK
+        y: WillChange
+    }
+
+    // The fields change, not the type itself.
+    #[rustc_then_this_would_need(type_of)] //~ ERROR no path
+    fn indirect(x: WillChanges) { }
+}
+
+mod invalid_signatures {
+    use WontChange;
+
+    #[rustc_then_this_would_need(type_of)] //~ ERROR no path
+    trait A {
+        #[rustc_then_this_would_need(fn_sig)] //~ ERROR no path
+        fn do_something_else_twice(x: WontChange);
+    }
+
+    #[rustc_then_this_would_need(fn_sig)] //~ ERROR no path
+    fn b(x: WontChange) { }
+
+    #[rustc_then_this_would_need(fn_sig)] //~ ERROR no path from `WillChange`
+    #[rustc_then_this_would_need(typeck)] //~ ERROR no path from `WillChange`
+    fn c(x: u32) { }
+}
diff --git a/tests/ui/dep-graph/dep-graph-struct-signature.stderr b/tests/ui/dep-graph/dep-graph-struct-signature.stderr
new file mode 100644
index 000000000..cfe1e62d9
--- /dev/null
+++ b/tests/ui/dep-graph/dep-graph-struct-signature.stderr
@@ -0,0 +1,134 @@
+error: no path from `WillChange` to `type_of`
+  --> $DIR/dep-graph-struct-signature.rs:28:5
+   |
+LL |     #[rustc_then_this_would_need(type_of)]
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: no path from `WillChange` to `associated_item`
+  --> $DIR/dep-graph-struct-signature.rs:29:5
+   |
+LL |     #[rustc_then_this_would_need(associated_item)]
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: no path from `WillChange` to `trait_def`
+  --> $DIR/dep-graph-struct-signature.rs:30:5
+   |
+LL |     #[rustc_then_this_would_need(trait_def)]
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: OK
+  --> $DIR/dep-graph-struct-signature.rs:36:5
+   |
+LL |     #[rustc_then_this_would_need(fn_sig)]
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: OK
+  --> $DIR/dep-graph-struct-signature.rs:37:5
+   |
+LL |     #[rustc_then_this_would_need(typeck)]
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: OK
+  --> $DIR/dep-graph-struct-signature.rs:40:5
+   |
+LL |     #[rustc_then_this_would_need(fn_sig)]
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: OK
+  --> $DIR/dep-graph-struct-signature.rs:41:5
+   |
+LL |     #[rustc_then_this_would_need(typeck)]
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: OK
+  --> $DIR/dep-graph-struct-signature.rs:46:5
+   |
+LL |     #[rustc_then_this_would_need(type_of)]
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: OK
+  --> $DIR/dep-graph-struct-signature.rs:53:5
+   |
+LL |     #[rustc_then_this_would_need(type_of)]
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: OK
+  --> $DIR/dep-graph-struct-signature.rs:61:9
+   |
+LL |         #[rustc_then_this_would_need(type_of)]
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: OK
+  --> $DIR/dep-graph-struct-signature.rs:63:9
+   |
+LL |         #[rustc_then_this_would_need(type_of)]
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: no path from `WillChange` to `type_of`
+  --> $DIR/dep-graph-struct-signature.rs:68:5
+   |
+LL |     #[rustc_then_this_would_need(type_of)]
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: no path from `WillChange` to `type_of`
+  --> $DIR/dep-graph-struct-signature.rs:75:5
+   |
+LL |     #[rustc_then_this_would_need(type_of)]
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: no path from `WillChange` to `fn_sig`
+  --> $DIR/dep-graph-struct-signature.rs:81:5
+   |
+LL |     #[rustc_then_this_would_need(fn_sig)]
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: no path from `WillChange` to `fn_sig`
+  --> $DIR/dep-graph-struct-signature.rs:84:5
+   |
+LL |     #[rustc_then_this_would_need(fn_sig)]
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: no path from `WillChange` to `typeck`
+  --> $DIR/dep-graph-struct-signature.rs:85:5
+   |
+LL |     #[rustc_then_this_would_need(typeck)]
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: OK
+  --> $DIR/dep-graph-struct-signature.rs:32:9
+   |
+LL |         #[rustc_then_this_would_need(fn_sig)]
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: no path from `WillChange` to `fn_sig`
+  --> $DIR/dep-graph-struct-signature.rs:77:9
+   |
+LL |         #[rustc_then_this_would_need(fn_sig)]
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: OK
+  --> $DIR/dep-graph-struct-signature.rs:48:9
+   |
+LL |         #[rustc_then_this_would_need(fn_sig)]
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: OK
+  --> $DIR/dep-graph-struct-signature.rs:49:9
+   |
+LL |         #[rustc_then_this_would_need(typeck)]
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: OK
+  --> $DIR/dep-graph-struct-signature.rs:55:9
+   |
+LL |         #[rustc_then_this_would_need(fn_sig)]
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: OK
+  --> $DIR/dep-graph-struct-signature.rs:56:9
+   |
+LL |         #[rustc_then_this_would_need(typeck)]
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 22 previous errors
+
diff --git a/tests/ui/dep-graph/dep-graph-trait-impl-two-traits-same-method.rs b/tests/ui/dep-graph/dep-graph-trait-impl-two-traits-same-method.rs
new file mode 100644
index 000000000..5da8df570
--- /dev/null
+++ b/tests/ui/dep-graph/dep-graph-trait-impl-two-traits-same-method.rs
@@ -0,0 +1,46 @@
+// Test that adding an impl to a trait `Foo` DOES affect functions
+// that only use `Bar` if they have methods in common.
+
+// incremental
+// compile-flags: -Z query-dep-graph
+
+#![feature(rustc_attrs)]
+#![allow(dead_code)]
+#![allow(unused_imports)]
+
+fn main() { }
+
+pub trait Foo: Sized {
+    fn method(self) { }
+}
+
+pub trait Bar: Sized {
+    fn method(self) { }
+}
+
+mod x {
+    use {Foo, Bar};
+
+    #[rustc_if_this_changed]
+    impl Foo for u32 { }
+
+    impl Bar for char { }
+}
+
+mod y {
+    use {Foo, Bar};
+
+    #[rustc_then_this_would_need(typeck)] //~ ERROR OK
+    pub fn with_char() {
+        char::method('a');
+    }
+}
+
+mod z {
+    use y;
+
+    #[rustc_then_this_would_need(typeck)] //~ ERROR no path
+    pub fn z() {
+        y::with_char();
+    }
+}
diff --git a/tests/ui/dep-graph/dep-graph-trait-impl-two-traits-same-method.stderr b/tests/ui/dep-graph/dep-graph-trait-impl-two-traits-same-method.stderr
new file mode 100644
index 000000000..6f56cbc8d
--- /dev/null
+++ b/tests/ui/dep-graph/dep-graph-trait-impl-two-traits-same-method.stderr
@@ -0,0 +1,14 @@
+error: OK
+  --> $DIR/dep-graph-trait-impl-two-traits-same-method.rs:33:5
+   |
+LL |     #[rustc_then_this_would_need(typeck)]
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: no path from `x::<impl Foo for u32>` to `typeck`
+  --> $DIR/dep-graph-trait-impl-two-traits-same-method.rs:42:5
+   |
+LL |     #[rustc_then_this_would_need(typeck)]
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 2 previous errors
+
diff --git a/tests/ui/dep-graph/dep-graph-trait-impl-two-traits.rs b/tests/ui/dep-graph/dep-graph-trait-impl-two-traits.rs
new file mode 100644
index 000000000..590475fa0
--- /dev/null
+++ b/tests/ui/dep-graph/dep-graph-trait-impl-two-traits.rs
@@ -0,0 +1,45 @@
+// Test that adding an impl to a trait `Foo` does not affect functions
+// that only use `Bar`, so long as they do not have methods in common.
+
+// incremental
+// compile-flags: -Z query-dep-graph
+
+#![feature(rustc_attrs)]
+#![allow(warnings)]
+
+fn main() { }
+
+pub trait Foo: Sized {
+    fn foo(self) { }
+}
+
+pub trait Bar: Sized {
+    fn bar(self) { }
+}
+
+mod x {
+    use {Foo, Bar};
+
+    #[rustc_if_this_changed]
+    impl Foo for char { }
+
+    impl Bar for char { }
+}
+
+mod y {
+    use {Foo, Bar};
+
+    #[rustc_then_this_would_need(typeck)] //~ ERROR OK
+    pub fn call_bar() {
+        char::bar('a');
+    }
+}
+
+mod z {
+    use y;
+
+    #[rustc_then_this_would_need(typeck)] //~ ERROR no path
+    pub fn z() {
+        y::call_bar();
+    }
+}
diff --git a/tests/ui/dep-graph/dep-graph-trait-impl-two-traits.stderr b/tests/ui/dep-graph/dep-graph-trait-impl-two-traits.stderr
new file mode 100644
index 000000000..4e1043736
--- /dev/null
+++ b/tests/ui/dep-graph/dep-graph-trait-impl-two-traits.stderr
@@ -0,0 +1,14 @@
+error: OK
+  --> $DIR/dep-graph-trait-impl-two-traits.rs:32:5
+   |
+LL |     #[rustc_then_this_would_need(typeck)]
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: no path from `x::<impl Foo for char>` to `typeck`
+  --> $DIR/dep-graph-trait-impl-two-traits.rs:41:5
+   |
+LL |     #[rustc_then_this_would_need(typeck)]
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 2 previous errors
+
diff --git a/tests/ui/dep-graph/dep-graph-trait-impl.rs b/tests/ui/dep-graph/dep-graph-trait-impl.rs
new file mode 100644
index 000000000..19002965b
--- /dev/null
+++ b/tests/ui/dep-graph/dep-graph-trait-impl.rs
@@ -0,0 +1,61 @@
+// Test that when a trait impl changes, fns whose body uses that trait
+// must also be recompiled.
+
+// incremental
+// compile-flags: -Z query-dep-graph
+
+#![feature(rustc_attrs)]
+#![allow(warnings)]
+
+fn main() { }
+
+pub trait Foo: Sized {
+    fn method(self) { }
+}
+
+mod x {
+    use Foo;
+
+    #[rustc_if_this_changed]
+    impl Foo for char { }
+
+    impl Foo for u32 { }
+}
+
+mod y {
+    use Foo;
+
+    #[rustc_then_this_would_need(typeck)] //~ ERROR OK
+    pub fn with_char() {
+        char::method('a');
+    }
+
+    #[rustc_then_this_would_need(typeck)] //~ ERROR OK
+    pub fn take_foo_with_char() {
+        take_foo::<char>('a');
+    }
+
+    #[rustc_then_this_would_need(typeck)] //~ ERROR OK
+    pub fn with_u32() {
+        u32::method(22);
+    }
+
+    #[rustc_then_this_would_need(typeck)] //~ ERROR OK
+    pub fn take_foo_with_u32() {
+        take_foo::<u32>(22);
+    }
+
+    pub fn take_foo<T:Foo>(t: T) { }
+}
+
+mod z {
+    use y;
+
+    // These are expected to yield errors, because changes to `x`
+    // affect the BODY of `y`, but not its signature.
+    #[rustc_then_this_would_need(typeck)] //~ ERROR no path
+    pub fn z() {
+        y::with_char();
+        y::with_u32();
+    }
+}
diff --git a/tests/ui/dep-graph/dep-graph-trait-impl.stderr b/tests/ui/dep-graph/dep-graph-trait-impl.stderr
new file mode 100644
index 000000000..bfee6d5c8
--- /dev/null
+++ b/tests/ui/dep-graph/dep-graph-trait-impl.stderr
@@ -0,0 +1,32 @@
+error: OK
+  --> $DIR/dep-graph-trait-impl.rs:28:5
+   |
+LL |     #[rustc_then_this_would_need(typeck)]
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: OK
+  --> $DIR/dep-graph-trait-impl.rs:33:5
+   |
+LL |     #[rustc_then_this_would_need(typeck)]
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: OK
+  --> $DIR/dep-graph-trait-impl.rs:38:5
+   |
+LL |     #[rustc_then_this_would_need(typeck)]
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: OK
+  --> $DIR/dep-graph-trait-impl.rs:43:5
+   |
+LL |     #[rustc_then_this_would_need(typeck)]
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: no path from `x::<impl Foo for char>` to `typeck`
+  --> $DIR/dep-graph-trait-impl.rs:56:5
+   |
+LL |     #[rustc_then_this_would_need(typeck)]
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 5 previous errors
+
diff --git a/tests/ui/dep-graph/dep-graph-type-alias.rs b/tests/ui/dep-graph/dep-graph-type-alias.rs
new file mode 100644
index 000000000..0e1b3db19
--- /dev/null
+++ b/tests/ui/dep-graph/dep-graph-type-alias.rs
@@ -0,0 +1,56 @@
+// Test that changing what a `type` points to does not go unnoticed.
+
+// incremental
+// compile-flags: -Z query-dep-graph
+
+#![feature(rustc_attrs)]
+#![allow(dead_code)]
+#![allow(unused_variables)]
+
+fn main() { }
+
+
+#[rustc_if_this_changed]
+type TypeAlias = u32;
+
+// The type alias directly affects the type of the field,
+// not the enclosing struct:
+#[rustc_then_this_would_need(type_of)] //~ ERROR no path
+struct Struct {
+    #[rustc_then_this_would_need(type_of)] //~ ERROR OK
+    x: TypeAlias,
+    y: u32
+}
+
+#[rustc_then_this_would_need(type_of)] //~ ERROR no path
+enum Enum {
+    Variant1 {
+        #[rustc_then_this_would_need(type_of)] //~ ERROR OK
+        t: TypeAlias
+    },
+    Variant2(i32)
+}
+
+#[rustc_then_this_would_need(type_of)] //~ ERROR no path
+trait Trait {
+    #[rustc_then_this_would_need(fn_sig)] //~ ERROR OK
+    fn method(&self, _: TypeAlias);
+}
+
+struct SomeType;
+
+#[rustc_then_this_would_need(type_of)] //~ ERROR no path
+impl SomeType {
+    #[rustc_then_this_would_need(fn_sig)] //~ ERROR OK
+    #[rustc_then_this_would_need(typeck)] //~ ERROR OK
+    fn method(&self, _: TypeAlias) {}
+}
+
+#[rustc_then_this_would_need(type_of)] //~ ERROR OK
+type TypeAlias2 = TypeAlias;
+
+#[rustc_then_this_would_need(fn_sig)] //~ ERROR OK
+#[rustc_then_this_would_need(typeck)] //~ ERROR OK
+fn function(_: TypeAlias) {
+
+}
diff --git a/tests/ui/dep-graph/dep-graph-type-alias.stderr b/tests/ui/dep-graph/dep-graph-type-alias.stderr
new file mode 100644
index 000000000..42ac803b2
--- /dev/null
+++ b/tests/ui/dep-graph/dep-graph-type-alias.stderr
@@ -0,0 +1,74 @@
+error: no path from `TypeAlias` to `type_of`
+  --> $DIR/dep-graph-type-alias.rs:18:1
+   |
+LL | #[rustc_then_this_would_need(type_of)]
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: OK
+  --> $DIR/dep-graph-type-alias.rs:20:5
+   |
+LL |     #[rustc_then_this_would_need(type_of)]
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: no path from `TypeAlias` to `type_of`
+  --> $DIR/dep-graph-type-alias.rs:25:1
+   |
+LL | #[rustc_then_this_would_need(type_of)]
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: OK
+  --> $DIR/dep-graph-type-alias.rs:28:9
+   |
+LL |         #[rustc_then_this_would_need(type_of)]
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: no path from `TypeAlias` to `type_of`
+  --> $DIR/dep-graph-type-alias.rs:34:1
+   |
+LL | #[rustc_then_this_would_need(type_of)]
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: no path from `TypeAlias` to `type_of`
+  --> $DIR/dep-graph-type-alias.rs:42:1
+   |
+LL | #[rustc_then_this_would_need(type_of)]
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: OK
+  --> $DIR/dep-graph-type-alias.rs:49:1
+   |
+LL | #[rustc_then_this_would_need(type_of)]
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: OK
+  --> $DIR/dep-graph-type-alias.rs:52:1
+   |
+LL | #[rustc_then_this_would_need(fn_sig)]
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: OK
+  --> $DIR/dep-graph-type-alias.rs:53:1
+   |
+LL | #[rustc_then_this_would_need(typeck)]
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: OK
+  --> $DIR/dep-graph-type-alias.rs:36:5
+   |
+LL |     #[rustc_then_this_would_need(fn_sig)]
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: OK
+  --> $DIR/dep-graph-type-alias.rs:44:5
+   |
+LL |     #[rustc_then_this_would_need(fn_sig)]
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: OK
+  --> $DIR/dep-graph-type-alias.rs:45:5
+   |
+LL |     #[rustc_then_this_would_need(typeck)]
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 12 previous errors
+
diff --git a/tests/ui/dep-graph/dep-graph-variance-alias.rs b/tests/ui/dep-graph/dep-graph-variance-alias.rs
new file mode 100644
index 000000000..008434696
--- /dev/null
+++ b/tests/ui/dep-graph/dep-graph-variance-alias.rs
@@ -0,0 +1,22 @@
+// Test that changing what a `type` points to does not go unnoticed
+// by the variance analysis.
+
+// incremental
+// compile-flags: -Z query-dep-graph
+
+#![feature(rustc_attrs)]
+#![allow(dead_code)]
+#![allow(unused_variables)]
+fn main() {}
+
+#[rustc_if_this_changed]
+struct Foo<T> {
+    f: T,
+}
+
+type TypeAlias<T> = Foo<T>;
+
+#[rustc_then_this_would_need(variances_of)] //~ ERROR OK
+struct Use<T> {
+    x: TypeAlias<T>,
+}
diff --git a/tests/ui/dep-graph/dep-graph-variance-alias.stderr b/tests/ui/dep-graph/dep-graph-variance-alias.stderr
new file mode 100644
index 000000000..554ff455a
--- /dev/null
+++ b/tests/ui/dep-graph/dep-graph-variance-alias.stderr
@@ -0,0 +1,8 @@
+error: OK
+  --> $DIR/dep-graph-variance-alias.rs:19:1
+   |
+LL | #[rustc_then_this_would_need(variances_of)]
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
-- 
cgit v1.2.3