about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-02-11 05:13:02 +0000
committerbors <bors@rust-lang.org>2024-02-11 05:13:02 +0000
commita40a100e4bc5db830169f59cc301a1105dd366d8 (patch)
tree3dfb18335ff56656383b97106112e199617842e6 /tests
parent5a3a2d5a5ea80b04df3fd3406f2bd924763d78a6 (diff)
parent48bb2bf4e6bfc5c9ffc9cb3f34a9163c05ce2cb2 (diff)
downloadrust-a40a100e4bc5db830169f59cc301a1105dd366d8.tar.gz
rust-a40a100e4bc5db830169f59cc301a1105dd366d8.zip
Auto merge of #3294 - rust-lang:rustup-2024-02-11, r=saethlin
Automatic Rustup
Diffstat (limited to 'tests')
-rw-r--r--tests/coverage/closure.cov-map36
-rw-r--r--tests/coverage/issue-84561.cov-map38
-rw-r--r--tests/coverage/try_error_result.cov-map237
-rw-r--r--tests/coverage/yield.cov-map6
-rw-r--r--tests/mir-opt/const_goto.issue_77355_opt.ConstGoto.diff50
-rw-r--r--tests/mir-opt/const_goto.rs19
-rw-r--r--tests/mir-opt/const_goto_const_eval_fail.f.ConstGoto.diff51
-rw-r--r--tests/mir-opt/const_goto_const_eval_fail.f.JumpThreading.diff47
-rw-r--r--tests/mir-opt/const_goto_const_eval_fail.rs2
-rw-r--r--tests/mir-opt/const_goto_storage.match_nested_if.ConstGoto.diff102
-rw-r--r--tests/mir-opt/const_goto_storage.rs22
-rw-r--r--tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.mir56
-rw-r--r--tests/mir-opt/pre-codegen/loops.int_range.PreCodegen.after.mir69
-rw-r--r--tests/mir-opt/pre-codegen/matches_macro.issue_77355_opt.PreCodegen.after.mir22
-rw-r--r--tests/mir-opt/pre-codegen/matches_macro.rs27
-rw-r--r--tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-abort.mir89
-rw-r--r--tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-unwind.mir95
-rw-r--r--tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-abort.mir107
-rw-r--r--tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-unwind.mir113
-rw-r--r--tests/mir-opt/pre-codegen/try_identity.new.PreCodegen.after.mir46
-rw-r--r--tests/mir-opt/separate_const_switch.identity.JumpThreading.diff (renamed from tests/mir-opt/separate_const_switch.identity.SeparateConstSwitch.diff)19
-rw-r--r--tests/mir-opt/separate_const_switch.rs4
-rw-r--r--tests/mir-opt/separate_const_switch.too_complex.JumpThreading.diff (renamed from tests/mir-opt/separate_const_switch.too_complex.SeparateConstSwitch.diff)15
-rw-r--r--tests/ui/array-slice-vec/check-static-mut-slices.rs15
-rw-r--r--tests/ui/asm/aarch64/type-check-4.rs6
-rw-r--r--tests/ui/asm/aarch64/type-check-4.stderr26
-rw-r--r--tests/ui/asm/x86_64/type-check-4.rs6
-rw-r--r--tests/ui/asm/x86_64/type-check-4.stderr26
-rw-r--r--tests/ui/associated-type-bounds/assoc-type-eq-with-dyn-atb-fail.rs2
-rw-r--r--tests/ui/associated-type-bounds/assoc-type-eq-with-dyn-atb-fail.stderr14
-rw-r--r--tests/ui/associated-type-bounds/bad-universal-in-dyn-in-where-clause.rs2
-rw-r--r--tests/ui/associated-type-bounds/bad-universal-in-dyn-in-where-clause.stderr2
-rw-r--r--tests/ui/associated-type-bounds/bad-universal-in-impl-sig.rs2
-rw-r--r--tests/ui/associated-type-bounds/bad-universal-in-impl-sig.stderr2
-rw-r--r--tests/ui/associated-type-bounds/duplicate.rs7
-rw-r--r--tests/ui/associated-type-bounds/duplicate.stderr26
-rw-r--r--tests/ui/associated-type-bounds/dyn-impl-trait-type.rs66
-rw-r--r--tests/ui/associated-type-bounds/dyn-impl-trait-type.stderr12
-rw-r--r--tests/ui/associated-type-bounds/dyn-rpit-and-let.rs73
-rw-r--r--tests/ui/associated-type-bounds/dyn-rpit-and-let.stderr12
-rw-r--r--tests/ui/associated-type-bounds/elision.rs4
-rw-r--r--tests/ui/associated-type-bounds/elision.stderr18
-rw-r--r--tests/ui/associated-type-bounds/fn-dyn-apit.rs61
-rw-r--r--tests/ui/associated-type-bounds/inside-adt.rs18
-rw-r--r--tests/ui/associated-type-bounds/inside-adt.stderr18
-rw-r--r--tests/ui/associated-type-bounds/issue-104916.rs2
-rw-r--r--tests/ui/associated-type-bounds/issue-104916.stderr2
-rw-r--r--tests/ui/async-await/async-closures/is-not-fn.rs5
-rw-r--r--tests/ui/async-await/async-closures/is-not-fn.stderr10
-rw-r--r--tests/ui/async-await/async-closures/once.rs22
-rw-r--r--tests/ui/async-await/async-closures/refd.rs18
-rw-r--r--tests/ui/async-await/async-fn/dyn-pos.stderr24
-rw-r--r--tests/ui/async-await/async-fn/simple.rs2
-rw-r--r--tests/ui/const_prop/const-prop-read-static-in-const.rs10
-rw-r--r--tests/ui/const_prop/const-prop-read-static-in-const.stderr17
-rw-r--r--tests/ui/consts/const-address-of-mut.rs2
-rw-r--r--tests/ui/consts/const-address-of-mut.stderr14
-rw-r--r--tests/ui/consts/const-fn-not-safe-for-const.rs4
-rw-r--r--tests/ui/consts/const-fn-not-safe-for-const.stderr20
-rw-r--r--tests/ui/consts/const_refs_to_static.rs19
-rw-r--r--tests/ui/consts/const_refs_to_static_fail.rs21
-rw-r--r--tests/ui/consts/const_refs_to_static_fail.stderr26
-rw-r--r--tests/ui/consts/const_refs_to_static_fail_invalid.rs51
-rw-r--r--tests/ui/consts/const_refs_to_static_fail_invalid.stderr69
-rw-r--r--tests/ui/consts/issue-17718-const-bad-values.rs6
-rw-r--r--tests/ui/consts/issue-17718-const-bad-values.stderr20
-rw-r--r--tests/ui/consts/issue-17718-references.rs6
-rw-r--r--tests/ui/consts/issue-17718-references.stderr26
-rw-r--r--tests/ui/consts/issue-52060.rs2
-rw-r--r--tests/ui/consts/issue-52060.stderr10
-rw-r--r--tests/ui/consts/min_const_fn/min_const_fn.rs4
-rw-r--r--tests/ui/consts/min_const_fn/min_const_fn.stderr20
-rw-r--r--tests/ui/consts/miri_unleashed/const_refers_to_static.32bit.stderr53
-rw-r--r--tests/ui/consts/miri_unleashed/const_refers_to_static.64bit.stderr53
-rw-r--r--tests/ui/consts/miri_unleashed/const_refers_to_static.rs16
-rw-r--r--tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.32bit.stderr77
-rw-r--r--tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.64bit.stderr77
-rw-r--r--tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.rs17
-rw-r--r--tests/ui/consts/miri_unleashed/mutable_references_err.32bit.stderr32
-rw-r--r--tests/ui/consts/miri_unleashed/mutable_references_err.64bit.stderr32
-rw-r--r--tests/ui/consts/miri_unleashed/mutable_references_err.rs10
-rw-r--r--tests/ui/consts/static-mut-refs.rs24
-rw-r--r--tests/ui/consts/static_mut_containing_mut_ref2.rs2
-rw-r--r--tests/ui/consts/static_mut_containing_mut_ref2.stock.stderr6
-rw-r--r--tests/ui/did_you_mean/bad-assoc-ty.stderr9
-rw-r--r--tests/ui/error-codes/E0013.rs4
-rw-r--r--tests/ui/error-codes/E0013.stderr11
-rw-r--r--tests/ui/feature-gates/feature-gate-associated_type_bounds.rs11
-rw-r--r--tests/ui/feature-gates/feature-gate-associated_type_bounds.stderr36
-rw-r--r--tests/ui/feature-gates/feature-gate-const-refs-to-static.rs12
-rw-r--r--tests/ui/feature-gates/feature-gate-const-refs-to-static.stderr40
-rw-r--r--tests/ui/generic-associated-types/gat-in-trait-path.base.stderr2
-rw-r--r--tests/ui/generic-associated-types/issue-79422.base.stderr4
-rw-r--r--tests/ui/specialization/min_specialization/allow_internal_unstable.rs (renamed from tests/ui/specialization/allow_internal_unstable.rs)9
-rw-r--r--tests/ui/static/issue-18118-2.rs2
-rw-r--r--tests/ui/static/issue-18118-2.stderr10
-rw-r--r--tests/ui/thread-local/thread-local-static.rs2
-rw-r--r--tests/ui/thread-local/thread-local-static.stderr12
-rw-r--r--tests/ui/trait-bounds/suggest-maybe-sized-bound.rs20
-rw-r--r--tests/ui/trait-bounds/suggest-maybe-sized-bound.stderr37
-rw-r--r--tests/ui/traits/issue-28576.stderr8
-rw-r--r--tests/ui/typeck/issue-120856.rs5
-rw-r--r--tests/ui/typeck/issue-120856.stderr21
-rw-r--r--tests/ui/wf/wf-unsafe-trait-obj-match.stderr4
104 files changed, 1251 insertions, 1529 deletions
diff --git a/tests/coverage/closure.cov-map b/tests/coverage/closure.cov-map
index 921ca6cf4e1..9f0d33745bc 100644
--- a/tests/coverage/closure.cov-map
+++ b/tests/coverage/closure.cov-map
@@ -33,20 +33,16 @@ Number of file 0 mappings: 24
 - Code(Expression(1, Add)) at (prev + 1, 5) to (start + 3, 2)
     = (c1 + (c0 - c1))
 
-Function name: closure::main::{closure#0}
-Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 28, 05, 02, 14, 05, 02, 15, 02, 0a, 02, 02, 0a, 00, 0b, 07, 01, 09, 01, 06]
+Function name: closure::main::{closure#0} (unused)
+Raw bytes (24): 0x[01, 01, 00, 04, 00, 28, 05, 02, 14, 00, 02, 15, 02, 0a, 00, 02, 0a, 00, 0b, 00, 01, 09, 01, 06]
 Number of files: 1
 - file 0 => global file 1
-Number of expressions: 2
-- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
-- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub)
+Number of expressions: 0
 Number of file 0 mappings: 4
