diff --git a/compiler/rustc_const_eval/messages.ftl b/compiler/rustc_const_eval/messages.ftl
index 2dbeb7d5e0ca4..cb5aac7e56010 100644
--- a/compiler/rustc_const_eval/messages.ftl
+++ b/compiler/rustc_const_eval/messages.ftl
@@ -399,7 +399,6 @@ const_eval_unwind_past_top =
 
 ## The `front_matter`s here refer to either `const_eval_front_matter_invalid_value` or `const_eval_front_matter_invalid_value_with_path`.
 ## (We'd love to sort this differently to make that more clear but tidy won't let us...)
-const_eval_validation_box_to_static = {$front_matter}: encountered a box pointing to a static variable in a constant
 const_eval_validation_box_to_uninhabited = {$front_matter}: encountered a box pointing to uninhabited type {$ty}
 
 const_eval_validation_const_ref_to_extern = {$front_matter}: encountered reference to `extern` static in `const`
@@ -454,7 +453,6 @@ const_eval_validation_out_of_range = {$front_matter}: encountered {$value}, but
 const_eval_validation_partial_pointer = {$front_matter}: encountered a partial pointer or a mix of pointers
 const_eval_validation_pointer_as_int = {$front_matter}: encountered a pointer, but {$expected}
 const_eval_validation_ptr_out_of_range = {$front_matter}: encountered a pointer, but expected something that cannot possibly fail to be {$in_range}
-const_eval_validation_ref_to_static = {$front_matter}: encountered a reference pointing to a static variable in a constant
 const_eval_validation_ref_to_uninhabited = {$front_matter}: encountered a reference pointing to uninhabited type {$ty}
 const_eval_validation_unaligned_box = {$front_matter}: encountered an unaligned box (required {$required_bytes} byte alignment but found {$found_bytes})
 const_eval_validation_unaligned_ref = {$front_matter}: encountered an unaligned reference (required {$required_bytes} byte alignment but found {$found_bytes})
diff --git a/compiler/rustc_const_eval/src/errors.rs b/compiler/rustc_const_eval/src/errors.rs
index e5ea4c3442eac..91d17fdd8959c 100644
--- a/compiler/rustc_const_eval/src/errors.rs
+++ b/compiler/rustc_const_eval/src/errors.rs
@@ -640,9 +640,6 @@ impl<'tcx> ReportErrorExt for ValidationErrorInfo<'tcx> {
                 const_eval_validation_ref_to_uninhabited
             }
 
-            PtrToStatic { ptr_kind: PointerKind::Box } => const_eval_validation_box_to_static,
-            PtrToStatic { ptr_kind: PointerKind::Ref(_) } => const_eval_validation_ref_to_static,
-
             PointerAsInt { .. } => const_eval_validation_pointer_as_int,
             PartialPointer => const_eval_validation_partial_pointer,
             ConstRefToMutable => const_eval_validation_const_ref_to_mutable,
@@ -807,7 +804,6 @@ impl<'tcx> ReportErrorExt for ValidationErrorInfo<'tcx> {
                 );
             }
             NullPtr { .. }
-            | PtrToStatic { .. }
             | ConstRefToMutable
             | ConstRefToExtern
             | MutableRefToImmutable
diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs
index 9531c002829ea..061afd0306230 100644
--- a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs
+++ b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs
@@ -750,16 +750,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
 
     /// Resolves an associated value path into a base type and associated constant, or method
     /// resolution. The newly resolved definition is written into `type_dependent_defs`.
