about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/assembly/cstring-merging.rs2
-rw-r--r--tests/pretty/hir-fn-variadic.pp36
-rw-r--r--tests/pretty/hir-fn-variadic.rs16
-rw-r--r--tests/ui/contracts/contract-captures-via-closure-noncopy.stderr1
-rw-r--r--tests/ui/contracts/contract-const-fn.all_pass.stderr11
-rw-r--r--tests/ui/contracts/contract-const-fn.rs56
-rw-r--r--tests/ui/contracts/contract-const-fn.runtime_fail_post.stderr11
-rw-r--r--tests/ui/contracts/contract-const-fn.runtime_fail_pre.stderr11
-rw-r--r--tests/ui/contracts/internal_machinery/contract-intrinsics.rs6
-rw-r--r--tests/ui/contracts/internal_machinery/contract-lang-items.rs4
-rw-r--r--tests/ui/contracts/internal_machinery/internal-feature-gating.rs2
-rw-r--r--tests/ui/contracts/internal_machinery/internal-feature-gating.stderr2
-rw-r--r--tests/ui/generic-associated-types/impl_bounds.stderr4
-rw-r--r--tests/ui/impl-trait/auto-trait-leakage/auto-trait-coherence.rs (renamed from tests/ui/impl-trait/auto-trait-coherence.rs)0
-rw-r--r--tests/ui/impl-trait/auto-trait-leakage/auto-trait-coherence.stderr (renamed from tests/ui/impl-trait/auto-trait-coherence.stderr)0
-rw-r--r--tests/ui/impl-trait/auto-trait-leakage/auto-trait-contains-err.rs (renamed from tests/ui/impl-trait/auto-trait-contains-err.rs)0
-rw-r--r--tests/ui/impl-trait/auto-trait-leakage/auto-trait-contains-err.stderr (renamed from tests/ui/impl-trait/auto-trait-contains-err.stderr)0
-rw-r--r--tests/ui/impl-trait/auto-trait-leakage/auto-trait-leak-rpass.rs (renamed from tests/ui/impl-trait/auto-trait-leak-rpass.rs)0
-rw-r--r--tests/ui/impl-trait/auto-trait-leakage/auto-trait-leak.rs (renamed from tests/ui/impl-trait/auto-trait-leak.rs)0
-rw-r--r--tests/ui/impl-trait/auto-trait-leakage/auto-trait-leak.stderr (renamed from tests/ui/impl-trait/auto-trait-leak.stderr)0
-rw-r--r--tests/ui/impl-trait/auto-trait-leakage/auto-trait-leak2.rs (renamed from tests/ui/impl-trait/auto-trait-leak2.rs)0
-rw-r--r--tests/ui/impl-trait/auto-trait-leakage/auto-trait-leak2.stderr (renamed from tests/ui/impl-trait/auto-trait-leak2.stderr)0
-rw-r--r--tests/ui/impl-trait/auto-trait-leakage/avoid-query-cycle-via-item-bound.rs33
-rw-r--r--tests/ui/impl-trait/in-trait/method-compatability-via-leakage-cycle.current.stderr58
-rw-r--r--tests/ui/impl-trait/in-trait/method-compatability-via-leakage-cycle.next.stderr122
-rw-r--r--tests/ui/impl-trait/in-trait/method-compatability-via-leakage-cycle.rs30
-rw-r--r--tests/ui/impl-trait/in-trait/method-compatability-via-leakage.rs14
-rw-r--r--tests/ui/impl-trait/in-trait/refine-cycle.rs3
-rw-r--r--tests/ui/proc-macro/auxiliary/expand-expr.rs8
-rw-r--r--tests/ui/proc-macro/auxiliary/macro-only-syntax.rs2
-rw-r--r--tests/ui/proc-macro/auxiliary/span-api-tests.rs15
-rw-r--r--tests/ui/proc-macro/span-api-tests.rs14
-rw-r--r--tests/ui/traits/next-solver/cycles/inductive-cycle-but-err.rs8
-rw-r--r--tests/ui/traits/next-solver/cycles/inductive-cycle-but-err.stderr21
-rw-r--r--tests/ui/traits/next-solver/normalize/normalize-param-env-2.stderr4
-rw-r--r--tests/ui/traits/winnowing/global-where-bound-region-constraints-2.rs33
-rw-r--r--tests/ui/traits/winnowing/global-where-bound-region-constraints.rs29
-rw-r--r--tests/ui/traits/winnowing/norm-where-bound-gt-alias-bound.rs29
-rw-r--r--tests/ui/type/pattern_types/derives.rs3
-rw-r--r--tests/ui/type/pattern_types/derives.stderr2
-rw-r--r--tests/ui/type/pattern_types/derives_fail.rs26
-rw-r--r--tests/ui/type/pattern_types/derives_fail.stderr74
-rw-r--r--tests/ui/type/pattern_types/matching.rs26
-rw-r--r--tests/ui/type/pattern_types/matching_fail.rs25
-rw-r--r--tests/ui/type/pattern_types/matching_fail.stderr43
45 files changed, 740 insertions, 44 deletions
diff --git a/tests/assembly/cstring-merging.rs b/tests/assembly/cstring-merging.rs
index 07f25d1e1a4..b5c530ac35d 100644
--- a/tests/assembly/cstring-merging.rs
+++ b/tests/assembly/cstring-merging.rs
@@ -5,7 +5,7 @@
 
 use std::ffi::CStr;
 
-// CHECK: .section .rodata.str1.1,"aMS"
+// CHECK: .section .rodata.str1.{{[12]}},"aMS"
 // CHECK: .Lanon.{{.+}}:
 // CHECK-NEXT: .asciz "foo"
 #[unsafe(no_mangle)]
diff --git a/tests/pretty/hir-fn-variadic.pp b/tests/pretty/hir-fn-variadic.pp
index dfbaff69644..b6bc8e95127 100644
--- a/tests/pretty/hir-fn-variadic.pp
+++ b/tests/pretty/hir-fn-variadic.pp
@@ -13,3 +13,39 @@ extern "C" {
 }
 
 unsafe extern "C" fn bar(_: i32, mut va2: ...) -> usize { va2.arg::<usize>() }