-- Code(Counter(0)) at (prev + 40, 5) to (start + 2, 20)
-- Code(Counter(1)) at (prev + 2, 21) to (start + 2, 10)
-- Code(Expression(0, Sub)) at (prev + 2, 10) to (start + 0, 11)
-    = (c0 - c1)
-- Code(Expression(1, Add)) at (prev + 1, 9) to (start + 1, 6)
-    = (c1 + (c0 - c1))
+- Code(Zero) at (prev + 40, 5) to (start + 2, 20)
+- Code(Zero) at (prev + 2, 21) to (start + 2, 10)
+- Code(Zero) at (prev + 2, 10) to (start + 0, 11)
+- Code(Zero) at (prev + 1, 9) to (start + 1, 6)
 
 Function name: closure::main::{closure#10} (unused)
 Raw bytes (10): 0x[01, 01, 00, 01, 00, 9b, 01, 07, 00, 21]
@@ -148,20 +144,16 @@ Number of file 0 mappings: 6
 - Code(Expression(0, Add)) at (prev + 2, 9) to (start + 0, 10)
     = (c1 + (c0 - c1))
 
-Function name: closure::main::{closure#18}
-Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 19, 0d, 02, 1c, 05, 02, 1d, 02, 12, 02, 02, 12, 00, 13, 07, 01, 11, 01, 0e]
+Function name: closure::main::{closure#18} (unused)
+Raw bytes (24): 0x[01, 01, 00, 04, 00, 19, 0d, 02, 1c, 00, 02, 1d, 02, 12, 00, 02, 12, 00, 13, 00, 01, 11, 01, 0e]
 Number of files: 1
 - file 0 => global file 1
-Number of expressions: 2
-- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
-- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub)
+Number of expressions: 0
 Number of file 0 mappings: 4
-- Code(Counter(0)) at (prev + 25, 13) to (start + 2, 28)
-- Code(Counter(1)) at (prev + 2, 29) to (start + 2, 18)
-- Code(Expression(0, Sub)) at (prev + 2, 18) to (start + 0, 19)
-    = (c0 - c1)
-- Code(Expression(1, Add)) at (prev + 1, 17) to (start + 1, 14)
-    = (c1 + (c0 - c1))
+- Code(Zero) at (prev + 25, 13) to (start + 2, 28)
+- Code(Zero) at (prev + 2, 29) to (start + 2, 18)
+- Code(Zero) at (prev + 2, 18) to (start + 0, 19)
+- Code(Zero) at (prev + 1, 17) to (start + 1, 14)
 
 Function name: closure::main::{closure#19}
 Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 43, 0d, 02, 1c, 05, 02, 1d, 02, 12, 02, 02, 12, 00, 13, 07, 01, 11, 01, 0e]
diff --git a/tests/coverage/issue-84561.cov-map b/tests/coverage/issue-84561.cov-map
index 88436964af0..a81884ea942 100644
--- a/tests/coverage/issue-84561.cov-map
+++ b/tests/coverage/issue-84561.cov-map
@@ -77,7 +77,7 @@ Number of file 0 mappings: 1
 - Code(Counter(0)) at (prev + 167, 9) to (start + 2, 10)
 
 Function name: issue_84561::test3
-Raw bytes (436): 0x[01, 01, 41, 05, 09, 0d, 00, 15, 19, 12, 00, 15, 19, 21, 00, 1e, 00, 21, 00, 31, 00, 3d, 41, 2e, 45, 3d, 41, 42, 49, 45, 00, 3f, 51, 42, 49, 45, 00, 5d, 8a, 01, 8f, 01, 5d, 92, 01, 55, 51, 00, 92, 01, 55, 51, 00, 8f, 01, 5d, 92, 01, 55, 51, 00, 87, 01, 61, 5d, 8a, 01, 8f, 01, 5d, 92, 01, 55, 51, 00, 82, 01, 65, 87, 01, 61, 5d, 8a, 01, 8f, 01, 5d, 92, 01, 55, 51, 00, 75, f6, 01, fb, 01, 79, 71, fe, 01, 82, 02, 71, 69, 6d, 71, fe, 01, 82, 02, 71, 69, 6d, 69, 6d, 82, 02, 71, 69, 6d, fb, 01, 79, 71, fe, 01, 82, 02, 71, 69, 6d, f3, 01, 7d, 75, f6, 01, fb, 01, 79, 71, fe, 01, 82, 02, 71, 69, 6d, ee, 01, 00, f3, 01, 7d, 75, f6, 01, fb, 01, 79, 71, fe, 01, 82, 02, 71, 69, 6d, 33, 01, 08, 01, 03, 1c, 05, 04, 09, 01, 1c, 02, 02, 05, 04, 1f, 0d, 05, 05, 00, 1f, 06, 01, 05, 00, 1f, 15, 01, 09, 01, 1c, 12, 02, 05, 00, 1f, 0e, 01, 05, 00, 0f, 00, 00, 20, 00, 30, 21, 01, 05, 03, 0f, 00, 03, 20, 00, 30, 00, 00, 33, 00, 41, 00, 00, 4b, 00, 5a, 1e, 01, 05, 00, 0f, 00, 05, 09, 03, 10, 00, 05, 0d, 00, 1b, 00, 02, 0d, 00, 1c, 1a, 04, 09, 05, 06, 31, 06, 05, 03, 06, 22, 04, 05, 03, 06, 3d, 04, 09, 04, 06, 2e, 05, 08, 00, 0f, 45, 01, 09, 03, 0a, 2a, 05, 09, 03, 0a, 3f, 05, 08, 00, 0f, 51, 01, 09, 00, 13, 00, 03, 0d, 00, 1d, 3a, 03, 09, 00, 13, 00, 03, 0d, 00, 1d, 87, 01, 03, 05, 00, 0f, 8f, 01, 01, 0c, 00, 13, 5d, 01, 0d, 00, 13, 8a, 01, 02, 0d, 00, 13, 82, 01, 04, 05, 02, 13, 65, 03, 0d, 00, 13, 7e, 02, 0d, 00, 13, f3, 01, 03, 05, 00, 0f, 69, 01, 0c, 00, 13, 6d, 01, 0d, 03, 0e, 75, 04, 0d, 00, 13, fb, 01, 02, 0d, 00, 17, 82, 02, 01, 14, 00, 1b, 71, 01, 15, 00, 1b, fe, 01, 02, 15, 00, 1b, f6, 01, 04, 0d, 00, 13, 7d, 03, 09, 00, 19, ee, 01, 02, 05, 00, 0f, ea, 01, 03, 09, 00, 22, 00, 02, 05, 00, 0f, 00, 03, 09, 00, 2c, 00, 02, 01, 00, 02]
+Raw bytes (436): 0x[01, 01, 41, 05, 09, 0d, 00, 15, 19, 12, 00, 15, 19, 21, 00, 1e, 00, 21, 00, 31, 00, 3d, 41, 2e, 45, 3d, 41, 42, 49, 45, 00, 3f, 51, 42, 49, 45, 00, 5d, 8a, 01, 8f, 01, 5d, 92, 01, 55, 51, 00, 92, 01, 55, 51, 00, 8f, 01, 5d, 92, 01, 55, 51, 00, 87, 01, 61, 5d, 8a, 01, 8f, 01, 5d, 92, 01, 55, 51, 00, 82, 01, 65, 87, 01, 61, 5d, 8a, 01, 8f, 01, 5d, 92, 01, 55, 51, 00, 75, f6, 01, fb, 01, 79, 00, fe, 01, 82, 02, 00, 69, 6d, 00, fe, 01, 82, 02, 00, 69, 6d, 69, 6d, 82, 02, 00, 69, 6d, fb, 01, 79, 00, fe, 01, 82, 02, 00, 69, 6d, f3, 01, 7d, 75, f6, 01, fb, 01, 79, 00, fe, 01, 82, 02, 00, 69, 6d, ee, 01, 00, f3, 01, 7d, 75, f6, 01, fb, 01, 79, 00, fe, 01, 82, 02, 00, 69, 6d, 33, 01, 08, 01, 03, 1c, 05, 04, 09, 01, 1c, 02, 02, 05, 04, 1f, 0d, 05, 05, 00, 1f, 06, 01, 05, 00, 1f, 15, 01, 09, 01, 1c, 12, 02, 05, 00, 1f, 0e, 01, 05, 00, 0f, 00, 00, 20, 00, 30, 21, 01, 05, 03, 0f, 00, 03, 20, 00, 30, 00, 00, 33, 00, 41, 00, 00, 4b, 00, 5a, 1e, 01, 05, 00, 0f, 00, 05, 09, 03, 10, 00, 05, 0d, 00, 1b, 00, 02, 0d, 00, 1c, 1a, 04, 09, 05, 06, 31, 06, 05, 03, 06, 22, 04, 05, 03, 06, 3d, 04, 09, 04, 06, 2e, 05, 08, 00, 0f, 45, 01, 09, 03, 0a, 2a, 05, 09, 03, 0a, 3f, 05, 08, 00, 0f, 51, 01, 09, 00, 13, 00, 03, 0d, 00, 1d, 3a, 03, 09, 00, 13, 00, 03, 0d, 00, 1d, 87, 01, 03, 05, 00, 0f, 8f, 01, 01, 0c, 00, 13, 5d, 01, 0d, 00, 13, 8a, 01, 02, 0d, 00, 13, 82, 01, 04, 05, 02, 13, 65, 03, 0d, 00, 13, 7e, 02, 0d, 00, 13, f3, 01, 03, 05, 00, 0f, 69, 01, 0c, 00, 13, 6d, 01, 0d, 03, 0e, 75, 04, 0d, 00, 13, fb, 01, 02, 0d, 00, 17, 82, 02, 01, 14, 00, 1b, 00, 01, 15, 00, 1b, fe, 01, 02, 15, 00, 1b, f6, 01, 04, 0d, 00, 13, 7d, 03, 09, 00, 19, ee, 01, 02, 05, 00, 0f, ea, 01, 03, 09, 00, 22, 00, 02, 05, 00, 0f, 00, 03, 09, 00, 2c, 00, 02, 01, 00, 02]
 Number of files: 1
 - file 0 => global file 1
 Number of expressions: 65
@@ -120,31 +120,31 @@ Number of expressions: 65
 - expression 36 operands: lhs = Counter(20), rhs = Zero
 - expression 37 operands: lhs = Counter(29), rhs = Expression(61, Sub)
 - expression 38 operands: lhs = Expression(62, Add), rhs = Counter(30)
-- expression 39 operands: lhs = Counter(28), rhs = Expression(63, Sub)
-- expression 40 operands: lhs = Expression(64, Sub), rhs = Counter(28)
+- expression 39 operands: lhs = Zero, rhs = Expression(63, Sub)
+- expression 40 operands: lhs = Expression(64, Sub), rhs = Zero
 - expression 41 operands: lhs = Counter(26), rhs = Counter(27)
-- expression 42 operands: lhs = Counter(28), rhs = Expression(63, Sub)
-- expression 43 operands: lhs = Expression(64, Sub), rhs = Counter(28)
+- expression 42 operands: lhs = Zero, rhs = Expression(63, Sub)
+- expression 43 operands: lhs = Expression(64, Sub), rhs = Zero
 - expression 44 operands: lhs = Counter(26), rhs = Counter(27)
 - expression 45 operands: lhs = Counter(26), rhs = Counter(27)
-- expression 46 operands: lhs = Expression(64, Sub), rhs = Counter(28)
+- expression 46 operands: lhs = Expression(64, Sub), rhs = Zero
 - expression 47 operands: lhs = Counter(26), rhs = Counter(27)
 - expression 48 operands: lhs = Expression(62, Add), rhs = Counter(30)
-- expression 49 operands: lhs = Counter(28), rhs = Expression(63, Sub)
-- expression 50 operands: lhs = Expression(64, Sub), rhs = Counter(28)
+- expression 49 operands: lhs = Zero, rhs = Expression(63, Sub)
+- expression 50 operands: lhs = Expression(64, Sub), rhs = Zero
 - expression 51 operands: lhs = Counter(26), rhs = Counter(27)
 - expression 52 operands: lhs = Expression(60, Add), rhs = Counter(31)
 - expression 53 operands: lhs = Counter(29), rhs = Expression(61, Sub)
 - expression 54 operands: lhs = Expression(62, Add), rhs = Counter(30)
-- expression 55 operands: lhs = Counter(28), rhs = Expression(63, Sub)
-- expression 56 operands: lhs = Expression(64, Sub), rhs = Counter(28)
+- expression 55 operands: lhs = Zero, rhs = Expression(63, Sub)
+- expression 56 operands: lhs = Expression(64, Sub), rhs = Zero
 - expression 57 operands: lhs = Counter(26), rhs = Counter(27)
 - expression 58 operands: lhs = Expression(59, Sub), rhs = Zero
 - expression 59 operands: lhs = Expression(60, Add), rhs = Counter(31)
 - expression 60 operands: lhs = Counter(29), rhs = Expression(61, Sub)
 - expression 61 operands: lhs = Expression(62, Add), rhs = Counter(30)
-- expression 62 operands: lhs = Counter(28), rhs = Expression(63, Sub)
-- expression 63 operands: lhs = Expression(64, Sub), rhs = Counter(28)
+- expression 62 operands: lhs = Zero, rhs = Expression(63, Sub)
+- expression 63 operands: lhs = Expression(64, Sub), rhs = Zero
 - expression 64 operands: lhs = Counter(26), rhs = Counter(27)
 Number of file 0 mappings: 51
 - Code(Counter(0)) at (prev + 8, 1) to (start + 3, 28)
@@ -200,24 +200,24 @@ Number of file 0 mappings: 51
 - Code(Expression(31, Sub)) at (prev + 2, 13) to (start + 0, 19)
     = (((c23 + (((c20 - Zero) + c21) - c23)) - c24) - c25)
 - Code(Expression(60, Add)) at (prev + 3, 5) to (start + 0, 15)
-    = (c29 + ((c28 + ((c26 - c27) - c28)) - c30))
+    = (c29 + ((Zero + ((c26 - c27) - Zero)) - c30))
 - Code(Counter(26)) at (prev + 1, 12) to (start + 0, 19)
 - Code(Counter(27)) at (prev + 1, 13) to (start + 3, 14)
 - Code(Counter(29)) at (prev + 4, 13) to (start + 0, 19)
 - Code(Expression(62, Add)) at (prev + 2, 13) to (start + 0, 23)
-    = (c28 + ((c26 - c27) - c28))
+    = (Zero + ((c26 - c27) - Zero))
 - Code(Expression(64, Sub)) at (prev + 1, 20) to (start + 0, 27)
     = (c26 - c27)
-- Code(Counter(28)) at (prev + 1, 21) to (start + 0, 27)
+- Code(Zero) at (prev + 1, 21) to (start + 0, 27)
 - Code(Expression(63, Sub)) at (prev + 2, 21) to (start + 0, 27)
-    = ((c26 - c27) - c28)
+    = ((c26 - c27) - Zero)
 - Code(Expression(61, Sub)) at (prev + 4, 13) to (start + 0, 19)
-    = ((c28 + ((c26 - c27) - c28)) - c30)
+    = ((Zero + ((c26 - c27) - Zero)) - c30)
 - Code(Counter(31)) at (prev + 3, 9) to (start + 0, 25)
 - Code(Expression(59, Sub)) at (prev + 2, 5) to (start + 0, 15)
-    = ((c29 + ((c28 + ((c26 - c27) - c28)) - c30)) - c31)
+    = ((c29 + ((Zero + ((c26 - c27) - Zero)) - c30)) - c31)
 - Code(Expression(58, Sub)) at (prev + 3, 9) to (start + 0, 34)
-    = (((c29 + ((c28 + ((c26 - c27) - c28)) - c30)) - c31) - Zero)
+    = (((c29 + ((Zero + ((c26 - c27) - Zero)) - c30)) - c31) - Zero)
 - Code(Zero) at (prev + 2, 5) to (start + 0, 15)
 - Code(Zero) at (prev + 3, 9) to (start + 0, 44)
 - Code(Zero) at (prev + 2, 1) to (start + 0, 2)
diff --git a/tests/coverage/try_error_result.cov-map b/tests/coverage/try_error_result.cov-map
index 5cfb40ce528..83f1869a31e 100644
--- a/tests/coverage/try_error_result.cov-map
+++ b/tests/coverage/try_error_result.cov-map
@@ -59,162 +59,131 @@ Number of file 0 mappings: 4
     = (c1 + (c0 - c1))
 
 Function name: try_error_result::test1
-Raw bytes (77): 0x[01, 01, 09, 01, 07, 05, 09, 03, 0d, 1d, 11, 16, 1d, 03, 0d, 1f, 0d, 23, 19, 11, 15, 0b, 01, 0d, 01, 02, 17, 03, 07, 09, 00, 0e, 16, 02, 09, 04, 1a, 1d, 06, 0d, 00, 29, 11, 00, 29, 00, 2a, 0e, 01, 0d, 00, 2a, 15, 00, 2a, 00, 2b, 12, 04, 0d, 00, 2a, 19, 00, 2a, 00, 2b, 0d, 03, 05, 00, 0b, 1b, 01, 01, 00, 02]
+Raw bytes (75): 0x[01, 01, 08, 01, 07, 00, 09, 03, 0d, 12, 1d, 03, 0d, 1b, 0d, 1f, 00, 11, 00, 0b, 01, 0d, 01, 02, 17, 03, 07, 09, 00, 0e, 12, 02, 09, 04, 1a, 1d, 06, 0d, 00, 29, 11, 00, 29, 00, 2a, 00, 01, 0d, 00, 2a, 00, 00, 2a, 00, 2b, 0e, 04, 0d, 00, 2a, 00, 00, 2a, 00, 2b, 0d, 03, 05, 00, 0b, 17, 01, 01, 00, 02]
 Number of files: 1
 - file 0 => global file 1
-Number of expressions: 9
+Number of expressions: 8
 - expression 0 operands: lhs = Counter(0), rhs = Expression(1, Add)
-- expression 1 operands: lhs = Counter(1), rhs = Counter(2)
+- expression 1 operands: lhs = Zero, rhs = Counter(2)
 - expression 2 operands: lhs = Expression(0, Add), rhs = Counter(3)
-- expression 3 operands: lhs = Counter(7), rhs = Counter(4)
-- expression 4 operands: lhs = Expression(5, Sub), rhs = Counter(7)
-- expression 5 operands: lhs = Expression(0, Add), rhs = Counter(3)
-- expression 6 operands: lhs = Expression(7, Add), rhs = Counter(3)
-- expression 7 operands: lhs = Expression(8, Add), rhs = Counter(6)
-- expression 8 operands: lhs = Counter(4), rhs = Counter(5)
+- expression 3 operands: lhs = Expression(4, Sub), rhs = Counter(7)
+- expression 4 operands: lhs = Expression(0, Add), rhs = Counter(3)
+- expression 5 operands: lhs = Expression(6, Add), rhs = Counter(3)
+- expression 6 operands: lhs = Expression(7, Add), rhs = Zero
+- expression 7 operands: lhs = Counter(4), rhs = Zero
 Number of file 0 mappings: 11
 - Code(Counter(0)) at (prev + 13, 1) to (start + 2, 23)
 - Code(Expression(0, Add)) at (prev + 7, 9) to (start + 0, 14)
-    = (c0 + (c1 + c2))
-- Code(Expression(5, Sub)) at (prev + 2, 9) to (start + 4, 26)
-    = ((c0 + (c1 + c2)) - c3)
+    = (c0 + (Zero + c2))
+- Code(Expression(4, Sub)) at (prev + 2, 9) to (start + 4, 26)
+    = ((c0 + (Zero + c2)) - c3)
 - Code(Counter(7)) at (prev + 6, 13) to (start + 0, 41)
 - Code(Counter(4)) at (prev + 0, 41) to (start + 0, 42)
-- Code(Expression(3, Sub)) at (prev + 1, 13) to (start + 0, 42)
-    = (c7 - c4)
-- Code(Counter(5)) at (prev + 0, 42) to (start + 0, 43)
-- Code(Expression(4, Sub)) at (prev + 4, 13) to (start + 0, 42)
-    = (((c0 + (c1 + c2)) - c3) - c7)
-- Code(Counter(6)) at (prev + 0, 42) to (start + 0, 43)
+- Code(Zero) at (prev + 1, 13) to (start + 0, 42)
+- Code(Zero) at (prev + 0, 42) to (start + 0, 43)
+- Code(Expression(3, Sub)) at (prev + 4, 13) to (start + 0, 42)
+    = (((c0 + (Zero + c2)) - c3) - c7)
+- Code(Zero) at (prev + 0, 42) to (start + 0, 43)
 - Code(Counter(3)) at (prev + 3, 5) to (start + 0, 11)
-- Code(Expression(6, Add)) at (prev + 1, 1) to (start + 0, 2)
-    = (((c4 + c5) + c6) + c3)
+- Code(Expression(5, Add)) at (prev + 1, 1) to (start + 0, 2)
+    = (((c4 + Zero) + Zero) + c3)
 
 Function name: try_error_result::test2
-Raw bytes (358): 0x[01, 01, 3b, 01, 07, 05, 09, 03, 0d, 41, 11, 4a, 15, 41, 11, 42, 1d, 46, 19, 4a, 15, 41, 11, 4a, 15, 41, 11, 46, 19, 4a, 15, 41, 11, 42, 1d, 46, 19, 4a, 15, 41, 11, 5e, 25, 49, 21, 49, 21, 5e, 25, 49, 21, 8a, 01, 2d, 8e, 01, 29, 92, 01, 41, 03, 0d, 92, 01, 41, 03, 0d, 8e, 01, 29, 92, 01, 41, 03, 0d, 8a, 01, 2d, 8e, 01, 29, 92, 01, 41, 03, 0d, a6, 01, 35, 45, 31, 45, 31, a6, 01, 35, 45, 31, ba, 01, 3d, 4d, 39, 4d, 39, ba, 01, 3d, 4d, 39, c3, 01, 0d, c7, 01, db, 01, cb, 01, cf, 01, 11, 15, d3, 01, d7, 01, 19, 1d, 21, 25, df, 01, e3, 01, 29, 2d, e7, 01, eb, 01, 31, 35, 39, 3d, 28, 01, 3e, 01, 03, 17, 03, 08, 09, 00, 0e, 92, 01, 02, 09, 04, 1a, 41, 06, 0d, 00, 2f, 11, 00, 2f, 00, 30, 4a, 00, 31, 03, 35, 15, 04, 11, 00, 12, 46, 02, 11, 04, 12, 3e, 05, 11, 00, 14, 46, 00, 17, 00, 41, 19, 00, 41, 00, 42, 42, 00, 43, 00, 5f, 1d, 00, 5f, 00, 60, 3e, 01, 0d, 00, 20, 5a, 01, 11, 00, 14, 49, 00, 17, 00, 41, 21, 00, 41, 00, 42, 5e, 00, 43, 00, 60, 25, 00, 60, 00, 61, 5a, 01, 0d, 00, 20, 86, 01, 04, 11, 00, 14, 8e, 01, 00, 17, 00, 42, 29, 00, 42, 00, 43, 8a, 01, 00, 44, 00, 61, 2d, 00, 61, 00, 62, 86, 01, 01, 0d, 00, 20, a2, 01, 01, 11, 00, 14, 45, 00, 17, 01, 36, 31, 01, 36, 00, 37, a6, 01, 01, 12, 00, 2f, 35, 00, 2f, 00, 30, a2, 01, 01, 0d, 00, 20, b6, 01, 01, 11, 00, 14, 4d, 00, 17, 01, 36, 39, 02, 11, 00, 12, ba, 01, 01, 12, 00, 2f, 3d, 01, 11, 00, 12, b6, 01, 02, 0d, 00, 20, 0d, 03, 05, 00, 0b, bf, 01, 01, 01, 00, 02]
+Raw bytes (280): 0x[01, 01, 24, 01, 07, 00, 09, 03, 0d, 41, 00, 1e, 00, 41, 00, 1e, 00, 41, 00, 4a, 00, 4e, 00, 52, 41, 03, 0d, 52, 41, 03, 0d, 4e, 00, 52, 41, 03, 0d, 4a, 00, 4e, 00, 52, 41, 03, 0d, 66, 00, 45, 00, 45, 00, 66, 00, 45, 00, 7a, 00, 4d, 00, 4d, 00, 7a, 00, 4d, 00, 83, 01, 0d, 87, 01, 00, 00, 8b, 01, 8f, 01, 00, 19, 00, 28, 01, 3e, 01, 03, 17, 03, 08, 09, 00, 0e, 52, 02, 09, 04, 1a, 41, 06, 0d, 00, 2f, 00, 00, 2f, 00, 30, 1e, 00, 31, 03, 35, 00, 04, 11, 00, 12, 1a, 02, 11, 04, 12, 00, 05, 11, 00, 14, 1a, 00, 17, 00, 41, 19, 00, 41, 00, 42, 00, 00, 43, 00, 5f, 00, 00, 5f, 00, 60, 00, 01, 0d, 00, 20, 00, 01, 11, 00, 14, 00, 00, 17, 00, 41, 00, 00, 41, 00, 42, 00, 00, 43, 00, 60, 00, 00, 60, 00, 61, 00, 01, 0d, 00, 20, 46, 04, 11, 00, 14, 4e, 00, 17, 00, 42, 00, 00, 42, 00, 43, 4a, 00, 44, 00, 61, 00, 00, 61, 00, 62, 46, 01, 0d, 00, 20, 62, 01, 11, 00, 14, 45, 00, 17, 01, 36, 00, 01, 36, 00, 37, 66, 01, 12, 00, 2f, 00, 00, 2f, 00, 30, 62, 01, 0d, 00, 20, 76, 01, 11, 00, 14, 4d, 00, 17, 01, 36, 00, 02, 11, 00, 12, 7a, 01, 12, 00, 2f, 00, 01, 11, 00, 12, 76, 02, 0d, 00, 20, 0d, 03, 05, 00, 0b, 7f, 01, 01, 00, 02]
 Number of files: 1
 - file 0 => global file 1
-Number of expressions: 59
+Number of expressions: 36
 - expression 0 operands: lhs = Counter(0), rhs = Expression(1, Add)
-- expression 1 operands: lhs = Counter(1), rhs = Counter(2)
+- expression 1 operands: lhs = Zero, rhs = Counter(2)
 - expression 2 operands: lhs = Expression(0, Add), rhs = Counter(3)
-- expression 3 operands: lhs = Counter(16), rhs = Counter(4)
-- expression 4 operands: lhs = Expression(18, Sub), rhs = Counter(5)
-- expression 5 operands: lhs = Counter(16), rhs = Counter(4)
-- expression 6 operands: lhs = Expression(16, Sub), rhs = Counter(7)
-- expression 7 operands: lhs = Expression(17, Sub), rhs = Counter(6)
-- expression 8 operands: lhs = Expression(18, Sub), rhs = Counter(5)
-- expression 9 operands: lhs = Counter(16), rhs = Counter(4)
-- expression 10 operands: lhs = Expression(18, Sub), rhs = Counter(5)
-- expression 11 operands: lhs = Counter(16), rhs = Counter(4)
-- expression 12 operands: lhs = Expression(17, Sub), rhs = Counter(6)
-- expression 13 operands: lhs = Expression(18, Sub), rhs = Counter(5)
-- expression 14 operands: lhs = Counter(16), rhs = Counter(4)
-- expression 15 operands: lhs = Expression(16, Sub), rhs = Counter(7)
-- expression 16 operands: lhs = Expression(17, Sub), rhs = Counter(6)
-- expression 17 operands: lhs = Expression(18, Sub), rhs = Counter(5)
-- expression 18 operands: lhs = Counter(16), rhs = Counter(4)
-- expression 19 operands: lhs = Expression(23, Sub), rhs = Counter(9)
-- expression 20 operands: lhs = Counter(18), rhs = Counter(8)
-- expression 21 operands: lhs = Counter(18), rhs = Counter(8)
-- expression 22 operands: lhs = Expression(23, Sub), rhs = Counter(9)
-- expression 23 operands: lhs = Counter(18), rhs = Counter(8)
-- expression 24 operands: lhs = Expression(34, Sub), rhs = Counter(11)
-- expression 25 operands: lhs = Expression(35, Sub), rhs = Counter(10)
-- expression 26 operands: lhs = Expression(36, Sub), rhs = Counter(16)
-- expression 27 operands: lhs = Expression(0, Add), rhs = Counter(3)
-- expression 28 operands: lhs = Expression(36, Sub), rhs = Counter(16)
-- expression 29 operands: lhs = Expression(0, Add), rhs = Counter(3)
-- expression 30 operands: lhs = Expression(35, Sub), rhs = Counter(10)
-- expression 31 operands: lhs = Expression(36, Sub), rhs = Counter(16)
-- expression 32 operands: lhs = Expression(0, Add), rhs = Counter(3)
-- expression 33 operands: lhs = Expression(34, Sub), rhs = Counter(11)
-- expression 34 operands: lhs = Expression(35, Sub), rhs = Counter(10)
-- expression 35 operands: lhs = Expression(36, Sub), rhs = Counter(16)
-- expression 36 operands: lhs = Expression(0, Add), rhs = Counter(3)
-- expression 37 operands: lhs = Expression(41, Sub), rhs = Counter(13)
-- expression 38 operands: lhs = Counter(17), rhs = Counter(12)
-- expression 39 operands: lhs = Counter(17), rhs = Counter(12)
-- expression 40 operands: lhs = Expression(41, Sub), rhs = Counter(13)
-- expression 41 operands: lhs = Counter(17), rhs = Counter(12)
-- expression 42 operands: lhs = Expression(46, Sub), rhs = Counter(15)
-- expression 43 operands: lhs = Counter(19), rhs = Counter(14)
-- expression 44 operands: lhs = Counter(19), rhs = Counter(14)
-- expression 45 operands: lhs = Expression(46, Sub), rhs = Counter(15)
-- expression 46 operands: lhs = Counter(19), rhs = Counter(14)
-- expression 47 operands: lhs = Expression(48, Add), rhs = Counter(3)
-- expression 48 operands: lhs = Expression(49, Add), rhs = Expression(54, Add)
-- expression 49 operands: lhs = Expression(50, Add), rhs = Expression(51, Add)
-- expression 50 operands: lhs = Counter(4), rhs = Counter(5)
-- expression 51 operands: lhs = Expression(52, Add), rhs = Expression(53, Add)
-- expression 52 operands: lhs = Counter(6), rhs = Counter(7)
-- expression 53 operands: lhs = Counter(8), rhs = Counter(9)
-- expression 54 operands: lhs = Expression(55, Add), rhs = Expression(56, Add)
-- expression 55 operands: lhs = Counter(10), rhs = Counter(11)
-- expression 56 operands: lhs = Expression(57, Add), rhs = Expression(58, Add)
-- expression 57 operands: lhs = Counter(12), rhs = Counter(13)
-- expression 58 operands: lhs = Counter(14), rhs = Counter(15)
+- expression 3 operands: lhs = Counter(16), rhs = Zero
+- expression 4 operands: lhs = Expression(7, Sub), rhs = Zero
+- expression 5 operands: lhs = Counter(16), rhs = Zero
+- expression 6 operands: lhs = Expression(7, Sub), rhs = Zero
+- expression 7 operands: lhs = Counter(16), rhs = Zero
+- expression 8 operands: lhs = Expression(18, Sub), rhs = Zero
+- expression 9 operands: lhs = Expression(19, Sub), rhs = Zero
+- expression 10 operands: lhs = Expression(20, Sub), rhs = Counter(16)
+- expression 11 operands: lhs = Expression(0, Add), rhs = Counter(3)
+- expression 12 operands: lhs = Expression(20, Sub), rhs = Counter(16)
+- expression 13 operands: lhs = Expression(0, Add), rhs = Counter(3)
+- expression 14 operands: lhs = Expression(19, Sub), rhs = Zero
+- expression 15 operands: lhs = Expression(20, Sub), rhs = Counter(16)
+- expression 16 operands: lhs = Expression(0, Add), rhs = Counter(3)
+- expression 17 operands: lhs = Expression(18, Sub), rhs = Zero
+- expression 18 operands: lhs = Expression(19, Sub), rhs = Zero
+- expression 19 operands: lhs = Expression(20, Sub), rhs = Counter(16)
+- expression 20 operands: lhs = Expression(0, Add), rhs = Counter(3)
+- expression 21 operands: lhs = Expression(25, Sub), rhs = Zero
+- expression 22 operands: lhs = Counter(17), rhs = Zero
+- expression 23 operands: lhs = Counter(17), rhs = Zero
+- expression 24 operands: lhs = Expression(25, Sub), rhs = Zero
+- expression 25 operands: lhs = Counter(17), rhs = Zero
+- expression 26 operands: lhs = Expression(30, Sub), rhs = Zero
+- expression 27 operands: lhs = Counter(19), rhs = Zero
+- expression 28 operands: lhs = Counter(19), rhs = Zero
+- expression 29 operands: lhs = Expression(30, Sub), rhs = Zero
+- expression 30 operands: lhs = Counter(19), rhs = Zero
+- expression 31 operands: lhs = Expression(32, Add), rhs = Counter(3)
+- expression 32 operands: lhs = Expression(33, Add), rhs = Zero
+- expression 33 operands: lhs = Zero, rhs = Expression(34, Add)
+- expression 34 operands: lhs = Expression(35, Add), rhs = Zero
+- expression 35 operands: lhs = Counter(6), rhs = Zero
 Number of file 0 mappings: 40
 - Code(Counter(0)) at (prev + 62, 1) to (start + 3, 23)
 - Code(Expression(0, Add)) at (prev + 8, 9) to (start + 0, 14)
-    = (c0 + (c1 + c2))
-- Code(Expression(36, Sub)) at (prev + 2, 9) to (start + 4, 26)
-    = ((c0 + (c1 + c2)) - c3)
+    = (c0 + (Zero + c2))
+- Code(Expression(20, Sub)) at (prev + 2, 9) to (start + 4, 26)
+    = ((c0 + (Zero + c2)) - c3)
 - Code(Counter(16)) at (prev + 6, 13) to (start + 0, 47)
-- Code(Counter(4)) at (prev + 0, 47) to (start + 0, 48)
-- Code(Expression(18, Sub)) at (prev + 0, 49) to (start + 3, 53)
-    = (c16 - c4)
-- Code(Counter(5)) at (prev + 4, 17) to (start + 0, 18)
-- Code(Expression(17, Sub)) at (prev + 2, 17) to (start + 4, 18)
-    = ((c16 - c4) - c5)
-- Code(Expression(15, Sub)) at (prev + 5, 17) to (start + 0, 20)
-    = ((((c16 - c4) - c5) - c6) - c7)
-- Code(Expression(17, Sub)) at (prev + 0, 23) to (start + 0, 65)
-    = ((c16 - c4) - c5)
+- Code(Zero) at (prev + 0, 47) to (start + 0, 48)
+- Code(Expression(7, Sub)) at (prev + 0, 49) to (start + 3, 53)
+    = (c16 - Zero)
+- Code(Zero) at (prev + 4, 17) to (start + 0, 18)
+- Code(Expression(6, Sub)) at (prev + 2, 17) to (start + 4, 18)
+    = ((c16 - Zero) - Zero)
+- Code(Zero) at (prev + 5, 17) to (start + 0, 20)
+- Code(Expression(6, Sub)) at (prev + 0, 23) to (start + 0, 65)
+    = ((c16 - Zero) - Zero)
 - Code(Counter(6)) at (prev + 0, 65) to (start + 0, 66)
-- Code(Expression(16, Sub)) at (prev + 0, 67) to (start + 0, 95)
-    = (((c16 - c4) - c5) - c6)
-- Code(Counter(7)) at (prev + 0, 95) to (start + 0, 96)
-- Code(Expression(15, Sub)) at (prev + 1, 13) to (start + 0, 32)
-    = ((((c16 - c4) - c5) - c6) - c7)
-- Code(Expression(22, Sub)) at (prev + 1, 17) to (start + 0, 20)
-    = ((c18 - c8) - c9)
-- Code(Counter(18)) at (prev + 0, 23) to (start + 0, 65)
-- Code(Counter(8)) at (prev + 0, 65) to (start + 0, 66)
-- Code(Expression(23, Sub)) at (prev + 0, 67) to (start + 0, 96)
-    = (c18 - c8)
-- Code(Counter(9)) at (prev + 0, 96) to (start + 0, 97)
-- Code(Expression(22, Sub)) at (prev + 1, 13) to (start + 0, 32)
-    = ((c18 - c8) - c9)
-- Code(Expression(33, Sub)) at (prev + 4, 17) to (start + 0, 20)
-    = (((((c0 + (c1 + c2)) - c3) - c16) - c10) - c11)
-- Code(Expression(35, Sub)) at (prev + 0, 23) to (start + 0, 66)
-    = (((c0 + (c1 + c2)) - c3) - c16)
-- Code(Counter(10)) at (prev + 0, 66) to (start + 0, 67)
-- Code(Expression(34, Sub)) at (prev + 0, 68) to (start + 0, 97)
-    = ((((c0 + (c1 + c2)) - c3) - c16) - c10)
-- Code(Counter(11)) at (prev + 0, 97) to (start + 0, 98)
-- Code(Expression(33, Sub)) at (prev + 1, 13) to (start + 0, 32)
-    = (((((c0 + (c1 + c2)) - c3) - c16) - c10) - c11)
-- Code(Expression(40, Sub)) at (prev + 1, 17) to (start + 0, 20)
-    = ((c17 - c12) - c13)
+- Code(Zero) at (prev + 0, 67) to (start + 0, 95)
+- Code(Zero) at (prev + 0, 95) to (start + 0, 96)
+- Code(Zero) at (prev + 1, 13) to (start + 0, 32)
+- Code(Zero) at (prev + 1, 17) to (start + 0, 20)
+- Code(Zero) at (prev + 0, 23) to (start + 0, 65)
+- Code(Zero) at (prev + 0, 65) to (start + 0, 66)
+- Code(Zero) at (prev + 0, 67) to (start + 0, 96)
+- Code(Zero) at (prev + 0, 96) to (start + 0, 97)
+- Code(Zero) at (prev + 1, 13) to (start + 0, 32)
+- Code(Expression(17, Sub)) at (prev + 4, 17) to (start + 0, 20)
+    = (((((c0 + (Zero + c2)) - c3) - c16) - Zero) - Zero)
+- Code(Expression(19, Sub)) at (prev + 0, 23) to (start + 0, 66)
+    = (((c0 + (Zero + c2)) - c3) - c16)
+- Code(Zero) at (prev + 0, 66) to (start + 0, 67)
+- Code(Expression(18, Sub)) at (prev + 0, 68) to (start + 0, 97)
+    = ((((c0 + (Zero + c2)) - c3) - c16) - Zero)
+- Code(Zero) at (prev + 0, 97) to (start + 0, 98)
+- Code(Expression(17, Sub)) at (prev + 1, 13) to (start + 0, 32)
+    = (((((c0 + (Zero + c2)) - c3) - c16) - Zero) - Zero)
+- Code(Expression(24, Sub)) at (prev + 1, 17) to (start + 0, 20)
+    = ((c17 - Zero) - Zero)
 - Code(Counter(17)) at (prev + 0, 23) to (start + 1, 54)
-- Code(Counter(12)) at (prev + 1, 54) to (start + 0, 55)
-- Code(Expression(41, Sub)) at (prev + 1, 18) to (start + 0, 47)
-    = (c17 - c12)
-- Code(Counter(13)) at (prev + 0, 47) to (start + 0, 48)
-- Code(Expression(40, Sub)) at (prev + 1, 13) to (start + 0, 32)
-    = ((c17 - c12) - c13)
-- Code(Expression(45, Sub)) at (prev + 1, 17) to (start + 0, 20)
-    = ((c19 - c14) - c15)
+- Code(Zero) at (prev + 1, 54) to (start + 0, 55)
+- Code(Expression(25, Sub)) at (prev + 1, 18) to (start + 0, 47)
+    = (c17 - Zero)
+- Code(Zero) at (prev + 0, 47) to (start + 0, 48)
+- Code(Expression(24, Sub)) at (prev + 1, 13) to (start + 0, 32)
+    = ((c17 - Zero) - Zero)
+- Code(Expression(29, Sub)) at (prev + 1, 17) to (start + 0, 20)
+    = ((c19 - Zero) - Zero)
 - Code(Counter(19)) at (prev + 0, 23) to (start + 1, 54)
-- Code(Counter(14)) at (prev + 2, 17) to (start + 0, 18)
-- Code(Expression(46, Sub)) at (prev + 1, 18) to (start + 0, 47)
-    = (c19 - c14)
-- Code(Counter(15)) at (prev + 1, 17) to (start + 0, 18)
-- Code(Expression(45, Sub)) at (prev + 2, 13) to (start + 0, 32)
-    = ((c19 - c14) - c15)
+- Code(Zero) at (prev + 2, 17) to (start + 0, 18)
+- Code(Expression(30, Sub)) at (prev + 1, 18) to (start + 0, 47)
+    = (c19 - Zero)
+- Code(Zero) at (prev + 1, 17) to (start + 0, 18)
+- Code(Expression(29, Sub)) at (prev + 2, 13) to (start + 0, 32)
+    = ((c19 - Zero) - Zero)
 - Code(Counter(3)) at (prev + 3, 5) to (start + 0, 11)
-- Code(Expression(47, Add)) at (prev + 1, 1) to (start + 0, 2)
-    = ((((c4 + c5) + ((c6 + c7) + (c8 + c9))) + ((c10 + c11) + ((c12 + c13) + (c14 + c15)))) + c3)
+- Code(Expression(31, Add)) at (prev + 1, 1) to (start + 0, 2)
+    = (((Zero + ((c6 + Zero) + Zero)) + Zero) + c3)
 
diff --git a/tests/coverage/yield.cov-map b/tests/coverage/yield.cov-map
index c9c9709fa4f..9cc67dfe88a 100644
--- a/tests/coverage/yield.cov-map
+++ b/tests/coverage/yield.cov-map
@@ -1,9 +1,9 @@
 Function name: yield::main
-Raw bytes (106): 0x[01, 01, 0b, 05, 09, 0d, 11, 22, 15, 0d, 11, 11, 15, 22, 15, 0d, 11, 22, 15, 0d, 11, 19, 1d, 25, 29, 10, 01, 07, 01, 01, 16, 01, 06, 0b, 00, 2e, 0d, 01, 27, 00, 29, 03, 01, 0e, 00, 34, 0d, 02, 0b, 00, 2e, 22, 01, 22, 00, 27, 1e, 00, 2c, 00, 2e, 13, 01, 0e, 00, 34, 1e, 03, 09, 00, 16, 1e, 07, 0b, 00, 2e, 21, 01, 27, 00, 29, 27, 01, 0e, 00, 34, 21, 02, 0b, 00, 2e, 2d, 01, 27, 00, 29, 2b, 01, 0e, 00, 34, 2d, 02, 01, 00, 02]
+Raw bytes (106): 0x[01, 01, 0b, 05, 00, 0d, 11, 22, 15, 0d, 11, 11, 15, 22, 15, 0d, 11, 22, 15, 0d, 11, 19, 1d, 25, 29, 10, 01, 07, 01, 01, 16, 01, 06, 0b, 00, 2e, 0d, 01, 27, 00, 29, 03, 01, 0e, 00, 34, 0d, 02, 0b, 00, 2e, 22, 01, 22, 00, 27, 1e, 00, 2c, 00, 2e, 13, 01, 0e, 00, 34, 1e, 03, 09, 00, 16, 1e, 07, 0b, 00, 2e, 21, 01, 27, 00, 29, 27, 01, 0e, 00, 34, 21, 02, 0b, 00, 2e, 2d, 01, 27, 00, 29, 2b, 01, 0e, 00, 34, 2d, 02, 01, 00, 02]
 Number of files: 1
 - file 0 => global file 1
 Number of expressions: 11
-- expression 0 operands: lhs = Counter(1), rhs = Counter(2)
+- expression 0 operands: lhs = Counter(1), rhs = Zero
 - expression 1 operands: lhs = Counter(3), rhs = Counter(4)
 - expression 2 operands: lhs = Expression(8, Sub), rhs = Counter(5)
 - expression 3 operands: lhs = Counter(3), rhs = Counter(4)
@@ -19,7 +19,7 @@ Number of file 0 mappings: 16
 - Code(Counter(0)) at (prev + 6, 11) to (start + 0, 46)
 - Code(Counter(3)) at (prev + 1, 39) to (start + 0, 41)
 - Code(Expression(0, Add)) at (prev + 1, 14) to (start + 0, 52)
-    = (c1 + c2)
+    = (c1 + Zero)
 - Code(Counter(3)) at (prev + 2, 11) to (start + 0, 46)
 - Code(Expression(8, Sub)) at (prev + 1, 34) to (start + 0, 39)
     = (c3 - c4)
diff --git a/tests/mir-opt/const_goto.issue_77355_opt.ConstGoto.diff b/tests/mir-opt/const_goto.issue_77355_opt.ConstGoto.diff
deleted file mode 100644
index 43bdb431129..00000000000
--- a/tests/mir-opt/const_goto.issue_77355_opt.ConstGoto.diff
+++ /dev/null
@@ -1,50 +0,0 @@
-- // MIR for `issue_77355_opt` before ConstGoto
-+ // MIR for `issue_77355_opt` after ConstGoto
-  
-  fn issue_77355_opt(_1: Foo) -> u64 {
-      debug num => _1;
-      let mut _0: u64;
--     let mut _2: bool;
--     let mut _3: isize;
-+     let mut _2: isize;
-  
-      bb0: {
--         StorageLive(_2);
--         _3 = discriminant(_1);
--         switchInt(move _3) -> [1: bb2, 2: bb2, otherwise: bb1];
-+         _2 = discriminant(_1);
-+         switchInt(move _2) -> [1: bb2, 2: bb2, otherwise: bb1];
-      }
-  
-      bb1: {
--         _2 = const false;
-+         _0 = const 42_u64;
-          goto -> bb3;
-      }
-  
-      bb2: {
--         _2 = const true;
-+         _0 = const 23_u64;
-          goto -> bb3;
-      }
-  
-      bb3: {
--         switchInt(move _2) -> [0: bb5, otherwise: bb4];
--     }
-- 
--     bb4: {
--         _0 = const 23_u64;
--         goto -> bb6;
--     }
-- 
--     bb5: {
--         _0 = const 42_u64;
--         goto -> bb6;
--     }
-- 
--     bb6: {
--         StorageDead(_2);
-          return;
-      }
-  }
-  
diff --git a/tests/mir-opt/const_goto.rs b/tests/mir-opt/const_goto.rs
deleted file mode 100644
index 93cb71c3a0f..00000000000
--- a/tests/mir-opt/const_goto.rs
+++ /dev/null
@@ -1,19 +0,0 @@
-// skip-filecheck
-// unit-test: ConstGoto
-
-pub enum Foo {
-    A,
-    B,
-    C,
-    D,
-    E,
-    F,
-}
-
-// EMIT_MIR const_goto.issue_77355_opt.ConstGoto.diff
-fn issue_77355_opt(num: Foo) -> u64 {
-    if matches!(num, Foo::B | Foo::C) { 23 } else { 42 }
-}
-fn main() {
-    issue_77355_opt(Foo::A);
-}
diff --git a/tests/mir-opt/const_goto_const_eval_fail.f.ConstGoto.diff b/tests/mir-opt/const_goto_const_eval_fail.f.ConstGoto.diff
deleted file mode 100644
index 84a13f28a31..00000000000
--- a/tests/mir-opt/const_goto_const_eval_fail.f.ConstGoto.diff
+++ /dev/null
@@ -1,51 +0,0 @@
-- // MIR for `f` before ConstGoto
-+ // MIR for `f` after ConstGoto
-  
-  fn f() -> u64 {
-      let mut _0: u64;
-      let mut _1: bool;
-      let mut _2: i32;
-  
-      bb0: {
-          StorageLive(_1);
-          StorageLive(_2);
-          _2 = const A;
-          switchInt(_2) -> [1: bb2, 2: bb2, 3: bb2, otherwise: bb1];
-      }
-  
-      bb1: {
-          _1 = const true;
-          goto -> bb3;
-      }
-  
-      bb2: {
-          _1 = const B;
--         goto -> bb3;
-+         switchInt(_1) -> [0: bb4, otherwise: bb3];
-      }
-  
-      bb3: {
--         switchInt(_1) -> [0: bb5, otherwise: bb4];
--     }
-- 
--     bb4: {
-          _0 = const 2_u64;
--         goto -> bb6;
-+         goto -> bb5;
-      }
-  
--     bb5: {
-+     bb4: {
-          _0 = const 1_u64;
--         goto -> bb6;
-+         goto -> bb5;
-      }
-  
--     bb6: {
-+     bb5: {
-          StorageDead(_2);
-          StorageDead(_1);
-          return;
-      }
-  }
-  
diff --git a/tests/mir-opt/const_goto_const_eval_fail.f.JumpThreading.diff b/tests/mir-opt/const_goto_const_eval_fail.f.JumpThreading.diff
new file mode 100644
index 00000000000..4fc9254b7ba
--- /dev/null
+++ b/tests/mir-opt/const_goto_const_eval_fail.f.JumpThreading.diff
@@ -0,0 +1,47 @@
+- // MIR for `f` before JumpThreading
++ // MIR for `f` after JumpThreading
+  
+  fn f() -> u64 {
+      let mut _0: u64;
+      let mut _1: bool;
+  
+      bb0: {
+          StorageLive(_1);
+          switchInt(const A) -> [1: bb2, 2: bb2, 3: bb2, otherwise: bb1];
+      }
+  
+      bb1: {
+          _1 = const true;
+-         goto -> bb3;
++         goto -> bb7;
+      }
+  
+      bb2: {
+          _1 = const B;
+          goto -> bb3;
+      }
+  
+      bb3: {
+          switchInt(_1) -> [0: bb5, otherwise: bb4];
+      }
+  
+      bb4: {
+          _0 = const 2_u64;
+          goto -> bb6;
+      }
+  
+      bb5: {
+          _0 = const 1_u64;
+          goto -> bb6;
+      }
+  
+      bb6: {
+          StorageDead(_1);
+          return;
++     }
++ 
++     bb7: {
++         goto -> bb4;
+      }
+  }
+  
diff --git a/tests/mir-opt/const_goto_const_eval_fail.rs b/tests/mir-opt/const_goto_const_eval_fail.rs
index 869f916001c..c0e8e144b15 100644
--- a/tests/mir-opt/const_goto_const_eval_fail.rs
+++ b/tests/mir-opt/const_goto_const_eval_fail.rs
@@ -5,7 +5,7 @@
 // compile-flags: -Zunsound-mir-opts
 
 // If const eval fails, then don't crash
-// EMIT_MIR const_goto_const_eval_fail.f.ConstGoto.diff
+// EMIT_MIR const_goto_const_eval_fail.f.JumpThreading.diff
 pub fn f<const A: i32, const B: bool>() -> u64 {
     match {
         match A {
diff --git a/tests/mir-opt/const_goto_storage.match_nested_if.ConstGoto.diff b/tests/mir-opt/const_goto_storage.match_nested_if.ConstGoto.diff
deleted file mode 100644
index 1768298d521..00000000000
--- a/tests/mir-opt/const_goto_storage.match_nested_if.ConstGoto.diff
+++ /dev/null
@@ -1,102 +0,0 @@
-- // MIR for `match_nested_if` before ConstGoto
-+ // MIR for `match_nested_if` after ConstGoto
-  
-  fn match_nested_if() -> bool {
-      let mut _0: bool;
-      let _1: bool;
--     let mut _2: ();
--     let mut _3: bool;
--     let mut _4: bool;
--     let mut _5: bool;
--     let mut _6: bool;
-+     let mut _2: bool;
-      scope 1 {
-          debug val => _1;
-      }
-  
-      bb0: {
-          StorageLive(_1);
-          StorageLive(_2);
--         _2 = ();
--         StorageLive(_3);
--         StorageLive(_4);
--         StorageLive(_5);
--         StorageLive(_6);
--         _6 = const true;
--         switchInt(move _6) -> [0: bb2, otherwise: bb1];
-+         _2 = const true;
-+         switchInt(move _2) -> [0: bb2, otherwise: bb1];
-      }
-  
-      bb1: {
--         _5 = const true;
-+         StorageDead(_2);
-+         _1 = const true;
-          goto -> bb3;
-      }
-  
-      bb2: {
--         _5 = const false;
-+         StorageDead(_2);
-+         _1 = const false;
-          goto -> bb3;
-      }
-  
-      bb3: {
--         switchInt(move _5) -> [0: bb5, otherwise: bb4];
--     }
-- 
--     bb4: {
--         StorageDead(_6);
--         _4 = const true;
--         goto -> bb6;
--     }
-- 
--     bb5: {
--         StorageDead(_6);
--         _4 = const false;
--         goto -> bb6;
--     }
-- 
--     bb6: {
--         switchInt(move _4) -> [0: bb8, otherwise: bb7];
--     }
-- 
--     bb7: {
--         StorageDead(_5);
--         _3 = const true;
--         goto -> bb9;
--     }
-- 
--     bb8: {
--         StorageDead(_5);
--         _3 = const false;
--         goto -> bb9;
--     }
-- 
--     bb9: {
--         switchInt(move _3) -> [0: bb11, otherwise: bb10];
--     }
-- 
--     bb10: {
--         StorageDead(_4);
--         StorageDead(_3);
--         _1 = const true;
--         goto -> bb12;
--     }
-- 
--     bb11: {
--         StorageDead(_4);
--         StorageDead(_3);
--         _1 = const false;
--         goto -> bb12;
--     }
-- 
--     bb12: {
--         StorageDead(_2);
-          _0 = _1;
-          StorageDead(_1);
-          return;
-      }
-  }
-  
diff --git a/tests/mir-opt/const_goto_storage.rs b/tests/mir-opt/const_goto_storage.rs
deleted file mode 100644
index 9d43da23990..00000000000
--- a/tests/mir-opt/const_goto_storage.rs
+++ /dev/null
@@ -1,22 +0,0 @@
-// skip-filecheck
-// unit-test: ConstGoto
-
-// EMIT_MIR const_goto_storage.match_nested_if.ConstGoto.diff
-fn match_nested_if() -> bool {
-    let val = match () {
-        () if if if if true { true } else { false } { true } else { false } {
-            true
-        } else {
-            false
-        } =>
-            {
-                true
-            }
-        _ => false,
-    };
-    val
-}
-
-fn main() {
-    let _ = match_nested_if();
-}
diff --git a/tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.mir
index cf7feef0051..f1d0da28b4e 100644
--- a/tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.mir
+++ b/tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.mir
@@ -4,66 +4,12 @@ fn step_forward(_1: u32, _2: usize) -> u32 {
     debug x => _1;
     debug n => _2;
     let mut _0: u32;
-    scope 1 (inlined <u32 as Step>::forward) {
-        debug start => _1;
-        debug n => _2;
-        let _3: std::option::Option<u32>;
-        let mut _4: &std::option::Option<u32>;
-        let mut _7: bool;
-        let mut _8: u32;
-        scope 2 {
-        }
-        scope 3 (inlined Option::<u32>::is_none) {
-            debug self => _4;
-            let mut _6: bool;
-            scope 4 (inlined Option::<u32>::is_some) {
-                debug self => _4;
-                let mut _5: isize;
-            }
-        }
-        scope 5 (inlined core::num::<impl u32>::wrapping_add) {
-            debug self => _1;
-            debug rhs => _8;
-        }
-    }
 
     bb0: {
-        StorageLive(_7);
-        StorageLive(_4);
-        StorageLive(_3);
-        _3 = <u32 as Step>::forward_checked(_1, _2) -> [return: bb1, unwind continue];
+        _0 = <u32 as Step>::forward(move _1, move _2) -> [return: bb1, unwind continue];
     }
 
     bb1: {
-        _4 = &_3;
-        StorageLive(_6);
-        StorageLive(_5);
-        _5 = discriminant(_3);
-        _6 = Eq(_5, const 1_isize);
-        StorageDead(_5);
-        _7 = Not(move _6);
-        StorageDead(_6);
-        switchInt(move _7) -> [0: bb2, otherwise: bb3];
-    }
-
-    bb2: {
-        StorageDead(_3);
-        StorageDead(_4);
-        goto -> bb4;
-    }
-
-    bb3: {
-        StorageDead(_3);
-        StorageDead(_4);
-        assert(!const true, "attempt to compute `{} + {}`, which would overflow", const _, const 1_u32) -> [success: bb4, unwind continue];
-    }
-
-    bb4: {
-        StorageDead(_7);
-        StorageLive(_8);
-        _8 = _2 as u32 (IntToInt);
-        _0 = Add(_1, _8);
-        StorageDead(_8);
         return;
     }
 }
diff --git a/tests/mir-opt/pre-codegen/loops.int_range.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/loops.int_range.PreCodegen.after.mir
index e27e417ed4a..0b5ed6ee169 100644
--- a/tests/mir-opt/pre-codegen/loops.int_range.PreCodegen.after.mir
+++ b/tests/mir-opt/pre-codegen/loops.int_range.PreCodegen.after.mir
@@ -7,14 +7,13 @@ fn int_range(_1: usize, _2: usize) -> () {
     let mut _3: std::ops::Range<usize>;
     let mut _4: std::ops::Range<usize>;
     let mut _5: &mut std::ops::Range<usize>;
-    let mut _11: std::option::Option<usize>;
-    let mut _14: isize;
-    let _16: ();
+    let mut _13: std::option::Option<usize>;
+    let _15: ();
     scope 1 {
         debug iter => _4;
-        let _15: usize;
+        let _14: usize;
         scope 2 {
-            debug i => _15;
+            debug i => _14;
         }
         scope 4 (inlined iter::range::<impl Iterator for std::ops::Range<usize>>::next) {
             debug self => _5;
@@ -23,10 +22,10 @@ fn int_range(_1: usize, _2: usize) -> () {
                 let mut _6: &usize;
                 let mut _7: &usize;
                 let mut _10: bool;
-                let _12: usize;
-                let mut _13: usize;
+                let _11: usize;
+                let mut _12: usize;
                 scope 6 {
-                    debug old => _12;
+                    debug old => _11;
                     scope 7 {
                     }
                 }
@@ -51,9 +50,9 @@ fn int_range(_1: usize, _2: usize) -> () {
     }
 
     bb1: {
-        StorageLive(_11);
+        StorageLive(_13);
         _5 = &mut _4;
-        StorageLive(_12);
+        StorageLive(_11);
         StorageLive(_10);
         StorageLive(_6);
         _6 = &(_4.0: usize);
@@ -72,53 +71,33 @@ fn int_range(_1: usize, _2: usize) -> () {
     bb2: {
         StorageDead(_7);
         StorageDead(_6);
-        _11 = const Option::<usize>::None;
-        goto -> bb5;
+        StorageDead(_10);
+        StorageDead(_11);
+        StorageDead(_13);
+        StorageDead(_4);
+        return;
     }
 
     bb3: {
         StorageDead(_7);
         StorageDead(_6);
-        _12 = (_4.0: usize);
-        StorageLive(_13);
-        _13 = <usize as Step>::forward_unchecked(_12, const 1_usize) -> [return: bb4, unwind continue];
+        _11 = (_4.0: usize);
+        StorageLive(_12);
+        _12 = <usize as Step>::forward_unchecked(_11, const 1_usize) -> [return: bb4, unwind continue];
     }
 
     bb4: {
-        (_4.0: usize) = move _13;
-        StorageDead(_13);
-        _11 = Option::<usize>::Some(_12);
-        goto -> bb5;
-    }
-
-    bb5: {
-        StorageDead(_10);
+        (_4.0: usize) = move _12;
         StorageDead(_12);
-        _14 = discriminant(_11);
-        switchInt(move _14) -> [0: bb6, 1: bb7, otherwise: bb9];
-    }
-
-    bb6: {
+        _13 = Option::<usize>::Some(_11);
+        StorageDead(_10);
         StorageDead(_11);
-        StorageDead(_4);
-        return;
-    }
-
-    bb7: {
-        _15 = ((_11 as Some).0: usize);
-        _16 = opaque::<usize>(move _15) -> [return: bb8, unwind continue];
+        _14 = ((_13 as Some).0: usize);
+        _15 = opaque::<usize>(move _14) -> [return: bb5, unwind continue];
     }
 
-    bb8: {
-        StorageDead(_11);
+    bb5: {
+        StorageDead(_13);
         goto -> bb1;
     }
-
-    bb9: {
-        unreachable;
-    }
-}
-
-ALLOC0 (size: 16, align: 8) {
-    00 00 00 00 00 00 00 00 __ __ __ __ __ __ __ __ │ ........░░░░░░░░
 }
diff --git a/tests/mir-opt/pre-codegen/matches_macro.issue_77355_opt.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/matches_macro.issue_77355_opt.PreCodegen.after.mir
new file mode 100644
index 00000000000..d41135c6a4f
--- /dev/null
+++ b/tests/mir-opt/pre-codegen/matches_macro.issue_77355_opt.PreCodegen.after.mir
@@ -0,0 +1,22 @@
+// MIR for `issue_77355_opt` after PreCodegen
+
+fn issue_77355_opt(_1: Foo) -> u64 {
+    debug num => _1;
+    let mut _0: u64;
+    let mut _2: isize;
+
+    bb0: {
+        _2 = discriminant(_1);
+        switchInt(move _2) -> [1: bb1, 2: bb1, otherwise: bb2];
+    }
+
+    bb1: {
+        _0 = const 23_u64;
+        return;
+    }
+
+    bb2: {
+        _0 = const 42_u64;
+        return;
+    }
+}
diff --git a/tests/mir-opt/pre-codegen/matches_macro.rs b/tests/mir-opt/pre-codegen/matches_macro.rs
new file mode 100644
index 00000000000..42de2296571
--- /dev/null
+++ b/tests/mir-opt/pre-codegen/matches_macro.rs
@@ -0,0 +1,27 @@
+// This test verifies that the MIR we output using the `matches!()` macro is close
+// to the MIR for an `if let` branch.
+
+pub enum Foo {
+    A,
+    B,
+    C,
+    D,
+    E,
+    F,
+}
+
+// EMIT_MIR matches_macro.issue_77355_opt.PreCodegen.after.mir
+fn issue_77355_opt(num: Foo) -> u64 {
+    // CHECK-LABEL: fn issue_77355_opt(
+    // CHECK: switchInt({{.*}}) -> [1: bb1, 2: bb1, otherwise: bb2];
+    // CHECK: bb1: {
+    // CHECK-NEXT: _0 = const 23_u64;
+    // CHECK-NEXT: return;
+    // CHECK: bb2: {
+    // CHECK-NEXT: _0 = const 42_u64;
+    // CHECK-NEXT: return;
+    if matches!(num, Foo::B | Foo::C) { 23 } else { 42 }
+}
+fn main() {
+    issue_77355_opt(Foo::A);
+}
diff --git a/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-abort.mir
index 99805da5669..ed965770adb 100644
--- a/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-abort.mir
+++ b/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-abort.mir
@@ -8,16 +8,15 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () {
     let mut _4: std::ops::Range<u32>;
     let mut _5: std::ops::Range<u32>;
     let mut _6: &mut std::ops::Range<u32>;
-    let mut _12: std::option::Option<u32>;
-    let mut _15: isize;
-    let mut _17: &impl Fn(u32);
-    let mut _18: (u32,);
-    let _19: ();
+    let mut _14: std::option::Option<u32>;
+    let mut _16: &impl Fn(u32);
+    let mut _17: (u32,);
+    let _18: ();
     scope 1 {
         debug iter => _5;
-        let _16: u32;
+        let _15: u32;
         scope 2 {
-            debug x => _16;
+            debug x => _15;
         }
         scope 4 (inlined iter::range::<impl Iterator for std::ops::Range<u32>>::next) {
             debug self => _6;
@@ -26,10 +25,10 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () {
                 let mut _7: &u32;
                 let mut _8: &u32;
                 let mut _11: bool;
-                let _13: u32;
-                let mut _14: u32;
+                let _12: u32;
+                let mut _13: u32;
                 scope 6 {
-                    debug old => _13;
+                    debug old => _12;
                     scope 7 {
                     }
                 }
@@ -54,9 +53,9 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () {
     }
 
     bb1: {
-        StorageLive(_12);
+        StorageLive(_14);
         _6 = &mut _5;
-        StorageLive(_13);
+        StorageLive(_12);
         StorageLive(_11);
         StorageLive(_7);
         _7 = &(_5.0: u32);
@@ -69,69 +68,49 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () {
         _11 = Lt(move _9, move _10);
         StorageDead(_10);
         StorageDead(_9);
-        switchInt(move _11) -> [0: bb2, otherwise: bb3];
+        switchInt(move _11) -> [0: bb2, otherwise: bb4];
     }
 
     bb2: {
         StorageDead(_8);
         StorageDead(_7);
-        _12 = const Option::<u32>::None;
-        goto -> bb5;
+        StorageDead(_11);
+        StorageDead(_12);
+        StorageDead(_14);
+        StorageDead(_5);
+        drop(_3) -> [return: bb3, unwind unreachable];
     }
 
     bb3: {
-        StorageDead(_8);
-        StorageDead(_7);
-        _13 = (_5.0: u32);
-        StorageLive(_14);
-        _14 = <u32 as Step>::forward_unchecked(_13, const 1_usize) -> [return: bb4, unwind unreachable];
+        return;
     }
 
     bb4: {
-        (_5.0: u32) = move _14;
-        StorageDead(_14);
-        _12 = Option::<u32>::Some(_13);
-        goto -> bb5;
+        StorageDead(_8);
+        StorageDead(_7);
+        _12 = (_5.0: u32);
+        StorageLive(_13);
+        _13 = <u32 as Step>::forward_unchecked(_12, const 1_usize) -> [return: bb5, unwind unreachable];
     }
 
     bb5: {
-        StorageDead(_11);
+        (_5.0: u32) = move _13;
         StorageDead(_13);
-        _15 = discriminant(_12);
-        switchInt(move _15) -> [0: bb6, 1: bb8, otherwise: bb10];
-    }
-
-    bb6: {
+        _14 = Option::<u32>::Some(_12);
+        StorageDead(_11);
         StorageDead(_12);
-        StorageDead(_5);
-        drop(_3) -> [return: bb7, unwind unreachable];
-    }
-
-    bb7: {
-        return;
-    }
-
-    bb8: {
-        _16 = ((_12 as Some).0: u32);
+        _15 = ((_14 as Some).0: u32);
+        StorageLive(_16);
+        _16 = &_3;
         StorageLive(_17);
-        _17 = &_3;
-        StorageLive(_18);
-        _18 = (_16,);
-        _19 = <impl Fn(u32) as Fn<(u32,)>>::call(move _17, move _18) -> [return: bb9, unwind unreachable];
+        _17 = (_15,);
+        _18 = <impl Fn(u32) as Fn<(u32,)>>::call(move _16, move _17) -> [return: bb6, unwind unreachable];
     }
 
-    bb9: {
-        StorageDead(_18);
+    bb6: {
         StorageDead(_17);
-        StorageDead(_12);
+        StorageDead(_16);
+        StorageDead(_14);
         goto -> bb1;
     }
-
-    bb10: {
-        unreachable;
-    }
-}
-
-ALLOC0 (size: 8, align: 4) {
-    00 00 00 00 __ __ __ __                         │ ....░░░░
 }
diff --git a/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-unwind.mir
index f40f1307175..a7ee9be19bd 100644
--- a/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-unwind.mir
+++ b/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-unwind.mir
@@ -8,16 +8,15 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () {
     let mut _4: std::ops::Range<u32>;
     let mut _5: std::ops::Range<u32>;
     let mut _6: &mut std::ops::Range<u32>;
-    let mut _12: std::option::Option<u32>;
-    let mut _15: isize;
-    let mut _17: &impl Fn(u32);
-    let mut _18: (u32,);
-    let _19: ();
+    let mut _14: std::option::Option<u32>;
+    let mut _16: &impl Fn(u32);
+    let mut _17: (u32,);
+    let _18: ();
     scope 1 {
         debug iter => _5;
-        let _16: u32;
+        let _15: u32;
         scope 2 {
-            debug x => _16;
+            debug x => _15;
         }
         scope 4 (inlined iter::range::<impl Iterator for std::ops::Range<u32>>::next) {
             debug self => _6;
@@ -26,10 +25,10 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () {
                 let mut _7: &u32;
                 let mut _8: &u32;
                 let mut _11: bool;
-                let _13: u32;
-                let mut _14: u32;
+                let _12: u32;
+                let mut _13: u32;
                 scope 6 {
-                    debug old => _13;
+                    debug old => _12;
                     scope 7 {
                     }
                 }
@@ -54,9 +53,9 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () {
     }
 
     bb1: {
-        StorageLive(_12);
+        StorageLive(_14);
         _6 = &mut _5;
-        StorageLive(_13);
+        StorageLive(_12);
         StorageLive(_11);
         StorageLive(_7);
         _7 = &(_5.0: u32);
@@ -69,77 +68,57 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () {
         _11 = Lt(move _9, move _10);
         StorageDead(_10);
         StorageDead(_9);
-        switchInt(move _11) -> [0: bb2, otherwise: bb3];
+        switchInt(move _11) -> [0: bb2, otherwise: bb4];
     }
 
     bb2: {
         StorageDead(_8);
         StorageDead(_7);
-        _12 = const Option::<u32>::None;
-        goto -> bb5;
+        StorageDead(_11);
+        StorageDead(_12);
+        StorageDead(_14);
+        StorageDead(_5);
+        drop(_3) -> [return: bb3, unwind continue];
     }
 
     bb3: {
-        StorageDead(_8);
-        StorageDead(_7);
-        _13 = (_5.0: u32);
-        StorageLive(_14);
-        _14 = <u32 as Step>::forward_unchecked(_13, const 1_usize) -> [return: bb4, unwind: bb11];
+        return;
     }
 
     bb4: {
-        (_5.0: u32) = move _14;
-        StorageDead(_14);
-        _12 = Option::<u32>::Some(_13);
-        goto -> bb5;
+        StorageDead(_8);
+        StorageDead(_7);
+        _12 = (_5.0: u32);
+        StorageLive(_13);
+        _13 = <u32 as Step>::forward_unchecked(_12, const 1_usize) -> [return: bb5, unwind: bb7];
     }
 
     bb5: {
-        StorageDead(_11);
+        (_5.0: u32) = move _13;
         StorageDead(_13);
-        _15 = discriminant(_12);
-        switchInt(move _15) -> [0: bb6, 1: bb8, otherwise: bb10];
-    }
-
-    bb6: {
+        _14 = Option::<u32>::Some(_12);
+        StorageDead(_11);
         StorageDead(_12);
-        StorageDead(_5);
-        drop(_3) -> [return: bb7, unwind continue];
-    }
-
-    bb7: {
-        return;
-    }
-
-    bb8: {
-        _16 = ((_12 as Some).0: u32);
+        _15 = ((_14 as Some).0: u32);
+        StorageLive(_16);
+        _16 = &_3;
         StorageLive(_17);
-        _17 = &_3;
-        StorageLive(_18);
-        _18 = (_16,);
-        _19 = <impl Fn(u32) as Fn<(u32,)>>::call(move _17, move _18) -> [return: bb9, unwind: bb11];
+        _17 = (_15,);
+        _18 = <impl Fn(u32) as Fn<(u32,)>>::call(move _16, move _17) -> [return: bb6, unwind: bb7];
     }
 
-    bb9: {
-        StorageDead(_18);
+    bb6: {
         StorageDead(_17);
-        StorageDead(_12);
+        StorageDead(_16);
+        StorageDead(_14);
         goto -> bb1;
     }
 
-    bb10: {
-        unreachable;
+    bb7 (cleanup): {
+        drop(_3) -> [return: bb8, unwind terminate(cleanup)];
     }
 
-    bb11 (cleanup): {
-        drop(_3) -> [return: bb12, unwind terminate(cleanup)];
-    }
-
-    bb12 (cleanup): {
+    bb8 (cleanup): {
         resume;
     }
 }
-
-ALLOC0 (size: 8, align: 4) {
-    00 00 00 00 __ __ __ __                         │ ....░░░░
-}
diff --git a/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-abort.mir
index 83915d3c449..543e8918e39 100644
--- a/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-abort.mir
+++ b/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-abort.mir
@@ -8,21 +8,20 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () {
     let mut _4: std::ops::Range<usize>;
     let mut _5: std::ops::Range<usize>;
     let mut _6: &mut std::ops::Range<usize>;
-    let mut _12: std::option::Option<usize>;
-    let mut _15: isize;
-    let mut _17: usize;
-    let mut _18: bool;
-    let mut _20: &impl Fn(usize, &T);
-    let mut _21: (usize, &T);
-    let _22: ();
+    let mut _14: std::option::Option<usize>;
+    let mut _16: usize;
+    let mut _17: bool;
+    let mut _19: &impl Fn(usize, &T);
+    let mut _20: (usize, &T);
+    let _21: ();
     scope 1 {
         debug iter => _5;
-        let _16: usize;
+        let _15: usize;
         scope 2 {
-            debug i => _16;
-            let _19: &T;
+            debug i => _15;
+            let _18: &T;
             scope 3 {
-                debug x => _19;
+                debug x => _18;
             }
         }
         scope 5 (inlined iter::range::<impl Iterator for std::ops::Range<usize>>::next) {
@@ -32,10 +31,10 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () {
                 let mut _7: &usize;
                 let mut _8: &usize;
                 let mut _11: bool;
-                let _13: usize;
-                let mut _14: usize;
+                let _12: usize;
+                let mut _13: usize;
                 scope 7 {
-                    debug old => _13;
+                    debug old => _12;
                     scope 8 {
                     }
                 }
@@ -63,9 +62,9 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () {
     }
 
     bb1: {
-        StorageLive(_12);
+        StorageLive(_14);
         _6 = &mut _5;
-        StorageLive(_13);
+        StorageLive(_12);
         StorageLive(_11);
         StorageLive(_7);
         _7 = &(_5.0: usize);
@@ -78,76 +77,56 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () {
         _11 = Lt(move _9, move _10);
         StorageDead(_10);
         StorageDead(_9);
-        switchInt(move _11) -> [0: bb2, otherwise: bb3];
+        switchInt(move _11) -> [0: bb2, otherwise: bb4];
     }
 
     bb2: {
         StorageDead(_8);
         StorageDead(_7);
-        _12 = const Option::<usize>::None;
-        goto -> bb5;
+        StorageDead(_11);
+        StorageDead(_12);
+        StorageDead(_14);
+        StorageDead(_5);
+        drop(_2) -> [return: bb3, unwind unreachable];
     }
 
     bb3: {
-        StorageDead(_8);
-        StorageDead(_7);
-        _13 = (_5.0: usize);
-        StorageLive(_14);
-        _14 = <usize as Step>::forward_unchecked(_13, const 1_usize) -> [return: bb4, unwind unreachable];
+        return;
     }
 
     bb4: {
-        (_5.0: usize) = move _14;
-        StorageDead(_14);
-        _12 = Option::<usize>::Some(_13);
-        goto -> bb5;
+        StorageDead(_8);
+        StorageDead(_7);
+        _12 = (_5.0: usize);
+        StorageLive(_13);
+        _13 = <usize as Step>::forward_unchecked(_12, const 1_usize) -> [return: bb5, unwind unreachable];
     }
 
     bb5: {
-        StorageDead(_11);
+        (_5.0: usize) = move _13;
         StorageDead(_13);
-        _15 = discriminant(_12);
-        switchInt(move _15) -> [0: bb6, 1: bb8, otherwise: bb11];
-    }
-
-    bb6: {
+        _14 = Option::<usize>::Some(_12);
+        StorageDead(_11);
         StorageDead(_12);
-        StorageDead(_5);
-        drop(_2) -> [return: bb7, unwind unreachable];
-    }
-
-    bb7: {
-        return;
-    }
-
-    bb8: {
-        _16 = ((_12 as Some).0: usize);
-        _17 = Len((*_1));
-        _18 = Lt(_16, _17);
-        assert(move _18, "index out of bounds: the length is {} but the index is {}", move _17, _16) -> [success: bb9, unwind unreachable];
+        _15 = ((_14 as Some).0: usize);
+        _16 = Len((*_1));
+        _17 = Lt(_15, _16);
+        assert(move _17, "index out of bounds: the length is {} but the index is {}", move _16, _15) -> [success: bb6, unwind unreachable];
     }
 
-    bb9: {
-        _19 = &(*_1)[_16];
+    bb6: {
+        _18 = &(*_1)[_15];
+        StorageLive(_19);
+        _19 = &_2;
         StorageLive(_20);
-        _20 = &_2;
-        StorageLive(_21);
-        _21 = (_16, _19);
-        _22 = <impl Fn(usize, &T) as Fn<(usize, &T)>>::call(move _20, move _21) -> [return: bb10, unwind unreachable];
+        _20 = (_15, _18);
+        _21 = <impl Fn(usize, &T) as Fn<(usize, &T)>>::call(move _19, move _20) -> [return: bb7, unwind unreachable];
     }
 
-    bb10: {
-        StorageDead(_21);
+    bb7: {
         StorageDead(_20);
-        StorageDead(_12);
+        StorageDead(_19);
+        StorageDead(_14);
         goto -> bb1;
     }
-
-    bb11: {
-        unreachable;
-    }
-}
-
-ALLOC0 (size: 16, align: 8) {
-    00 00 00 00 00 00 00 00 __ __ __ __ __ __ __ __ │ ........░░░░░░░░
 }
diff --git a/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-unwind.mir
index 0a005a460e8..a16e9cd9e51 100644
--- a/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-unwind.mir
+++ b/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-unwind.mir
@@ -8,21 +8,20 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () {
     let mut _4: std::ops::Range<usize>;
     let mut _5: std::ops::Range<usize>;
     let mut _6: &mut std::ops::Range<usize>;
-    let mut _12: std::option::Option<usize>;
-    let mut _15: isize;
-    let mut _17: usize;
-    let mut _18: bool;
-    let mut _20: &impl Fn(usize, &T);
-    let mut _21: (usize, &T);
-    let _22: ();
+    let mut _14: std::option::Option<usize>;
+    let mut _16: usize;
+    let mut _17: bool;
+    let mut _19: &impl Fn(usize, &T);
+    let mut _20: (usize, &T);
+    let _21: ();
     scope 1 {
         debug iter => _5;
-        let _16: usize;
+        let _15: usize;
         scope 2 {
-            debug i => _16;
-            let _19: &T;
+            debug i => _15;
+            let _18: &T;
             scope 3 {
-                debug x => _19;
+                debug x => _18;
             }
         }
         scope 5 (inlined iter::range::<impl Iterator for std::ops::Range<usize>>::next) {
@@ -32,10 +31,10 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () {
                 let mut _7: &usize;
                 let mut _8: &usize;
                 let mut _11: bool;
-                let _13: usize;
-                let mut _14: usize;
+                let _12: usize;
+                let mut _13: usize;
                 scope 7 {
-                    debug old => _13;
+                    debug old => _12;
                     scope 8 {
                     }
                 }
@@ -63,9 +62,9 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () {
     }
 
     bb1: {
-        StorageLive(_12);
+        StorageLive(_14);
         _6 = &mut _5;
-        StorageLive(_13);
+        StorageLive(_12);
         StorageLive(_11);
         StorageLive(_7);
         _7 = &(_5.0: usize);
@@ -78,84 +77,64 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () {
         _11 = Lt(move _9, move _10);
         StorageDead(_10);
         StorageDead(_9);
-        switchInt(move _11) -> [0: bb2, otherwise: bb3];
+        switchInt(move _11) -> [0: bb2, otherwise: bb4];
     }
 
     bb2: {
         StorageDead(_8);
         StorageDead(_7);
-        _12 = const Option::<usize>::None;
-        goto -> bb5;
+        StorageDead(_11);
+        StorageDead(_12);
+        StorageDead(_14);
+        StorageDead(_5);
+        drop(_2) -> [return: bb3, unwind continue];
     }
 
     bb3: {
-        StorageDead(_8);
-        StorageDead(_7);
-        _13 = (_5.0: usize);
-        StorageLive(_14);
-        _14 = <usize as Step>::forward_unchecked(_13, const 1_usize) -> [return: bb4, unwind: bb12];
+        return;
     }
 
     bb4: {
-        (_5.0: usize) = move _14;
-        StorageDead(_14);
-        _12 = Option::<usize>::Some(_13);
-        goto -> bb5;
+        StorageDead(_8);
+        StorageDead(_7);
+        _12 = (_5.0: usize);
+        StorageLive(_13);
+        _13 = <usize as Step>::forward_unchecked(_12, const 1_usize) -> [return: bb5, unwind: bb8];
     }
 
     bb5: {
-        StorageDead(_11);
+        (_5.0: usize) = move _13;
         StorageDead(_13);
-        _15 = discriminant(_12);
-        switchInt(move _15) -> [0: bb6, 1: bb8, otherwise: bb11];
-    }
-
-    bb6: {
+        _14 = Option::<usize>::Some(_12);
+        StorageDead(_11);
         StorageDead(_12);
-        StorageDead(_5);
-        drop(_2) -> [return: bb7, unwind continue];
-    }
-
-    bb7: {
-        return;
-    }
-
-    bb8: {
-        _16 = ((_12 as Some).0: usize);
-        _17 = Len((*_1));
-        _18 = Lt(_16, _17);
-        assert(move _18, "index out of bounds: the length is {} but the index is {}", move _17, _16) -> [success: bb9, unwind: bb12];
+        _15 = ((_14 as Some).0: usize);
+        _16 = Len((*_1));
+        _17 = Lt(_15, _16);
+        assert(move _17, "index out of bounds: the length is {} but the index is {}", move _16, _15) -> [success: bb6, unwind: bb8];
     }
 
-    bb9: {
-        _19 = &(*_1)[_16];
+    bb6: {
+        _18 = &(*_1)[_15];
+        StorageLive(_19);
+        _19 = &_2;
         StorageLive(_20);
-        _20 = &_2;
-        StorageLive(_21);
-        _21 = (_16, _19);
-        _22 = <impl Fn(usize, &T) as Fn<(usize, &T)>>::call(move _20, move _21) -> [return: bb10, unwind: bb12];
+        _20 = (_15, _18);
+        _21 = <impl Fn(usize, &T) as Fn<(usize, &T)>>::call(move _19, move _20) -> [return: bb7, unwind: bb8];
     }
 
-    bb10: {
-        StorageDead(_21);
+    bb7: {
         StorageDead(_20);
-        StorageDead(_12);
+        StorageDead(_19);
+        StorageDead(_14);
         goto -> bb1;
     }
 
-    bb11: {
-        unreachable;
+    bb8 (cleanup): {
+        drop(_2) -> [return: bb9, unwind terminate(cleanup)];
     }
 
-    bb12 (cleanup): {
-        drop(_2) -> [return: bb13, unwind terminate(cleanup)];
-    }
-
-    bb13 (cleanup): {
+    bb9 (cleanup): {
         resume;
     }
 }
-
-ALLOC0 (size: 16, align: 8) {
-    00 00 00 00 00 00 00 00 __ __ __ __ __ __ __ __ │ ........░░░░░░░░
-}
diff --git a/tests/mir-opt/pre-codegen/try_identity.new.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/try_identity.new.PreCodegen.after.mir
index c1d4d4871d0..16d6d9719b6 100644
--- a/tests/mir-opt/pre-codegen/try_identity.new.PreCodegen.after.mir
+++ b/tests/mir-opt/pre-codegen/try_identity.new.PreCodegen.after.mir
@@ -6,65 +6,51 @@ fn new(_1: Result<T, E>) -> Result<T, E> {
     let mut _2: isize;
     let _3: T;
     let mut _4: std::ops::ControlFlow<E, T>;
-    let _5: E;
-    let mut _6: isize;
-    let _7: T;
-    let _8: E;
+    let _5: T;
+    let _6: E;
+    let _7: E;
     scope 1 {
         debug v => _3;
     }
     scope 2 {
-        debug e => _5;
+        debug e => _6;
     }
     scope 3 {
-        debug v => _7;
+        debug v => _5;
     }
     scope 4 {
-        debug e => _8;
+        debug e => _7;
     }
 
     bb0: {
         StorageLive(_4);
         _2 = discriminant(_1);
-        switchInt(move _2) -> [0: bb1, 1: bb2, otherwise: bb7];
+        switchInt(move _2) -> [0: bb1, 1: bb2, otherwise: bb4];
     }
 
     bb1: {
         _3 = move ((_1 as Ok).0: T);
         _4 = ControlFlow::<E, T>::Continue(_3);
+        _5 = move ((_4 as Continue).0: T);
+        _0 = Result::<T, E>::Ok(_5);
+        StorageDead(_4);
         goto -> bb3;
     }
 
     bb2: {
-        _5 = move ((_1 as Err).0: E);
-        _4 = ControlFlow::<E, T>::Break(_5);
+        _6 = move ((_1 as Err).0: E);
+        _4 = ControlFlow::<E, T>::Break(_6);
+        _7 = move ((_4 as Break).0: E);
+        _0 = Result::<T, E>::Err(_7);
+        StorageDead(_4);
         goto -> bb3;
     }
 
     bb3: {
-        _6 = discriminant(_4);
-        switchInt(move _6) -> [0: bb4, 1: bb5, otherwise: bb7];
-    }
-
-    bb4: {
-        _7 = move ((_4 as Continue).0: T);
-        _0 = Result::<T, E>::Ok(_7);
-        StorageDead(_4);
-        goto -> bb6;
-    }
-
-    bb5: {
-        _8 = move ((_4 as Break).0: E);
-        _0 = Result::<T, E>::Err(_8);
-        StorageDead(_4);
-        goto -> bb6;
-    }
-
-    bb6: {
         return;
     }
 
-    bb7: {
+    bb4: {
         unreachable;
     }
 }
diff --git a/tests/mir-opt/separate_const_switch.identity.SeparateConstSwitch.diff b/tests/mir-opt/separate_const_switch.identity.JumpThreading.diff
index d2731615284..ab3d91ab918 100644
--- a/tests/mir-opt/separate_const_switch.identity.SeparateConstSwitch.diff
+++ b/tests/mir-opt/separate_const_switch.identity.JumpThreading.diff
@@ -1,5 +1,5 @@
-- // MIR for `identity` before SeparateConstSwitch
-+ // MIR for `identity` after SeparateConstSwitch
+- // MIR for `identity` before JumpThreading
++ // MIR for `identity` after JumpThreading
   
   fn identity(_1: Result<i32, i32>) -> Result<i32, i32> {
       debug x => _1;
@@ -79,7 +79,8 @@
           StorageDead(_8);
           StorageDead(_3);
           _4 = discriminant(_2);
-          switchInt(move _4) -> [0: bb1, 1: bb2, otherwise: bb6];
+-         switchInt(move _4) -> [0: bb1, 1: bb2, otherwise: bb6];
++         goto -> bb1;
       }
   
       bb4: {
@@ -88,7 +89,8 @@
           _11 = Result::<Infallible, i32>::Err(_10);
           _2 = ControlFlow::<Result<Infallible, i32>, i32>::Break(move _11);
           StorageDead(_11);
-          goto -> bb3;
+-         goto -> bb3;
++         goto -> bb7;
       }
   
       bb5: {
@@ -99,6 +101,15 @@
   
       bb6: {
           unreachable;
++     }
++ 
++     bb7: {
++         StorageDead(_10);
++         StorageDead(_9);
++         StorageDead(_8);
++         StorageDead(_3);
++         _4 = discriminant(_2);
++         goto -> bb2;
       }
   }
   
diff --git a/tests/mir-opt/separate_const_switch.rs b/tests/mir-opt/separate_const_switch.rs
index 3f43cdf4350..bad61d97475 100644
--- a/tests/mir-opt/separate_const_switch.rs
+++ b/tests/mir-opt/separate_const_switch.rs
@@ -6,7 +6,7 @@
 
 use std::ops::ControlFlow;
 
-// EMIT_MIR separate_const_switch.too_complex.SeparateConstSwitch.diff
+// EMIT_MIR separate_const_switch.too_complex.JumpThreading.diff
 fn too_complex(x: Result<i32, usize>) -> Option<i32> {
     // The pass should break the outer match into
     // two blocks that only have one parent each.
@@ -23,7 +23,7 @@ fn too_complex(x: Result<i32, usize>) -> Option<i32> {
     }
 }
 
-// EMIT_MIR separate_const_switch.identity.SeparateConstSwitch.diff
+// EMIT_MIR separate_const_switch.identity.JumpThreading.diff
 fn identity(x: Result<i32, i32>) -> Result<i32, i32> {
     Ok(x?)
 }
diff --git a/tests/mir-opt/separate_const_switch.too_complex.SeparateConstSwitch.diff b/tests/mir-opt/separate_const_switch.too_complex.JumpThreading.diff
index 294bfa661cf..1ac527e9338 100644
--- a/tests/mir-opt/separate_const_switch.too_complex.SeparateConstSwitch.diff
+++ b/tests/mir-opt/separate_const_switch.too_complex.JumpThreading.diff
@@ -1,5 +1,5 @@
-- // MIR for `too_complex` before SeparateConstSwitch
-+ // MIR for `too_complex` after SeparateConstSwitch
+- // MIR for `too_complex` before JumpThreading
++ // MIR for `too_complex` after JumpThreading
   
   fn too_complex(_1: Result<i32, usize>) -> Option<i32> {
       debug x => _1;
@@ -33,7 +33,8 @@
       bb1: {
           _5 = ((_1 as Err).0: usize);
           _2 = ControlFlow::<usize, i32>::Break(_5);
-          goto -> bb3;
+-         goto -> bb3;
++         goto -> bb8;
       }
   
       bb2: {
@@ -44,7 +45,8 @@
   
       bb3: {
           _6 = discriminant(_2);
-          switchInt(move _6) -> [0: bb5, 1: bb4, otherwise: bb7];
+-         switchInt(move _6) -> [0: bb5, 1: bb4, otherwise: bb7];
++         goto -> bb5;
       }
   
       bb4: {
@@ -68,6 +70,11 @@
   
       bb7: {
           unreachable;
++     }
++ 
++     bb8: {
++         _6 = discriminant(_2);
++         goto -> bb4;
       }
   }
   
diff --git a/tests/ui/array-slice-vec/check-static-mut-slices.rs b/tests/ui/array-slice-vec/check-static-mut-slices.rs
deleted file mode 100644
index b89c634036e..00000000000
--- a/tests/ui/array-slice-vec/check-static-mut-slices.rs
+++ /dev/null
@@ -1,15 +0,0 @@
-// run-pass
-#![allow(dead_code)]
-
-// Checks that mutable static items can have mutable slices
-
-
-static mut TEST: &'static mut [isize] = &mut [1];
-static mut EMPTY: &'static mut [isize] = &mut [];
-
-pub fn main() {
-    unsafe {
-        TEST[0] += 1;
-        assert_eq!(TEST[0], 2);
-    }
-}
diff --git a/tests/ui/asm/aarch64/type-check-4.rs b/tests/ui/asm/aarch64/type-check-4.rs
index 5dec60a2138..a14010481fc 100644
--- a/tests/ui/asm/aarch64/type-check-4.rs
+++ b/tests/ui/asm/aarch64/type-check-4.rs
@@ -23,10 +23,10 @@ const fn const_bar<T>(x: T) -> T {
     x
 }
 global_asm!("{}", const S);
-//~^ ERROR constants cannot refer to statics
+//~^ ERROR referencing statics
 global_asm!("{}", const const_foo(0));
 global_asm!("{}", const const_foo(S));
-//~^ ERROR constants cannot refer to statics
+//~^ ERROR referencing statics
 global_asm!("{}", const const_bar(0));
 global_asm!("{}", const const_bar(S));
-//~^ ERROR constants cannot refer to statics
+//~^ ERROR referencing statics
diff --git a/tests/ui/asm/aarch64/type-check-4.stderr b/tests/ui/asm/aarch64/type-check-4.stderr
index 4837e647bea..3e675f69e84 100644
--- a/tests/ui/asm/aarch64/type-check-4.stderr
+++ b/tests/ui/asm/aarch64/type-check-4.stderr
@@ -1,27 +1,39 @@
-error[E0013]: constants cannot refer to statics
+error[E0658]: referencing statics in constants is unstable
   --> $DIR/type-check-4.rs:25:25
    |
 LL | global_asm!("{}", const S);
    |                         ^
    |
-   = help: consider extracting the value of the `static` to a `const`, and referring to that
+   = note: see issue #119618 <https://github.com/rust-lang/rust/issues/119618> for more information
+   = help: add `#![feature(const_refs_to_static)]` to the crate attributes to enable
+   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
+   = note: `static` and `const` variables can refer to other `const` variables. A `const` variable, however, cannot refer to a `static` variable.
+   = help: to fix this, the value can be extracted to a `const` and then used.
 
-error[E0013]: constants cannot refer to statics
+error[E0658]: referencing statics in constants is unstable
   --> $DIR/type-check-4.rs:28:35
    |
 LL | global_asm!("{}", const const_foo(S));
    |                                   ^
    |
-   = help: consider extracting the value of the `static` to a `const`, and referring to that
+   = note: see issue #119618 <https://github.com/rust-lang/rust/issues/119618> for more information
+   = help: add `#![feature(const_refs_to_static)]` to the crate attributes to enable
+   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
+   = note: `static` and `const` variables can refer to other `const` variables. A `const` variable, however, cannot refer to a `static` variable.
+   = help: to fix this, the value can be extracted to a `const` and then used.
 
-error[E0013]: constants cannot refer to statics
+error[E0658]: referencing statics in constants is unstable
   --> $DIR/type-check-4.rs:31:35
    |
 LL | global_asm!("{}", const const_bar(S));
    |                                   ^
    |
-   = help: consider extracting the value of the `static` to a `const`, and referring to that
+   = note: see issue #119618 <https://github.com/rust-lang/rust/issues/119618> for more information
+   = help: add `#![feature(const_refs_to_static)]` to the crate attributes to enable
+   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
+   = note: `static` and `const` variables can refer to other `const` variables. A `const` variable, however, cannot refer to a `static` variable.
+   = help: to fix this, the value can be extracted to a `const` and then used.
 
 error: aborting due to 3 previous errors
 
-For more information about this error, try `rustc --explain E0013`.
+For more information about this error, try `rustc --explain E0658`.
diff --git a/tests/ui/asm/x86_64/type-check-4.rs b/tests/ui/asm/x86_64/type-check-4.rs
index 3d5d3807c53..d0dacda4afb 100644
--- a/tests/ui/asm/x86_64/type-check-4.rs
+++ b/tests/ui/asm/x86_64/type-check-4.rs
@@ -19,10 +19,10 @@ const fn const_bar<T>(x: T) -> T {
     x
 }
 global_asm!("{}", const S);
-//~^ ERROR constants cannot refer to statics
+//~^ ERROR referencing statics
 global_asm!("{}", const const_foo(0));
 global_asm!("{}", const const_foo(S));
-//~^ ERROR constants cannot refer to statics
+//~^ ERROR referencing statics
 global_asm!("{}", const const_bar(0));
 global_asm!("{}", const const_bar(S));
-//~^ ERROR constants cannot refer to statics
+//~^ ERROR referencing statics
diff --git a/tests/ui/asm/x86_64/type-check-4.stderr b/tests/ui/asm/x86_64/type-check-4.stderr
index 3875bcc2112..cbdc051b343 100644
--- a/tests/ui/asm/x86_64/type-check-4.stderr
+++ b/tests/ui/asm/x86_64/type-check-4.stderr
@@ -1,27 +1,39 @@
-error[E0013]: constants cannot refer to statics
+error[E0658]: referencing statics in constants is unstable
   --> $DIR/type-check-4.rs:21:25
    |
 LL | global_asm!("{}", const S);
    |                         ^
    |
-   = help: consider extracting the value of the `static` to a `const`, and referring to that
+   = note: see issue #119618 <https://github.com/rust-lang/rust/issues/119618> for more information
+   = help: add `#![feature(const_refs_to_static)]` to the crate attributes to enable
+   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
+   = note: `static` and `const` variables can refer to other `const` variables. A `const` variable, however, cannot refer to a `static` variable.
+   = help: to fix this, the value can be extracted to a `const` and then used.
 
-error[E0013]: constants cannot refer to statics
+error[E0658]: referencing statics in constants is unstable
   --> $DIR/type-check-4.rs:24:35
    |
 LL | global_asm!("{}", const const_foo(S));
    |                                   ^
    |
-   = help: consider extracting the value of the `static` to a `const`, and referring to that
+   = note: see issue #119618 <https://github.com/rust-lang/rust/issues/119618> for more information
+   = help: add `#![feature(const_refs_to_static)]` to the crate attributes to enable
+   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
+   = note: `static` and `const` variables can refer to other `const` variables. A `const` variable, however, cannot refer to a `static` variable.
+   = help: to fix this, the value can be extracted to a `const` and then used.
 
-error[E0013]: constants cannot refer to statics
+error[E0658]: referencing statics in constants is unstable
   --> $DIR/type-check-4.rs:27:35
    |
 LL | global_asm!("{}", const const_bar(S));
    |                                   ^
    |
-   = help: consider extracting the value of the `static` to a `const`, and referring to that
+   = note: see issue #119618 <https://github.com/rust-lang/rust/issues/119618> for more information
+   = help: add `#![feature(const_refs_to_static)]` to the crate attributes to enable
+   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
+   = note: `static` and `const` variables can refer to other `const` variables. A `const` variable, however, cannot refer to a `static` variable.
+   = help: to fix this, the value can be extracted to a `const` and then used.
 
 error: aborting due to 3 previous errors
 
-For more information about this error, try `rustc --explain E0013`.
+For more information about this error, try `rustc --explain E0658`.
diff --git a/tests/ui/associated-type-bounds/assoc-type-eq-with-dyn-atb-fail.rs b/tests/ui/associated-type-bounds/assoc-type-eq-with-dyn-atb-fail.rs
index 4c36289f47b..8a580e19186 100644
--- a/tests/ui/associated-type-bounds/assoc-type-eq-with-dyn-atb-fail.rs
+++ b/tests/ui/associated-type-bounds/assoc-type-eq-with-dyn-atb-fail.rs
@@ -28,9 +28,9 @@ impl Bar for AssocNoCopy {
 
 impl Thing for AssocNoCopy {
     type Out = Box<dyn Bar<Assoc: Copy>>;
+    //~^ ERROR associated type bounds are not allowed in `dyn` types
 
     fn func() -> Self::Out {
-        //~^ ERROR the trait bound `String: Copy` is not satisfied
         Box::new(AssocNoCopy)
     }
 }
diff --git a/tests/ui/associated-type-bounds/assoc-type-eq-with-dyn-atb-fail.stderr b/tests/ui/associated-type-bounds/assoc-type-eq-with-dyn-atb-fail.stderr
index 7942992874d..ad540909411 100644
--- a/tests/ui/associated-type-bounds/assoc-type-eq-with-dyn-atb-fail.stderr
+++ b/tests/ui/associated-type-bounds/assoc-type-eq-with-dyn-atb-fail.stderr
@@ -1,9 +1,13 @@
-error[E0277]: the trait bound `String: Copy` is not satisfied
-  --> $DIR/assoc-type-eq-with-dyn-atb-fail.rs:32:18
+error: associated type bounds are not allowed in `dyn` types
+  --> $DIR/assoc-type-eq-with-dyn-atb-fail.rs:30:28
    |
-LL |     fn func() -> Self::Out {
-   |                  ^^^^^^^^^ the trait `Copy` is not implemented for `String`
+LL |     type Out = Box<dyn Bar<Assoc: Copy>>;
+   |                            ^^^^^^^^^^^
+   |
+help: use `impl Trait` to introduce a type instead
+   |
+LL |     type Out = Box<dyn Bar<Assoc = impl Copy>>;
+   |                                  ~~~~~~
 
 error: aborting due to 1 previous error
 
-For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/associated-type-bounds/bad-universal-in-dyn-in-where-clause.rs b/tests/ui/associated-type-bounds/bad-universal-in-dyn-in-where-clause.rs
index 8cab1f66c27..81c8fe829f9 100644
--- a/tests/ui/associated-type-bounds/bad-universal-in-dyn-in-where-clause.rs
+++ b/tests/ui/associated-type-bounds/bad-universal-in-dyn-in-where-clause.rs
@@ -7,7 +7,7 @@ trait B {
 fn f()
 where
     dyn for<'j> B<AssocType: 'j>:,
-    //~^ ERROR associated type bounds are only allowed in where clauses and function signatures
+    //~^ ERROR associated type bounds are not allowed in `dyn` types
 {
 }
 
diff --git a/tests/ui/associated-type-bounds/bad-universal-in-dyn-in-where-clause.stderr b/tests/ui/associated-type-bounds/bad-universal-in-dyn-in-where-clause.stderr
index fe300a7de42..7d9870c72d4 100644
--- a/tests/ui/associated-type-bounds/bad-universal-in-dyn-in-where-clause.stderr
+++ b/tests/ui/associated-type-bounds/bad-universal-in-dyn-in-where-clause.stderr
@@ -1,4 +1,4 @@
-error: associated type bounds are only allowed in where clauses and function signatures, not in bounds
+error: associated type bounds are not allowed in `dyn` types
   --> $DIR/bad-universal-in-dyn-in-where-clause.rs:9:19
    |
 LL |     dyn for<'j> B<AssocType: 'j>:,
diff --git a/tests/ui/associated-type-bounds/bad-universal-in-impl-sig.rs b/tests/ui/associated-type-bounds/bad-universal-in-impl-sig.rs
index 1d5d181efcc..f465123f34c 100644
--- a/tests/ui/associated-type-bounds/bad-universal-in-impl-sig.rs
+++ b/tests/ui/associated-type-bounds/bad-universal-in-impl-sig.rs
@@ -8,6 +8,6 @@ trait Trait2 {}
 
 // It's not possible to insert a universal `impl Trait` here!
 impl dyn Trait<Item: Trait2> {}
-//~^ ERROR associated type bounds are only allowed in where clauses and function signatures
+//~^ ERROR associated type bounds are not allowed in `dyn` types
 
 fn main() {}
diff --git a/tests/ui/associated-type-bounds/bad-universal-in-impl-sig.stderr b/tests/ui/associated-type-bounds/bad-universal-in-impl-sig.stderr
index 7bdb2c5a7c2..8855bd9c312 100644
--- a/tests/ui/associated-type-bounds/bad-universal-in-impl-sig.stderr
+++ b/tests/ui/associated-type-bounds/bad-universal-in-impl-sig.stderr
@@ -1,4 +1,4 @@
-error: associated type bounds are only allowed in where clauses and function signatures, not in impl headers
+error: associated type bounds are not allowed in `dyn` types
   --> $DIR/bad-universal-in-impl-sig.rs:10:16
    |
 LL | impl dyn Trait<Item: Trait2> {}
diff --git a/tests/ui/associated-type-bounds/duplicate.rs b/tests/ui/associated-type-bounds/duplicate.rs
index 036f8ede1b3..54c8cd3fde0 100644
--- a/tests/ui/associated-type-bounds/duplicate.rs
+++ b/tests/ui/associated-type-bounds/duplicate.rs
@@ -261,11 +261,4 @@ trait TRA3 {
     //~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
 }
 
-type TADyn1 = dyn Iterator<Item: Copy, Item: Send>;
-//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
-type TADyn2 = Box<dyn Iterator<Item: Copy, Item: Copy>>;
-//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
-type TADyn3 = dyn Iterator<Item: 'static, Item: 'static>;
-//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
-
 fn main() {}
diff --git a/tests/ui/associated-type-bounds/duplicate.stderr b/tests/ui/associated-type-bounds/duplicate.stderr
index bf6aab96dc7..9816d11a40a 100644
--- a/tests/ui/associated-type-bounds/duplicate.stderr
+++ b/tests/ui/associated-type-bounds/duplicate.stderr
@@ -7,30 +7,6 @@ LL | struct SI1<T: Iterator<Item: Copy, Item: Send>> {
    |                        `Item` bound here first
 
 error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified
-  --> $DIR/duplicate.rs:264:40
-   |
-LL | type TADyn1 = dyn Iterator<Item: Copy, Item: Send>;
-   |                            ----------  ^^^^^^^^^^ re-bound here
-   |                            |
-   |                            `Item` bound here first
-
-error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified
-  --> $DIR/duplicate.rs:266:44
-   |
-LL | type TADyn2 = Box<dyn Iterator<Item: Copy, Item: Copy>>;
-   |                                ----------  ^^^^^^^^^^ re-bound here
-   |                                |
-   |                                `Item` bound here first
-
-error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified
-  --> $DIR/duplicate.rs:268:43
-   |
-LL | type TADyn3 = dyn Iterator<Item: 'static, Item: 'static>;
-   |                            -------------  ^^^^^^^^^^^^^ re-bound here
-   |                            |
-   |                            `Item` bound here first
-
-error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified
   --> $DIR/duplicate.rs:11:36
    |
 LL | struct SI2<T: Iterator<Item: Copy, Item: Copy>> {
@@ -631,7 +607,7 @@ LL |     Self: Iterator<Item: 'static, Item: 'static>,
    |
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 
-error: aborting due to 75 previous errors
+error: aborting due to 72 previous errors
 
 Some errors have detailed explanations: E0282, E0719.
 For more information about an error, try `rustc --explain E0282`.
diff --git a/tests/ui/associated-type-bounds/dyn-impl-trait-type.rs b/tests/ui/associated-type-bounds/dyn-impl-trait-type.rs
deleted file mode 100644
index 079c44b3a59..00000000000
--- a/tests/ui/associated-type-bounds/dyn-impl-trait-type.rs
+++ /dev/null
@@ -1,66 +0,0 @@
-// run-pass
-
-#![feature(associated_type_bounds)]
-
-use std::ops::Add;
-
-trait Tr1 { type As1; fn mk(&self) -> Self::As1; }
-trait Tr2<'a> { fn tr2(self) -> &'a Self; } //~ WARN method `tr2` is never used
-
-fn assert_copy<T: Copy>(x: T) { let _x = x; let _x = x; }
-fn assert_static<T: 'static>(_: T) {}
-fn assert_forall_tr2<T: for<'a> Tr2<'a>>(_: T) {}
-
-struct S1;
-#[derive(Copy, Clone)]
-struct S2;
-impl Tr1 for S1 { type As1 = S2; fn mk(&self) -> Self::As1 { S2 } }
-
-type Et1 = Box<dyn Tr1<As1: Copy>>;
-fn def_et1() -> Et1 { Box::new(S1) }
-pub fn use_et1() { assert_copy(def_et1().mk()); }
-
-type Et2 = Box<dyn Tr1<As1: 'static>>;
-fn def_et2() -> Et2 { Box::new(S1) }
-pub fn use_et2() { assert_static(def_et2().mk()); }
-
-type Et3 = Box<dyn Tr1<As1: Clone + Iterator<Item: Add<u8, Output: Into<u8>>>>>;
-fn def_et3() -> Et3 {
-    struct A;
-    impl Tr1 for A {
-        type As1 = core::ops::Range<u8>;
-        fn mk(&self) -> Self::As1 { 0..10 }
-    }
-    Box::new(A)
-}
-pub fn use_et3() {
-    let _0 = def_et3().mk().clone();
-    let mut s = 0u8;
-    for _1 in _0 {
-        let _2 = _1 + 1u8;
-        s += _2.into();
-    }
-    assert_eq!(s, (0..10).map(|x| x + 1).sum());
-}
-
-type Et4 = Box<dyn Tr1<As1: for<'a> Tr2<'a>>>;
-fn def_et4() -> Et4 {
-    #[derive(Copy, Clone)]
-    struct A;
-    impl Tr1 for A {
-        type As1 = A;
-        fn mk(&self) -> A { A }
-    }
-    impl<'a> Tr2<'a> for A {
-        fn tr2(self) -> &'a Self { &A }
-    }
-    Box::new(A)
-}
-pub fn use_et4() { assert_forall_tr2(def_et4().mk()); }
-
-fn main() {
-    use_et1();
-    use_et2();
-    use_et3();
-    use_et4();
-}
diff --git a/tests/ui/associated-type-bounds/dyn-impl-trait-type.stderr b/tests/ui/associated-type-bounds/dyn-impl-trait-type.stderr
deleted file mode 100644
index 2e26a434f5d..00000000000
--- a/tests/ui/associated-type-bounds/dyn-impl-trait-type.stderr
+++ /dev/null
@@ -1,12 +0,0 @@
-warning: method `tr2` is never used
-  --> $DIR/dyn-impl-trait-type.rs:8:20
-   |
-LL | trait Tr2<'a> { fn tr2(self) -> &'a Self; }
-   |       ---          ^^^
-   |       |
-   |       method in this trait
-   |
-   = note: `#[warn(dead_code)]` on by default
-
-warning: 1 warning emitted
-
diff --git a/tests/ui/associated-type-bounds/dyn-rpit-and-let.rs b/tests/ui/associated-type-bounds/dyn-rpit-and-let.rs
deleted file mode 100644
index 49e5e72f225..00000000000
--- a/tests/ui/associated-type-bounds/dyn-rpit-and-let.rs
+++ /dev/null
@@ -1,73 +0,0 @@
-// run-pass
-
-// FIXME: uncomment let binding types below when `impl_trait_in_bindings` feature is fixed.
-
-#![feature(associated_type_bounds)]
-
-use std::ops::Add;
-
-trait Tr1 { type As1; fn mk(&self) -> Self::As1; }
-trait Tr2<'a> { fn tr2(self) -> &'a Self; } //~ WARN method `tr2` is never used
-
-fn assert_copy<T: Copy>(x: T) { let _x = x; let _x = x; }
-fn assert_static<T: 'static>(_: T) {}
-fn assert_forall_tr2<T: for<'a> Tr2<'a>>(_: T) {}
-
-struct S1;
-#[derive(Copy, Clone)]
-struct S2;
-impl Tr1 for S1 { type As1 = S2; fn mk(&self) -> Self::As1 { S2 } }
-
-fn def_et1() -> Box<dyn Tr1<As1: Copy>> {
-    let x /* : Box<dyn Tr1<As1: Copy>> */ = Box::new(S1);
-    x
-}
-pub fn use_et1() { assert_copy(def_et1().mk()); }
-
-fn def_et2() -> Box<dyn Tr1<As1: Send + 'static>> {
-    let x /* : Box<dyn Tr1<As1: Send + 'static>> */ = Box::new(S1);
-    x
-}
-pub fn use_et2() { assert_static(def_et2().mk()); }
-
-fn def_et3() -> Box<dyn Tr1<As1: Clone + Iterator<Item: Add<u8, Output: Into<u8>>>>> {
-    struct A;
-    impl Tr1 for A {
-        type As1 = core::ops::Range<u8>;
-        fn mk(&self) -> Self::As1 { 0..10 }
-    }
-    let x /* : Box<dyn Tr1<As1: Clone + Iterator<Item: Add<u8, Output: Into<u8>>>>> */
-        = Box::new(A);
-    x
-}
-pub fn use_et3() {
-    let _0 = def_et3().mk().clone();
-    let mut s = 0u8;
-    for _1 in _0 {
-        let _2 = _1 + 1u8;
-        s += _2.into();
-    }
-    assert_eq!(s, (0..10).map(|x| x + 1).sum());
-}
-
-fn def_et4() -> Box<dyn Tr1<As1: for<'a> Tr2<'a>>> {
-    #[derive(Copy, Clone)]
-    struct A;
-    impl Tr1 for A {
-        type As1 = A;
-        fn mk(&self) -> A { A }
-    }
-    impl<'a> Tr2<'a> for A {
-        fn tr2(self) -> &'a Self { &A }
-    }
-    let x /* : Box<dyn Tr1<As1: for<'a> Tr2<'a>>> */ = Box::new(A);
-    x
-}
-pub fn use_et4() { assert_forall_tr2(def_et4().mk()); }
-
-fn main() {
-    use_et1();
-    use_et2();
-    use_et3();
-    use_et4();
-}
diff --git a/tests/ui/associated-type-bounds/dyn-rpit-and-let.stderr b/tests/ui/associated-type-bounds/dyn-rpit-and-let.stderr
deleted file mode 100644
index 9eddbe46284..00000000000
--- a/tests/ui/associated-type-bounds/dyn-rpit-and-let.stderr
+++ /dev/null
@@ -1,12 +0,0 @@
-warning: method `tr2` is never used
-  --> $DIR/dyn-rpit-and-let.rs:10:20
-   |
-LL | trait Tr2<'a> { fn tr2(self) -> &'a Self; }
-   |       ---          ^^^
-   |       |
-   |       method in this trait
-   |
-   = note: `#[warn(dead_code)]` on by default
-
-warning: 1 warning emitted
-
diff --git a/tests/ui/associated-type-bounds/elision.rs b/tests/ui/associated-type-bounds/elision.rs
index d00def57166..5d7ed940ac6 100644
--- a/tests/ui/associated-type-bounds/elision.rs
+++ b/tests/ui/associated-type-bounds/elision.rs
@@ -3,7 +3,7 @@
 
 // The same thing should happen for constraints in dyn trait.
 fn f(x: &mut dyn Iterator<Item: Iterator<Item = &'_ ()>>) -> Option<&'_ ()> { x.next() }
-//~^ ERROR missing lifetime specifier
-//~| ERROR mismatched types
+//~^ ERROR associated type bounds are not allowed in `dyn` types
+//~| ERROR missing lifetime specifier
 
 fn main() {}
diff --git a/tests/ui/associated-type-bounds/elision.stderr b/tests/ui/associated-type-bounds/elision.stderr
index a29e32a784f..749dffdc4d3 100644
--- a/tests/ui/associated-type-bounds/elision.stderr
+++ b/tests/ui/associated-type-bounds/elision.stderr
@@ -10,19 +10,17 @@ help: consider introducing a named lifetime parameter
 LL | fn f<'a>(x: &'a mut dyn Iterator<Item: Iterator<Item = &'a ()>>) -> Option<&'a ()> { x.next() }
    |     ++++     ++                                         ~~                  ~~
 
-error[E0308]: mismatched types
-  --> $DIR/elision.rs:5:79
+error: associated type bounds are not allowed in `dyn` types
+  --> $DIR/elision.rs:5:27
    |
 LL | fn f(x: &mut dyn Iterator<Item: Iterator<Item = &'_ ()>>) -> Option<&'_ ()> { x.next() }
-   |                           -----------------------------      --------------   ^^^^^^^^ expected `Option<&()>`, found `Option<impl Iterator<Item = &'_ ()>>`
-   |                           |                                  |
-   |                           |                                  expected `Option<&()>` because of return type
-   |                           found this type parameter
+   |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
-   = note: expected enum `Option<&()>`
-              found enum `Option<impl Iterator<Item = &'_ ()>>`
+help: use `impl Trait` to introduce a type instead
+   |
+LL | fn f(x: &mut dyn Iterator<Item = impl Iterator<Item = &'_ ()>>) -> Option<&'_ ()> { x.next() }
+   |                                ~~~~~~
 
 error: aborting due to 2 previous errors
 
-Some errors have detailed explanations: E0106, E0308.
-For more information about an error, try `rustc --explain E0106`.
+For more information about this error, try `rustc --explain E0106`.
diff --git a/tests/ui/associated-type-bounds/fn-dyn-apit.rs b/tests/ui/associated-type-bounds/fn-dyn-apit.rs
deleted file mode 100644
index c4e8092c211..00000000000
--- a/tests/ui/associated-type-bounds/fn-dyn-apit.rs
+++ /dev/null
@@ -1,61 +0,0 @@
-// run-pass
-// aux-build:fn-dyn-aux.rs
-
-#![allow(unused)]
-#![feature(associated_type_bounds)]
-
-extern crate fn_dyn_aux;
-
-use fn_dyn_aux::*;
-
-// ATB, APIT (dyn trait):
-
-fn dyn_apit_bound(beta: &dyn Beta<Gamma: Alpha>) -> usize {
-    desugared_bound(beta)
-}
-
-fn dyn_apit_bound_region(beta: &dyn Beta<Gamma: 'static>) -> usize {
-    desugared_bound_region(beta)
-}
-
-fn dyn_apit_bound_multi(
-    beta: &(dyn Beta<Gamma: Alpha + 'static + Delta> + Send)
-) -> usize {
-    desugared_bound_multi(beta)
-}
-
-fn dyn_apit_bound_region_forall(
-    beta: &dyn Beta<Gamma: Copy + for<'a> Epsilon<'a>>
-) -> usize {
-    desugared_bound_region_forall(beta)
-}
-
-fn dyn_apit_bound_region_forall2(
-    beta: &dyn Beta<Gamma: Copy + for<'a> Epsilon<'a, Zeta: Eta>>
-) -> usize {
-    desugared_bound_region_forall2(beta)
-}
-
-fn dyn_apit_bound_nested(
-    beta: &dyn Beta<Gamma: Copy + Alpha + Beta<Gamma: Delta>>
-) -> usize {
-    desugared_bound_nested(beta)
-}
-
-fn dyn_apit_bound_nested2(
-    beta: &dyn Beta<Gamma = impl Copy + Alpha + Beta<Gamma: Delta>>
-) -> usize {
-    desugared_bound_nested(beta)
-}
-
-fn main() {
-    let beta = BetaType;
-    let _gamma = beta.gamma();
-
-    assert_eq!(42, dyn_apit_bound(&beta));
-    assert_eq!(24, dyn_apit_bound_region(&beta));
-    assert_eq!(42 + 24 + 1337, dyn_apit_bound_multi(&beta));
-    assert_eq!(7331 * 2, dyn_apit_bound_region_forall(&beta));
-    assert_eq!(42 + 1337, dyn_apit_bound_nested(&beta));
-    assert_eq!(42 + 1337, dyn_apit_bound_nested2(&beta));
-}
diff --git a/tests/ui/associated-type-bounds/inside-adt.rs b/tests/ui/associated-type-bounds/inside-adt.rs
index 057966941dc..2b4b060983e 100644
--- a/tests/ui/associated-type-bounds/inside-adt.rs
+++ b/tests/ui/associated-type-bounds/inside-adt.rs
@@ -3,24 +3,24 @@
 use std::mem::ManuallyDrop;
 
 struct S1 { f: dyn Iterator<Item: Copy> }
-//~^ ERROR associated type bounds are only allowed in where clauses and function signatures
+//~^ ERROR associated type bounds are not allowed in `dyn` types
 struct S2 { f: Box<dyn Iterator<Item: Copy>> }
-//~^ ERROR associated type bounds are only allowed in where clauses and function signatures
+//~^ ERROR associated type bounds are not allowed in `dyn` types
 struct S3 { f: dyn Iterator<Item: 'static> }
-//~^ ERROR associated type bounds are only allowed in where clauses and function signatures
+//~^ ERROR associated type bounds are not allowed in `dyn` types
 
 enum E1 { V(dyn Iterator<Item: Copy>) }
-//~^ ERROR associated type bounds are only allowed in where clauses and function signatures
+//~^ ERROR associated type bounds are not allowed in `dyn` types
 enum E2 { V(Box<dyn Iterator<Item: Copy>>) }
-//~^ ERROR associated type bounds are only allowed in where clauses and function signatures
+//~^ ERROR associated type bounds are not allowed in `dyn` types
 enum E3 { V(dyn Iterator<Item: 'static>) }
-//~^ ERROR associated type bounds are only allowed in where clauses and function signatures
+//~^ ERROR associated type bounds are not allowed in `dyn` types
 
 union U1 { f: ManuallyDrop<dyn Iterator<Item: Copy>> }
-//~^ ERROR associated type bounds are only allowed in where clauses and function signatures
+//~^ ERROR associated type bounds are not allowed in `dyn` types
 union U2 { f: ManuallyDrop<Box<dyn Iterator<Item: Copy>>> }
-//~^ ERROR associated type bounds are only allowed in where clauses and function signatures
+//~^ ERROR associated type bounds are not allowed in `dyn` types
 union U3 { f: ManuallyDrop<dyn Iterator<Item: 'static>> }
-//~^ ERROR associated type bounds are only allowed in where clauses and function signatures
+//~^ ERROR associated type bounds are not allowed in `dyn` types
 
 fn main() {}
diff --git a/tests/ui/associated-type-bounds/inside-adt.stderr b/tests/ui/associated-type-bounds/inside-adt.stderr
index f848bd798ee..ef45fae8f2a 100644
--- a/tests/ui/associated-type-bounds/inside-adt.stderr
+++ b/tests/ui/associated-type-bounds/inside-adt.stderr
@@ -1,52 +1,52 @@
-error: associated type bounds are only allowed in where clauses and function signatures, not in field types
+error: associated type bounds are not allowed in `dyn` types
   --> $DIR/inside-adt.rs:5:29
    |
 LL | struct S1 { f: dyn Iterator<Item: Copy> }
    |                             ^^^^^^^^^^
 
-error: associated type bounds are only allowed in where clauses and function signatures, not in field types
+error: associated type bounds are not allowed in `dyn` types
   --> $DIR/inside-adt.rs:7:33
    |
 LL | struct S2 { f: Box<dyn Iterator<Item: Copy>> }
    |                                 ^^^^^^^^^^
 
-error: associated type bounds are only allowed in where clauses and function signatures, not in field types
+error: associated type bounds are not allowed in `dyn` types
   --> $DIR/inside-adt.rs:9:29
    |
 LL | struct S3 { f: dyn Iterator<Item: 'static> }
    |                             ^^^^^^^^^^^^^
 
-error: associated type bounds are only allowed in where clauses and function signatures, not in field types
+error: associated type bounds are not allowed in `dyn` types
   --> $DIR/inside-adt.rs:12:26
    |
 LL | enum E1 { V(dyn Iterator<Item: Copy>) }
    |                          ^^^^^^^^^^
 
-error: associated type bounds are only allowed in where clauses and function signatures, not in field types
+error: associated type bounds are not allowed in `dyn` types
   --> $DIR/inside-adt.rs:14:30
    |
 LL | enum E2 { V(Box<dyn Iterator<Item: Copy>>) }
    |                              ^^^^^^^^^^
 
-error: associated type bounds are only allowed in where clauses and function signatures, not in field types
+error: associated type bounds are not allowed in `dyn` types
   --> $DIR/inside-adt.rs:16:26
    |
 LL | enum E3 { V(dyn Iterator<Item: 'static>) }
    |                          ^^^^^^^^^^^^^
 
-error: associated type bounds are only allowed in where clauses and function signatures, not in field types
+error: associated type bounds are not allowed in `dyn` types
   --> $DIR/inside-adt.rs:19:41
    |
 LL | union U1 { f: ManuallyDrop<dyn Iterator<Item: Copy>> }
    |                                         ^^^^^^^^^^
 
-error: associated type bounds are only allowed in where clauses and function signatures, not in field types
+error: associated type bounds are not allowed in `dyn` types
   --> $DIR/inside-adt.rs:21:45
    |
 LL | union U2 { f: ManuallyDrop<Box<dyn Iterator<Item: Copy>>> }
    |                                             ^^^^^^^^^^
 
-error: associated type bounds are only allowed in where clauses and function signatures, not in field types
+error: associated type bounds are not allowed in `dyn` types
   --> $DIR/inside-adt.rs:23:41
    |
 LL | union U3 { f: ManuallyDrop<dyn Iterator<Item: 'static>> }
diff --git a/tests/ui/associated-type-bounds/issue-104916.rs b/tests/ui/associated-type-bounds/issue-104916.rs
index 3361fa011ed..ee29a0a2fc4 100644
--- a/tests/ui/associated-type-bounds/issue-104916.rs
+++ b/tests/ui/associated-type-bounds/issue-104916.rs
@@ -7,7 +7,7 @@ trait B {
 fn f()
 where
     dyn for<'j> B<AssocType: 'j>:,
-    //~^ ERROR: associated type bounds are only allowed in where clauses and function signatures
+    //~^ ERROR: associated type bounds are not allowed in `dyn` types
 {
 }
 
diff --git a/tests/ui/associated-type-bounds/issue-104916.stderr b/tests/ui/associated-type-bounds/issue-104916.stderr
index 65c89735c5d..e8618b72103 100644
--- a/tests/ui/associated-type-bounds/issue-104916.stderr
+++ b/tests/ui/associated-type-bounds/issue-104916.stderr
@@ -1,4 +1,4 @@
-error: associated type bounds are only allowed in where clauses and function signatures, not in bounds
+error: associated type bounds are not allowed in `dyn` types
   --> $DIR/issue-104916.rs:9:19
    |
 LL |     dyn for<'j> B<AssocType: 'j>:,
diff --git a/tests/ui/async-await/async-closures/is-not-fn.rs b/tests/ui/async-await/async-closures/is-not-fn.rs
index 94c8e8563bd..40b0febbf06 100644
--- a/tests/ui/async-await/async-closures/is-not-fn.rs
+++ b/tests/ui/async-await/async-closures/is-not-fn.rs
@@ -5,8 +5,5 @@
 fn main() {
     fn needs_fn(x: impl FnOnce()) {}
     needs_fn(async || {});
-    //~^ ERROR expected a `FnOnce()` closure, found `{coroutine-closure@
-    // FIXME(async_closures): This should explain in more detail how async fns don't
-    // implement the regular `Fn` traits. Or maybe we should just fix it and make them
-    // when there are no upvars or whatever.
+    //~^ ERROR expected `{coroutine-closure@is-not-fn.rs:7:14}` to be a closure that returns `()`
 }
diff --git a/tests/ui/async-await/async-closures/is-not-fn.stderr b/tests/ui/async-await/async-closures/is-not-fn.stderr
index 12da4b1fc6f..6169cee85fd 100644
--- a/tests/ui/async-await/async-closures/is-not-fn.stderr
+++ b/tests/ui/async-await/async-closures/is-not-fn.stderr
@@ -1,13 +1,13 @@
-error[E0277]: expected a `FnOnce()` closure, found `{coroutine-closure@$DIR/is-not-fn.rs:7:14: 7:22}`
+error[E0271]: expected `{coroutine-closure@is-not-fn.rs:7:14}` to be a closure that returns `()`, but it returns `{async closure body@$DIR/is-not-fn.rs:7:23: 7:25}`
   --> $DIR/is-not-fn.rs:7:14
    |
 LL |     needs_fn(async || {});
-   |     -------- ^^^^^^^^^^^ expected an `FnOnce()` closure, found `{coroutine-closure@$DIR/is-not-fn.rs:7:14: 7:22}`
+   |     -------- ^^^^^^^^^^^ expected `()`, found `async` closure body
    |     |
    |     required by a bound introduced by this call
    |
-   = help: the trait `FnOnce<()>` is not implemented for `{coroutine-closure@$DIR/is-not-fn.rs:7:14: 7:22}`
-   = note: wrap the `{coroutine-closure@$DIR/is-not-fn.rs:7:14: 7:22}` in a closure with no arguments: `|| { /* code */ }`
+   = note:         expected unit type `()`
+           found `async` closure body `{async closure body@$DIR/is-not-fn.rs:7:23: 7:25}`
 note: required by a bound in `needs_fn`
   --> $DIR/is-not-fn.rs:6:25
    |
@@ -16,4 +16,4 @@ LL |     fn needs_fn(x: impl FnOnce()) {}
 
 error: aborting due to 1 previous error
 
-For more information about this error, try `rustc --explain E0277`.
+For more information about this error, try `rustc --explain E0271`.
diff --git a/tests/ui/async-await/async-closures/once.rs b/tests/ui/async-await/async-closures/once.rs
new file mode 100644
index 00000000000..a1c56c5de6a
--- /dev/null
+++ b/tests/ui/async-await/async-closures/once.rs
@@ -0,0 +1,22 @@
+// aux-build:block-on.rs
+// edition:2021
+// build-pass
+
+#![feature(async_closure)]
+
+use std::future::Future;
+
+extern crate block_on;
+
+struct NoCopy;
+
+fn main() {
+    block_on::block_on(async {
+        async fn call_once<F: Future>(x: impl Fn(&'static str) -> F) -> F::Output {
+            x("hello, world").await
+        }
+        call_once(async |x: &'static str| {
+            println!("hello, {x}");
+        }).await
+    });
+}
diff --git a/tests/ui/async-await/async-closures/refd.rs b/tests/ui/async-await/async-closures/refd.rs
new file mode 100644
index 00000000000..7c61ff2d9bd
--- /dev/null
+++ b/tests/ui/async-await/async-closures/refd.rs
@@ -0,0 +1,18 @@
+// aux-build:block-on.rs
+// edition:2021
+// build-pass
+
+// check that `&{async-closure}` implements `AsyncFn`.
+
+#![feature(async_closure)]
+
+extern crate block_on;
+
+struct NoCopy;
+
+fn main() {
+    block_on::block_on(async {
+        async fn call_once(x: impl async Fn()) { x().await }
+        call_once(&async || {}).await
+    });
+}
diff --git a/tests/ui/async-await/async-fn/dyn-pos.stderr b/tests/ui/async-await/async-fn/dyn-pos.stderr
index c9323526516..488c5d06938 100644
--- a/tests/ui/async-await/async-fn/dyn-pos.stderr
+++ b/tests/ui/async-await/async-fn/dyn-pos.stderr
@@ -8,6 +8,9 @@ note: for a trait to be "object safe" it needs to allow building a vtable to all
   --> $SRC_DIR/core/src/ops/async_function.rs:LL:COL
    |
    = note: the trait cannot be made into an object because it contains the generic associated type `CallFuture`
+   = help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `AsyncFn` for this new enum and using it instead:
+             &F
+             std::boxed::Box<F, A>
 
 error[E0038]: the trait `AsyncFnMut` cannot be made into an object
   --> $DIR/dyn-pos.rs:5:16
@@ -19,6 +22,10 @@ note: for a trait to be "object safe" it needs to allow building a vtable to all
   --> $SRC_DIR/core/src/ops/async_function.rs:LL:COL
    |
    = note: the trait cannot be made into an object because it contains the generic associated type `CallMutFuture`
+   = help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `AsyncFnMut` for this new enum and using it instead:
+             &F
+             &mut F
+             std::boxed::Box<F, A>
 
 error[E0038]: the trait `AsyncFn` cannot be made into an object
   --> $DIR/dyn-pos.rs:5:16
@@ -30,6 +37,9 @@ note: for a trait to be "object safe" it needs to allow building a vtable to all
   --> $SRC_DIR/core/src/ops/async_function.rs:LL:COL
    |
    = note: the trait cannot be made into an object because it contains the generic associated type `CallFuture`
+   = help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `AsyncFn` for this new enum and using it instead:
+             &F
+             std::boxed::Box<F, A>
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 
 error[E0038]: the trait `AsyncFnMut` cannot be made into an object
@@ -42,6 +52,10 @@ note: for a trait to be "object safe" it needs to allow building a vtable to all
   --> $SRC_DIR/core/src/ops/async_function.rs:LL:COL
    |
    = note: the trait cannot be made into an object because it contains the generic associated type `CallMutFuture`
+   = help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `AsyncFnMut` for this new enum and using it instead:
+             &F
+             &mut F
+             std::boxed::Box<F, A>
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 
 error[E0038]: the trait `AsyncFn` cannot be made into an object
@@ -54,6 +68,9 @@ note: for a trait to be "object safe" it needs to allow building a vtable to all
   --> $SRC_DIR/core/src/ops/async_function.rs:LL:COL
    |
    = note: the trait cannot be made into an object because it contains the generic associated type `CallFuture`
+   = help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `AsyncFn` for this new enum and using it instead:
+             &F
+             std::boxed::Box<F, A>
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 
 error[E0038]: the trait `AsyncFnMut` cannot be made into an object
@@ -66,6 +83,10 @@ note: for a trait to be "object safe" it needs to allow building a vtable to all
   --> $SRC_DIR/core/src/ops/async_function.rs:LL:COL
    |
    = note: the trait cannot be made into an object because it contains the generic associated type `CallMutFuture`
+   = help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `AsyncFnMut` for this new enum and using it instead:
+             &F
+             &mut F
+             std::boxed::Box<F, A>
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 
 error[E0038]: the trait `AsyncFn` cannot be made into an object
@@ -81,6 +102,9 @@ note: for a trait to be "object safe" it needs to allow building a vtable to all
   ::: $SRC_DIR/core/src/ops/async_function.rs:LL:COL
    |
    = note: the trait cannot be made into an object because it contains the generic associated type `CallMutFuture`
+   = help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `AsyncFn` for this new enum and using it instead:
+             &F
+             std::boxed::Box<F, A>
 
 error: aborting due to 7 previous errors
 
diff --git a/tests/ui/async-await/async-fn/simple.rs b/tests/ui/async-await/async-fn/simple.rs
index 99a5d56a309..172ede7098a 100644
--- a/tests/ui/async-await/async-fn/simple.rs
+++ b/tests/ui/async-await/async-fn/simple.rs
@@ -1,5 +1,5 @@
 // edition: 2021
-// check-pass
+// build-pass
 
 #![feature(async_fn_traits)]
 
diff --git a/tests/ui/const_prop/const-prop-read-static-in-const.rs b/tests/ui/const_prop/const-prop-read-static-in-const.rs
deleted file mode 100644
index 21426205955..00000000000
--- a/tests/ui/const_prop/const-prop-read-static-in-const.rs
+++ /dev/null
@@ -1,10 +0,0 @@
-// compile-flags: -Zunleash-the-miri-inside-of-you
-
-#![allow(dead_code)]
-
-const TEST: u8 = MY_STATIC; //~ ERROR constant
-
-static MY_STATIC: u8 = 4;
-
-fn main() {
-}
diff --git a/tests/ui/const_prop/const-prop-read-static-in-const.stderr b/tests/ui/const_prop/const-prop-read-static-in-const.stderr
deleted file mode 100644
index 9af1f7e3a24..00000000000
--- a/tests/ui/const_prop/const-prop-read-static-in-const.stderr
+++ /dev/null
@@ -1,17 +0,0 @@
-error[E0080]: evaluation of constant value failed
-  --> $DIR/const-prop-read-static-in-const.rs:5:18
-   |
-LL | const TEST: u8 = MY_STATIC;
-   |                  ^^^^^^^^^ constant accesses static
-
-warning: skipping const checks
-   |
-help: skipping check that does not even have a feature gate
-  --> $DIR/const-prop-read-static-in-const.rs:5:18
-   |
-LL | const TEST: u8 = MY_STATIC;
-   |                  ^^^^^^^^^
-
-error: aborting due to 1 previous error; 1 warning emitted
-
-For more information about this error, try `rustc --explain E0080`.
diff --git a/tests/ui/consts/const-address-of-mut.rs b/tests/ui/consts/const-address-of-mut.rs
index 5f0c76d6285..0018bf18e41 100644
--- a/tests/ui/consts/const-address-of-mut.rs
+++ b/tests/ui/consts/const-address-of-mut.rs
@@ -4,8 +4,6 @@ const A: () = { let mut x = 2; &raw mut x; };           //~ mutable pointer
 
 static B: () = { let mut x = 2; &raw mut x; };          //~ mutable pointer
 
-static mut C: () = { let mut x = 2; &raw mut x; };      //~ mutable pointer
-
 const fn foo() {
     let mut x = 0;
     let y = &raw mut x;                                 //~ mutable pointer
diff --git a/tests/ui/consts/const-address-of-mut.stderr b/tests/ui/consts/const-address-of-mut.stderr
index 1b371fcee98..95a91ff463f 100644
--- a/tests/ui/consts/const-address-of-mut.stderr
+++ b/tests/ui/consts/const-address-of-mut.stderr
@@ -18,18 +18,8 @@ LL | static B: () = { let mut x = 2; &raw mut x; };
    = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
    = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
 
-error[E0658]: raw mutable pointers are not allowed in statics
-  --> $DIR/const-address-of-mut.rs:7:37
-   |
-LL | static mut C: () = { let mut x = 2; &raw mut x; };
-   |                                     ^^^^^^^^^^
-   |
-   = note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
-   = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
-   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
-
 error[E0658]: raw mutable pointers are not allowed in constant functions
-  --> $DIR/const-address-of-mut.rs:11:13
+  --> $DIR/const-address-of-mut.rs:9:13
    |
 LL |     let y = &raw mut x;
    |             ^^^^^^^^^^
@@ -38,6 +28,6 @@ LL |     let y = &raw mut x;
    = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
    = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
 
-error: aborting due to 4 previous errors
+error: aborting due to 3 previous errors
 
 For more information about this error, try `rustc --explain E0658`.
diff --git a/tests/ui/consts/const-fn-not-safe-for-const.rs b/tests/ui/consts/const-fn-not-safe-for-const.rs
index b2fe73ae930..6d8404880ca 100644
--- a/tests/ui/consts/const-fn-not-safe-for-const.rs
+++ b/tests/ui/consts/const-fn-not-safe-for-const.rs
@@ -18,12 +18,12 @@ static Y: u32 = 0;
 
 const fn get_Y() -> u32 {
     Y
-    //~^ ERROR E0013
+    //~^ ERROR referencing statics in constant functions
 }
 
 const fn get_Y_addr() -> &'static u32 {
     &Y
-    //~^ ERROR E0013
+    //~^ ERROR referencing statics in constant functions
 }
 
 const fn get() -> u32 {
diff --git a/tests/ui/consts/const-fn-not-safe-for-const.stderr b/tests/ui/consts/const-fn-not-safe-for-const.stderr
index 4c7effc0d15..7d7e94da86f 100644
--- a/tests/ui/consts/const-fn-not-safe-for-const.stderr
+++ b/tests/ui/consts/const-fn-not-safe-for-const.stderr
@@ -6,23 +6,31 @@ LL |     random()
    |
    = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
 
-error[E0013]: constant functions cannot refer to statics
+error[E0658]: referencing statics in constant functions is unstable
   --> $DIR/const-fn-not-safe-for-const.rs:20:5
    |
 LL |     Y
    |     ^
    |
-   = help: consider extracting the value of the `static` to a `const`, and referring to that
+   = note: see issue #119618 <https://github.com/rust-lang/rust/issues/119618> for more information
+   = help: add `#![feature(const_refs_to_static)]` to the crate attributes to enable
+   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
+   = note: `static` and `const` variables can refer to other `const` variables. A `const` variable, however, cannot refer to a `static` variable.
+   = help: to fix this, the value can be extracted to a `const` and then used.
 
-error[E0013]: constant functions cannot refer to statics
+error[E0658]: referencing statics in constant functions is unstable
   --> $DIR/const-fn-not-safe-for-const.rs:25:6
    |
 LL |     &Y
    |      ^
    |
-   = help: consider extracting the value of the `static` to a `const`, and referring to that
+   = note: see issue #119618 <https://github.com/rust-lang/rust/issues/119618> for more information
+   = help: add `#![feature(const_refs_to_static)]` to the crate attributes to enable
+   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
+   = note: `static` and `const` variables can refer to other `const` variables. A `const` variable, however, cannot refer to a `static` variable.
+   = help: to fix this, the value can be extracted to a `const` and then used.
 
 error: aborting due to 3 previous errors
 
-Some errors have detailed explanations: E0013, E0015.
-For more information about an error, try `rustc --explain E0013`.
+Some errors have detailed explanations: E0015, E0658.
+For more information about an error, try `rustc --explain E0015`.
diff --git a/tests/ui/consts/const_refs_to_static.rs b/tests/ui/consts/const_refs_to_static.rs
new file mode 100644
index 00000000000..f5e5ef5f699
--- /dev/null
+++ b/tests/ui/consts/const_refs_to_static.rs
@@ -0,0 +1,19 @@
+// run-pass
+#![feature(const_refs_to_static)]
+
+static S: i32 = 0;
+static mut S_MUT: i32 = 0;
+
+const C1: &i32 = &S;
+#[allow(unused)]
+const C1_READ: () = {
+    assert!(*C1 == 0);
+};
+const C2: *const i32 = unsafe { std::ptr::addr_of!(S_MUT) };
+
+fn main() {
+    assert_eq!(*C1, 0);
+    assert_eq!(unsafe { *C2 }, 0);
+    // Computing this pattern will read from an immutable static. That's fine.
+    assert!(matches!(&0, C1));
+}
diff --git a/tests/ui/consts/const_refs_to_static_fail.rs b/tests/ui/consts/const_refs_to_static_fail.rs
new file mode 100644
index 00000000000..d5bcccf82d5
--- /dev/null
+++ b/tests/ui/consts/const_refs_to_static_fail.rs
@@ -0,0 +1,21 @@
+// normalize-stderr-test "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)"
+// normalize-stderr-test "([0-9a-f][0-9a-f] |╾─*ALLOC[0-9]+(\+[a-z0-9]+)?(<imm>)?─*╼ )+ *│.*" -> "HEX_DUMP"
+#![feature(const_refs_to_static, const_mut_refs, sync_unsafe_cell)]
+use std::cell::SyncUnsafeCell;
+
+static S: SyncUnsafeCell<i32> = SyncUnsafeCell::new(0);
+static mut S_MUT: i32 = 0;
+
+const C1: &SyncUnsafeCell<i32> = &S; //~ERROR undefined behavior
+//~| encountered reference to mutable memory
+const C1_READ: () = unsafe {
+    assert!(*C1.get() == 0);
+};
+const C2: *const i32 = unsafe { std::ptr::addr_of!(S_MUT) };
+const C2_READ: () = unsafe {
+    assert!(*C2 == 0); //~ERROR evaluation of constant value failed
+    //~^ constant accesses mutable global memory
+};
+
+fn main() {
+}
diff --git a/tests/ui/consts/const_refs_to_static_fail.stderr b/tests/ui/consts/const_refs_to_static_fail.stderr
new file mode 100644
index 00000000000..cdabd86b183
--- /dev/null
+++ b/tests/ui/consts/const_refs_to_static_fail.stderr
@@ -0,0 +1,26 @@
+error[E0080]: it is undefined behavior to use this value
+  --> $DIR/const_refs_to_static_fail.rs:9:1
+   |
+LL | const C1: &SyncUnsafeCell<i32> = &S;
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered reference to mutable memory in `const`
+   |
+   = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
+   = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
+               HEX_DUMP
+           }
+
+note: erroneous constant encountered
+  --> $DIR/const_refs_to_static_fail.rs:12:14
+   |
+LL |     assert!(*C1.get() == 0);
+   |              ^^
+
+error[E0080]: evaluation of constant value failed
+  --> $DIR/const_refs_to_static_fail.rs:16:13
+   |
+LL |     assert!(*C2 == 0);
+   |             ^^^ constant accesses mutable global memory
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0080`.
diff --git a/tests/ui/consts/const_refs_to_static_fail_invalid.rs b/tests/ui/consts/const_refs_to_static_fail_invalid.rs
new file mode 100644
index 00000000000..bf52f884209
--- /dev/null
+++ b/tests/ui/consts/const_refs_to_static_fail_invalid.rs
@@ -0,0 +1,51 @@
+// normalize-stderr-test "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)"
+// normalize-stderr-test "([0-9a-f][0-9a-f] |╾─*ALLOC[0-9]+(\+[a-z0-9]+)?(<imm>)?─*╼ )+ *│.*" -> "HEX_DUMP"
+#![feature(const_refs_to_static)]
+
+fn invalid() {
+    static S: i8 = 10;
+
+    const C: &bool = unsafe { std::mem::transmute(&S) };
+    //~^ERROR: undefined behavior
+    //~| expected a boolean
+
+    // This must be rejected here (or earlier), since it's not a valid `&bool`.
+    match &true {
+        C => {} //~ERROR: could not evaluate constant pattern
+        _ => {}
+    }
+}
+
+fn extern_() {
+    extern "C" {
+        static S: i8;
+    }
+
+    const C: &i8 = unsafe { &S };
+    //~^ERROR: undefined behavior
+    //~| `extern` static
+
+    // This must be rejected here (or earlier), since the pattern cannot be read.
+    match &0 {
+        C => {} //~ERROR: could not evaluate constant pattern
+        _ => {}
+    }
+}
+
+fn mutable() {
+    static mut S_MUT: i32 = 0;
+
+    const C: &i32 = unsafe { &S_MUT };
+    //~^ERROR: undefined behavior
+    //~| encountered reference to mutable memory
+    //~| WARN shared reference of mutable static is discouraged
+
+    // This *must not build*, the constant we are matching against
+    // could change its value!
+    match &42 {
+        C => {}, //~ERROR: could not evaluate constant pattern
+        _ => {},
+    }
+}
+
+fn main() {}
diff --git a/tests/ui/consts/const_refs_to_static_fail_invalid.stderr b/tests/ui/consts/const_refs_to_static_fail_invalid.stderr
new file mode 100644
index 00000000000..35051557b61
--- /dev/null
+++ b/tests/ui/consts/const_refs_to_static_fail_invalid.stderr
@@ -0,0 +1,69 @@
+warning: shared reference of mutable static is discouraged
+  --> $DIR/const_refs_to_static_fail_invalid.rs:38:30
+   |
+LL |     const C: &i32 = unsafe { &S_MUT };
+   |                              ^^^^^^ shared reference of mutable static
+   |
+   = note: for more information, see issue #114447 <https://github.com/rust-lang/rust/issues/114447>
+   = note: reference of mutable static is a hard error from 2024 edition
+   = note: mutable statics can be written to by multiple threads: aliasing violations or data races will cause undefined behavior
+   = note: `#[warn(static_mut_ref)]` on by default
+help: shared references are dangerous since if there's any kind of mutation of that static while the reference lives, that's UB; use `addr_of!` instead to create a raw pointer
+   |
+LL |     const C: &i32 = unsafe { addr_of!(S_MUT) };
+   |                              ~~~~~~~~~~~~~~~
+
+error[E0080]: it is undefined behavior to use this value
+  --> $DIR/const_refs_to_static_fail_invalid.rs:8:5
+   |
+LL |     const C: &bool = unsafe { std::mem::transmute(&S) };
+   |     ^^^^^^^^^^^^^^ constructing invalid value at .<deref>: encountered 0x0a, but expected a boolean
+   |
+   = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
+   = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
+               HEX_DUMP
+           }
+
+error: could not evaluate constant pattern
+  --> $DIR/const_refs_to_static_fail_invalid.rs:14:9
+   |
+LL |         C => {}
+   |         ^
+
+error[E0080]: it is undefined behavior to use this value
+  --> $DIR/const_refs_to_static_fail_invalid.rs:24:5
+   |
+LL |     const C: &i8 = unsafe { &S };
+   |     ^^^^^^^^^^^^ constructing invalid value: encountered reference to `extern` static in `const`
+   |
+   = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
+   = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
+               HEX_DUMP
+           }
+
+error: could not evaluate constant pattern
+  --> $DIR/const_refs_to_static_fail_invalid.rs:30:9
+   |
+LL |         C => {}
+   |         ^
+
+error[E0080]: it is undefined behavior to use this value
+  --> $DIR/const_refs_to_static_fail_invalid.rs:38:5
+   |
+LL |     const C: &i32 = unsafe { &S_MUT };
+   |     ^^^^^^^^^^^^^ constructing invalid value: encountered reference to mutable memory in `const`
+   |
+   = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
+   = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
+               HEX_DUMP
+           }
+
+error: could not evaluate constant pattern
+  --> $DIR/const_refs_to_static_fail_invalid.rs:46:9
+   |
+LL |         C => {},
+   |         ^
+
+error: aborting due to 6 previous errors; 1 warning emitted
+
+For more information about this error, try `rustc --explain E0080`.
diff --git a/tests/ui/consts/issue-17718-const-bad-values.rs b/tests/ui/consts/issue-17718-const-bad-values.rs
index 4fedc48452b..af50fed972d 100644
--- a/tests/ui/consts/issue-17718-const-bad-values.rs
+++ b/tests/ui/consts/issue-17718-const-bad-values.rs
@@ -3,8 +3,8 @@ const C1: &'static mut [usize] = &mut [];
 
 static mut S: usize = 3;
 const C2: &'static mut usize = unsafe { &mut S };
-//~^ WARN mutable reference of mutable static is discouraged [static_mut_ref]
-//~^^ ERROR: constants cannot refer to statics
-//~| ERROR: constants cannot refer to statics
+//~^ ERROR: referencing statics in constants
+//~| ERROR: referencing statics in constants
+//~| WARN mutable reference of mutable static is discouraged [static_mut_ref]
 
 fn main() {}
diff --git a/tests/ui/consts/issue-17718-const-bad-values.stderr b/tests/ui/consts/issue-17718-const-bad-values.stderr
index 2dc91f52669..cda94490155 100644
--- a/tests/ui/consts/issue-17718-const-bad-values.stderr
+++ b/tests/ui/consts/issue-17718-const-bad-values.stderr
@@ -19,24 +19,32 @@ error[E0764]: mutable references are not allowed in the final value of constants
 LL | const C1: &'static mut [usize] = &mut [];
    |                                  ^^^^^^^
 
-error[E0013]: constants cannot refer to statics
+error[E0658]: referencing statics in constants is unstable
   --> $DIR/issue-17718-const-bad-values.rs:5:46
    |
 LL | const C2: &'static mut usize = unsafe { &mut S };
    |                                              ^
    |
-   = help: consider extracting the value of the `static` to a `const`, and referring to that
+   = note: see issue #119618 <https://github.com/rust-lang/rust/issues/119618> for more information
+   = help: add `#![feature(const_refs_to_static)]` to the crate attributes to enable
+   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
+   = note: `static` and `const` variables can refer to other `const` variables. A `const` variable, however, cannot refer to a `static` variable.
+   = help: to fix this, the value can be extracted to a `const` and then used.
 
-error[E0013]: constants cannot refer to statics
+error[E0658]: referencing statics in constants is unstable
   --> $DIR/issue-17718-const-bad-values.rs:5:46
    |
 LL | const C2: &'static mut usize = unsafe { &mut S };
    |                                              ^
    |
-   = help: consider extracting the value of the `static` to a `const`, and referring to that
+   = note: see issue #119618 <https://github.com/rust-lang/rust/issues/119618> for more information
+   = help: add `#![feature(const_refs_to_static)]` to the crate attributes to enable
+   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
+   = note: `static` and `const` variables can refer to other `const` variables. A `const` variable, however, cannot refer to a `static` variable.
+   = help: to fix this, the value can be extracted to a `const` and then used.
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 
 error: aborting due to 3 previous errors; 1 warning emitted
 
-Some errors have detailed explanations: E0013, E0764.
-For more information about an error, try `rustc --explain E0013`.
+Some errors have detailed explanations: E0658, E0764.
+For more information about an error, try `rustc --explain E0658`.
diff --git a/tests/ui/consts/issue-17718-references.rs b/tests/ui/consts/issue-17718-references.rs
index 03d5f8bb3f1..6a8955f4634 100644
--- a/tests/ui/consts/issue-17718-references.rs
+++ b/tests/ui/consts/issue-17718-references.rs
@@ -6,18 +6,18 @@ const C: usize = 1;
 static S: usize = 1;
 
 const T1: &'static usize = &C;
-const T2: &'static usize = &S; //~ ERROR: constants cannot refer to statics
+const T2: &'static usize = &S; //~ ERROR: referencing statics in constants
 static T3: &'static usize = &C;
 static T4: &'static usize = &S;
 
 const T5: usize = C;
-const T6: usize = S; //~ ERROR: constants cannot refer to statics
+const T6: usize = S; //~ ERROR: referencing statics in constants
 static T7: usize = C;
 static T8: usize = S;
 
 const T9: Struct = Struct { a: C };
 const T10: Struct = Struct { a: S };
-//~^ ERROR: constants cannot refer to statics
+//~^ ERROR: referencing statics in constants
 static T11: Struct = Struct { a: C };
 static T12: Struct = Struct { a: S };
 
diff --git a/tests/ui/consts/issue-17718-references.stderr b/tests/ui/consts/issue-17718-references.stderr
index e3c3b369ffb..8b572203781 100644
--- a/tests/ui/consts/issue-17718-references.stderr
+++ b/tests/ui/consts/issue-17718-references.stderr
@@ -1,27 +1,39 @@
-error[E0013]: constants cannot refer to statics
+error[E0658]: referencing statics in constants is unstable
   --> $DIR/issue-17718-references.rs:9:29
    |
 LL | const T2: &'static usize = &S;
    |                             ^
    |
-   = help: consider extracting the value of the `static` to a `const`, and referring to that
+   = note: see issue #119618 <https://github.com/rust-lang/rust/issues/119618> for more information
+   = help: add `#![feature(const_refs_to_static)]` to the crate attributes to enable
+   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
+   = note: `static` and `const` variables can refer to other `const` variables. A `const` variable, however, cannot refer to a `static` variable.
+   = help: to fix this, the value can be extracted to a `const` and then used.
 
-error[E0013]: constants cannot refer to statics
+error[E0658]: referencing statics in constants is unstable
   --> $DIR/issue-17718-references.rs:14:19
    |
 LL | const T6: usize = S;
    |                   ^
    |
-   = help: consider extracting the value of the `static` to a `const`, and referring to that
+   = note: see issue #119618 <https://github.com/rust-lang/rust/issues/119618> for more information
+   = help: add `#![feature(const_refs_to_static)]` to the crate attributes to enable
+   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
+   = note: `static` and `const` variables can refer to other `const` variables. A `const` variable, however, cannot refer to a `static` variable.
+   = help: to fix this, the value can be extracted to a `const` and then used.
 
-error[E0013]: constants cannot refer to statics
+error[E0658]: referencing statics in constants is unstable
   --> $DIR/issue-17718-references.rs:19:33
    |
 LL | const T10: Struct = Struct { a: S };
    |                                 ^
    |
-   = help: consider extracting the value of the `static` to a `const`, and referring to that
+   = note: see issue #119618 <https://github.com/rust-lang/rust/issues/119618> for more information
+   = help: add `#![feature(const_refs_to_static)]` to the crate attributes to enable
+   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
+   = note: `static` and `const` variables can refer to other `const` variables. A `const` variable, however, cannot refer to a `static` variable.
+   = help: to fix this, the value can be extracted to a `const` and then used.
 
 error: aborting due to 3 previous errors
 
-For more information about this error, try `rustc --explain E0013`.
+For more information about this error, try `rustc --explain E0658`.
diff --git a/tests/ui/consts/issue-52060.rs b/tests/ui/consts/issue-52060.rs
index 13b914c0331..0f16ede0400 100644
--- a/tests/ui/consts/issue-52060.rs
+++ b/tests/ui/consts/issue-52060.rs
@@ -2,6 +2,6 @@
 // The compiler shouldn't ICE in this case
 static A: &'static [u32] = &[1];
 static B: [u32; 1] = [0; A.len()];
-//~^ ERROR [E0013]
+//~^ ERROR referencing statics in constants
 
 fn main() {}
diff --git a/tests/ui/consts/issue-52060.stderr b/tests/ui/consts/issue-52060.stderr
index 27d00ad0442..644a5314622 100644
--- a/tests/ui/consts/issue-52060.stderr
+++ b/tests/ui/consts/issue-52060.stderr
@@ -1,11 +1,15 @@
-error[E0013]: constants cannot refer to statics
+error[E0658]: referencing statics in constants is unstable
   --> $DIR/issue-52060.rs:4:26
    |
 LL | static B: [u32; 1] = [0; A.len()];
    |                          ^
    |
-   = help: consider extracting the value of the `static` to a `const`, and referring to that
+   = note: see issue #119618 <https://github.com/rust-lang/rust/issues/119618> for more information
+   = help: add `#![feature(const_refs_to_static)]` to the crate attributes to enable
+   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
+   = note: `static` and `const` variables can refer to other `const` variables. A `const` variable, however, cannot refer to a `static` variable.
+   = help: to fix this, the value can be extracted to a `const` and then used.
 
 error: aborting due to 1 previous error
 
-For more information about this error, try `rustc --explain E0013`.
+For more information about this error, try `rustc --explain E0658`.
diff --git a/tests/ui/consts/min_const_fn/min_const_fn.rs b/tests/ui/consts/min_const_fn/min_const_fn.rs
index c2891488c7f..76245c08ffc 100644
--- a/tests/ui/consts/min_const_fn/min_const_fn.rs
+++ b/tests/ui/consts/min_const_fn/min_const_fn.rs
@@ -86,8 +86,8 @@ const fn foo11_2<T: Send>(t: T) -> T { t }
 // not ok
 
 static BAR: u32 = 42;
-const fn foo25() -> u32 { BAR } //~ ERROR cannot refer to statics
-const fn foo26() -> &'static u32 { &BAR } //~ ERROR cannot refer to statics
+const fn foo25() -> u32 { BAR } //~ ERROR referencing statics in constant functions
+const fn foo26() -> &'static u32 { &BAR } //~ ERROR referencing statics in constant functions
 const fn foo30(x: *const u32) -> usize { x as usize }
 //~^ ERROR pointers cannot be cast to integers
 const fn foo30_with_unsafe(x: *const u32) -> usize { unsafe { x as usize } }
diff --git a/tests/ui/consts/min_const_fn/min_const_fn.stderr b/tests/ui/consts/min_const_fn/min_const_fn.stderr
index d646c7de8da..daa0ab2614f 100644
--- a/tests/ui/consts/min_const_fn/min_const_fn.stderr
+++ b/tests/ui/consts/min_const_fn/min_const_fn.stderr
@@ -142,21 +142,29 @@ LL |     const fn get_mut_sq(&mut self) -> &mut T { &mut self.0 }
    = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
    = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
 
-error[E0013]: constant functions cannot refer to statics
+error[E0658]: referencing statics in constant functions is unstable
   --> $DIR/min_const_fn.rs:89:27
    |
 LL | const fn foo25() -> u32 { BAR }
    |                           ^^^
    |
-   = help: consider extracting the value of the `static` to a `const`, and referring to that
+   = note: see issue #119618 <https://github.com/rust-lang/rust/issues/119618> for more information
+   = help: add `#![feature(const_refs_to_static)]` to the crate attributes to enable
+   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
+   = note: `static` and `const` variables can refer to other `const` variables. A `const` variable, however, cannot refer to a `static` variable.
+   = help: to fix this, the value can be extracted to a `const` and then used.
 
-error[E0013]: constant functions cannot refer to statics
+error[E0658]: referencing statics in constant functions is unstable
   --> $DIR/min_const_fn.rs:90:37
    |
 LL | const fn foo26() -> &'static u32 { &BAR }
    |                                     ^^^
    |
-   = help: consider extracting the value of the `static` to a `const`, and referring to that
+   = note: see issue #119618 <https://github.com/rust-lang/rust/issues/119618> for more information
+   = help: add `#![feature(const_refs_to_static)]` to the crate attributes to enable
+   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
+   = note: `static` and `const` variables can refer to other `const` variables. A `const` variable, however, cannot refer to a `static` variable.
+   = help: to fix this, the value can be extracted to a `const` and then used.
 
 error: pointers cannot be cast to integers during const eval
   --> $DIR/min_const_fn.rs:91:42
@@ -222,5 +230,5 @@ LL | const fn no_apit(_x: impl std::fmt::Debug) {}
 
 error: aborting due to 24 previous errors
 
-Some errors have detailed explanations: E0013, E0493, E0658.
-For more information about an error, try `rustc --explain E0013`.
+Some errors have detailed explanations: E0493, E0658.
+For more information about an error, try `rustc --explain E0493`.
diff --git a/tests/ui/consts/miri_unleashed/const_refers_to_static.32bit.stderr b/tests/ui/consts/miri_unleashed/const_refers_to_static.32bit.stderr
index 5fe8e250df9..35b9ed6735e 100644
--- a/tests/ui/consts/miri_unleashed/const_refers_to_static.32bit.stderr
+++ b/tests/ui/consts/miri_unleashed/const_refers_to_static.32bit.stderr
@@ -8,50 +8,28 @@ error[E0080]: evaluation of constant value failed
   --> $DIR/const_refers_to_static.rs:14:14
    |
 LL |     unsafe { *(&FOO as *const _ as *const usize) }
-   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant accesses static
+   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant accesses mutable global memory
 
 error[E0080]: evaluation of constant value failed
   --> $DIR/const_refers_to_static.rs:18:32
    |
 LL | const READ_MUT: u32 = unsafe { MUTABLE };
-   |                                ^^^^^^^ constant accesses static
+   |                                ^^^^^^^ constant accesses mutable global memory
 
 error[E0080]: it is undefined behavior to use this value
-  --> $DIR/const_refers_to_static.rs:20:1
+  --> $DIR/const_refers_to_static.rs:21:1
    |
 LL | const REF_INTERIOR_MUT: &usize = {
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to a static variable in a constant
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered reference to mutable memory in `const`
    |
    = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
    = note: the raw bytes of the constant (size: 4, align: 4) {
                ╾ALLOC0<imm>╼                                     │ ╾──╼
            }
 
-error[E0080]: it is undefined behavior to use this value
-  --> $DIR/const_refers_to_static.rs:27:1
-   |
-LL | const READ_IMMUT: &usize = {
-   | ^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to a static variable in a constant
-   |
-   = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
-   = note: the raw bytes of the constant (size: 4, align: 4) {
-               ╾ALLOC1<imm>╼                                     │ ╾──╼
-           }
-
-error[E0080]: it is undefined behavior to use this value
-  --> $DIR/const_refers_to_static.rs:34:1
-   |
-LL | const REF_IMMUT: &u8 = &MY_STATIC;
-   | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to a static variable in a constant
-   |
-   = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
-   = note: the raw bytes of the constant (size: 4, align: 4) {
-               ╾ALLOC2<imm>╼                                     │ ╾──╼
-           }
-
 warning: skipping const checks
    |
-help: skipping check that does not even have a feature gate
+help: skipping check for `const_refs_to_static` feature
   --> $DIR/const_refers_to_static.rs:9:5
    |
 LL |     FOO.fetch_add(1, Ordering::Relaxed)
@@ -61,37 +39,32 @@ help: skipping check that does not even have a feature gate
    |
 LL |     FOO.fetch_add(1, Ordering::Relaxed)
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-help: skipping check that does not even have a feature gate
+help: skipping check for `const_refs_to_static` feature
   --> $DIR/const_refers_to_static.rs:14:17
    |
 LL |     unsafe { *(&FOO as *const _ as *const usize) }
    |                 ^^^
-help: skipping check that does not even have a feature gate
+help: skipping check for `const_refs_to_static` feature
   --> $DIR/const_refers_to_static.rs:18:32
    |
 LL | const READ_MUT: u32 = unsafe { MUTABLE };
    |                                ^^^^^^^
-help: skipping check that does not even have a feature gate
+help: skipping check for `const_refs_to_static` feature
   --> $DIR/const_refers_to_static.rs:18:32
    |
 LL | const READ_MUT: u32 = unsafe { MUTABLE };
    |                                ^^^^^^^
-help: skipping check that does not even have a feature gate
-  --> $DIR/const_refers_to_static.rs:23:18
+help: skipping check for `const_refs_to_static` feature
+  --> $DIR/const_refers_to_static.rs:24:18
    |
 LL |     unsafe { &*(&FOO as *const _ as *const usize) }
    |                  ^^^
-help: skipping check that does not even have a feature gate
-  --> $DIR/const_refers_to_static.rs:30:6
-   |
-LL |     &FOO
-   |      ^^^
-help: skipping check that does not even have a feature gate
-  --> $DIR/const_refers_to_static.rs:34:25
+help: skipping check for `const_refs_to_static` feature
+  --> $DIR/const_refers_to_static.rs:29:25
    |
 LL | const REF_IMMUT: &u8 = &MY_STATIC;
    |                         ^^^^^^^^^
 
-error: aborting due to 6 previous errors; 1 warning emitted
+error: aborting due to 4 previous errors; 1 warning emitted
 
 For more information about this error, try `rustc --explain E0080`.
diff --git a/tests/ui/consts/miri_unleashed/const_refers_to_static.64bit.stderr b/tests/ui/consts/miri_unleashed/const_refers_to_static.64bit.stderr
index a80b07056a3..8511673b684 100644
--- a/tests/ui/consts/miri_unleashed/const_refers_to_static.64bit.stderr
+++ b/tests/ui/consts/miri_unleashed/const_refers_to_static.64bit.stderr
@@ -8,50 +8,28 @@ error[E0080]: evaluation of constant value failed
   --> $DIR/const_refers_to_static.rs:14:14
    |
 LL |     unsafe { *(&FOO as *const _ as *const usize) }
-   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant accesses static
+   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant accesses mutable global memory
 
 error[E0080]: evaluation of constant value failed
   --> $DIR/const_refers_to_static.rs:18:32
    |
 LL | const READ_MUT: u32 = unsafe { MUTABLE };
-   |                                ^^^^^^^ constant accesses static
+   |                                ^^^^^^^ constant accesses mutable global memory
 
 error[E0080]: it is undefined behavior to use this value
-  --> $DIR/const_refers_to_static.rs:20:1
+  --> $DIR/const_refers_to_static.rs:21:1
    |
 LL | const REF_INTERIOR_MUT: &usize = {
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to a static variable in a constant
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered reference to mutable memory in `const`
    |
    = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
    = note: the raw bytes of the constant (size: 8, align: 8) {
                ╾ALLOC0<imm>╼                         │ ╾──────╼
            }
 
-error[E0080]: it is undefined behavior to use this value
-  --> $DIR/const_refers_to_static.rs:27:1
-   |
-LL | const READ_IMMUT: &usize = {
-   | ^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to a static variable in a constant
-   |
-   = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
-   = note: the raw bytes of the constant (size: 8, align: 8) {
-               ╾ALLOC1<imm>╼                         │ ╾──────╼
-           }
-
-error[E0080]: it is undefined behavior to use this value
-  --> $DIR/const_refers_to_static.rs:34:1
-   |
-LL | const REF_IMMUT: &u8 = &MY_STATIC;
-   | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to a static variable in a constant
-   |
-   = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
-   = note: the raw bytes of the constant (size: 8, align: 8) {
-               ╾ALLOC2<imm>╼                         │ ╾──────╼
-           }
-
 warning: skipping const checks
    |
-help: skipping check that does not even have a feature gate
+help: skipping check for `const_refs_to_static` feature
   --> $DIR/const_refers_to_static.rs:9:5
    |
 LL |     FOO.fetch_add(1, Ordering::Relaxed)
@@ -61,37 +39,32 @@ help: skipping check that does not even have a feature gate
    |
 LL |     FOO.fetch_add(1, Ordering::Relaxed)
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-help: skipping check that does not even have a feature gate
+help: skipping check for `const_refs_to_static` feature
   --> $DIR/const_refers_to_static.rs:14:17
    |
 LL |     unsafe { *(&FOO as *const _ as *const usize) }
    |                 ^^^
-help: skipping check that does not even have a feature gate
+help: skipping check for `const_refs_to_static` feature
   --> $DIR/const_refers_to_static.rs:18:32
    |
 LL | const READ_MUT: u32 = unsafe { MUTABLE };
    |                                ^^^^^^^
-help: skipping check that does not even have a feature gate
+help: skipping check for `const_refs_to_static` feature
   --> $DIR/const_refers_to_static.rs:18:32
    |
 LL | const READ_MUT: u32 = unsafe { MUTABLE };
    |                                ^^^^^^^
-help: skipping check that does not even have a feature gate
-  --> $DIR/const_refers_to_static.rs:23:18
+help: skipping check for `const_refs_to_static` feature
+  --> $DIR/const_refers_to_static.rs:24:18
    |
 LL |     unsafe { &*(&FOO as *const _ as *const usize) }
    |                  ^^^
-help: skipping check that does not even have a feature gate
-  --> $DIR/const_refers_to_static.rs:30:6
-   |
-LL |     &FOO
-   |      ^^^
-help: skipping check that does not even have a feature gate
-  --> $DIR/const_refers_to_static.rs:34:25
+help: skipping check for `const_refs_to_static` feature
+  --> $DIR/const_refers_to_static.rs:29:25
    |
 LL | const REF_IMMUT: &u8 = &MY_STATIC;
    |                         ^^^^^^^^^
 
-error: aborting due to 6 previous errors; 1 warning emitted
+error: aborting due to 4 previous errors; 1 warning emitted
 
 For more information about this error, try `rustc --explain E0080`.
diff --git a/tests/ui/consts/miri_unleashed/const_refers_to_static.rs b/tests/ui/consts/miri_unleashed/const_refers_to_static.rs
index df2563d8d7f..f8d956b3dd8 100644
--- a/tests/ui/consts/miri_unleashed/const_refers_to_static.rs
+++ b/tests/ui/consts/miri_unleashed/const_refers_to_static.rs
@@ -17,22 +17,16 @@ const READ_INTERIOR_MUT: usize = {
 static mut MUTABLE: u32 = 0;
 const READ_MUT: u32 = unsafe { MUTABLE }; //~ERROR evaluation of constant value failed
 
-const REF_INTERIOR_MUT: &usize = { //~ ERROR undefined behavior to use this value
-//~| encountered a reference pointing to a static variable
+// Evaluating this does not read anything mutable, but validation does, so this should error.
+const REF_INTERIOR_MUT: &usize = { //~ ERROR undefined behavior
+    //~| encountered reference to mutable memory
     static FOO: AtomicUsize = AtomicUsize::new(0);
     unsafe { &*(&FOO as *const _ as *const usize) }
 };
 
-// ok some day perhaps
-const READ_IMMUT: &usize = { //~ ERROR it is undefined behavior to use this value
-//~| encountered a reference pointing to a static variable
-    static FOO: usize = 0;
-    &FOO
-};
-
+// Not actually reading from anything mutable, so these are fine.
 static MY_STATIC: u8 = 4;
 const REF_IMMUT: &u8 = &MY_STATIC;
-//~^ ERROR it is undefined behavior to use this value
-//~| encountered a reference pointing to a static variable
+const READ_IMMUT: u8 = *REF_IMMUT;
 
 fn main() {}
diff --git a/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.32bit.stderr b/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.32bit.stderr
index ed9db675426..a2c9034c831 100644
--- a/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.32bit.stderr
+++ b/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.32bit.stderr
@@ -1,5 +1,5 @@
 warning: shared reference of mutable static is discouraged
-  --> $DIR/const_refers_to_static_cross_crate.rs:13:14
+  --> $DIR/const_refers_to_static_cross_crate.rs:12:14
    |
 LL |     unsafe { &static_cross_crate::ZERO }
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^ shared reference of mutable static
@@ -17,7 +17,7 @@ error[E0080]: it is undefined behavior to use this value
   --> $DIR/const_refers_to_static_cross_crate.rs:10:1
    |
 LL | const SLICE_MUT: &[u8; 1] = {
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to a static variable in a constant
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered reference to mutable memory in `const`
    |
    = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
    = note: the raw bytes of the constant (size: 4, align: 4) {
@@ -25,16 +25,16 @@ LL | const SLICE_MUT: &[u8; 1] = {
            }
 
 error: could not evaluate constant pattern
-  --> $DIR/const_refers_to_static_cross_crate.rs:42:9
+  --> $DIR/const_refers_to_static_cross_crate.rs:39:9
    |
 LL |         SLICE_MUT => true,
    |         ^^^^^^^^^
 
 error[E0080]: it is undefined behavior to use this value
-  --> $DIR/const_refers_to_static_cross_crate.rs:17:1
+  --> $DIR/const_refers_to_static_cross_crate.rs:16:1
    |
 LL | const U8_MUT: &u8 = {
-   | ^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to a static variable in a constant
+   | ^^^^^^^^^^^^^^^^^ constructing invalid value: encountered reference to mutable memory in `const`
    |
    = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
    = note: the raw bytes of the constant (size: 4, align: 4) {
@@ -42,89 +42,94 @@ LL | const U8_MUT: &u8 = {
            }
 
 error: could not evaluate constant pattern
-  --> $DIR/const_refers_to_static_cross_crate.rs:50:9
+  --> $DIR/const_refers_to_static_cross_crate.rs:47:9
    |
 LL |         U8_MUT => true,
    |         ^^^^^^
 
-error[E0080]: evaluation of constant value failed
-  --> $DIR/const_refers_to_static_cross_crate.rs:25:15
+error[E0080]: it is undefined behavior to use this value
+  --> $DIR/const_refers_to_static_cross_crate.rs:22:1
    |
-LL |     unsafe { &(*static_cross_crate::ZERO_REF)[0] }
-   |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant accesses static
+LL | const U8_MUT2: &u8 = {
+   | ^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered reference to mutable memory in `const`
+   |
+   = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
+   = note: the raw bytes of the constant (size: 4, align: 4) {
+               ╾ALLOC0<imm>╼                                     │ ╾──╼
+           }
 
 error: could not evaluate constant pattern
-  --> $DIR/const_refers_to_static_cross_crate.rs:60:9
+  --> $DIR/const_refers_to_static_cross_crate.rs:57:9
    |
 LL |         U8_MUT2 => true,
    |         ^^^^^^^
 
 error[E0080]: evaluation of constant value failed
-  --> $DIR/const_refers_to_static_cross_crate.rs:31:15
+  --> $DIR/const_refers_to_static_cross_crate.rs:28:15
    |
 LL |         match static_cross_crate::OPT_ZERO {
-   |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant accesses static
+   |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant accesses mutable global memory
 
 error: could not evaluate constant pattern
-  --> $DIR/const_refers_to_static_cross_crate.rs:67:9
+  --> $DIR/const_refers_to_static_cross_crate.rs:64:9
    |
 LL |         U8_MUT3 => true,
    |         ^^^^^^^
 
 warning: skipping const checks
    |
-help: skipping check that does not even have a feature gate
-  --> $DIR/const_refers_to_static_cross_crate.rs:13:15
+help: skipping check for `const_refs_to_static` feature
+  --> $DIR/const_refers_to_static_cross_crate.rs:12:15
    |
 LL |     unsafe { &static_cross_crate::ZERO }
    |               ^^^^^^^^^^^^^^^^^^^^^^^^
-help: skipping check that does not even have a feature gate
-  --> $DIR/const_refers_to_static_cross_crate.rs:13:15
+help: skipping check for `const_refs_to_static` feature
+  --> $DIR/const_refers_to_static_cross_crate.rs:12:15
    |
 LL |     unsafe { &static_cross_crate::ZERO }
    |               ^^^^^^^^^^^^^^^^^^^^^^^^
-help: skipping check that does not even have a feature gate
-  --> $DIR/const_refers_to_static_cross_crate.rs:20:15
+help: skipping check for `const_refs_to_static` feature
+  --> $DIR/const_refers_to_static_cross_crate.rs:18:15
    |
 LL |     unsafe { &static_cross_crate::ZERO[0] }
    |               ^^^^^^^^^^^^^^^^^^^^^^^^
-help: skipping check that does not even have a feature gate
-  --> $DIR/const_refers_to_static_cross_crate.rs:20:15
+help: skipping check for `const_refs_to_static` feature
+  --> $DIR/const_refers_to_static_cross_crate.rs:18:15
    |
 LL |     unsafe { &static_cross_crate::ZERO[0] }
    |               ^^^^^^^^^^^^^^^^^^^^^^^^
-help: skipping check that does not even have a feature gate
-  --> $DIR/const_refers_to_static_cross_crate.rs:20:15
+help: skipping check for `const_refs_to_static` feature
+  --> $DIR/const_refers_to_static_cross_crate.rs:18:15
    |
 LL |     unsafe { &static_cross_crate::ZERO[0] }
    |               ^^^^^^^^^^^^^^^^^^^^^^^^
-help: skipping check that does not even have a feature gate
-  --> $DIR/const_refers_to_static_cross_crate.rs:25:17
+help: skipping check for `const_refs_to_static` feature
+  --> $DIR/const_refers_to_static_cross_crate.rs:24:17
    |
 LL |     unsafe { &(*static_cross_crate::ZERO_REF)[0] }
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-help: skipping check that does not even have a feature gate
-  --> $DIR/const_refers_to_static_cross_crate.rs:31:15
+help: skipping check for `const_refs_to_static` feature
+  --> $DIR/const_refers_to_static_cross_crate.rs:28:15
    |
 LL |         match static_cross_crate::OPT_ZERO {
    |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-help: skipping check that does not even have a feature gate
-  --> $DIR/const_refers_to_static_cross_crate.rs:31:15
+help: skipping check for `const_refs_to_static` feature
+  --> $DIR/const_refers_to_static_cross_crate.rs:28:15
    |
 LL |         match static_cross_crate::OPT_ZERO {
    |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-help: skipping check that does not even have a feature gate
-  --> $DIR/const_refers_to_static_cross_crate.rs:31:15
+help: skipping check for `const_refs_to_static` feature
+  --> $DIR/const_refers_to_static_cross_crate.rs:28:15
    |
 LL |         match static_cross_crate::OPT_ZERO {
    |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-help: skipping check that does not even have a feature gate
-  --> $DIR/const_refers_to_static_cross_crate.rs:31:15
+help: skipping check for `const_refs_to_static` feature
+  --> $DIR/const_refers_to_static_cross_crate.rs:28:15
    |
 LL |         match static_cross_crate::OPT_ZERO {
    |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-help: skipping check that does not even have a feature gate
-  --> $DIR/const_refers_to_static_cross_crate.rs:31:15
+help: skipping check for `const_refs_to_static` feature
+  --> $DIR/const_refers_to_static_cross_crate.rs:28:15
    |
 LL |         match static_cross_crate::OPT_ZERO {
    |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.64bit.stderr b/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.64bit.stderr
index 275323bc286..2b44a8b12fa 100644
--- a/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.64bit.stderr
+++ b/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.64bit.stderr
@@ -1,5 +1,5 @@
 warning: shared reference of mutable static is discouraged
-  --> $DIR/const_refers_to_static_cross_crate.rs:13:14
+  --> $DIR/const_refers_to_static_cross_crate.rs:12:14
    |
 LL |     unsafe { &static_cross_crate::ZERO }
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^ shared reference of mutable static
@@ -17,7 +17,7 @@ error[E0080]: it is undefined behavior to use this value
   --> $DIR/const_refers_to_static_cross_crate.rs:10:1
    |
 LL | const SLICE_MUT: &[u8; 1] = {
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to a static variable in a constant
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered reference to mutable memory in `const`
    |
    = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
    = note: the raw bytes of the constant (size: 8, align: 8) {
@@ -25,16 +25,16 @@ LL | const SLICE_MUT: &[u8; 1] = {
            }
 
 error: could not evaluate constant pattern
-  --> $DIR/const_refers_to_static_cross_crate.rs:42:9
+  --> $DIR/const_refers_to_static_cross_crate.rs:39:9
    |
 LL |         SLICE_MUT => true,
    |         ^^^^^^^^^
 
 error[E0080]: it is undefined behavior to use this value
-  --> $DIR/const_refers_to_static_cross_crate.rs:17:1
+  --> $DIR/const_refers_to_static_cross_crate.rs:16:1
    |
 LL | const U8_MUT: &u8 = {
-   | ^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to a static variable in a constant
+   | ^^^^^^^^^^^^^^^^^ constructing invalid value: encountered reference to mutable memory in `const`
    |
    = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
    = note: the raw bytes of the constant (size: 8, align: 8) {
@@ -42,89 +42,94 @@ LL | const U8_MUT: &u8 = {
            }
 
 error: could not evaluate constant pattern
-  --> $DIR/const_refers_to_static_cross_crate.rs:50:9
+  --> $DIR/const_refers_to_static_cross_crate.rs:47:9
    |
 LL |         U8_MUT => true,
    |         ^^^^^^
 
-error[E0080]: evaluation of constant value failed
-  --> $DIR/const_refers_to_static_cross_crate.rs:25:15
+error[E0080]: it is undefined behavior to use this value
+  --> $DIR/const_refers_to_static_cross_crate.rs:22:1
    |
-LL |     unsafe { &(*static_cross_crate::ZERO_REF)[0] }
-   |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant accesses static
+LL | const U8_MUT2: &u8 = {
+   | ^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered reference to mutable memory in `const`
+   |
+   = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
+   = note: the raw bytes of the constant (size: 8, align: 8) {
+               ╾ALLOC0<imm>╼                         │ ╾──────╼
+           }
 
 error: could not evaluate constant pattern
-  --> $DIR/const_refers_to_static_cross_crate.rs:60:9
+  --> $DIR/const_refers_to_static_cross_crate.rs:57:9
    |
 LL |         U8_MUT2 => true,
    |         ^^^^^^^
 
 error[E0080]: evaluation of constant value failed
-  --> $DIR/const_refers_to_static_cross_crate.rs:31:15
+  --> $DIR/const_refers_to_static_cross_crate.rs:28:15
    |
 LL |         match static_cross_crate::OPT_ZERO {
-   |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant accesses static
+   |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant accesses mutable global memory
 
 error: could not evaluate constant pattern
-  --> $DIR/const_refers_to_static_cross_crate.rs:67:9
+  --> $DIR/const_refers_to_static_cross_crate.rs:64:9
    |
 LL |         U8_MUT3 => true,
    |         ^^^^^^^
 
 warning: skipping const checks
    |
-help: skipping check that does not even have a feature gate
-  --> $DIR/const_refers_to_static_cross_crate.rs:13:15
+help: skipping check for `const_refs_to_static` feature
+  --> $DIR/const_refers_to_static_cross_crate.rs:12:15
    |
 LL |     unsafe { &static_cross_crate::ZERO }
    |               ^^^^^^^^^^^^^^^^^^^^^^^^
-help: skipping check that does not even have a feature gate
-  --> $DIR/const_refers_to_static_cross_crate.rs:13:15
+help: skipping check for `const_refs_to_static` feature
+  --> $DIR/const_refers_to_static_cross_crate.rs:12:15
    |
 LL |     unsafe { &static_cross_crate::ZERO }
    |               ^^^^^^^^^^^^^^^^^^^^^^^^
-help: skipping check that does not even have a feature gate
-  --> $DIR/const_refers_to_static_cross_crate.rs:20:15
+help: skipping check for `const_refs_to_static` feature
+  --> $DIR/const_refers_to_static_cross_crate.rs:18:15
    |
 LL |     unsafe { &static_cross_crate::ZERO[0] }
    |               ^^^^^^^^^^^^^^^^^^^^^^^^
-help: skipping check that does not even have a feature gate
-  --> $DIR/const_refers_to_static_cross_crate.rs:20:15
+help: skipping check for `const_refs_to_static` feature
+  --> $DIR/const_refers_to_static_cross_crate.rs:18:15
    |
 LL |     unsafe { &static_cross_crate::ZERO[0] }
    |               ^^^^^^^^^^^^^^^^^^^^^^^^
-help: skipping check that does not even have a feature gate
-  --> $DIR/const_refers_to_static_cross_crate.rs:20:15
+help: skipping check for `const_refs_to_static` feature
+  --> $DIR/const_refers_to_static_cross_crate.rs:18:15
    |
 LL |     unsafe { &static_cross_crate::ZERO[0] }
    |               ^^^^^^^^^^^^^^^^^^^^^^^^
-help: skipping check that does not even have a feature gate
-  --> $DIR/const_refers_to_static_cross_crate.rs:25:17
+help: skipping check for `const_refs_to_static` feature
+  --> $DIR/const_refers_to_static_cross_crate.rs:24:17
    |
 LL |     unsafe { &(*static_cross_crate::ZERO_REF)[0] }
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-help: skipping check that does not even have a feature gate
-  --> $DIR/const_refers_to_static_cross_crate.rs:31:15
+help: skipping check for `const_refs_to_static` feature
+  --> $DIR/const_refers_to_static_cross_crate.rs:28:15
    |
 LL |         match static_cross_crate::OPT_ZERO {
    |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-help: skipping check that does not even have a feature gate
-  --> $DIR/const_refers_to_static_cross_crate.rs:31:15
+help: skipping check for `const_refs_to_static` feature
+  --> $DIR/const_refers_to_static_cross_crate.rs:28:15
    |
 LL |         match static_cross_crate::OPT_ZERO {
    |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-help: skipping check that does not even have a feature gate
-  --> $DIR/const_refers_to_static_cross_crate.rs:31:15
+help: skipping check for `const_refs_to_static` feature
+  --> $DIR/const_refers_to_static_cross_crate.rs:28:15
    |
 LL |         match static_cross_crate::OPT_ZERO {
    |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-help: skipping check that does not even have a feature gate
-  --> $DIR/const_refers_to_static_cross_crate.rs:31:15
+help: skipping check for `const_refs_to_static` feature
+  --> $DIR/const_refers_to_static_cross_crate.rs:28:15
    |
 LL |         match static_cross_crate::OPT_ZERO {
    |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-help: skipping check that does not even have a feature gate
-  --> $DIR/const_refers_to_static_cross_crate.rs:31:15
+help: skipping check for `const_refs_to_static` feature
+  --> $DIR/const_refers_to_static_cross_crate.rs:28:15
    |
 LL |         match static_cross_crate::OPT_ZERO {
    |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.rs b/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.rs
index 3eafa58d9f9..cdbfb37c7c7 100644
--- a/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.rs
+++ b/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.rs
@@ -7,30 +7,27 @@ extern crate static_cross_crate;
 
 // Sneaky: reference to a mutable static.
 // Allowing this would be a disaster for pattern matching, we could violate exhaustiveness checking!
-const SLICE_MUT: &[u8; 1] = {
-    //~^ ERROR undefined behavior to use this value
-    //~| encountered a reference pointing to a static variable
+const SLICE_MUT: &[u8; 1] = { //~ ERROR undefined behavior
+    //~| encountered reference to mutable memory
     unsafe { &static_cross_crate::ZERO }
     //~^ WARN shared reference of mutable static is discouraged [static_mut_ref]
 };
 
-const U8_MUT: &u8 = {
-    //~^ ERROR undefined behavior to use this value
-    //~| encountered a reference pointing to a static variable
+const U8_MUT: &u8 = { //~ ERROR undefined behavior
+    //~| encountered reference to mutable memory
     unsafe { &static_cross_crate::ZERO[0] }
 };
 
 // Also test indirection that reads from other static.
-const U8_MUT2: &u8 = {
+const U8_MUT2: &u8 = { //~ ERROR undefined behavior
+    //~| encountered reference to mutable memory
     unsafe { &(*static_cross_crate::ZERO_REF)[0] }
-    //~^ ERROR evaluation of constant value failed
-    //~| constant accesses static
 };
 const U8_MUT3: &u8 = {
     unsafe {
         match static_cross_crate::OPT_ZERO {
             //~^ ERROR evaluation of constant value failed
-            //~| constant accesses static
+            //~| constant accesses mutable global memory
             Some(ref u) => u,
             None => panic!(),
         }
diff --git a/tests/ui/consts/miri_unleashed/mutable_references_err.32bit.stderr b/tests/ui/consts/miri_unleashed/mutable_references_err.32bit.stderr
index 2df80020fdc..b60f9a24f8c 100644
--- a/tests/ui/consts/miri_unleashed/mutable_references_err.32bit.stderr
+++ b/tests/ui/consts/miri_unleashed/mutable_references_err.32bit.stderr
@@ -42,18 +42,24 @@ error[E0080]: it is undefined behavior to use this value
   --> $DIR/mutable_references_err.rs:47:1
    |
 LL | const POINTS_TO_MUTABLE1: &i32 = unsafe { &MUTABLE };
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to a static variable in a constant
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered reference to mutable memory in `const`
    |
    = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
    = note: the raw bytes of the constant (size: 4, align: 4) {
                ╾ALLOC2<imm>╼                                     │ ╾──╼
            }
 
+note: erroneous constant encountered
+  --> $DIR/mutable_references_err.rs:49:34
+   |
+LL | const READS_FROM_MUTABLE: i32 = *POINTS_TO_MUTABLE1;
+   |                                  ^^^^^^^^^^^^^^^^^^
+
 error[E0080]: evaluation of constant value failed
   --> $DIR/mutable_references_err.rs:51:43
    |
 LL | const POINTS_TO_MUTABLE2: &i32 = unsafe { &*MUTABLE_REF };
-   |                                           ^^^^^^^^^^^^^ constant accesses static
+   |                                           ^^^^^^^^^^^^^ constant accesses mutable global memory
 
 error: encountered mutable pointer in final value of constant
   --> $DIR/mutable_references_err.rs:55:1
@@ -103,12 +109,12 @@ help: skipping check that does not even have a feature gate
    |
 LL | const SNEAKY: &dyn Sync = &Synced { x: UnsafeCell::new(42) };
    |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-help: skipping check that does not even have a feature gate
+help: skipping check for `const_refs_to_static` feature
   --> $DIR/mutable_references_err.rs:32:40
    |
 LL | const SUBTLE: &mut i32 = unsafe { &mut FOO };
    |                                        ^^^
-help: skipping check that does not even have a feature gate
+help: skipping check for `const_refs_to_static` feature
   --> $DIR/mutable_references_err.rs:32:40
    |
 LL | const SUBTLE: &mut i32 = unsafe { &mut FOO };
@@ -133,32 +139,22 @@ help: skipping check for `const_mut_refs` feature
    |
 LL | static mut MUT_TO_READONLY: &mut i32 = unsafe { &mut *(&READONLY as *const _ as *mut _) };
    |                                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-help: skipping check that does not even have a feature gate
-  --> $DIR/mutable_references_err.rs:40:49
-   |
-LL | static mut MUT_TO_READONLY: &mut i32 = unsafe { &mut *(&READONLY as *const _ as *mut _) };
-   |                                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-help: skipping check that does not even have a feature gate
+help: skipping check for `const_refs_to_static` feature
   --> $DIR/mutable_references_err.rs:47:44
    |
 LL | const POINTS_TO_MUTABLE1: &i32 = unsafe { &MUTABLE };
    |                                            ^^^^^^^
-help: skipping check that does not even have a feature gate
+help: skipping check for `const_refs_to_static` feature
   --> $DIR/mutable_references_err.rs:47:44
    |
 LL | const POINTS_TO_MUTABLE1: &i32 = unsafe { &MUTABLE };
    |                                            ^^^^^^^
-help: skipping check that does not even have a feature gate
-  --> $DIR/mutable_references_err.rs:50:36
-   |
-LL | static mut MUTABLE_REF: &mut i32 = &mut 42;
-   |                                    ^^^^^^^
-help: skipping check that does not even have a feature gate
+help: skipping check for `const_refs_to_static` feature
   --> $DIR/mutable_references_err.rs:51:45
    |
 LL | const POINTS_TO_MUTABLE2: &i32 = unsafe { &*MUTABLE_REF };
    |                                             ^^^^^^^^^^^
-help: skipping check that does not even have a feature gate
+help: skipping check for `const_refs_to_static` feature
   --> $DIR/mutable_references_err.rs:51:45
    |
 LL | const POINTS_TO_MUTABLE2: &i32 = unsafe { &*MUTABLE_REF };
diff --git a/tests/ui/consts/miri_unleashed/mutable_references_err.64bit.stderr b/tests/ui/consts/miri_unleashed/mutable_references_err.64bit.stderr
index 3ff6811ea61..1e5d4bd890b 100644
--- a/tests/ui/consts/miri_unleashed/mutable_references_err.64bit.stderr
+++ b/tests/ui/consts/miri_unleashed/mutable_references_err.64bit.stderr
@@ -42,18 +42,24 @@ error[E0080]: it is undefined behavior to use this value
   --> $DIR/mutable_references_err.rs:47:1
    |
 LL | const POINTS_TO_MUTABLE1: &i32 = unsafe { &MUTABLE };
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to a static variable in a constant
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered reference to mutable memory in `const`
    |
    = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
    = note: the raw bytes of the constant (size: 8, align: 8) {
                ╾ALLOC2<imm>╼                         │ ╾──────╼
            }
 
+note: erroneous constant encountered
+  --> $DIR/mutable_references_err.rs:49:34
+   |
+LL | const READS_FROM_MUTABLE: i32 = *POINTS_TO_MUTABLE1;
+   |                                  ^^^^^^^^^^^^^^^^^^
+
 error[E0080]: evaluation of constant value failed
   --> $DIR/mutable_references_err.rs:51:43
    |
 LL | const POINTS_TO_MUTABLE2: &i32 = unsafe { &*MUTABLE_REF };
-   |                                           ^^^^^^^^^^^^^ constant accesses static
+   |                                           ^^^^^^^^^^^^^ constant accesses mutable global memory
 
 error: encountered mutable pointer in final value of constant
   --> $DIR/mutable_references_err.rs:55:1
@@ -103,12 +109,12 @@ help: skipping check that does not even have a feature gate
    |
 LL | const SNEAKY: &dyn Sync = &Synced { x: UnsafeCell::new(42) };
    |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-help: skipping check that does not even have a feature gate
+help: skipping check for `const_refs_to_static` feature
   --> $DIR/mutable_references_err.rs:32:40
    |
 LL | const SUBTLE: &mut i32 = unsafe { &mut FOO };
    |                                        ^^^
-help: skipping check that does not even have a feature gate
+help: skipping check for `const_refs_to_static` feature
   --> $DIR/mutable_references_err.rs:32:40
    |
 LL | const SUBTLE: &mut i32 = unsafe { &mut FOO };
@@ -133,32 +139,22 @@ help: skipping check for `const_mut_refs` feature
    |
 LL | static mut MUT_TO_READONLY: &mut i32 = unsafe { &mut *(&READONLY as *const _ as *mut _) };
    |                                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-help: skipping check that does not even have a feature gate
-  --> $DIR/mutable_references_err.rs:40:49
-   |
-LL | static mut MUT_TO_READONLY: &mut i32 = unsafe { &mut *(&READONLY as *const _ as *mut _) };
-   |                                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-help: skipping check that does not even have a feature gate
+help: skipping check for `const_refs_to_static` feature
   --> $DIR/mutable_references_err.rs:47:44
    |
 LL | const POINTS_TO_MUTABLE1: &i32 = unsafe { &MUTABLE };
    |                                            ^^^^^^^
-help: skipping check that does not even have a feature gate
+help: skipping check for `const_refs_to_static` feature
   --> $DIR/mutable_references_err.rs:47:44
    |
 LL | const POINTS_TO_MUTABLE1: &i32 = unsafe { &MUTABLE };
    |                                            ^^^^^^^
-help: skipping check that does not even have a feature gate
-  --> $DIR/mutable_references_err.rs:50:36
-   |
-LL | static mut MUTABLE_REF: &mut i32 = &mut 42;
-   |                                    ^^^^^^^
-help: skipping check that does not even have a feature gate
+help: skipping check for `const_refs_to_static` feature
   --> $DIR/mutable_references_err.rs:51:45
    |
 LL | const POINTS_TO_MUTABLE2: &i32 = unsafe { &*MUTABLE_REF };
    |                                             ^^^^^^^^^^^
-help: skipping check that does not even have a feature gate
+help: skipping check for `const_refs_to_static` feature
   --> $DIR/mutable_references_err.rs:51:45
    |
 LL | const POINTS_TO_MUTABLE2: &i32 = unsafe { &*MUTABLE_REF };
diff --git a/tests/ui/consts/miri_unleashed/mutable_references_err.rs b/tests/ui/consts/miri_unleashed/mutable_references_err.rs
index 83a460dadd0..43b65f459a1 100644
--- a/tests/ui/consts/miri_unleashed/mutable_references_err.rs
+++ b/tests/ui/consts/miri_unleashed/mutable_references_err.rs
@@ -42,15 +42,15 @@ static mut MUT_TO_READONLY: &mut i32 = unsafe { &mut *(&READONLY as *const _ as
 //~| pointing to read-only memory
 
 // Check for consts pointing to mutable memory.
-// Currently it's not even possible to create such a const.
+// These are fine as long as they are not being read.
 static mut MUTABLE: i32 = 42;
-const POINTS_TO_MUTABLE1: &i32 = unsafe { &MUTABLE };
-//~^ ERROR: undefined behavior to use this value
-//~| pointing to a static
+const POINTS_TO_MUTABLE1: &i32 = unsafe { &MUTABLE }; //~ERROR: undefined behavior
+//~| encountered reference to mutable memory
+const READS_FROM_MUTABLE: i32 = *POINTS_TO_MUTABLE1;
 static mut MUTABLE_REF: &mut i32 = &mut 42;
 const POINTS_TO_MUTABLE2: &i32 = unsafe { &*MUTABLE_REF };
 //~^ ERROR: evaluation of constant value failed
-//~| accesses static
+//~| accesses mutable global memory
 
 const POINTS_TO_MUTABLE_INNER: *const i32 = &mut 42 as *mut _ as *const _;
 //~^ ERROR: mutable pointer in final value
diff --git a/tests/ui/consts/static-mut-refs.rs b/tests/ui/consts/static-mut-refs.rs
new file mode 100644
index 00000000000..ff865da5aa8
--- /dev/null
+++ b/tests/ui/consts/static-mut-refs.rs
@@ -0,0 +1,24 @@
+// run-pass
+#![allow(dead_code)]
+
+// Checks that mutable static items can have mutable slices and other references
+
+
+static mut TEST: &'static mut [isize] = &mut [1];
+static mut EMPTY: &'static mut [isize] = &mut [];
+static mut INT: &'static mut isize = &mut 1;
+
+// And the same for raw pointers.
+
+static mut TEST_RAW: *mut [isize] = &mut [1isize] as *mut _;
+static mut EMPTY_RAW: *mut [isize] = &mut [] as *mut _;
+static mut INT_RAW: *mut isize = &mut 1isize as *mut _;
+
+pub fn main() {
+    unsafe {
+        TEST[0] += 1;
+        assert_eq!(TEST[0], 2);
+        *INT_RAW += 1;
+        assert_eq!(*INT_RAW, 2);
+    }
+}
diff --git a/tests/ui/consts/static_mut_containing_mut_ref2.rs b/tests/ui/consts/static_mut_containing_mut_ref2.rs
index fa79a78eab4..b71f1122cd0 100644
--- a/tests/ui/consts/static_mut_containing_mut_ref2.rs
+++ b/tests/ui/consts/static_mut_containing_mut_ref2.rs
@@ -7,7 +7,7 @@ static mut STDERR_BUFFER_SPACE: u8 = 0;
 pub static mut STDERR_BUFFER: () = unsafe {
     *(&mut STDERR_BUFFER_SPACE) = 42;
     //[mut_refs]~^ ERROR could not evaluate static initializer
-    //[stock]~^^ ERROR mutable references are not allowed in statics
+    //[stock]~^^ ERROR mutation through a reference is not allowed in statics
     //[mut_refs]~^^^ WARN mutable reference of mutable static is discouraged [static_mut_ref]
     //[stock]~^^^^ WARN mutable reference of mutable static is discouraged [static_mut_ref]
 };
diff --git a/tests/ui/consts/static_mut_containing_mut_ref2.stock.stderr b/tests/ui/consts/static_mut_containing_mut_ref2.stock.stderr
index e9fe82d2f87..aea5b8a33b5 100644
--- a/tests/ui/consts/static_mut_containing_mut_ref2.stock.stderr
+++ b/tests/ui/consts/static_mut_containing_mut_ref2.stock.stderr
@@ -13,11 +13,11 @@ help: mutable references are dangerous since if there's any other pointer or ref
 LL |     *addr_of_mut!(STDERR_BUFFER_SPACE) = 42;
    |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-error[E0658]: mutable references are not allowed in statics
-  --> $DIR/static_mut_containing_mut_ref2.rs:8:6
+error[E0658]: mutation through a reference is not allowed in statics
+  --> $DIR/static_mut_containing_mut_ref2.rs:8:5
    |
 LL |     *(&mut STDERR_BUFFER_SPACE) = 42;
-   |      ^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
    = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
diff --git a/tests/ui/did_you_mean/bad-assoc-ty.stderr b/tests/ui/did_you_mean/bad-assoc-ty.stderr
index d5754bdc664..4a119f673c8 100644
--- a/tests/ui/did_you_mean/bad-assoc-ty.stderr
+++ b/tests/ui/did_you_mean/bad-assoc-ty.stderr
@@ -191,14 +191,7 @@ error[E0223]: ambiguous associated type
   --> $DIR/bad-assoc-ty.rs:33:10
    |
 LL | type H = Fn(u8) -> (u8)::Output;
-   |          ^^^^^^^^^^^^^^^^^^^^^^
-   |
-help: use fully-qualified syntax
-   |
-LL | type H = <(dyn Fn(u8) -> u8 + 'static) as AsyncFnOnce>::Output;
-   |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-LL | type H = <(dyn Fn(u8) -> u8 + 'static) as IntoFuture>::Output;
-   |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+   |          ^^^^^^^^^^^^^^^^^^^^^^ help: use fully-qualified syntax: `<(dyn Fn(u8) -> u8 + 'static) as IntoFuture>::Output`
 
 error[E0223]: ambiguous associated type
   --> $DIR/bad-assoc-ty.rs:39:19
diff --git a/tests/ui/error-codes/E0013.rs b/tests/ui/error-codes/E0013.rs
deleted file mode 100644
index 9b3982a785b..00000000000
--- a/tests/ui/error-codes/E0013.rs
+++ /dev/null
@@ -1,4 +0,0 @@
-static X: i32 = 42;
-const Y: i32 = X; //~ ERROR constants cannot refer to statics [E0013]
-
-fn main() {}
diff --git a/tests/ui/error-codes/E0013.stderr b/tests/ui/error-codes/E0013.stderr
deleted file mode 100644
index b07c8bdb700..00000000000
--- a/tests/ui/error-codes/E0013.stderr
+++ /dev/null
@@ -1,11 +0,0 @@
-error[E0013]: constants cannot refer to statics
-  --> $DIR/E0013.rs:2:16
-   |
-LL | const Y: i32 = X;
-   |                ^
-   |
-   = help: consider extracting the value of the `static` to a `const`, and referring to that
-
-error: aborting due to 1 previous error
-
-For more information about this error, try `rustc --explain E0013`.
diff --git a/tests/ui/feature-gates/feature-gate-associated_type_bounds.rs b/tests/ui/feature-gates/feature-gate-associated_type_bounds.rs
index f87d3aab635..717da41f871 100644
--- a/tests/ui/feature-gates/feature-gate-associated_type_bounds.rs
+++ b/tests/ui/feature-gates/feature-gate-associated_type_bounds.rs
@@ -42,31 +42,20 @@ type _TaWhere1<T> where T: Iterator<Item: Copy> = T;
 
 fn _apit(_: impl Tr1<As1: Copy>) {}
 //~^ ERROR associated type bounds are unstable
-fn _apit_dyn(_: &dyn Tr1<As1: Copy>) {}
-//~^ ERROR associated type bounds are unstable
 
 fn _rpit() -> impl Tr1<As1: Copy> { S1 }
 //~^ ERROR associated type bounds are unstable
 
-fn _rpit_dyn() -> Box<dyn Tr1<As1: Copy>> { Box::new(S1) }
-//~^ ERROR associated type bounds are unstable
-
 const _cdef: impl Tr1<As1: Copy> = S1;
 //~^ ERROR associated type bounds are unstable
 //~| ERROR `impl Trait` is not allowed in const types
-// FIXME: uncomment when `impl_trait_in_bindings` feature is fixed.
-// const _cdef_dyn: &dyn Tr1<As1: Copy> = &S1;
 
 static _sdef: impl Tr1<As1: Copy> = S1;
 //~^ ERROR associated type bounds are unstable
 //~| ERROR `impl Trait` is not allowed in static types
-// FIXME: uncomment when `impl_trait_in_bindings` feature is fixed.
-// static _sdef_dyn: &dyn Tr1<As1: Copy> = &S1;
 
 fn main() {
     let _: impl Tr1<As1: Copy> = S1;
     //~^ ERROR associated type bounds are unstable
     //~| ERROR `impl Trait` is not allowed in the type of variable bindings
-    // FIXME: uncomment when `impl_trait_in_bindings` feature is fixed.
-    // let _: &dyn Tr1<As1: Copy> = &S1;
 }
diff --git a/tests/ui/feature-gates/feature-gate-associated_type_bounds.stderr b/tests/ui/feature-gates/feature-gate-associated_type_bounds.stderr
index 855a29953f1..1838eab5cda 100644
--- a/tests/ui/feature-gates/feature-gate-associated_type_bounds.stderr
+++ b/tests/ui/feature-gates/feature-gate-associated_type_bounds.stderr
@@ -69,17 +69,7 @@ LL | fn _apit(_: impl Tr1<As1: Copy>) {}
    = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
 
 error[E0658]: associated type bounds are unstable
-  --> $DIR/feature-gate-associated_type_bounds.rs:45:26
-   |
-LL | fn _apit_dyn(_: &dyn Tr1<As1: Copy>) {}
-   |                          ^^^^^^^^^
-   |
-   = note: see issue #52662 <https://github.com/rust-lang/rust/issues/52662> for more information
-   = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable
-   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
-
-error[E0658]: associated type bounds are unstable
-  --> $DIR/feature-gate-associated_type_bounds.rs:48:24
+  --> $DIR/feature-gate-associated_type_bounds.rs:46:24
    |
 LL | fn _rpit() -> impl Tr1<As1: Copy> { S1 }
    |                        ^^^^^^^^^
@@ -89,17 +79,7 @@ LL | fn _rpit() -> impl Tr1<As1: Copy> { S1 }
    = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
 
 error[E0658]: associated type bounds are unstable
-  --> $DIR/feature-gate-associated_type_bounds.rs:51:31
-   |
-LL | fn _rpit_dyn() -> Box<dyn Tr1<As1: Copy>> { Box::new(S1) }
-   |                               ^^^^^^^^^
-   |
-   = note: see issue #52662 <https://github.com/rust-lang/rust/issues/52662> for more information
-   = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable
-   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
-
-error[E0658]: associated type bounds are unstable
-  --> $DIR/feature-gate-associated_type_bounds.rs:54:23
+  --> $DIR/feature-gate-associated_type_bounds.rs:49:23
    |
 LL | const _cdef: impl Tr1<As1: Copy> = S1;
    |                       ^^^^^^^^^
@@ -109,7 +89,7 @@ LL | const _cdef: impl Tr1<As1: Copy> = S1;
    = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
 
 error[E0658]: associated type bounds are unstable
-  --> $DIR/feature-gate-associated_type_bounds.rs:60:24
+  --> $DIR/feature-gate-associated_type_bounds.rs:53:24
    |
 LL | static _sdef: impl Tr1<As1: Copy> = S1;
    |                        ^^^^^^^^^
@@ -119,7 +99,7 @@ LL | static _sdef: impl Tr1<As1: Copy> = S1;
    = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
 
 error[E0658]: associated type bounds are unstable
-  --> $DIR/feature-gate-associated_type_bounds.rs:67:21
+  --> $DIR/feature-gate-associated_type_bounds.rs:58:21
    |
 LL |     let _: impl Tr1<As1: Copy> = S1;
    |                     ^^^^^^^^^
@@ -129,7 +109,7 @@ LL |     let _: impl Tr1<As1: Copy> = S1;
    = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
 
 error[E0562]: `impl Trait` is not allowed in const types
-  --> $DIR/feature-gate-associated_type_bounds.rs:54:14
+  --> $DIR/feature-gate-associated_type_bounds.rs:49:14
    |
 LL | const _cdef: impl Tr1<As1: Copy> = S1;
    |              ^^^^^^^^^^^^^^^^^^^
@@ -137,7 +117,7 @@ LL | const _cdef: impl Tr1<As1: Copy> = S1;
    = note: `impl Trait` is only allowed in arguments and return types of functions and methods
 
 error[E0562]: `impl Trait` is not allowed in static types
-  --> $DIR/feature-gate-associated_type_bounds.rs:60:15
+  --> $DIR/feature-gate-associated_type_bounds.rs:53:15
    |
 LL | static _sdef: impl Tr1<As1: Copy> = S1;
    |               ^^^^^^^^^^^^^^^^^^^
@@ -145,14 +125,14 @@ LL | static _sdef: impl Tr1<As1: Copy> = S1;
    = note: `impl Trait` is only allowed in arguments and return types of functions and methods
 
 error[E0562]: `impl Trait` is not allowed in the type of variable bindings
-  --> $DIR/feature-gate-associated_type_bounds.rs:67:12
+  --> $DIR/feature-gate-associated_type_bounds.rs:58:12
    |
 LL |     let _: impl Tr1<As1: Copy> = S1;
    |            ^^^^^^^^^^^^^^^^^^^
    |
    = note: `impl Trait` is only allowed in arguments and return types of functions and methods
 
-error: aborting due to 16 previous errors
+error: aborting due to 14 previous errors
 
 Some errors have detailed explanations: E0562, E0658.
 For more information about an error, try `rustc --explain E0562`.
diff --git a/tests/ui/feature-gates/feature-gate-const-refs-to-static.rs b/tests/ui/feature-gates/feature-gate-const-refs-to-static.rs
new file mode 100644
index 00000000000..c020bb37a99
--- /dev/null
+++ b/tests/ui/feature-gates/feature-gate-const-refs-to-static.rs
@@ -0,0 +1,12 @@
+static S: i32 = 0;
+static mut S_MUT: i32 = 0;
+
+const C1: &i32 = &S; //~ERROR:  referencing statics in constants is unstable
+const C1_READ: () = {
+    assert!(*C1 == 0);
+};
+const C2: *const i32 = unsafe { std::ptr::addr_of!(S_MUT) }; //~ERROR:  referencing statics in constants is unstable
+//~^ERROR:  referencing statics in constants is unstable
+
+fn main() {
+}
diff --git a/tests/ui/feature-gates/feature-gate-const-refs-to-static.stderr b/tests/ui/feature-gates/feature-gate-const-refs-to-static.stderr
new file mode 100644
index 00000000000..f94cff5b550
--- /dev/null
+++ b/tests/ui/feature-gates/feature-gate-const-refs-to-static.stderr
@@ -0,0 +1,40 @@
+error[E0658]: referencing statics in constants is unstable
+  --> $DIR/feature-gate-const-refs-to-static.rs:4:19
+   |
+LL | const C1: &i32 = &S;
+   |                   ^
+   |
+   = note: see issue #119618 <https://github.com/rust-lang/rust/issues/119618> for more information
+   = help: add `#![feature(const_refs_to_static)]` to the crate attributes to enable
+   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
+   = note: `static` and `const` variables can refer to other `const` variables. A `const` variable, however, cannot refer to a `static` variable.
+   = help: to fix this, the value can be extracted to a `const` and then used.
+
+error[E0658]: referencing statics in constants is unstable
+  --> $DIR/feature-gate-const-refs-to-static.rs:8:52
+   |
+LL | const C2: *const i32 = unsafe { std::ptr::addr_of!(S_MUT) };
+   |                                                    ^^^^^
+   |
+   = note: see issue #119618 <https://github.com/rust-lang/rust/issues/119618> for more information
+   = help: add `#![feature(const_refs_to_static)]` to the crate attributes to enable
+   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
+   = note: `static` and `const` variables can refer to other `const` variables. A `const` variable, however, cannot refer to a `static` variable.
+   = help: to fix this, the value can be extracted to a `const` and then used.
+
+error[E0658]: referencing statics in constants is unstable
+  --> $DIR/feature-gate-const-refs-to-static.rs:8:52
+   |
+LL | const C2: *const i32 = unsafe { std::ptr::addr_of!(S_MUT) };
+   |                                                    ^^^^^
+   |
+   = note: see issue #119618 <https://github.com/rust-lang/rust/issues/119618> for more information
+   = help: add `#![feature(const_refs_to_static)]` to the crate attributes to enable
+   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
+   = note: `static` and `const` variables can refer to other `const` variables. A `const` variable, however, cannot refer to a `static` variable.
+   = help: to fix this, the value can be extracted to a `const` and then used.
+   = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
+
+error: aborting due to 3 previous errors
+
+For more information about this error, try `rustc --explain E0658`.
diff --git a/tests/ui/generic-associated-types/gat-in-trait-path.base.stderr b/tests/ui/generic-associated-types/gat-in-trait-path.base.stderr
index bd3728cec8c..e05c83ebc76 100644
--- a/tests/ui/generic-associated-types/gat-in-trait-path.base.stderr
+++ b/tests/ui/generic-associated-types/gat-in-trait-path.base.stderr
@@ -13,8 +13,8 @@ LL |     type A<'a> where Self: 'a;
    |          ^ ...because it contains the generic associated type `A`
    = help: consider moving `A` to another trait
    = help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `Foo` for this new enum and using it instead:
-             Fooy
              Fooer<T>
+             Fooy
 
 error: aborting due to 1 previous error
 
diff --git a/tests/ui/generic-associated-types/issue-79422.base.stderr b/tests/ui/generic-associated-types/issue-79422.base.stderr
index bcc6382cf7c..7f58f825702 100644
--- a/tests/ui/generic-associated-types/issue-79422.base.stderr
+++ b/tests/ui/generic-associated-types/issue-79422.base.stderr
@@ -29,8 +29,8 @@ LL |     type VRefCont<'a>: RefCont<'a, V> where Self: 'a;
    |          ^^^^^^^^ ...because it contains the generic associated type `VRefCont`
    = help: consider moving `VRefCont` to another trait
    = help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `MapLike` for this new enum and using it instead:
-             std::collections::BTreeMap<K, V>
              Source
+             std::collections::BTreeMap<K, V>
 
 error[E0038]: the trait `MapLike` cannot be made into an object
   --> $DIR/issue-79422.rs:44:13
@@ -47,8 +47,8 @@ LL |     type VRefCont<'a>: RefCont<'a, V> where Self: 'a;
    |          ^^^^^^^^ ...because it contains the generic associated type `VRefCont`
    = help: consider moving `VRefCont` to another trait
    = help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `MapLike` for this new enum and using it instead:
-             std::collections::BTreeMap<K, V>
              Source
+             std::collections::BTreeMap<K, V>
    = note: required for the cast from `Box<BTreeMap<u8, u8>>` to `Box<dyn MapLike<u8, u8, VRefCont = (dyn RefCont<'_, u8> + 'static)>>`
 
 error: aborting due to 3 previous errors
diff --git a/tests/ui/specialization/allow_internal_unstable.rs b/tests/ui/specialization/min_specialization/allow_internal_unstable.rs
index 317782b7b72..8f3677d9769 100644
--- a/tests/ui/specialization/allow_internal_unstable.rs
+++ b/tests/ui/specialization/min_specialization/allow_internal_unstable.rs
@@ -5,6 +5,9 @@
 #![allow(internal_features)]
 #![feature(allow_internal_unstable)]
 
+// aux-build:specialization-trait.rs
+extern crate specialization_trait;
+
 #[allow_internal_unstable(min_specialization)]
 macro_rules! test {
     () => {
@@ -12,7 +15,11 @@ macro_rules! test {
         trait Tr {}
         impl<U> Tr for T<U> {}
         impl Tr for T<u8> {}
-    }
+
+        impl<U> specialization_trait::SpecTrait for T<U> {
+            fn method(&self) {}
+        }
+    };
 }
 
 test! {}
diff --git a/tests/ui/static/issue-18118-2.rs b/tests/ui/static/issue-18118-2.rs
index f712a2eedb7..6c81eec7d7e 100644
--- a/tests/ui/static/issue-18118-2.rs
+++ b/tests/ui/static/issue-18118-2.rs
@@ -1,6 +1,6 @@
 pub fn main() {
     const z: &'static isize = {
         static p: isize = 3;
-        &p //~ ERROR constants cannot refer to statics
+        &p //~ ERROR referencing statics
     };
 }
diff --git a/tests/ui/static/issue-18118-2.stderr b/tests/ui/static/issue-18118-2.stderr
index 6231a276f99..f084f2b9fdf 100644
--- a/tests/ui/static/issue-18118-2.stderr
+++ b/tests/ui/static/issue-18118-2.stderr
@@ -1,11 +1,15 @@
-error[E0013]: constants cannot refer to statics
+error[E0658]: referencing statics in constants is unstable
   --> $DIR/issue-18118-2.rs:4:10
    |
 LL |         &p
    |          ^
    |
-   = help: consider extracting the value of the `static` to a `const`, and referring to that
+   = note: see issue #119618 <https://github.com/rust-lang/rust/issues/119618> for more information
+   = help: add `#![feature(const_refs_to_static)]` to the crate attributes to enable
+   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
+   = note: `static` and `const` variables can refer to other `const` variables. A `const` variable, however, cannot refer to a `static` variable.
+   = help: to fix this, the value can be extracted to a `const` and then used.
 
 error: aborting due to 1 previous error
 
-For more information about this error, try `rustc --explain E0013`.
+For more information about this error, try `rustc --explain E0658`.
diff --git a/tests/ui/thread-local/thread-local-static.rs b/tests/ui/thread-local/thread-local-static.rs
index f5fb0984897..7b69ffed197 100644
--- a/tests/ui/thread-local/thread-local-static.rs
+++ b/tests/ui/thread-local/thread-local-static.rs
@@ -12,7 +12,7 @@ const fn g(x: &mut [u32; 8]) {
     //~^^ ERROR thread-local statics cannot be accessed
     //~| ERROR mutable references are not allowed
     //~| ERROR use of mutable static is unsafe
-    //~| constant functions cannot refer to statics
+    //~| referencing statics
 }
 
 fn main() {}
diff --git a/tests/ui/thread-local/thread-local-static.stderr b/tests/ui/thread-local/thread-local-static.stderr
index 59bd17b39d8..d91742686c6 100644
--- a/tests/ui/thread-local/thread-local-static.stderr
+++ b/tests/ui/thread-local/thread-local-static.stderr
@@ -37,13 +37,17 @@ error[E0625]: thread-local statics cannot be accessed at compile-time
 LL |     std::mem::swap(x, &mut STATIC_VAR_2)
    |                            ^^^^^^^^^^^^
 
-error[E0013]: constant functions cannot refer to statics
+error[E0658]: referencing statics in constant functions is unstable
   --> $DIR/thread-local-static.rs:10:28
    |
 LL |     std::mem::swap(x, &mut STATIC_VAR_2)
    |                            ^^^^^^^^^^^^
    |
-   = help: consider extracting the value of the `static` to a `const`, and referring to that
+   = note: see issue #119618 <https://github.com/rust-lang/rust/issues/119618> for more information
+   = help: add `#![feature(const_refs_to_static)]` to the crate attributes to enable
+   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
+   = note: `static` and `const` variables can refer to other `const` variables. A `const` variable, however, cannot refer to a `static` variable.
+   = help: to fix this, the value can be extracted to a `const` and then used.
 
 error[E0658]: mutable references are not allowed in constant functions
   --> $DIR/thread-local-static.rs:10:23
@@ -57,5 +61,5 @@ LL |     std::mem::swap(x, &mut STATIC_VAR_2)
 
 error: aborting due to 5 previous errors; 1 warning emitted
 
-Some errors have detailed explanations: E0013, E0133, E0625, E0658.
-For more information about an error, try `rustc --explain E0013`.
+Some errors have detailed explanations: E0133, E0625, E0658.
+For more information about an error, try `rustc --explain E0133`.
diff --git a/tests/ui/trait-bounds/suggest-maybe-sized-bound.rs b/tests/ui/trait-bounds/suggest-maybe-sized-bound.rs
new file mode 100644
index 00000000000..15aa27349aa
--- /dev/null
+++ b/tests/ui/trait-bounds/suggest-maybe-sized-bound.rs
@@ -0,0 +1,20 @@
+// issue: 120878
+fn main() {
+    struct StructA<A, B = A> {
+        _marker: std::marker::PhantomData<fn() -> (A, B)>,
+    }
+
+    struct StructB {
+        a: StructA<isize, [u8]>,
+        //~^ ERROR: the size for values of type `[u8]` cannot be known at compilation time [E0277]
+    }
+
+    trait Trait {
+        type P<X>;
+    }
+
+    impl Trait for () {
+        type P<X> = [u8];
+        //~^ ERROR: the size for values of type `[u8]` cannot be known at compilation time [E0277]
+    }
+}
diff --git a/tests/ui/trait-bounds/suggest-maybe-sized-bound.stderr b/tests/ui/trait-bounds/suggest-maybe-sized-bound.stderr
new file mode 100644
index 00000000000..4ce936582f4
--- /dev/null
+++ b/tests/ui/trait-bounds/suggest-maybe-sized-bound.stderr
@@ -0,0 +1,37 @@
+error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
+  --> $DIR/suggest-maybe-sized-bound.rs:8:12
+   |
+LL |         a: StructA<isize, [u8]>,
+   |            ^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
+   |
+   = help: the trait `Sized` is not implemented for `[u8]`
+note: required by an implicit `Sized` bound in `StructA`
+  --> $DIR/suggest-maybe-sized-bound.rs:3:23
+   |
+LL |     struct StructA<A, B = A> {
+   |                       ^^^^^ required by the implicit `Sized` requirement on this type parameter in `StructA`
+help: consider relaxing the implicit `Sized` restriction
+   |
+LL |     struct StructA<A, B: ?Sized = A> {
+   |                        ++++++++
+
+error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
+  --> $DIR/suggest-maybe-sized-bound.rs:17:21
+   |
+LL |         type P<X> = [u8];
+   |                     ^^^^ doesn't have a size known at compile-time
+   |
+   = help: the trait `Sized` is not implemented for `[u8]`
+note: required by a bound in `Trait::P`
+  --> $DIR/suggest-maybe-sized-bound.rs:13:9
+   |
+LL |         type P<X>;
+   |         ^^^^^^^^^^ required by this bound in `Trait::P`
+help: consider relaxing the implicit `Sized` restriction
+   |
+LL |         type P<X>: ?Sized;
+   |                  ++++++++
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/traits/issue-28576.stderr b/tests/ui/traits/issue-28576.stderr
index adba5830b10..653ce05d285 100644
--- a/tests/ui/traits/issue-28576.stderr
+++ b/tests/ui/traits/issue-28576.stderr
@@ -36,8 +36,8 @@ LL | pub trait Bar: Foo<Assoc=()> + Sized {
    |                              +++++++
 help: consider relaxing the implicit `Sized` restriction
    |
-LL | pub trait Foo<RHS=Self: ?Sized> {
-   |                       ++++++++
+LL | pub trait Foo<RHS: ?Sized=Self> {
+   |                  ++++++++
 
 error[E0277]: the size for values of type `Self` cannot be known at compilation time
   --> $DIR/issue-28576.rs:5:16
@@ -56,8 +56,8 @@ LL |     ) where Self: Sized;
    |       +++++++++++++++++
 help: consider relaxing the implicit `Sized` restriction
    |
-LL | pub trait Foo<RHS=Self: ?Sized> {
-   |                       ++++++++
+LL | pub trait Foo<RHS: ?Sized=Self> {
+   |                  ++++++++
 
 error: aborting due to 3 previous errors
 
diff --git a/tests/ui/typeck/issue-120856.rs b/tests/ui/typeck/issue-120856.rs
new file mode 100644
index 00000000000..e435a0f9d8e
--- /dev/null
+++ b/tests/ui/typeck/issue-120856.rs
@@ -0,0 +1,5 @@
+pub type Archived<T> = <m::Alias as n::Trait>::Archived;
+//~^ ERROR failed to resolve: use of undeclared crate or module `m`
+//~| ERROR failed to resolve: use of undeclared crate or module `n`
+
+fn main() {}
diff --git a/tests/ui/typeck/issue-120856.stderr b/tests/ui/typeck/issue-120856.stderr
new file mode 100644
index 00000000000..1fc8b200473
--- /dev/null
+++ b/tests/ui/typeck/issue-120856.stderr
@@ -0,0 +1,21 @@
+error[E0433]: failed to resolve: use of undeclared crate or module `n`
+  --> $DIR/issue-120856.rs:1:37
+   |
+LL | pub type Archived<T> = <m::Alias as n::Trait>::Archived;
+   |                                     ^
+   |                                     |
+   |                                     use of undeclared crate or module `n`
+   |                                     help: a trait with a similar name exists: `Fn`
+
+error[E0433]: failed to resolve: use of undeclared crate or module `m`
+  --> $DIR/issue-120856.rs:1:25
+   |
+LL | pub type Archived<T> = <m::Alias as n::Trait>::Archived;
+   |                         ^
+   |                         |
+   |                         use of undeclared crate or module `m`
+   |                         help: a type parameter with a similar name exists: `T`
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0433`.
diff --git a/tests/ui/wf/wf-unsafe-trait-obj-match.stderr b/tests/ui/wf/wf-unsafe-trait-obj-match.stderr
index a0279774abe..3b53f55ffdc 100644
--- a/tests/ui/wf/wf-unsafe-trait-obj-match.stderr
+++ b/tests/ui/wf/wf-unsafe-trait-obj-match.stderr
@@ -30,8 +30,8 @@ LL | trait Trait: Sized {}
    |       |
    |       this trait cannot be made into an object...
    = help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `Trait` for this new enum and using it instead:
-             S
              R
+             S
    = note: required for the cast from `&S` to `&dyn Trait`
 
 error[E0038]: the trait `Trait` cannot be made into an object
@@ -52,8 +52,8 @@ LL | trait Trait: Sized {}
    |       |
    |       this trait cannot be made into an object...
    = help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `Trait` for this new enum and using it instead:
-             S
              R
+             S
    = note: required for the cast from `&R` to `&dyn Trait`
 
 error: aborting due to 3 previous errors