+    #[instrument(level = "trace", skip(self), ret)]
     pub fn resolve_ty_and_res_fully_qualified_call(
         &self,
         qpath: &'tcx QPath<'tcx>,
         hir_id: HirId,
         span: Span,
     ) -> (Res, Option<LoweredTy<'tcx>>, &'tcx [hir::PathSegment<'tcx>]) {
-        debug!(
-            "resolve_ty_and_res_fully_qualified_call: qpath={:?} hir_id={:?} span={:?}",
-            qpath, hir_id, span
-        );
         let (ty, qself, item_segment) = match *qpath {
             QPath::Resolved(ref opt_qself, path) => {
                 return (
@@ -1417,10 +1414,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
             // This also occurs for an enum variant on a type alias.
             let impl_ty = self.normalize(span, tcx.type_of(impl_def_id).instantiate(tcx, args));
             let self_ty = self.normalize(span, self_ty);
-            match self.at(&self.misc(span), self.param_env).eq(
+            match self.at(&self.misc(span), self.param_env).sub(
                 DefineOpaqueTypes::Yes,
-                impl_ty,
                 self_ty,
+                impl_ty,
             ) {
                 Ok(ok) => self.register_infer_ok_obligations(ok),
                 Err(_) => {
diff --git a/compiler/rustc_middle/src/mir/interpret/error.rs b/compiler/rustc_middle/src/mir/interpret/error.rs
index eabbcc2033f1f..23680f143970d 100644
--- a/compiler/rustc_middle/src/mir/interpret/error.rs
+++ b/compiler/rustc_middle/src/mir/interpret/error.rs
@@ -438,9 +438,6 @@ pub enum ValidationErrorKind<'tcx> {
         ptr_kind: PointerKind,
         ty: Ty<'tcx>,
     },
-    PtrToStatic {
-        ptr_kind: PointerKind,
-    },
     ConstRefToMutable,
     ConstRefToExtern,
     MutableRefToImmutable,
diff --git a/compiler/rustc_privacy/src/lib.rs b/compiler/rustc_privacy/src/lib.rs
index fb57d42f6df18..d37056269385d 100644
--- a/compiler/rustc_privacy/src/lib.rs
+++ b/compiler/rustc_privacy/src/lib.rs
@@ -973,8 +973,12 @@ impl<'tcx> NamePrivacyVisitor<'tcx> {
 
 impl<'tcx> Visitor<'tcx> for NamePrivacyVisitor<'tcx> {
     fn visit_nested_body(&mut self, body_id: hir::BodyId) {
-        let old_maybe_typeck_results =
-            self.maybe_typeck_results.replace(self.tcx.typeck_body(body_id));
+        let new_typeck_results = self.tcx.typeck_body(body_id);
+        // Do not try reporting privacy violations if we failed to infer types.
+        if new_typeck_results.tainted_by_errors.is_some() {
+            return;
+        }
+        let old_maybe_typeck_results = self.maybe_typeck_results.replace(new_typeck_results);
         self.visit_body(self.tcx.hir().body(body_id));
         self.maybe_typeck_results = old_maybe_typeck_results;
     }
diff --git a/tests/crashes/126062.rs b/tests/crashes/126062.rs
deleted file mode 100644
index 9f1bec1d46e40..0000000000000
--- a/tests/crashes/126062.rs
+++ /dev/null
@@ -1,11 +0,0 @@
-//@ known-bug: rust-lang/rust#126062
-struct Fail<T>(Fail);
-impl<T> Fail<i32> {
-    const C: () = panic!();
-}
-
-fn f<T>() {
-    if false {
-        let _val = &Fail::<T>::C;
-    }
-}
diff --git a/tests/ui/associated-consts/wrong-projection-self-ty-invalid-bivariant-arg.rs b/tests/ui/associated-consts/wrong-projection-self-ty-invalid-bivariant-arg.rs
new file mode 100644
index 0000000000000..e2fc2961a448d
--- /dev/null
+++ b/tests/ui/associated-consts/wrong-projection-self-ty-invalid-bivariant-arg.rs
@@ -0,0 +1,10 @@
+struct Fail<T>;
+//~^ ERROR: type parameter `T` is never used
+
+impl Fail<i32> {
+    const C: () = ();
+}
+
+fn main() {
+    Fail::<()>::C
+}
diff --git a/tests/ui/associated-consts/wrong-projection-self-ty-invalid-bivariant-arg.stderr b/tests/ui/associated-consts/wrong-projection-self-ty-invalid-bivariant-arg.stderr
new file mode 100644
index 0000000000000..f0a6ccf243a9e
--- /dev/null
+++ b/tests/ui/associated-consts/wrong-projection-self-ty-invalid-bivariant-arg.stderr
@@ -0,0 +1,12 @@
+error[E0392]: type parameter `T` is never used
+  --> $DIR/wrong-projection-self-ty-invalid-bivariant-arg.rs:1:13
+   |
+LL | struct Fail<T>;
+   |             ^ unused type parameter
+   |
+   = help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData`
+   = help: if you intended `T` to be a const parameter, use `const T: /* Type */` instead
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0392`.
diff --git a/tests/ui/associated-consts/wrong-projection-self-ty-invalid-bivariant-arg2.rs b/tests/ui/associated-consts/wrong-projection-self-ty-invalid-bivariant-arg2.rs
new file mode 100644
index 0000000000000..cb53d902ba18a
--- /dev/null
+++ b/tests/ui/associated-consts/wrong-projection-self-ty-invalid-bivariant-arg2.rs
@@ -0,0 +1,17 @@
+trait Proj {
+    type Assoc;
+}
+impl<T> Proj for T {
+    type Assoc = T;
+}
+
+struct Fail<T: Proj<Assoc = U>, U>(T);
+
+impl Fail<i32, i32> {
+    const C: () = ();
+}
+
+fn main() {
+    Fail::<i32, u32>::C
+    //~^ ERROR: type mismatch
+}
diff --git a/tests/ui/associated-consts/wrong-projection-self-ty-invalid-bivariant-arg2.stderr b/tests/ui/associated-consts/wrong-projection-self-ty-invalid-bivariant-arg2.stderr
new file mode 100644
index 0000000000000..0d63b7f5b2934
--- /dev/null
+++ b/tests/ui/associated-consts/wrong-projection-self-ty-invalid-bivariant-arg2.stderr
@@ -0,0 +1,20 @@
+error[E0271]: type mismatch resolving `<i32 as Proj>::Assoc == u32`
+  --> $DIR/wrong-projection-self-ty-invalid-bivariant-arg2.rs:15:5
+   |
+LL |     Fail::<i32, u32>::C
+   |     ^^^^^^^^^^^^^^^^ type mismatch resolving `<i32 as Proj>::Assoc == u32`
+   |
+note: expected this to be `u32`
+  --> $DIR/wrong-projection-self-ty-invalid-bivariant-arg2.rs:5:18
+   |
+LL |     type Assoc = T;
+   |                  ^
+note: required by a bound in `Fail`
+  --> $DIR/wrong-projection-self-ty-invalid-bivariant-arg2.rs:8:21
+   |
+LL | struct Fail<T: Proj<Assoc = U>, U>(T);
+   |                     ^^^^^^^^^ required by this bound in `Fail`
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0271`.
diff --git a/tests/ui/coercion/coerce-issue-49593-box-never-windows.nofallback.stderr b/tests/ui/coercion/coerce-issue-49593-box-never-windows.nofallback.stderr
deleted file mode 100644
index b976f70acf76a..0000000000000
--- a/tests/ui/coercion/coerce-issue-49593-box-never-windows.nofallback.stderr
+++ /dev/null
@@ -1,19 +0,0 @@
-error[E0277]: the trait bound `(): std::error::Error` is not satisfied
-  --> $DIR/coerce-issue-49593-box-never-windows.rs:18:53
-   |
-LL |     /* *mut $0 is coerced to Box<dyn Error> here */ Box::<_ /* ! */>::new(x)
-   |                                                     ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::error::Error` is not implemented for `()`
-   |
-   = note: required for the cast from `Box<()>` to `Box<(dyn std::error::Error + 'static)>`
-
-error[E0277]: the trait bound `(): std::error::Error` is not satisfied
-  --> $DIR/coerce-issue-49593-box-never-windows.rs:23:49
-   |
-LL |     /* *mut $0 is coerced to *mut Error here */ raw_ptr_box::<_ /* ! */>(x)
-   |                                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::error::Error` is not implemented for `()`
-   |
-   = note: required for the cast from `*mut ()` to `*mut (dyn std::error::Error + 'static)`
-
-error: aborting due to 2 previous errors
-
-For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/coercion/coerce-issue-49593-box-never-windows.rs b/tests/ui/coercion/coerce-issue-49593-box-never-windows.rs
deleted file mode 100644
index b317841ab6e71..0000000000000
--- a/tests/ui/coercion/coerce-issue-49593-box-never-windows.rs
+++ /dev/null
@@ -1,58 +0,0 @@
-//@ revisions: nofallback fallback
-//@ only-windows - the number of `Error` impls is platform-dependent
-//@[fallback] check-pass
-//@[nofallback] check-fail
-
-#![feature(never_type)]
-#![cfg_attr(fallback, feature(never_type_fallback))]
-#![allow(unreachable_code)]
-
-use std::error::Error;
-use std::mem;
-
-fn raw_ptr_box<T>(t: T) -> *mut T {
-    panic!()
-}
-
-fn foo(x: !) -> Box<dyn Error> {
-    /* *mut $0 is coerced to Box<dyn Error> here */ Box::<_ /* ! */>::new(x)
-    //[nofallback]~^ ERROR trait bound `(): std::error::Error` is not satisfied
-}
-
-fn foo_raw_ptr(x: !) -> *mut dyn Error {
-    /* *mut $0 is coerced to *mut Error here */ raw_ptr_box::<_ /* ! */>(x)
-    //[nofallback]~^ ERROR trait bound `(): std::error::Error` is not satisfied
-}
-
-fn no_coercion(d: *mut dyn Error) -> *mut dyn Error {
-    /* an unsize coercion won't compile here, and it is indeed not used
-       because there is nothing requiring the _ to be Sized */
-    d as *mut _
-}
-
-trait Xyz {}
-struct S;
-struct T;
-impl Xyz for S {}
-impl Xyz for T {}
-
-fn foo_no_never() {
-    let mut x /* : Option<S> */ = None;
-    let mut first_iter = false;
-    loop {
-        if !first_iter {
-            let y: Box<dyn Xyz>
-                = /* Box<$0> is coerced to Box<Xyz> here */ Box::new(x.unwrap());
-        }
-
-        x = Some(S);
-        first_iter = true;
-    }
-
-    let mut y : Option<S> = None;
-    // assert types are equal
-    mem::swap(&mut x, &mut y);
-}
-
-fn main() {
-}
diff --git a/tests/ui/coercion/coerce-issue-49593-box-never.fallback.stderr b/tests/ui/coercion/coerce-issue-49593-box-never.fallback.stderr
new file mode 100644
index 0000000000000..ef5633f71348a
--- /dev/null
+++ b/tests/ui/coercion/coerce-issue-49593-box-never.fallback.stderr
@@ -0,0 +1,11 @@
+error[E0277]: the trait bound `(): std::error::Error` is not satisfied
+  --> $DIR/coerce-issue-49593-box-never.rs:18:5
+   |
+LL |     Box::<_ /* ! */>::new(x)
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::error::Error` is not implemented for `()`
+   |
+   = note: required for the cast from `Box<()>` to `Box<(dyn std::error::Error + 'static)>`
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/coercion/coerce-issue-49593-box-never.nofallback.stderr b/tests/ui/coercion/coerce-issue-49593-box-never.nofallback.stderr
index 0d98fa93e5a4b..7222af43b0137 100644
--- a/tests/ui/coercion/coerce-issue-49593-box-never.nofallback.stderr
+++ b/tests/ui/coercion/coerce-issue-49593-box-never.nofallback.stderr
@@ -1,16 +1,16 @@
 error[E0277]: the trait bound `(): std::error::Error` is not satisfied
-  --> $DIR/coerce-issue-49593-box-never.rs:18:53
+  --> $DIR/coerce-issue-49593-box-never.rs:18:5
    |
-LL |     /* *mut $0 is coerced to Box<dyn Error> here */ Box::<_ /* ! */>::new(x)
-   |                                                     ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::error::Error` is not implemented for `()`
+LL |     Box::<_ /* ! */>::new(x)
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::error::Error` is not implemented for `()`
    |
    = note: required for the cast from `Box<()>` to `Box<(dyn std::error::Error + 'static)>`
 
 error[E0277]: the trait bound `(): std::error::Error` is not satisfied
-  --> $DIR/coerce-issue-49593-box-never.rs:23:49
+  --> $DIR/coerce-issue-49593-box-never.rs:24:5
    |
-LL |     /* *mut $0 is coerced to *mut Error here */ raw_ptr_box::<_ /* ! */>(x)
-   |                                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::error::Error` is not implemented for `()`
+LL |     raw_ptr_box::<_ /* ! */>(x)
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::error::Error` is not implemented for `()`
    |
    = note: required for the cast from `*mut ()` to `*mut (dyn std::error::Error + 'static)`
 
diff --git a/tests/ui/coercion/coerce-issue-49593-box-never.rs b/tests/ui/coercion/coerce-issue-49593-box-never.rs
index 19a2c036fbcb3..53071be47dcbe 100644
--- a/tests/ui/coercion/coerce-issue-49593-box-never.rs
+++ b/tests/ui/coercion/coerce-issue-49593-box-never.rs
@@ -1,7 +1,5 @@
 //@ revisions: nofallback fallback
-//@ ignore-windows - the number of `Error` impls is platform-dependent
-//@[fallback] check-pass
-//@[nofallback] check-fail
+//@check-fail
 
 #![feature(never_type)]
 #![cfg_attr(fallback, feature(never_type_fallback))]
@@ -15,18 +13,21 @@ fn raw_ptr_box<T>(t: T) -> *mut T {
 }
 
 fn foo(x: !) -> Box<dyn Error> {
-    /* *mut $0 is coerced to Box<dyn Error> here */ Box::<_ /* ! */>::new(x)
-    //[nofallback]~^ ERROR trait bound `(): std::error::Error` is not satisfied
+    // Subtyping during method resolution will generate new inference vars and
+    // subtype them. Thus fallback will not fall back to `!`, but `()` instead.
+    Box::<_ /* ! */>::new(x)
+    //~^ ERROR trait bound `(): std::error::Error` is not satisfied
 }
 
 fn foo_raw_ptr(x: !) -> *mut dyn Error {
-    /* *mut $0 is coerced to *mut Error here */ raw_ptr_box::<_ /* ! */>(x)
+    /* *mut $0 is coerced to *mut Error here */
+    raw_ptr_box::<_ /* ! */>(x)
     //[nofallback]~^ ERROR trait bound `(): std::error::Error` is not satisfied
 }
 
 fn no_coercion(d: *mut dyn Error) -> *mut dyn Error {
     /* an unsize coercion won't compile here, and it is indeed not used
-       because there is nothing requiring the _ to be Sized */
+    because there is nothing requiring the _ to be Sized */
     d as *mut _
 }
 
@@ -49,10 +50,9 @@ fn foo_no_never() {
         first_iter = true;
     }
 
-    let mut y : Option<S> = None;
+    let mut y: Option<S> = None;
     // assert types are equal
     mem::swap(&mut x, &mut y);
 }
 
-fn main() {
-}
+fn main() {}
diff --git a/tests/ui/const-generics/generic_arg_infer/issue-91614.stderr b/tests/ui/const-generics/generic_arg_infer/issue-91614.stderr
index 5ee42c19dd3db..563406ad5eaa9 100644
--- a/tests/ui/const-generics/generic_arg_infer/issue-91614.stderr
+++ b/tests/ui/const-generics/generic_arg_infer/issue-91614.stderr
@@ -15,7 +15,7 @@ note: required by a bound in `Mask::<T, N>::splat`
   --> $SRC_DIR/core/src/../../portable-simd/crates/core_simd/src/masks.rs:LL:COL
 help: consider giving `y` an explicit type, where the type for type parameter `T` is specified
    |
-LL |     let y: Mask<_, N> = Mask::<_, _>::splat(false);
+LL |     let y: Mask<T, N> = Mask::<_, _>::splat(false);
    |          ++++++++++++
 
 error: aborting due to 1 previous error
diff --git a/tests/ui/inference/need_type_info/type-alias-indirect.stderr b/tests/ui/inference/need_type_info/type-alias-indirect.stderr
index 535c0044aec03..5c5b4c149c170 100644
--- a/tests/ui/inference/need_type_info/type-alias-indirect.stderr
+++ b/tests/ui/inference/need_type_info/type-alias-indirect.stderr
@@ -2,7 +2,7 @@ error[E0282]: type annotations needed
   --> $DIR/type-alias-indirect.rs:14:5
    |
 LL |     IndirectAlias::new();
-   |     ^^^^^^^^^^^^^ cannot infer type for type parameter `T` declared on the type alias `IndirectAlias`
+   |     ^^^^^^^^^^^^^^^^^^^^ cannot infer type for type parameter `T` declared on the type alias `IndirectAlias`
 
 error: aborting due to 1 previous error
 
diff --git a/tests/ui/inference/need_type_info/type-alias.stderr b/tests/ui/inference/need_type_info/type-alias.stderr
index 2c39a3f56466f..fd9bcf2fe3f39 100644
--- a/tests/ui/inference/need_type_info/type-alias.stderr
+++ b/tests/ui/inference/need_type_info/type-alias.stderr
@@ -2,19 +2,19 @@ error[E0282]: type annotations needed
   --> $DIR/type-alias.rs:12:5
    |
 LL |     DirectAlias::new()
-   |     ^^^^^^^^^^^^^^^^^^ cannot infer type for type parameter `T`
+   |     ^^^^^^^^^^^^^^^^^^ cannot infer type for type parameter `T` declared on the type alias `DirectAlias`
 
 error[E0282]: type annotations needed
   --> $DIR/type-alias.rs:18:5
    |
 LL |     IndirectAlias::new();
-   |     ^^^^^^^^^^^^^ cannot infer type for type parameter `T` declared on the type alias `IndirectAlias`
+   |     ^^^^^^^^^^^^^^^^^^^^ cannot infer type for type parameter `T` declared on the type alias `IndirectAlias`
 
 error[E0282]: type annotations needed
   --> $DIR/type-alias.rs:32:5
    |
 LL |     DirectButWithDefaultAlias::new();
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type for type parameter `T`
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type for type parameter `T` declared on the type alias `DirectButWithDefaultAlias`
 
 error: aborting due to 3 previous errors
 
diff --git a/tests/crashes/122736.rs b/tests/ui/privacy/no-ice-on-inference-failure.rs
similarity index 80%
rename from tests/crashes/122736.rs
rename to tests/ui/privacy/no-ice-on-inference-failure.rs
index 83b60444c2f4d..e63b7bff9bc48 100644
--- a/tests/crashes/122736.rs
+++ b/tests/ui/privacy/no-ice-on-inference-failure.rs
@@ -1,9 +1,9 @@
-//@ known-bug: #122736
 fn main_ref() {
     let array = [(); {
         let mut x = &0;
         let mut n = 0;
         while n < 5 {
+            //~^ ERROR constant evaluation is taking a long time
             x = &0;
         }
         0
diff --git a/tests/ui/privacy/no-ice-on-inference-failure.stderr b/tests/ui/privacy/no-ice-on-inference-failure.stderr
new file mode 100644
index 0000000000000..67476e6e21899
--- /dev/null
+++ b/tests/ui/privacy/no-ice-on-inference-failure.stderr
@@ -0,0 +1,27 @@
+error: constant evaluation is taking a long time
+  --> $DIR/no-ice-on-inference-failure.rs:5:9
+   |
+LL | /         while n < 5 {
+LL | |
+LL | |             x = &0;
+LL | |         }
+   | |_________^
+   |
+   = note: this lint makes sure the compiler doesn't get stuck due to infinite loops in const eval.
+           If your compilation actually takes a long time, you can safely allow the lint.
+help: the constant being evaluated
+  --> $DIR/no-ice-on-inference-failure.rs:2:22
+   |
+LL |       let array = [(); {
+   |  ______________________^
+LL | |         let mut x = &0;
+LL | |         let mut n = 0;
+LL | |         while n < 5 {
+...  |
+LL | |         0
+LL | |     }];
+   | |_____^
+   = note: `#[deny(long_running_const_eval)]` on by default
+
+error: aborting due to 1 previous error
+
diff --git a/tests/ui/statics/const_generics.rs b/tests/ui/statics/const_generics.rs
new file mode 100644
index 0000000000000..70d9b933a7656
--- /dev/null
+++ b/tests/ui/statics/const_generics.rs
@@ -0,0 +1,26 @@
+//! Check that we lose the information that `BAR` points to `FOO`
+//! when going through a const generic.
+//! This is not an intentional guarantee, it just describes the status quo.
+
+//@ run-pass
+// With optimizations, LLVM will deduplicate the constant `X` whose
+// value is `&42` to just be a reference to the static. This is correct,
+// but obscures the issue we're trying to show.
+//@ revisions: opt noopt
+//@[noopt] compile-flags: -Copt-level=0
+//@[opt] compile-flags: -O
+
+#![feature(const_refs_to_static)]
+#![feature(adt_const_params)]
+#![allow(incomplete_features)]
+
+static FOO: usize = 42;
+const BAR: &usize = &FOO;
+fn foo<const X: &'static usize>() {
+    // Without optimizations, `X` ends up pointing to a copy of `FOO` instead of `FOO` itself.
+    assert_eq!(cfg!(opt), std::ptr::eq(X, &FOO));
+}
+
+fn main() {
+    foo::<BAR>();
+}
diff --git a/tests/ui/suggestions/mut-borrow-needed-by-trait.rs b/tests/ui/suggestions/mut-borrow-needed-by-trait.rs
index 66e1e77c905e0..924bfd82eb832 100644
--- a/tests/ui/suggestions/mut-borrow-needed-by-trait.rs
+++ b/tests/ui/suggestions/mut-borrow-needed-by-trait.rs
@@ -17,6 +17,7 @@ fn main() {
     let fp = BufWriter::new(fp);
     //~^ ERROR the trait bound `&dyn std::io::Write: std::io::Write` is not satisfied
     //~| ERROR the trait bound `&dyn std::io::Write: std::io::Write` is not satisfied
+    //~| ERROR the trait bound `&dyn std::io::Write: std::io::Write` is not satisfied
 
     writeln!(fp, "hello world").unwrap(); //~ ERROR the method
 }
diff --git a/tests/ui/suggestions/mut-borrow-needed-by-trait.stderr b/tests/ui/suggestions/mut-borrow-needed-by-trait.stderr
index 09a9b1d3b3482..b2f9150142fe4 100644
--- a/tests/ui/suggestions/mut-borrow-needed-by-trait.stderr
+++ b/tests/ui/suggestions/mut-borrow-needed-by-trait.stderr
@@ -10,6 +10,16 @@ LL |     let fp = BufWriter::new(fp);
 note: required by a bound in `BufWriter::<W>::new`
   --> $SRC_DIR/std/src/io/buffered/bufwriter.rs:LL:COL
 
+error[E0277]: the trait bound `&dyn std::io::Write: std::io::Write` is not satisfied
+  --> $DIR/mut-borrow-needed-by-trait.rs:17:14
+   |
+LL |     let fp = BufWriter::new(fp);
+   |              ^^^^^^^^^ the trait `std::io::Write` is not implemented for `&dyn std::io::Write`
+   |
+   = note: `std::io::Write` is implemented for `&mut dyn std::io::Write`, but not for `&dyn std::io::Write`
+note: required by a bound in `BufWriter`
+  --> $SRC_DIR/std/src/io/buffered/bufwriter.rs:LL:COL
+
 error[E0277]: the trait bound `&dyn std::io::Write: std::io::Write` is not satisfied
   --> $DIR/mut-borrow-needed-by-trait.rs:17:14
    |
@@ -21,13 +31,13 @@ note: required by a bound in `BufWriter`
   --> $SRC_DIR/std/src/io/buffered/bufwriter.rs:LL:COL
 
 error[E0599]: the method `write_fmt` exists for struct `BufWriter<&dyn Write>`, but its trait bounds were not satisfied
-  --> $DIR/mut-borrow-needed-by-trait.rs:21:14
+  --> $DIR/mut-borrow-needed-by-trait.rs:22:14
    |
 LL |     writeln!(fp, "hello world").unwrap();
    |     ---------^^---------------- method cannot be called on `BufWriter<&dyn Write>` due to unsatisfied trait bounds
    |
 note: must implement `io::Write`, `fmt::Write`, or have a `write_fmt` method
-  --> $DIR/mut-borrow-needed-by-trait.rs:21:14
+  --> $DIR/mut-borrow-needed-by-trait.rs:22:14
    |
 LL |     writeln!(fp, "hello world").unwrap();
    |              ^^
@@ -35,7 +45,7 @@ LL |     writeln!(fp, "hello world").unwrap();
            `&dyn std::io::Write: std::io::Write`
            which is required by `BufWriter<&dyn std::io::Write>: std::io::Write`
 
-error: aborting due to 3 previous errors
+error: aborting due to 4 previous errors
 
 Some errors have detailed explanations: E0277, E0599.
 For more information about an error, try `rustc --explain E0277`.