+
+fn main() {
+    fn g1(_: extern "C" fn(_: u8, va: ...)) { }
+    fn g2(_: extern "C" fn(_: u8, ...)) { }
+    fn g3(_: extern "C" fn(u8, va: ...)) { }
+    fn g4(_: extern "C" fn(u8, ...)) { }
+
+    fn g5(_: extern "C" fn(va: ...)) { }
+    fn g6(_: extern "C" fn(...)) { }
+
+    {
+        let _ =
+            {
+                unsafe extern "C" fn f1(_: u8, va: ...) { }
+            };
+    };
+    {
+        let _ =
+            {
+                unsafe extern "C" fn f2(_: u8, _: ...) { }
+            };
+    };
+
+    {
+        let _ =
+            {
+                unsafe extern "C" fn f5(va: ...) { }
+            };
+    };
+    {
+        let _ =
+            {
+                unsafe extern "C" fn f6(_: ...) { }
+            };
+    };
+}
diff --git a/tests/pretty/hir-fn-variadic.rs b/tests/pretty/hir-fn-variadic.rs
index 3d3f7ee1831..99aa402c480 100644
--- a/tests/pretty/hir-fn-variadic.rs
+++ b/tests/pretty/hir-fn-variadic.rs
@@ -11,3 +11,19 @@ extern "C" {
 pub unsafe extern "C" fn bar(_: i32, mut va2: ...) -> usize {
     va2.arg::<usize>()
 }
+
+fn main() {
+    fn g1(_: extern "C" fn(_: u8, va: ...)) {}
+    fn g2(_: extern "C" fn(_: u8, ...)) {}
+    fn g3(_: extern "C" fn(u8, va: ...)) {}
+    fn g4(_: extern "C" fn(u8, ...)) {}
+
+    fn g5(_: extern "C" fn(va: ...)) {}
+    fn g6(_: extern "C" fn(...)) {}
+
+    _ = { unsafe extern "C" fn f1(_: u8, va: ...) {} };
+    _ = { unsafe extern "C" fn f2(_: u8, ...) {} };
+
+    _ = { unsafe extern "C" fn f5(va: ...) {} };
+    _ = { unsafe extern "C" fn f6(...) {} };
+}
diff --git a/tests/ui/contracts/contract-captures-via-closure-noncopy.stderr b/tests/ui/contracts/contract-captures-via-closure-noncopy.stderr
index 4a47671fee1..b6f2e014e0a 100644
--- a/tests/ui/contracts/contract-captures-via-closure-noncopy.stderr
+++ b/tests/ui/contracts/contract-captures-via-closure-noncopy.stderr
@@ -16,6 +16,7 @@ LL | #[core::contracts::ensures({let old = x; move |ret:&Baz| ret.baz == old.baz
    | |                                        within this `{closure@$DIR/contract-captures-via-closure-noncopy.rs:12:42: 12:57}`
    | |                                        this tail expression is of type `{closure@contract-captures-via-closure-noncopy.rs:12:42}`
    | unsatisfied trait bound
+   | required by a bound introduced by this call
    |
    = help: within `{closure@$DIR/contract-captures-via-closure-noncopy.rs:12:42: 12:57}`, the trait `std::marker::Copy` is not implemented for `Baz`
 note: required because it's used within this closure
diff --git a/tests/ui/contracts/contract-const-fn.all_pass.stderr b/tests/ui/contracts/contract-const-fn.all_pass.stderr
new file mode 100644
index 00000000000..e5b1df65582
--- /dev/null
+++ b/tests/ui/contracts/contract-const-fn.all_pass.stderr
@@ -0,0 +1,11 @@
+warning: the feature `contracts` is incomplete and may not be safe to use and/or cause compiler crashes
+  --> $DIR/contract-const-fn.rs:17:12
+   |
+LL | #![feature(contracts)]
+   |            ^^^^^^^^^
+   |
+   = note: see issue #128044 <https://github.com/rust-lang/rust/issues/128044> for more information
+   = note: `#[warn(incomplete_features)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/contracts/contract-const-fn.rs b/tests/ui/contracts/contract-const-fn.rs
new file mode 100644
index 00000000000..733a06ae570
--- /dev/null
+++ b/tests/ui/contracts/contract-const-fn.rs
@@ -0,0 +1,56 @@
+//! Check if we can annotate a constant function with contracts.
+//!
+//! The contract is only checked at runtime, and it will not fail if evaluated statically.
+//! This is an existing limitation due to the existing architecture and the lack of constant
+//! closures.
+//!
+//@ revisions: all_pass runtime_fail_pre runtime_fail_post
+//
+//@ [all_pass] run-pass
+//
+//@ [runtime_fail_pre] run-fail
+//@ [runtime_fail_post] run-fail
+//
+//@ [all_pass] compile-flags: -Zcontract-checks=yes
+//@ [runtime_fail_pre] compile-flags: -Zcontract-checks=yes
+//@ [runtime_fail_post] compile-flags: -Zcontract-checks=yes
+#![feature(contracts)]
+//~^ WARN the feature `contracts` is incomplete and may not be safe to use and/or cause compiler crashes [incomplete_features]
+
+extern crate core;
+use core::contracts::*;
+
+#[requires(x < 100)]
+const fn less_than_100(x: u8) -> u8 {
+    x
+}
+
+// This is wrong on purpose.
+#[ensures(|ret| *ret)]
+const fn always_true(b: bool) -> bool {
+    b
+}
+
+const ZERO: u8 = less_than_100(0);
+// This is no-op because the contract cannot be checked at compilation time.
+const TWO_HUNDRED: u8 = less_than_100(200);
+
+/// Example from <https://github.com/rust-lang/rust/issues/136925>.
+#[ensures(move |ret: &u32| *ret > x)]
+const fn broken_sum(x: u32, y: u32) -> u32 {
+    x + y
+}
+
+fn main() {
+    assert_eq!(ZERO, 0);
+    assert_eq!(TWO_HUNDRED, 200);
+    assert_eq!(broken_sum(0, 1), 1);
+    assert_eq!(always_true(true), true);
+
+    #[cfg(runtime_fail_post)]
+    let _ok = always_true(false);
+
+    // Runtime check should fail.
+    #[cfg(runtime_fail_pre)]
+    let _200 = less_than_100(200);
+}
diff --git a/tests/ui/contracts/contract-const-fn.runtime_fail_post.stderr b/tests/ui/contracts/contract-const-fn.runtime_fail_post.stderr
new file mode 100644
index 00000000000..e5b1df65582
--- /dev/null
+++ b/tests/ui/contracts/contract-const-fn.runtime_fail_post.stderr
@@ -0,0 +1,11 @@
+warning: the feature `contracts` is incomplete and may not be safe to use and/or cause compiler crashes
+  --> $DIR/contract-const-fn.rs:17:12
+   |
+LL | #![feature(contracts)]
+   |            ^^^^^^^^^
+   |
+   = note: see issue #128044 <https://github.com/rust-lang/rust/issues/128044> for more information
+   = note: `#[warn(incomplete_features)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/contracts/contract-const-fn.runtime_fail_pre.stderr b/tests/ui/contracts/contract-const-fn.runtime_fail_pre.stderr
new file mode 100644
index 00000000000..e5b1df65582
--- /dev/null
+++ b/tests/ui/contracts/contract-const-fn.runtime_fail_pre.stderr
@@ -0,0 +1,11 @@
+warning: the feature `contracts` is incomplete and may not be safe to use and/or cause compiler crashes
+  --> $DIR/contract-const-fn.rs:17:12
+   |
+LL | #![feature(contracts)]
+   |            ^^^^^^^^^
+   |
+   = note: see issue #128044 <https://github.com/rust-lang/rust/issues/128044> for more information
+   = note: `#[warn(incomplete_features)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/contracts/internal_machinery/contract-intrinsics.rs b/tests/ui/contracts/internal_machinery/contract-intrinsics.rs
index ae692afd146..c62b8cca75a 100644
--- a/tests/ui/contracts/internal_machinery/contract-intrinsics.rs
+++ b/tests/ui/contracts/internal_machinery/contract-intrinsics.rs
@@ -26,11 +26,11 @@ fn main() {
     #[cfg(any(default, unchk_pass, chk_fail_requires))]
     core::intrinsics::contract_check_requires(|| false);
 
-    let doubles_to_two = { let old = 2; move |ret| ret + ret == old };
+    let doubles_to_two = { let old = 2; move |ret: &u32 | ret + ret == old };
     // Always pass
-    core::intrinsics::contract_check_ensures(&1, doubles_to_two);
+    core::intrinsics::contract_check_ensures(doubles_to_two, 1);
 
     // Fail if enabled
     #[cfg(any(default, unchk_pass, chk_fail_ensures))]
-    core::intrinsics::contract_check_ensures(&2, doubles_to_two);
+    core::intrinsics::contract_check_ensures(doubles_to_two, 2);
 }
diff --git a/tests/ui/contracts/internal_machinery/contract-lang-items.rs b/tests/ui/contracts/internal_machinery/contract-lang-items.rs
index e91bbed294d..73c59194531 100644
--- a/tests/ui/contracts/internal_machinery/contract-lang-items.rs
+++ b/tests/ui/contracts/internal_machinery/contract-lang-items.rs
@@ -15,14 +15,14 @@
 #![feature(contracts)] // to access core::contracts
 //~^ WARN the feature `contracts` is incomplete and may not be safe to use and/or cause compiler crashes [incomplete_features]
 #![feature(contracts_internals)] // to access check_requires lang item
-
+#![feature(core_intrinsics)]
 fn foo(x: Baz) -> i32 {
     let injected_checker = {
         core::contracts::build_check_ensures(|ret| *ret > 100)
     };
 
     let ret = x.baz + 50;
-    injected_checker(ret)
+    core::intrinsics::contract_check_ensures(injected_checker, ret)
 }
 
 struct Baz { baz: i32 }
diff --git a/tests/ui/contracts/internal_machinery/internal-feature-gating.rs b/tests/ui/contracts/internal_machinery/internal-feature-gating.rs
index 1b76eef6780..6e5a7a3f950 100644
--- a/tests/ui/contracts/internal_machinery/internal-feature-gating.rs
+++ b/tests/ui/contracts/internal_machinery/internal-feature-gating.rs
@@ -6,7 +6,7 @@ fn main() {
     //~^ ERROR use of unstable library feature `contracts_internals`
     core::intrinsics::contract_check_requires(|| true);
     //~^ ERROR use of unstable library feature `contracts_internals`
-    core::intrinsics::contract_check_ensures(&1, |_|true);
+    core::intrinsics::contract_check_ensures( |_|true, &1);
     //~^ ERROR use of unstable library feature `contracts_internals`
 
     core::contracts::build_check_ensures(|_: &()| true);
diff --git a/tests/ui/contracts/internal_machinery/internal-feature-gating.stderr b/tests/ui/contracts/internal_machinery/internal-feature-gating.stderr
index 7302694a787..1e39bd62e24 100644
--- a/tests/ui/contracts/internal_machinery/internal-feature-gating.stderr
+++ b/tests/ui/contracts/internal_machinery/internal-feature-gating.stderr
@@ -41,7 +41,7 @@ LL |     core::intrinsics::contract_check_requires(|| true);
 error[E0658]: use of unstable library feature `contracts_internals`
   --> $DIR/internal-feature-gating.rs:9:5
    |
-LL |     core::intrinsics::contract_check_ensures(&1, |_|true);
+LL |     core::intrinsics::contract_check_ensures( |_|true, &1);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: see issue #128044 <https://github.com/rust-lang/rust/issues/128044> for more information
diff --git a/tests/ui/generic-associated-types/impl_bounds.stderr b/tests/ui/generic-associated-types/impl_bounds.stderr
index 231c0dd89c5..7847bbd813c 100644
--- a/tests/ui/generic-associated-types/impl_bounds.stderr
+++ b/tests/ui/generic-associated-types/impl_bounds.stderr
@@ -57,14 +57,14 @@ note: required for `Fooy<T>` to implement `Copy`
    |
 LL | #[derive(Copy, Clone)]
    |          ^^^^ unsatisfied trait bound introduced in this `derive` macro
-note: the requirement `Fooy<T>: Copy` appears on the `impl`'s method `d` but not on the corresponding trait's method
+note: the requirement `Fooy<T>: Copy` appears on the `impl`'s associated function `d` but not on the corresponding trait's associated function
   --> $DIR/impl_bounds.rs:7:8
    |
 LL | trait Foo {
    |       --- in this trait
 ...
 LL |     fn d() where Self: Clone;
-   |        ^ this trait's method doesn't have the requirement `Fooy<T>: Copy`
+   |        ^ this trait's associated function doesn't have the requirement `Fooy<T>: Copy`
 help: consider restricting type parameter `T` with trait `Copy`
    |
 LL | impl<T: std::marker::Copy> Foo for Fooy<T> {
diff --git a/tests/ui/impl-trait/auto-trait-coherence.rs b/tests/ui/impl-trait/auto-trait-leakage/auto-trait-coherence.rs
index fdb981ea406..fdb981ea406 100644
--- a/tests/ui/impl-trait/auto-trait-coherence.rs
+++ b/tests/ui/impl-trait/auto-trait-leakage/auto-trait-coherence.rs
diff --git a/tests/ui/impl-trait/auto-trait-coherence.stderr b/tests/ui/impl-trait/auto-trait-leakage/auto-trait-coherence.stderr
index cfeccc3d766..cfeccc3d766 100644
--- a/tests/ui/impl-trait/auto-trait-coherence.stderr
+++ b/tests/ui/impl-trait/auto-trait-leakage/auto-trait-coherence.stderr
diff --git a/tests/ui/impl-trait/auto-trait-contains-err.rs b/tests/ui/impl-trait/auto-trait-leakage/auto-trait-contains-err.rs
index 8a2ebe301f1..8a2ebe301f1 100644
--- a/tests/ui/impl-trait/auto-trait-contains-err.rs
+++ b/tests/ui/impl-trait/auto-trait-leakage/auto-trait-contains-err.rs
diff --git a/tests/ui/impl-trait/auto-trait-contains-err.stderr b/tests/ui/impl-trait/auto-trait-leakage/auto-trait-contains-err.stderr
index 4da6b285ae1..4da6b285ae1 100644
--- a/tests/ui/impl-trait/auto-trait-contains-err.stderr
+++ b/tests/ui/impl-trait/auto-trait-leakage/auto-trait-contains-err.stderr
diff --git a/tests/ui/impl-trait/auto-trait-leak-rpass.rs b/tests/ui/impl-trait/auto-trait-leakage/auto-trait-leak-rpass.rs
index 55ba3e0d14e..55ba3e0d14e 100644
--- a/tests/ui/impl-trait/auto-trait-leak-rpass.rs
+++ b/tests/ui/impl-trait/auto-trait-leakage/auto-trait-leak-rpass.rs
diff --git a/tests/ui/impl-trait/auto-trait-leak.rs b/tests/ui/impl-trait/auto-trait-leakage/auto-trait-leak.rs
index de4f523c23a..de4f523c23a 100644
--- a/tests/ui/impl-trait/auto-trait-leak.rs
+++ b/tests/ui/impl-trait/auto-trait-leakage/auto-trait-leak.rs
diff --git a/tests/ui/impl-trait/auto-trait-leak.stderr b/tests/ui/impl-trait/auto-trait-leakage/auto-trait-leak.stderr
index cc9939f2d57..cc9939f2d57 100644
--- a/tests/ui/impl-trait/auto-trait-leak.stderr
+++ b/tests/ui/impl-trait/auto-trait-leakage/auto-trait-leak.stderr
diff --git a/tests/ui/impl-trait/auto-trait-leak2.rs b/tests/ui/impl-trait/auto-trait-leakage/auto-trait-leak2.rs
index 09450089ada..09450089ada 100644
--- a/tests/ui/impl-trait/auto-trait-leak2.rs
+++ b/tests/ui/impl-trait/auto-trait-leakage/auto-trait-leak2.rs
diff --git a/tests/ui/impl-trait/auto-trait-leak2.stderr b/tests/ui/impl-trait/auto-trait-leakage/auto-trait-leak2.stderr
index 52fa28145d6..52fa28145d6 100644
--- a/tests/ui/impl-trait/auto-trait-leak2.stderr
+++ b/tests/ui/impl-trait/auto-trait-leakage/auto-trait-leak2.stderr
diff --git a/tests/ui/impl-trait/auto-trait-leakage/avoid-query-cycle-via-item-bound.rs b/tests/ui/impl-trait/auto-trait-leakage/avoid-query-cycle-via-item-bound.rs
new file mode 100644
index 00000000000..7f366fdcabd
--- /dev/null
+++ b/tests/ui/impl-trait/auto-trait-leakage/avoid-query-cycle-via-item-bound.rs
@@ -0,0 +1,33 @@
+//@ check-pass
+//@ revisions: current next
+//@[next] compile-flags: -Znext-solver
+//@ ignore-compare-mode-next-solver (explicit revisions)
+
+// When proving auto trait bounds, make sure that we depend on auto trait
+// leakage if we can also prove it via an item bound.
+fn is_send<T: Send>(_: T) {}
+
+fn direct() -> impl Send {
+    is_send(check(false)); // leaks auto traits, depends on `check`
+    1u16
+}
+
+trait Indir: Send {}
+impl Indir for u32 {}
+fn indir() -> impl Indir {
+    is_send(check(false)); // leaks auto traits, depends on `check`
+    1u32
+}
+
+fn check(b: bool) -> impl Sized {
+    if b {
+        // must not leak auto traits, as we otherwise get a query cycle.
+        is_send(direct());
+        is_send(indir());
+    }
+    1u64
+}
+
+fn main() {
+    check(true);
+}
diff --git a/tests/ui/impl-trait/in-trait/method-compatability-via-leakage-cycle.current.stderr b/tests/ui/impl-trait/in-trait/method-compatability-via-leakage-cycle.current.stderr
new file mode 100644
index 00000000000..bf598d62709
--- /dev/null
+++ b/tests/ui/impl-trait/in-trait/method-compatability-via-leakage-cycle.current.stderr
@@ -0,0 +1,58 @@
+error[E0391]: cycle detected when computing type of `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>::{anon_assoc#0}`
+  --> $DIR/method-compatability-via-leakage-cycle.rs:21:24
+   |
+LL |     fn foo(b: bool) -> impl Sized {
+   |                        ^^^^^^^^^^
+   |
+note: ...which requires comparing an impl and trait method signature, inferring any hidden `impl Trait` types in the process...
+  --> $DIR/method-compatability-via-leakage-cycle.rs:21:24
+   |
+LL |     fn foo(b: bool) -> impl Sized {
+   |                        ^^^^^^^^^^
+   = note: ...which requires evaluating trait selection obligation `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>::foo::{opaque#0}: core::marker::Send`...
+note: ...which requires computing type of opaque `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>::foo::{opaque#0}`...
+  --> $DIR/method-compatability-via-leakage-cycle.rs:21:24
+   |
+LL |     fn foo(b: bool) -> impl Sized {
+   |                        ^^^^^^^^^^
+note: ...which requires borrow-checking `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>::foo`...
+  --> $DIR/method-compatability-via-leakage-cycle.rs:21:5
+   |
+LL |     fn foo(b: bool) -> impl Sized {
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+note: ...which requires promoting constants in MIR for `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>::foo`...
+  --> $DIR/method-compatability-via-leakage-cycle.rs:21:5
+   |
+LL |     fn foo(b: bool) -> impl Sized {
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+note: ...which requires checking if `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>::foo` contains FFI-unwind calls...
+  --> $DIR/method-compatability-via-leakage-cycle.rs:21:5
+   |
+LL |     fn foo(b: bool) -> impl Sized {
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+note: ...which requires building MIR for `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>::foo`...
+  --> $DIR/method-compatability-via-leakage-cycle.rs:21:5
+   |
+LL |     fn foo(b: bool) -> impl Sized {
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+note: ...which requires match-checking `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>::foo`...
+  --> $DIR/method-compatability-via-leakage-cycle.rs:21:5
+   |
+LL |     fn foo(b: bool) -> impl Sized {
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+note: ...which requires type-checking `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>::foo`...
+  --> $DIR/method-compatability-via-leakage-cycle.rs:21:5
+   |
+LL |     fn foo(b: bool) -> impl Sized {
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   = note: ...which again requires computing type of `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>::{anon_assoc#0}`, completing the cycle
+note: cycle used when checking that `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>` is well-formed
+  --> $DIR/method-compatability-via-leakage-cycle.rs:17:1
+   |
+LL | impl Trait for u32 {
+   | ^^^^^^^^^^^^^^^^^^
+   = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0391`.
diff --git a/tests/ui/impl-trait/in-trait/method-compatability-via-leakage-cycle.next.stderr b/tests/ui/impl-trait/in-trait/method-compatability-via-leakage-cycle.next.stderr
new file mode 100644
index 00000000000..6bec5bbc063
--- /dev/null
+++ b/tests/ui/impl-trait/in-trait/method-compatability-via-leakage-cycle.next.stderr
@@ -0,0 +1,122 @@
+error[E0391]: cycle detected when computing type of `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>::{anon_assoc#0}`
+  --> $DIR/method-compatability-via-leakage-cycle.rs:21:24
+   |
+LL |     fn foo(b: bool) -> impl Sized {
+   |                        ^^^^^^^^^^
+   |
+note: ...which requires comparing an impl and trait method signature, inferring any hidden `impl Trait` types in the process...
+  --> $DIR/method-compatability-via-leakage-cycle.rs:21:5
+   |
+LL |     fn foo(b: bool) -> impl Sized {
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+note: ...which requires computing type of `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>::foo::{opaque#0}`...
+  --> $DIR/method-compatability-via-leakage-cycle.rs:21:24
+   |
+LL |     fn foo(b: bool) -> impl Sized {
+   |                        ^^^^^^^^^^
+note: ...which requires computing type of opaque `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>::foo::{opaque#0}`...
+  --> $DIR/method-compatability-via-leakage-cycle.rs:21:24
+   |
+LL |     fn foo(b: bool) -> impl Sized {
+   |                        ^^^^^^^^^^
+note: ...which requires borrow-checking `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>::foo`...
+  --> $DIR/method-compatability-via-leakage-cycle.rs:21:5
+   |
+LL |     fn foo(b: bool) -> impl Sized {
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+note: ...which requires promoting constants in MIR for `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>::foo`...
+  --> $DIR/method-compatability-via-leakage-cycle.rs:21:5
+   |
+LL |     fn foo(b: bool) -> impl Sized {
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+note: ...which requires checking if `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>::foo` contains FFI-unwind calls...
+  --> $DIR/method-compatability-via-leakage-cycle.rs:21:5
+   |
+LL |     fn foo(b: bool) -> impl Sized {
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+note: ...which requires building MIR for `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>::foo`...
+  --> $DIR/method-compatability-via-leakage-cycle.rs:21:5
+   |
+LL |     fn foo(b: bool) -> impl Sized {
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+note: ...which requires match-checking `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>::foo`...
+  --> $DIR/method-compatability-via-leakage-cycle.rs:21:5
+   |
+LL |     fn foo(b: bool) -> impl Sized {
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+note: ...which requires type-checking `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>::foo`...
+  --> $DIR/method-compatability-via-leakage-cycle.rs:21:5
+   |
+LL |     fn foo(b: bool) -> impl Sized {
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   = note: ...which again requires computing type of `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>::{anon_assoc#0}`, completing the cycle
+note: cycle used when checking that `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>` is well-formed
+  --> $DIR/method-compatability-via-leakage-cycle.rs:17:1
+   |
+LL | impl Trait for u32 {
+   | ^^^^^^^^^^^^^^^^^^
+   = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
+
+error[E0391]: cycle detected when computing type of `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>::{anon_assoc#0}`
+  --> $DIR/method-compatability-via-leakage-cycle.rs:21:24
+   |
+LL |     fn foo(b: bool) -> impl Sized {
+   |                        ^^^^^^^^^^
+   |
+note: ...which requires comparing an impl and trait method signature, inferring any hidden `impl Trait` types in the process...
+  --> $DIR/method-compatability-via-leakage-cycle.rs:21:5
+   |
+LL |     fn foo(b: bool) -> impl Sized {
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+note: ...which requires computing type of `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>::foo::{opaque#0}`...
+  --> $DIR/method-compatability-via-leakage-cycle.rs:21:24
+   |
+LL |     fn foo(b: bool) -> impl Sized {
+   |                        ^^^^^^^^^^
+note: ...which requires computing type of opaque `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>::foo::{opaque#0}`...
+  --> $DIR/method-compatability-via-leakage-cycle.rs:21:24
+   |
+LL |     fn foo(b: bool) -> impl Sized {
+   |                        ^^^^^^^^^^
+note: ...which requires borrow-checking `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>::foo`...
+  --> $DIR/method-compatability-via-leakage-cycle.rs:21:5
+   |
+LL |     fn foo(b: bool) -> impl Sized {
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+note: ...which requires promoting constants in MIR for `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>::foo`...
+  --> $DIR/method-compatability-via-leakage-cycle.rs:21:5
+   |
+LL |     fn foo(b: bool) -> impl Sized {
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+note: ...which requires checking if `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>::foo` contains FFI-unwind calls...
+  --> $DIR/method-compatability-via-leakage-cycle.rs:21:5
+   |
+LL |     fn foo(b: bool) -> impl Sized {
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+note: ...which requires building MIR for `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>::foo`...
+  --> $DIR/method-compatability-via-leakage-cycle.rs:21:5
+   |
+LL |     fn foo(b: bool) -> impl Sized {
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+note: ...which requires match-checking `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>::foo`...
+  --> $DIR/method-compatability-via-leakage-cycle.rs:21:5
+   |
+LL |     fn foo(b: bool) -> impl Sized {
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+note: ...which requires type-checking `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>::foo`...
+  --> $DIR/method-compatability-via-leakage-cycle.rs:21:5
+   |
+LL |     fn foo(b: bool) -> impl Sized {
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   = note: ...which again requires computing type of `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>::{anon_assoc#0}`, completing the cycle
+note: cycle used when checking that `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>` is well-formed
+  --> $DIR/method-compatability-via-leakage-cycle.rs:17:1
+   |
+LL | impl Trait for u32 {
+   | ^^^^^^^^^^^^^^^^^^
+   = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
+   = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0391`.
diff --git a/tests/ui/impl-trait/in-trait/method-compatability-via-leakage-cycle.rs b/tests/ui/impl-trait/in-trait/method-compatability-via-leakage-cycle.rs
new file mode 100644
index 00000000000..917820dc2b8
--- /dev/null
+++ b/tests/ui/impl-trait/in-trait/method-compatability-via-leakage-cycle.rs
@@ -0,0 +1,30 @@
+//@ revisions: current next
+//@[next] compile-flags: -Znext-solver
+//@ ignore-compare-mode-next-solver (explicit revisions)
+//@ known-bug: #139788
+
+// Recursively using the trait method inside of an impl in case checking
+// method compatability relies on opaque type leakage currently causes a
+// cycle error.
+
+trait Trait {
+    // desugars to
+    // type Assoc: Sized + Send;
+    // fn foo(b: bool) -> Self::Assoc;
+    fn foo(b: bool) -> impl Sized + Send;
+}
+
+impl Trait for u32 {
+    // desugars to
+    // type Assoc = impl_rpit::<Self>;
+    // fn foo(b: bool) -> Self::Assoc { .. }
+    fn foo(b: bool) -> impl Sized {
+        if b {
+            u32::foo(false)
+        } else {
+            1u32
+        }
+    }
+}
+
+fn main() {}
diff --git a/tests/ui/impl-trait/in-trait/method-compatability-via-leakage.rs b/tests/ui/impl-trait/in-trait/method-compatability-via-leakage.rs
new file mode 100644
index 00000000000..249ec0728c1
--- /dev/null
+++ b/tests/ui/impl-trait/in-trait/method-compatability-via-leakage.rs
@@ -0,0 +1,14 @@
+//@ check-pass
+//@ revisions: current next
+//@[next] compile-flags: -Znext-solver
+//@ ignore-compare-mode-next-solver (explicit revisions)
+
+trait Trait {
+    fn foo() -> impl Sized + Send;
+}
+
+impl Trait for u32 {
+    fn foo() -> impl Sized {}
+}
+
+fn main() {}
diff --git a/tests/ui/impl-trait/in-trait/refine-cycle.rs b/tests/ui/impl-trait/in-trait/refine-cycle.rs
index 78d672a7ed6..d97f9821347 100644
--- a/tests/ui/impl-trait/in-trait/refine-cycle.rs
+++ b/tests/ui/impl-trait/in-trait/refine-cycle.rs
@@ -1,4 +1,7 @@
 //@ check-pass
+//@ revisions: current next
+//@[next] compile-flags: -Znext-solver
+//@ ignore-compare-mode-next-solver (explicit revisions)
 
 // Make sure that refinement checking doesn't cause a cycle in `Instance::resolve`
 // which calls `compare_impl_item`.
diff --git a/tests/ui/proc-macro/auxiliary/expand-expr.rs b/tests/ui/proc-macro/auxiliary/expand-expr.rs
index 78c9fa75d9f..14efc3c6b9f 100644
--- a/tests/ui/proc-macro/auxiliary/expand-expr.rs
+++ b/tests/ui/proc-macro/auxiliary/expand-expr.rs
@@ -3,9 +3,10 @@
 
 extern crate proc_macro;
 
-use proc_macro::*;
 use std::str::FromStr;
 
+use proc_macro::*;
+
 // Flatten the TokenStream, removing any toplevel `Delimiter::None`s for
 // comparison.
 fn flatten(ts: TokenStream) -> Vec<TokenTree> {
@@ -136,9 +137,8 @@ pub fn check_expand_expr_file(ts: TokenStream) -> TokenStream {
         .to_string();
     assert_eq!(input_t, parse_t);
 
-    // Check that the literal matches `Span::call_site().source_file().path()`
-    let expect_t =
-        Literal::string(&Span::call_site().source_file().path().to_string_lossy()).to_string();
+    // Check that the literal matches `Span::call_site().file()`
+    let expect_t = Literal::string(&Span::call_site().file()).to_string();
     assert_eq!(input_t, expect_t);
 
     TokenStream::new()
diff --git a/tests/ui/proc-macro/auxiliary/macro-only-syntax.rs b/tests/ui/proc-macro/auxiliary/macro-only-syntax.rs
index 4971de284b7..11e1910288e 100644
--- a/tests/ui/proc-macro/auxiliary/macro-only-syntax.rs
+++ b/tests/ui/proc-macro/auxiliary/macro-only-syntax.rs
@@ -79,7 +79,7 @@ fn check_useful_span(token: TokenTree, expected_filename: &str) {
     let span = token.span();
     assert!(span.column() < span.end().column());
 
-    let source_path = span.source_file().path();
+    let source_path = span.local_file().unwrap();
     let filename = source_path.components().last().unwrap();
     assert_eq!(filename, Component::Normal(expected_filename.as_ref()));
 }
diff --git a/tests/ui/proc-macro/auxiliary/span-api-tests.rs b/tests/ui/proc-macro/auxiliary/span-api-tests.rs
index 99db66ed6a9..036f2e3ac3f 100644
--- a/tests/ui/proc-macro/auxiliary/span-api-tests.rs
+++ b/tests/ui/proc-macro/auxiliary/span-api-tests.rs
@@ -11,20 +11,9 @@ pub fn reemit(input: TokenStream) -> TokenStream {
 }
 
 #[proc_macro]
-pub fn assert_fake_source_file(input: TokenStream) -> TokenStream {
+pub fn assert_local_file(input: TokenStream) -> TokenStream {
     for tk in input {
-        let source_file = tk.span().source_file();
-        assert!(!source_file.is_real(), "Source file is real: {:?}", source_file);
-    }
-
-    "".parse().unwrap()
-}
-
-#[proc_macro]
-pub fn assert_source_file(input: TokenStream) -> TokenStream {
-    for tk in input {
-        let source_file = tk.span().source_file();
-        assert!(source_file.is_real(), "Source file is not real: {:?}", source_file);
+        assert!(tk.span().local_file().is_some(), "No local file for span: {:?}", tk.span());
     }
 
     "".parse().unwrap()
diff --git a/tests/ui/proc-macro/span-api-tests.rs b/tests/ui/proc-macro/span-api-tests.rs
index ac42a7ea611..792859ed05b 100644
--- a/tests/ui/proc-macro/span-api-tests.rs
+++ b/tests/ui/proc-macro/span-api-tests.rs
@@ -8,26 +8,24 @@ extern crate span_test_macros;
 
 extern crate span_api_tests;
 
-// FIXME(69775): Investigate `assert_fake_source_file`.
-
-use span_api_tests::{reemit, assert_source_file, macro_stringify};
+use span_api_tests::{reemit, assert_local_file, macro_stringify};
 
 macro_rules! say_hello {
     ($macname:ident) => ( $macname! { "Hello, world!" })
 }
 
-assert_source_file! { "Hello, world!" }
+assert_local_file! { "Hello, world!" }
 
-say_hello! { assert_source_file }
+say_hello! { assert_local_file }
 
 reemit_legacy! {
-    assert_source_file! { "Hello, world!" }
+    assert_local_file! { "Hello, world!" }
 }
 
-say_hello_extern! { assert_source_file }
+say_hello_extern! { assert_local_file }
 
 reemit! {
-    assert_source_file! { "Hello, world!" }
+    assert_local_file! { "Hello, world!" }
 }
 
 fn main() {
diff --git a/tests/ui/traits/next-solver/cycles/inductive-cycle-but-err.rs b/tests/ui/traits/next-solver/cycles/inductive-cycle-but-err.rs
index b0c778e7f57..754fc872e45 100644
--- a/tests/ui/traits/next-solver/cycles/inductive-cycle-but-err.rs
+++ b/tests/ui/traits/next-solver/cycles/inductive-cycle-but-err.rs
@@ -34,9 +34,17 @@ where
     MultipleNested: Trait,
 {}
 
+// We ignore the trivially true global where-bounds when checking that this
+// impl is well-formed, meaning that we depend on `MultipleNested: Trait` when
+// recursively proving `MultipleCandidates: Trait`.
+//
+// These overflow errors will disappear once we treat these cycles as either
+// productive or an error.
 impl Trait for MultipleNested
+//~^ ERROR overflow evaluating the requirement `MultipleNested: Trait`
 where
     MultipleCandidates: Trait,
+    //~^ ERROR overflow evaluating the requirement `MultipleCandidates: Trait`
     DoesNotImpl: Trait,
 {}
 
diff --git a/tests/ui/traits/next-solver/cycles/inductive-cycle-but-err.stderr b/tests/ui/traits/next-solver/cycles/inductive-cycle-but-err.stderr
index acacaf6a331..7895a263634 100644
--- a/tests/ui/traits/next-solver/cycles/inductive-cycle-but-err.stderr
+++ b/tests/ui/traits/next-solver/cycles/inductive-cycle-but-err.stderr
@@ -1,16 +1,29 @@
+error[E0275]: overflow evaluating the requirement `MultipleNested: Trait`
+  --> $DIR/inductive-cycle-but-err.rs:43:16
+   |
+LL | impl Trait for MultipleNested
+   |                ^^^^^^^^^^^^^^
+
+error[E0275]: overflow evaluating the requirement `MultipleCandidates: Trait`
+  --> $DIR/inductive-cycle-but-err.rs:46:25
+   |
+LL |     MultipleCandidates: Trait,
+   |                         ^^^^^
+
 error[E0277]: the trait bound `MultipleCandidates: Trait` is not satisfied
-  --> $DIR/inductive-cycle-but-err.rs:46:19
+  --> $DIR/inductive-cycle-but-err.rs:54:19
    |
 LL |     impls_trait::<MultipleCandidates>();
    |                   ^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `MultipleCandidates`
    |
    = help: the trait `Trait` is implemented for `MultipleCandidates`
 note: required by a bound in `impls_trait`
-  --> $DIR/inductive-cycle-but-err.rs:43:19
+  --> $DIR/inductive-cycle-but-err.rs:51:19
    |
 LL | fn impls_trait<T: Trait>() {}
    |                   ^^^^^ required by this bound in `impls_trait`
 
-error: aborting due to 1 previous error
+error: aborting due to 3 previous errors
 
-For more information about this error, try `rustc --explain E0277`.
+Some errors have detailed explanations: E0275, E0277.
+For more information about an error, try `rustc --explain E0275`.
diff --git a/tests/ui/traits/next-solver/normalize/normalize-param-env-2.stderr b/tests/ui/traits/next-solver/normalize/normalize-param-env-2.stderr
index 74a0a90885d..d179c805962 100644
--- a/tests/ui/traits/next-solver/normalize/normalize-param-env-2.stderr
+++ b/tests/ui/traits/next-solver/normalize/normalize-param-env-2.stderr
@@ -4,14 +4,14 @@ error[E0275]: overflow evaluating the requirement `<() as A<T>>::Assoc: A<T>`
 LL |         Self::Assoc: A<T>,
    |                      ^^^^
    |
-note: the requirement `<() as A<T>>::Assoc: A<T>` appears on the `impl`'s method `f` but not on the corresponding trait's method
+note: the requirement `<() as A<T>>::Assoc: A<T>` appears on the `impl`'s associated function `f` but not on the corresponding trait's associated function
   --> $DIR/normalize-param-env-2.rs:12:8
    |
 LL | trait A<T> {
    |       - in this trait
 ...
 LL |     fn f()
-   |        ^ this trait's method doesn't have the requirement `<() as A<T>>::Assoc: A<T>`
+   |        ^ this trait's associated function doesn't have the requirement `<() as A<T>>::Assoc: A<T>`
 
 error[E0275]: overflow evaluating the requirement `<() as A<T>>::Assoc: A<T>`
   --> $DIR/normalize-param-env-2.rs:24:22
diff --git a/tests/ui/traits/winnowing/global-where-bound-region-constraints-2.rs b/tests/ui/traits/winnowing/global-where-bound-region-constraints-2.rs
new file mode 100644
index 00000000000..d422605a292
--- /dev/null
+++ b/tests/ui/traits/winnowing/global-where-bound-region-constraints-2.rs
@@ -0,0 +1,33 @@
+//@ revisions: current next
+//@ ignore-compare-mode-next-solver (explicit revisions)
+//@[next] compile-flags: -Znext-solver
+//@ check-pass
+
+// Regression test for trait-system-refactor-initiative#172.
+//
+// In this test the global where-bound simply constrains the
+// object lifetime bound to 'static while the builtin impl
+// ends up also emitting a `dyn Any: 'static` type outlives
+// constraint. This previously resulted in ambiguity. We now
+// always prefer the impl.
+
+pub trait Any: 'static {}
+
+pub trait Downcast<T>: Any
+where
+    T: Any,
+{
+}
+
+// elided object lifetime: `dyn Any + 'static`
+impl dyn Any {
+    pub fn is<T>(&self)
+    where
+        T: Any,
+        // elaboration adds global where-clause `dyn Any + 'static: Any`
+        Self: Downcast<T>,
+    {
+    }
+}
+
+fn main() {}
diff --git a/tests/ui/traits/winnowing/global-where-bound-region-constraints.rs b/tests/ui/traits/winnowing/global-where-bound-region-constraints.rs
new file mode 100644
index 00000000000..3bc8b0438bf
--- /dev/null
+++ b/tests/ui/traits/winnowing/global-where-bound-region-constraints.rs
@@ -0,0 +1,29 @@
+//@ revisions: current next
+//@ ignore-compare-mode-next-solver (explicit revisions)
+//@[next] compile-flags: -Znext-solver
+//@ check-pass
+
+// Regression test for trait-system-refactor-initiative#172.
+//
+// The next-generation trait solver previously simply tried
+// to merge the global where-bounds with the impl candidates.
+// This caused ambiguity in case the where-bound had stricter
+// region requirements than the impl.
+
+trait Trait {}
+struct Foo<'a, 'b>(&'a (), &'b ());
+impl<'a> Trait for Foo<'a, 'static> {}
+
+fn impls_trait<T: Trait>() {}
+fn foo()
+where
+    Foo<'static, 'static>: Trait,
+{
+    // impl requires `'1 to be 'static
+    // global where-bound requires both '0 and '1 to be 'static
+    //
+    // we always prefer the impl here.
+    impls_trait::<Foo<'_, '_>>();
+}
+
+fn main() {}
diff --git a/tests/ui/traits/winnowing/norm-where-bound-gt-alias-bound.rs b/tests/ui/traits/winnowing/norm-where-bound-gt-alias-bound.rs
new file mode 100644
index 00000000000..cdfb0ee45af
--- /dev/null
+++ b/tests/ui/traits/winnowing/norm-where-bound-gt-alias-bound.rs
@@ -0,0 +1,29 @@
+//@ revisions: current next
+//@ ignore-compare-mode-next-solver (explicit revisions)
+//@[next] compile-flags: -Znext-solver
+//@ check-pass
+
+// Make sure we prefer the `I::IntoIterator: Iterator<Item = ()>`
+// where-bound over the `I::Intoiterator: Iterator<Item = I::Item>`
+// alias-bound.
+
+trait Iterator {
+    type Item;
+}
+
+trait IntoIterator {
+    type Item;
+    type IntoIter: Iterator<Item = Self::Item>;
+}
+
+fn normalize<I: Iterator<Item = ()>>() {}
+
+fn foo<I>()
+where
+    I: IntoIterator,
+    I::IntoIter: Iterator<Item = ()>,
+{
+    normalize::<I::IntoIter>();
+}
+
+fn main() {}
diff --git a/tests/ui/type/pattern_types/derives.rs b/tests/ui/type/pattern_types/derives.rs
index 3878c47554d..a3959b38317 100644
--- a/tests/ui/type/pattern_types/derives.rs
+++ b/tests/ui/type/pattern_types/derives.rs
@@ -1,4 +1,5 @@
-//! Check that pattern types don't implement traits of their base automatically
+//! Check that pattern types don't implement traits of their base automatically.
+//! Exceptions are `Clone` and `Copy`, which have builtin impls for pattern types.
 
 #![feature(pattern_types)]
 #![feature(pattern_type_macro)]
diff --git a/tests/ui/type/pattern_types/derives.stderr b/tests/ui/type/pattern_types/derives.stderr
index f59617ebc45..2d83684b152 100644
--- a/tests/ui/type/pattern_types/derives.stderr
+++ b/tests/ui/type/pattern_types/derives.stderr
@@ -1,5 +1,5 @@
 error[E0369]: binary operation `==` cannot be applied to type `(i32) is 0..=999999999`
-  --> $DIR/derives.rs:10:20
+  --> $DIR/derives.rs:11:20
    |
 LL | #[derive(Clone, Copy, PartialEq)]
    |                       --------- in this derive macro expansion
diff --git a/tests/ui/type/pattern_types/derives_fail.rs b/tests/ui/type/pattern_types/derives_fail.rs
new file mode 100644
index 00000000000..a3fbad66720
--- /dev/null
+++ b/tests/ui/type/pattern_types/derives_fail.rs
@@ -0,0 +1,26 @@
+//! Check that pattern types don't implement traits of their base automatically.
+//! Exceptions are `Clone` and `Copy`, which have bultin impls for pattern types.
+
+#![feature(pattern_types)]
+#![feature(pattern_type_macro)]
+
+use std::pat::pattern_type;
+
+#[derive(Clone, Copy, PartialEq, Eq, Debug, Ord, PartialOrd, Hash, Default)]
+#[repr(transparent)]
+struct Nanoseconds(NanoI32);
+//~^ ERROR: the trait bound `(i32) is 0..=999999999: Eq` is not satisfied
+//~| ERROR: `(i32) is 0..=999999999` doesn't implement `Debug`
+//~| ERROR: the trait bound `(i32) is 0..=999999999: Ord` is not satisfied
+//~| ERROR: the trait bound `(i32) is 0..=999999999: Hash` is not satisfied
+//~| ERROR: the trait bound `(i32) is 0..=999999999: Default` is not satisfied
+//~| ERROR: can't compare `(i32) is 0..=999999999` with `_`
+//~| ERROR: `==` cannot be applied
+
+type NanoI32 = crate::pattern_type!(i32 is 0..=999_999_999);
+
+fn main() {
+    let x = Nanoseconds(unsafe { std::mem::transmute(42) });
+    let y = x.clone();
+    if y == x {}
+}
diff --git a/tests/ui/type/pattern_types/derives_fail.stderr b/tests/ui/type/pattern_types/derives_fail.stderr
new file mode 100644
index 00000000000..78bef726341
--- /dev/null
+++ b/tests/ui/type/pattern_types/derives_fail.stderr
@@ -0,0 +1,74 @@
+error[E0369]: binary operation `==` cannot be applied to type `(i32) is 0..=999999999`
+  --> $DIR/derives_fail.rs:11:20
+   |
+LL | #[derive(Clone, Copy, PartialEq, Eq, Debug, Ord, PartialOrd, Hash, Default)]
+   |                       --------- in this derive macro expansion
+LL | #[repr(transparent)]
+LL | struct Nanoseconds(NanoI32);
+   |                    ^^^^^^^
+
+error[E0277]: the trait bound `(i32) is 0..=999999999: Eq` is not satisfied
+  --> $DIR/derives_fail.rs:11:20
+   |
+LL | #[derive(Clone, Copy, PartialEq, Eq, Debug, Ord, PartialOrd, Hash, Default)]
+   |                                  -- in this derive macro expansion
+LL | #[repr(transparent)]
+LL | struct Nanoseconds(NanoI32);
+   |                    ^^^^^^^ the trait `Eq` is not implemented for `(i32) is 0..=999999999`
+   |
+note: required by a bound in `AssertParamIsEq`
+  --> $SRC_DIR/core/src/cmp.rs:LL:COL
+
+error[E0277]: `(i32) is 0..=999999999` doesn't implement `Debug`
+  --> $DIR/derives_fail.rs:11:20
+   |
+LL | #[derive(Clone, Copy, PartialEq, Eq, Debug, Ord, PartialOrd, Hash, Default)]
+   |                                      ----- in this derive macro expansion
+LL | #[repr(transparent)]
+LL | struct Nanoseconds(NanoI32);
+   |                    ^^^^^^^ `(i32) is 0..=999999999` cannot be formatted using `{:?}` because it doesn't implement `Debug`
+   |
+   = help: the trait `Debug` is not implemented for `(i32) is 0..=999999999`
+
+error[E0277]: the trait bound `(i32) is 0..=999999999: Ord` is not satisfied
+  --> $DIR/derives_fail.rs:11:20
+   |
+LL | #[derive(Clone, Copy, PartialEq, Eq, Debug, Ord, PartialOrd, Hash, Default)]
+   |                                             --- in this derive macro expansion
+LL | #[repr(transparent)]
+LL | struct Nanoseconds(NanoI32);
+   |                    ^^^^^^^ the trait `Ord` is not implemented for `(i32) is 0..=999999999`
+
+error[E0277]: can't compare `(i32) is 0..=999999999` with `_`
+  --> $DIR/derives_fail.rs:11:20
+   |
+LL | #[derive(Clone, Copy, PartialEq, Eq, Debug, Ord, PartialOrd, Hash, Default)]
+   |                                                  ---------- in this derive macro expansion
+LL | #[repr(transparent)]
+LL | struct Nanoseconds(NanoI32);
+   |                    ^^^^^^^ no implementation for `(i32) is 0..=999999999 < _` and `(i32) is 0..=999999999 > _`
+   |
+   = help: the trait `PartialOrd<_>` is not implemented for `(i32) is 0..=999999999`
+
+error[E0277]: the trait bound `(i32) is 0..=999999999: Hash` is not satisfied
+  --> $DIR/derives_fail.rs:11:20
+   |
+LL | #[derive(Clone, Copy, PartialEq, Eq, Debug, Ord, PartialOrd, Hash, Default)]
+   |                                                              ---- in this derive macro expansion
+LL | #[repr(transparent)]
+LL | struct Nanoseconds(NanoI32);
+   |                    ^^^^^^^ the trait `Hash` is not implemented for `(i32) is 0..=999999999`
+
+error[E0277]: the trait bound `(i32) is 0..=999999999: Default` is not satisfied
+  --> $DIR/derives_fail.rs:11:20
+   |
+LL | #[derive(Clone, Copy, PartialEq, Eq, Debug, Ord, PartialOrd, Hash, Default)]
+   |                                                                    ------- in this derive macro expansion
+LL | #[repr(transparent)]
+LL | struct Nanoseconds(NanoI32);
+   |                    ^^^^^^^ the trait `Default` is not implemented for `(i32) is 0..=999999999`
+
+error: aborting due to 7 previous errors
+
+Some errors have detailed explanations: E0277, E0369.
+For more information about an error, try `rustc --explain E0277`.
diff --git a/tests/ui/type/pattern_types/matching.rs b/tests/ui/type/pattern_types/matching.rs
new file mode 100644
index 00000000000..b8463a8e822
--- /dev/null
+++ b/tests/ui/type/pattern_types/matching.rs
@@ -0,0 +1,26 @@
+#![feature(pattern_types, pattern_type_macro, structural_match)]
+
+//@ check-pass
+
+use std::marker::StructuralPartialEq;
+use std::pat::pattern_type;
+
+struct Thing(pattern_type!(u32 is 1..));
+
+impl StructuralPartialEq for Thing {}
+impl PartialEq for Thing {
+    fn eq(&self, other: &Thing) -> bool {
+        unsafe { std::mem::transmute::<_, u32>(self.0) == std::mem::transmute::<_, u32>(other.0) }
+    }
+}
+
+impl Eq for Thing {}
+
+const TWO: Thing = Thing(2);
+
+const _: () = match TWO {
+    TWO => {}
+    _ => unreachable!(),
+};
+
+fn main() {}
diff --git a/tests/ui/type/pattern_types/matching_fail.rs b/tests/ui/type/pattern_types/matching_fail.rs
new file mode 100644
index 00000000000..8e2c741e3e0
--- /dev/null
+++ b/tests/ui/type/pattern_types/matching_fail.rs
@@ -0,0 +1,25 @@
+#![feature(pattern_types, pattern_type_macro, structural_match)]
+
+use std::pat::pattern_type;
+
+const THREE: pattern_type!(u32 is 1..) = 3;
+
+const _: () = match THREE {
+    THREE => {}
+    //~^ ERROR non-structural type
+    _ => unreachable!(),
+};
+
+const _: () = match THREE {
+    3 => {}
+    //~^ ERROR mismatched types
+    _ => unreachable!(),
+};
+
+const _: () = match 3 {
+    THREE => {}
+    //~^ ERROR mismatched types
+    _ => unreachable!(),
+};
+
+fn main() {}
diff --git a/tests/ui/type/pattern_types/matching_fail.stderr b/tests/ui/type/pattern_types/matching_fail.stderr
new file mode 100644
index 00000000000..446180d80f2
--- /dev/null
+++ b/tests/ui/type/pattern_types/matching_fail.stderr
@@ -0,0 +1,43 @@
+error: constant of non-structural type `(u32) is 1..` in a pattern
+  --> $DIR/matching_fail.rs:8:5
+   |
+LL | const THREE: pattern_type!(u32 is 1..) = 3;
+   | -------------------------------------- constant defined here
+...
+LL |     THREE => {}
+   |     ^^^^^ constant of non-structural type
+   |
+   = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
+
+error[E0308]: mismatched types
+  --> $DIR/matching_fail.rs:14:5
+   |
+LL | const _: () = match THREE {
+   |                     ----- this expression has type `(u32) is 1..`
+LL |     3 => {}
+   |     ^ expected `(u32) is 1..`, found integer
+   |
+   = note: expected pattern type `(u32) is 1..`
+                      found type `{integer}`
+
+error[E0308]: mismatched types
+  --> $DIR/matching_fail.rs:20:5
+   |
+LL | const THREE: pattern_type!(u32 is 1..) = 3;
+   | -------------------------------------- constant defined here
+...
+LL | const _: () = match 3 {
+   |                     - this expression has type `{integer}`
+LL |     THREE => {}
+   |     ^^^^^
+   |     |
+   |     expected integer, found `(u32) is 1..`
+   |     `THREE` is interpreted as a constant, not a new binding
+   |     help: introduce a new binding instead: `other_three`
+   |
+   = note:      expected type `{integer}`
+           found pattern type `(u32) is 1..`
+
+error: aborting due to 3 previous errors
+
+For more information about this error, try `rustc --explain E0308`.