about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-09-13 01:10:51 +0000
committerbors <bors@rust-lang.org>2024-09-13 01:10:51 +0000
commitd3a8524e80244d66968ab4522d31145ccba610f4 (patch)
treec90f6a6cd2b24aa90f5038bd2e26ecef4c97d8ff /tests
parentadaff5368b0c7b328a0320a218751d65ab1bba97 (diff)
parente0bd01167e86d07c03e8ddd2bb0a25f689a2a7f5 (diff)
downloadrust-d3a8524e80244d66968ab4522d31145ccba610f4.tar.gz
rust-d3a8524e80244d66968ab4522d31145ccba610f4.zip
Auto merge of #129137 - camelid:lazy-def-macro-const, r=BoxyUwU
Fix anon const def-creation when macros are involved

Fixes #128016.

Ever since #125915, some `ast::AnonConst`s turn into `hir::ConstArgKind::Path`s,
which don't have associated `DefId`s. To deal with the fact that we don't have
resolution information in `DefCollector`, we decided to implement a process
where if the anon const *appeared* to be trivial (i.e., `N` or `{ N }`), we
would avoid creating a def for it in `DefCollector`. If later, in AST lowering,
we realized it turned out to be a unit struct literal, or we were lowering it
to something that didn't use `hir::ConstArg`, we'd create its def there.

However, let's say we have a macro `m!()` that expands to a reference to a free
constant `FOO`. If we use `m!()` in the body of an anon const (e.g., `Foo<{ m!() }>`),
then in def collection, it appears to be a nontrivial anon const and we create
a def. But the macro expands to something that looks like a trivial const arg,
but is not, so in AST lowering we "fix" the mistake we assumed def collection
made and create a def for it. This causes a duplicate definition ICE.

The long-term fix for this is to delay the creation of defs for all expression-like
nodes until AST lowering (see #128844 for an incomplete attempt at this). This
would avoid issues like this one that are caused by hacky workarounds. However,
doing this uncovers a pre-existing bug with opaque types that is quite involved
to fix (see #129023).

In the meantime, this PR fixes the bug by delaying def creation for anon consts
whose bodies are macro invocations until after we expand the macro and know
what is inside it. This is accomplished by adding information to create the
anon const's def to the data in `Resolver.invocation_parents`.

r? `@BoxyUwU`
Diffstat (limited to 'tests')
-rw-r--r--tests/ui-fulldeps/stable-mir/check_instance.rs2
-rw-r--r--tests/ui/coherence/negative-coherence/generic_const_type_mismatch.rs2
-rw-r--r--tests/ui/coherence/negative-coherence/generic_const_type_mismatch.stderr20
-rw-r--r--tests/ui/const-generics/bad-subst-const-kind.rs1
-rw-r--r--tests/ui/const-generics/bad-subst-const-kind.stderr11
-rw-r--r--tests/ui/const-generics/generic_const_exprs/type_mismatch.rs1
-rw-r--r--tests/ui/const-generics/generic_const_exprs/type_mismatch.stderr12
-rw-r--r--tests/ui/const-generics/generic_const_exprs/unevaluated-const-ice-119731.rs4
-rw-r--r--tests/ui/const-generics/generic_const_exprs/unevaluated-const-ice-119731.stderr4
-rw-r--r--tests/ui/const-generics/transmute-fail.rs2
-rw-r--r--tests/ui/const-generics/transmute-fail.stderr41
-rw-r--r--tests/ui/const-generics/type_mismatch.rs2
-rw-r--r--tests/ui/const-generics/type_mismatch.stderr20
-rw-r--r--tests/ui/consts/issue-36163.stderr6
-rw-r--r--tests/ui/feature-gates/feature-gate-const-arg-path.rs5
-rw-r--r--tests/ui/lifetimes/issue-95023.rs1
-rw-r--r--tests/ui/lifetimes/issue-95023.stderr10
-rw-r--r--tests/ui/specialization/default-proj-ty-as-type-of-const-issue-125757.rs1
-rw-r--r--tests/ui/specialization/default-proj-ty-as-type-of-const-issue-125757.stderr14
-rw-r--r--tests/ui/specialization/min_specialization/bad-const-wf-doesnt-specialize.rs1
-rw-r--r--tests/ui/specialization/min_specialization/bad-const-wf-doesnt-specialize.stderr14
-rw-r--r--tests/ui/transmutability/issue-101739-1.rs1
-rw-r--r--tests/ui/transmutability/issue-101739-1.stderr11
-rw-r--r--tests/ui/transmutability/issue-101739-2.rs2
-rw-r--r--tests/ui/transmutability/issue-101739-2.stderr11
-rw-r--r--tests/ui/typeck/issue-114918/const-in-impl-fn-return-type.rs1
-rw-r--r--tests/ui/typeck/issue-114918/const-in-impl-fn-return-type.stderr10
27 files changed, 46 insertions, 164 deletions
diff --git a/tests/ui-fulldeps/stable-mir/check_instance.rs b/tests/ui-fulldeps/stable-mir/check_instance.rs
index 5449c09d35a..68eb3c54593 100644
--- a/tests/ui-fulldeps/stable-mir/check_instance.rs
+++ b/tests/ui-fulldeps/stable-mir/check_instance.rs
@@ -35,7 +35,7 @@ fn test_stable_mir() -> ControlFlow<()> {
     // Get all items and split generic vs monomorphic items.
     let (generic, mono): (Vec<_>, Vec<_>) =
         items.into_iter().partition(|item| item.requires_monomorphization());
-    assert_eq!(mono.len(), 4, "Expected 3 mono functions");
+    assert_eq!(mono.len(), 3, "Expected 3 mono functions");
     assert_eq!(generic.len(), 2, "Expected 2 generic functions");
 
     // For all monomorphic items, get the correspondent instances.
diff --git a/tests/ui/coherence/negative-coherence/generic_const_type_mismatch.rs b/tests/ui/coherence/negative-coherence/generic_const_type_mismatch.rs
index cdfeb9c434e..e07fa78463c 100644
--- a/tests/ui/coherence/negative-coherence/generic_const_type_mismatch.rs
+++ b/tests/ui/coherence/negative-coherence/generic_const_type_mismatch.rs
@@ -5,9 +5,7 @@
 #![feature(with_negative_coherence)]
 trait Trait {}
 impl<const N: u8> Trait for [(); N] {}
-//~^ ERROR: mismatched types
 impl<const N: i8> Trait for [(); N] {}
 //~^ ERROR: conflicting implementations of trait `Trait`
-//~| ERROR: mismatched types
 
 fn main() {}
diff --git a/tests/ui/coherence/negative-coherence/generic_const_type_mismatch.stderr b/tests/ui/coherence/negative-coherence/generic_const_type_mismatch.stderr
index d65450845bc..2087be8e711 100644
--- a/tests/ui/coherence/negative-coherence/generic_const_type_mismatch.stderr
+++ b/tests/ui/coherence/negative-coherence/generic_const_type_mismatch.stderr
@@ -1,25 +1,11 @@
 error[E0119]: conflicting implementations of trait `Trait` for type `[(); _]`
-  --> $DIR/generic_const_type_mismatch.rs:9:1
+  --> $DIR/generic_const_type_mismatch.rs:8:1
    |
 LL | impl<const N: u8> Trait for [(); N] {}
    | ----------------------------------- first implementation here
-LL |
 LL | impl<const N: i8> Trait for [(); N] {}
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `[(); _]`
 
-error[E0308]: mismatched types
-  --> $DIR/generic_const_type_mismatch.rs:7:34
-   |
-LL | impl<const N: u8> Trait for [(); N] {}
-   |                                  ^ expected `usize`, found `u8`
-
-error[E0308]: mismatched types
-  --> $DIR/generic_const_type_mismatch.rs:9:34
-   |
-LL | impl<const N: i8> Trait for [(); N] {}
-   |                                  ^ expected `usize`, found `i8`
-
-error: aborting due to 3 previous errors
+error: aborting due to 1 previous error
 
-Some errors have detailed explanations: E0119, E0308.
-For more information about an error, try `rustc --explain E0119`.
+For more information about this error, try `rustc --explain E0119`.
diff --git a/tests/ui/const-generics/bad-subst-const-kind.rs b/tests/ui/const-generics/bad-subst-const-kind.rs
index c4e74596e9f..cc2ff9b8dea 100644
--- a/tests/ui/const-generics/bad-subst-const-kind.rs
+++ b/tests/ui/const-generics/bad-subst-const-kind.rs
@@ -7,7 +7,6 @@ trait Q {
 
 impl<const N: u64> Q for [u8; N] {
     //~^ ERROR: the constant `N` is not of type `usize`
-    //~| ERROR: mismatched types
     const ASSOC: usize = 1;
 }
 
diff --git a/tests/ui/const-generics/bad-subst-const-kind.stderr b/tests/ui/const-generics/bad-subst-const-kind.stderr
index 21ec8f0768c..5c8d9c90363 100644
--- a/tests/ui/const-generics/bad-subst-const-kind.stderr
+++ b/tests/ui/const-generics/bad-subst-const-kind.stderr
@@ -5,7 +5,7 @@ LL | impl<const N: u64> Q for [u8; N] {
    |                          ^^^^^^^ expected `usize`, found `u64`
 
 error: the constant `13` is not of type `u64`
-  --> $DIR/bad-subst-const-kind.rs:14:24
+  --> $DIR/bad-subst-const-kind.rs:13:24
    |
 LL | pub fn test() -> [u8; <[u8; 13] as Q>::ASSOC] {
    |                        ^^^^^^^^ expected `u64`, found `usize`
@@ -18,12 +18,5 @@ LL | impl<const N: u64> Q for [u8; N] {
    |      |
    |      unsatisfied trait bound introduced here
 
-error[E0308]: mismatched types
-  --> $DIR/bad-subst-const-kind.rs:8:31
-   |
-LL | impl<const N: u64> Q for [u8; N] {
-   |                               ^ expected `usize`, found `u64`
-
-error: aborting due to 3 previous errors
+error: aborting due to 2 previous errors
 
-For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/const-generics/generic_const_exprs/type_mismatch.rs b/tests/ui/const-generics/generic_const_exprs/type_mismatch.rs
index a45deabbb0f..8e5e23b2337 100644
--- a/tests/ui/const-generics/generic_const_exprs/type_mismatch.rs
+++ b/tests/ui/const-generics/generic_const_exprs/type_mismatch.rs
@@ -8,7 +8,6 @@ trait Q {
 impl<const N: u64> Q for [u8; N] {}
 //~^ ERROR not all trait items implemented
 //~| ERROR the constant `N` is not of type `usize`
-//~| ERROR mismatched types
 
 pub fn q_user() -> [u8; <[u8; 13] as Q>::ASSOC] {}
 //~^ ERROR the constant `13` is not of type `u64`
diff --git a/tests/ui/const-generics/generic_const_exprs/type_mismatch.stderr b/tests/ui/const-generics/generic_const_exprs/type_mismatch.stderr
index 68870a8d38d..e03580ec007 100644
--- a/tests/ui/const-generics/generic_const_exprs/type_mismatch.stderr
+++ b/tests/ui/const-generics/generic_const_exprs/type_mismatch.stderr
@@ -14,7 +14,7 @@ LL | impl<const N: u64> Q for [u8; N] {}
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `ASSOC` in implementation
 
 error: the constant `13` is not of type `u64`
-  --> $DIR/type_mismatch.rs:13:26
+  --> $DIR/type_mismatch.rs:12:26
    |
 LL | pub fn q_user() -> [u8; <[u8; 13] as Q>::ASSOC] {}
    |                          ^^^^^^^^ expected `u64`, found `usize`
@@ -28,20 +28,14 @@ LL | impl<const N: u64> Q for [u8; N] {}
    |      unsatisfied trait bound introduced here
 
 error[E0308]: mismatched types
-  --> $DIR/type_mismatch.rs:13:20
+  --> $DIR/type_mismatch.rs:12:20
    |
 LL | pub fn q_user() -> [u8; <[u8; 13] as Q>::ASSOC] {}
    |        ------      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `[u8; <[u8; 13] as Q>::ASSOC]`, found `()`
    |        |
    |        implicitly returns `()` as its body has no tail or `return` expression
 
-error[E0308]: mismatched types
-  --> $DIR/type_mismatch.rs:8:31
-   |
-LL | impl<const N: u64> Q for [u8; N] {}
-   |                               ^ expected `usize`, found `u64`
-
-error: aborting due to 5 previous errors
+error: aborting due to 4 previous errors
 
 Some errors have detailed explanations: E0046, E0308.
 For more information about an error, try `rustc --explain E0046`.
diff --git a/tests/ui/const-generics/generic_const_exprs/unevaluated-const-ice-119731.rs b/tests/ui/const-generics/generic_const_exprs/unevaluated-const-ice-119731.rs
index 05a3487ffca..d11b457a3f6 100644
--- a/tests/ui/const-generics/generic_const_exprs/unevaluated-const-ice-119731.rs
+++ b/tests/ui/const-generics/generic_const_exprs/unevaluated-const-ice-119731.rs
@@ -25,8 +25,8 @@ mod v20 {
     }
 
     impl<const v10: usize> v17<v10, v2> {
-        //~^ ERROR maximum number of nodes exceeded in constant v20::v17::<v10, v2>::{constant#1}
-        //~| ERROR maximum number of nodes exceeded in constant v20::v17::<v10, v2>::{constant#1}
+        //~^ ERROR maximum number of nodes exceeded in constant v20::v17::<v10, v2>::{constant#0}
+        //~| ERROR maximum number of nodes exceeded in constant v20::v17::<v10, v2>::{constant#0}
         pub const fn v21() -> v18 {
             //~^ ERROR cannot find type `v18` in this scope
             v18 { _p: () }
diff --git a/tests/ui/const-generics/generic_const_exprs/unevaluated-const-ice-119731.stderr b/tests/ui/const-generics/generic_const_exprs/unevaluated-const-ice-119731.stderr
index 39f022fbee9..15d3c472585 100644
--- a/tests/ui/const-generics/generic_const_exprs/unevaluated-const-ice-119731.stderr
+++ b/tests/ui/const-generics/generic_const_exprs/unevaluated-const-ice-119731.stderr
@@ -72,13 +72,13 @@ help: add `#![feature(adt_const_params)]` to the crate attributes to enable more
 LL + #![feature(adt_const_params)]
    |
 
-error: maximum number of nodes exceeded in constant v20::v17::<v10, v2>::{constant#1}
+error: maximum number of nodes exceeded in constant v20::v17::<v10, v2>::{constant#0}
   --> $DIR/unevaluated-const-ice-119731.rs:27:37
    |
 LL |     impl<const v10: usize> v17<v10, v2> {
    |                                     ^^
 
-error: maximum number of nodes exceeded in constant v20::v17::<v10, v2>::{constant#1}
+error: maximum number of nodes exceeded in constant v20::v17::<v10, v2>::{constant#0}
   --> $DIR/unevaluated-const-ice-119731.rs:27:37
    |
 LL |     impl<const v10: usize> v17<v10, v2> {
diff --git a/tests/ui/const-generics/transmute-fail.rs b/tests/ui/const-generics/transmute-fail.rs
index a9b297ffb62..7faf670e468 100644
--- a/tests/ui/const-generics/transmute-fail.rs
+++ b/tests/ui/const-generics/transmute-fail.rs
@@ -11,8 +11,6 @@ fn foo<const W: usize, const H: usize>(v: [[u32; H + 1]; W]) -> [[u32; W + 1]; H
 
 fn bar<const W: bool, const H: usize>(v: [[u32; H]; W]) -> [[u32; W]; H] {
     //~^ ERROR: the constant `W` is not of type `usize`
-    //~| ERROR: mismatched types
-    //~| ERROR: mismatched types
     unsafe {
         std::mem::transmute(v)
         //~^ ERROR: the constant `W` is not of type `usize`
diff --git a/tests/ui/const-generics/transmute-fail.stderr b/tests/ui/const-generics/transmute-fail.stderr
index 124fbee8850..4a20034910d 100644
--- a/tests/ui/const-generics/transmute-fail.stderr
+++ b/tests/ui/const-generics/transmute-fail.stderr
@@ -14,13 +14,13 @@ LL |         std::mem::transmute(v)
    = note: target type: `[[u32; W + 1]; H]` (size can vary because of [u32; W + 1])
 
 error: the constant `W` is not of type `usize`
-  --> $DIR/transmute-fail.rs:17:9
+  --> $DIR/transmute-fail.rs:15:9
    |
 LL |         std::mem::transmute(v)
    |         ^^^^^^^^^^^^^^^^^^^ expected `usize`, found `bool`
 
 error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
-  --> $DIR/transmute-fail.rs:24:9
+  --> $DIR/transmute-fail.rs:22:9
    |
 LL |         std::mem::transmute(v)
    |         ^^^^^^^^^^^^^^^^^^^
@@ -29,7 +29,7 @@ LL |         std::mem::transmute(v)
    = note: target type: `[u32; W * H * H]` (this type does not have a fixed size)
 
 error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
-  --> $DIR/transmute-fail.rs:31:9
+  --> $DIR/transmute-fail.rs:29:9
    |
 LL |         std::mem::transmute(v)
    |         ^^^^^^^^^^^^^^^^^^^
@@ -38,7 +38,7 @@ LL |         std::mem::transmute(v)
    = note: target type: `[[[u32; 9999999]; 777777777]; 8888888]` (values of the type `[[u32; 9999999]; 777777777]` are too big for the current architecture)
 
 error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
-  --> $DIR/transmute-fail.rs:38:9
+  --> $DIR/transmute-fail.rs:36:9
    |
 LL |         std::mem::transmute(v)
    |         ^^^^^^^^^^^^^^^^^^^
@@ -47,7 +47,7 @@ LL |         std::mem::transmute(v)
    = note: target type: `[[u32; W]; H]` (size can vary because of [u32; W])
 
 error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
-  --> $DIR/transmute-fail.rs:49:9
+  --> $DIR/transmute-fail.rs:47:9
    |
 LL |         std::mem::transmute(v)
    |         ^^^^^^^^^^^^^^^^^^^
@@ -56,7 +56,7 @@ LL |         std::mem::transmute(v)
    = note: target type: `[u32; W * H]` (this type does not have a fixed size)
 
 error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
-  --> $DIR/transmute-fail.rs:56:9
+  --> $DIR/transmute-fail.rs:54:9
    |
 LL |         std::mem::transmute(v)
    |         ^^^^^^^^^^^^^^^^^^^
@@ -65,7 +65,7 @@ LL |         std::mem::transmute(v)
    = note: target type: `[[u32; W]; H]` (size can vary because of [u32; W])
 
 error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
-  --> $DIR/transmute-fail.rs:65:9
+  --> $DIR/transmute-fail.rs:63:9
    |
 LL |         std::mem::transmute(v)
    |         ^^^^^^^^^^^^^^^^^^^
@@ -74,7 +74,7 @@ LL |         std::mem::transmute(v)
    = note: target type: `[u32; D * W * H]` (this type does not have a fixed size)
 
 error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
-  --> $DIR/transmute-fail.rs:74:9
+  --> $DIR/transmute-fail.rs:72:9
    |
 LL |         std::mem::transmute(v)
    |         ^^^^^^^^^^^^^^^^^^^
@@ -83,7 +83,7 @@ LL |         std::mem::transmute(v)
    = note: target type: `[[u32; D * W]; H]` (size can vary because of [u32; D * W])
 
 error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
-  --> $DIR/transmute-fail.rs:81:9
+  --> $DIR/transmute-fail.rs:79:9
    |
 LL |         std::mem::transmute(v)
    |         ^^^^^^^^^^^^^^^^^^^
@@ -92,7 +92,7 @@ LL |         std::mem::transmute(v)
    = note: target type: `[u8; L * 2]` (this type does not have a fixed size)
 
 error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
-  --> $DIR/transmute-fail.rs:88:9
+  --> $DIR/transmute-fail.rs:86:9
    |
 LL |         std::mem::transmute(v)
    |         ^^^^^^^^^^^^^^^^^^^
@@ -101,7 +101,7 @@ LL |         std::mem::transmute(v)
    = note: target type: `[u16; L]` (this type does not have a fixed size)
 
 error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
-  --> $DIR/transmute-fail.rs:95:9
+  --> $DIR/transmute-fail.rs:93:9
    |
 LL |         std::mem::transmute(v)
    |         ^^^^^^^^^^^^^^^^^^^
@@ -110,7 +110,7 @@ LL |         std::mem::transmute(v)
    = note: target type: `[[u8; 1]; L]` (this type does not have a fixed size)
 
 error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
-  --> $DIR/transmute-fail.rs:104:9
+  --> $DIR/transmute-fail.rs:102:9
    |
 LL |         std::mem::transmute(v)
    |         ^^^^^^^^^^^^^^^^^^^
@@ -118,19 +118,6 @@ LL |         std::mem::transmute(v)
    = note: source type: `[[u32; 2 * H]; W + W]` (size can vary because of [u32; 2 * H])
    = note: target type: `[[u32; W + W]; 2 * H]` (size can vary because of [u32; W + W])
 
-error[E0308]: mismatched types
-  --> $DIR/transmute-fail.rs:12:53
-   |
-LL | fn bar<const W: bool, const H: usize>(v: [[u32; H]; W]) -> [[u32; W]; H] {
-   |                                                     ^ expected `usize`, found `bool`
-
-error[E0308]: mismatched types
-  --> $DIR/transmute-fail.rs:12:67
-   |
-LL | fn bar<const W: bool, const H: usize>(v: [[u32; H]; W]) -> [[u32; W]; H] {
-   |                                                                   ^ expected `usize`, found `bool`
-
-error: aborting due to 16 previous errors
+error: aborting due to 14 previous errors
 
-Some errors have detailed explanations: E0308, E0512.
-For more information about an error, try `rustc --explain E0308`.
+For more information about this error, try `rustc --explain E0512`.
diff --git a/tests/ui/const-generics/type_mismatch.rs b/tests/ui/const-generics/type_mismatch.rs
index 9c7217cd83e..8187c785cd1 100644
--- a/tests/ui/const-generics/type_mismatch.rs
+++ b/tests/ui/const-generics/type_mismatch.rs
@@ -1,12 +1,10 @@
 fn foo<const N: usize>() -> [u8; N] {
     bar::<N>()
     //~^ ERROR the constant `N` is not of type `u8`
-    //~| ERROR: mismatched types
 }
 
 fn bar<const N: u8>() -> [u8; N] {}
 //~^ ERROR the constant `N` is not of type `usize`
-//~| ERROR: mismatched types
 //~| ERROR mismatched types
 
 fn main() {}
diff --git a/tests/ui/const-generics/type_mismatch.stderr b/tests/ui/const-generics/type_mismatch.stderr
index 77e9f5e2b44..d1bb5c1242f 100644
--- a/tests/ui/const-generics/type_mismatch.stderr
+++ b/tests/ui/const-generics/type_mismatch.stderr
@@ -1,5 +1,5 @@
 error: the constant `N` is not of type `usize`
-  --> $DIR/type_mismatch.rs:7:26
+  --> $DIR/type_mismatch.rs:6:26
    |
 LL | fn bar<const N: u8>() -> [u8; N] {}
    |                          ^^^^^^^ expected `usize`, found `u8`
@@ -11,31 +11,19 @@ LL |     bar::<N>()
    |           ^ expected `u8`, found `usize`
    |
 note: required by a const generic parameter in `bar`
-  --> $DIR/type_mismatch.rs:7:8
+  --> $DIR/type_mismatch.rs:6:8
    |
 LL | fn bar<const N: u8>() -> [u8; N] {}
    |        ^^^^^^^^^^^ required by this const generic parameter in `bar`
 
 error[E0308]: mismatched types
-  --> $DIR/type_mismatch.rs:7:26
+  --> $DIR/type_mismatch.rs:6:26
    |
 LL | fn bar<const N: u8>() -> [u8; N] {}
    |    ---                   ^^^^^^^ expected `[u8; N]`, found `()`
    |    |
    |    implicitly returns `()` as its body has no tail or `return` expression
 
-error[E0308]: mismatched types
-  --> $DIR/type_mismatch.rs:2:11
-   |
-LL |     bar::<N>()
-   |           ^ expected `u8`, found `usize`
-
-error[E0308]: mismatched types
-  --> $DIR/type_mismatch.rs:7:31
-   |
-LL | fn bar<const N: u8>() -> [u8; N] {}
-   |                               ^ expected `usize`, found `u8`
-
-error: aborting due to 5 previous errors
+error: aborting due to 3 previous errors
 
 For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/consts/issue-36163.stderr b/tests/ui/consts/issue-36163.stderr
index 8a7a0981f41..52d3e003f0a 100644
--- a/tests/ui/consts/issue-36163.stderr
+++ b/tests/ui/consts/issue-36163.stderr
@@ -1,10 +1,10 @@
-error[E0391]: cycle detected when simplifying constant for the type system `Foo::B::{constant#0}`
+error[E0391]: cycle detected when simplifying constant for the type system `Foo::{constant#0}`
   --> $DIR/issue-36163.rs:4:9
    |
 LL |     B = A,
    |         ^
    |
-note: ...which requires const-evaluating + checking `Foo::B::{constant#0}`...
+note: ...which requires const-evaluating + checking `Foo::{constant#0}`...
   --> $DIR/issue-36163.rs:4:9
    |
 LL |     B = A,
@@ -19,7 +19,7 @@ note: ...which requires const-evaluating + checking `A`...
    |
 LL | const A: isize = Foo::B as isize;
    |                  ^^^^^^^^^^^^^^^
-   = note: ...which again requires simplifying constant for the type system `Foo::B::{constant#0}`, completing the cycle
+   = note: ...which again requires simplifying constant for the type system `Foo::{constant#0}`, completing the cycle
 note: cycle used when checking that `Foo` is well-formed
   --> $DIR/issue-36163.rs:3:1
    |
diff --git a/tests/ui/feature-gates/feature-gate-const-arg-path.rs b/tests/ui/feature-gates/feature-gate-const-arg-path.rs
deleted file mode 100644
index 0938c5733a2..00000000000
--- a/tests/ui/feature-gates/feature-gate-const-arg-path.rs
+++ /dev/null
@@ -1,5 +0,0 @@
-//@ check-pass
-
-// this doesn't really have any user facing impact....
-
-fn main() {}
diff --git a/tests/ui/lifetimes/issue-95023.rs b/tests/ui/lifetimes/issue-95023.rs
index 8461d92fc33..1faae50d9f1 100644
--- a/tests/ui/lifetimes/issue-95023.rs
+++ b/tests/ui/lifetimes/issue-95023.rs
@@ -9,6 +9,5 @@ impl Fn(&isize) for Error {
     //~^ ERROR associated function in `impl` without body
     //~| ERROR method `foo` is not a member of trait `Fn` [E0407]
     //~| ERROR associated type `B` not found for `Self` [E0220]
-    //~| ERROR: associated type `B` not found for `Self`
 }
 fn main() {}
diff --git a/tests/ui/lifetimes/issue-95023.stderr b/tests/ui/lifetimes/issue-95023.stderr
index 310dee51406..cbc0eeebee1 100644
--- a/tests/ui/lifetimes/issue-95023.stderr
+++ b/tests/ui/lifetimes/issue-95023.stderr
@@ -56,15 +56,7 @@ error[E0220]: associated type `B` not found for `Self`
 LL |     fn foo<const N: usize>(&self) -> Self::B<{ N }>;
    |                                            ^ help: `Self` has the following associated type: `Output`
 
-error[E0220]: associated type `B` not found for `Self`
-  --> $DIR/issue-95023.rs:8:44
-   |
-LL |     fn foo<const N: usize>(&self) -> Self::B<{ N }>;
-   |                                            ^ help: `Self` has the following associated type: `Output`
-   |
-   = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
-
-error: aborting due to 8 previous errors
+error: aborting due to 7 previous errors
 
 Some errors have detailed explanations: E0046, E0183, E0220, E0229, E0277, E0407.
 For more information about an error, try `rustc --explain E0046`.
diff --git a/tests/ui/specialization/default-proj-ty-as-type-of-const-issue-125757.rs b/tests/ui/specialization/default-proj-ty-as-type-of-const-issue-125757.rs
index 858fba2132a..fb962ad24bf 100644
--- a/tests/ui/specialization/default-proj-ty-as-type-of-const-issue-125757.rs
+++ b/tests/ui/specialization/default-proj-ty-as-type-of-const-issue-125757.rs
@@ -14,6 +14,5 @@ struct Wrapper<const C: <i32 as Trait>::Type> {}
 
 impl<const C: usize> Wrapper<C> {}
 //~^ ERROR the constant `C` is not of type `<i32 as Trait>::Type`
-//~| ERROR: mismatched types
 
 fn main() {}
diff --git a/tests/ui/specialization/default-proj-ty-as-type-of-const-issue-125757.stderr b/tests/ui/specialization/default-proj-ty-as-type-of-const-issue-125757.stderr
index 71d4277275f..7094ee8c67c 100644
--- a/tests/ui/specialization/default-proj-ty-as-type-of-const-issue-125757.stderr
+++ b/tests/ui/specialization/default-proj-ty-as-type-of-const-issue-125757.stderr
@@ -20,17 +20,5 @@ note: required by a const generic parameter in `Wrapper`
 LL | struct Wrapper<const C: <i32 as Trait>::Type> {}
    |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this const generic parameter in `Wrapper`
 
-error[E0308]: mismatched types
-  --> $DIR/default-proj-ty-as-type-of-const-issue-125757.rs:15:30
-   |
-LL | impl<const C: usize> Wrapper<C> {}
-   |                              ^ expected associated type, found `usize`
-   |
-   = note: expected associated type `<i32 as Trait>::Type`
-                         found type `usize`
-   = help: consider constraining the associated type `<i32 as Trait>::Type` to `usize`
-   = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
-
-error: aborting due to 3 previous errors
+error: aborting due to 2 previous errors
 
-For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/specialization/min_specialization/bad-const-wf-doesnt-specialize.rs b/tests/ui/specialization/min_specialization/bad-const-wf-doesnt-specialize.rs
index f89a463bc58..a0ee7714417 100644
--- a/tests/ui/specialization/min_specialization/bad-const-wf-doesnt-specialize.rs
+++ b/tests/ui/specialization/min_specialization/bad-const-wf-doesnt-specialize.rs
@@ -6,7 +6,6 @@
 struct S<const L: usize>;
 
 impl<const N: i32> Copy for S<N> {}
-//~^ ERROR: mismatched types
 impl<const M: usize> Copy for S<M> {}
 //~^ ERROR: conflicting implementations of trait `Copy` for type `S<_>`
 
diff --git a/tests/ui/specialization/min_specialization/bad-const-wf-doesnt-specialize.stderr b/tests/ui/specialization/min_specialization/bad-const-wf-doesnt-specialize.stderr
index 1dac58e1f69..2953bc95917 100644
--- a/tests/ui/specialization/min_specialization/bad-const-wf-doesnt-specialize.stderr
+++ b/tests/ui/specialization/min_specialization/bad-const-wf-doesnt-specialize.stderr
@@ -1,19 +1,11 @@
 error[E0119]: conflicting implementations of trait `Copy` for type `S<_>`
-  --> $DIR/bad-const-wf-doesnt-specialize.rs:10:1
+  --> $DIR/bad-const-wf-doesnt-specialize.rs:9:1
    |
 LL | impl<const N: i32> Copy for S<N> {}
    | -------------------------------- first implementation here
-LL |
 LL | impl<const M: usize> Copy for S<M> {}
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `S<_>`
 
-error[E0308]: mismatched types
-  --> $DIR/bad-const-wf-doesnt-specialize.rs:8:31
-   |
-LL | impl<const N: i32> Copy for S<N> {}
-   |                               ^ expected `usize`, found `i32`
-
-error: aborting due to 2 previous errors
+error: aborting due to 1 previous error
 
-Some errors have detailed explanations: E0119, E0308.
-For more information about an error, try `rustc --explain E0119`.
+For more information about this error, try `rustc --explain E0119`.
diff --git a/tests/ui/transmutability/issue-101739-1.rs b/tests/ui/transmutability/issue-101739-1.rs
index fcc1db073ee..4fde120e2be 100644
--- a/tests/ui/transmutability/issue-101739-1.rs
+++ b/tests/ui/transmutability/issue-101739-1.rs
@@ -7,7 +7,6 @@ mod assert {
     where
         Dst: TransmuteFrom<Src, ASSUME_ALIGNMENT>, //~ ERROR cannot find type `Dst` in this scope
                                                            //~| the constant `ASSUME_ALIGNMENT` is not of type `Assume`
-                                                           //~| ERROR: mismatched types
     {
     }
 }
diff --git a/tests/ui/transmutability/issue-101739-1.stderr b/tests/ui/transmutability/issue-101739-1.stderr
index 3687631dc51..b3c640a00b4 100644
--- a/tests/ui/transmutability/issue-101739-1.stderr
+++ b/tests/ui/transmutability/issue-101739-1.stderr
@@ -13,13 +13,6 @@ LL |         Dst: TransmuteFrom<Src, ASSUME_ALIGNMENT>,
 note: required by a const generic parameter in `TransmuteFrom`
   --> $SRC_DIR/core/src/mem/transmutability.rs:LL:COL
 
-error[E0308]: mismatched types
-  --> $DIR/issue-101739-1.rs:8:33
-   |
-LL |         Dst: TransmuteFrom<Src, ASSUME_ALIGNMENT>,
-   |                                 ^^^^^^^^^^^^^^^^ expected `Assume`, found `bool`
-
-error: aborting due to 3 previous errors
+error: aborting due to 2 previous errors
 
-Some errors have detailed explanations: E0308, E0412.
-For more information about an error, try `rustc --explain E0308`.
+For more information about this error, try `rustc --explain E0412`.
diff --git a/tests/ui/transmutability/issue-101739-2.rs b/tests/ui/transmutability/issue-101739-2.rs
index 02aa4669e05..613626accbb 100644
--- a/tests/ui/transmutability/issue-101739-2.rs
+++ b/tests/ui/transmutability/issue-101739-2.rs
@@ -17,7 +17,7 @@ mod assert {
         Dst: TransmuteFrom<
                 //~^ ERROR trait takes at most 2 generic arguments but 5 generic arguments were supplied
                 Src,
-                ASSUME_ALIGNMENT, //~ ERROR: mismatched types
+                ASSUME_ALIGNMENT,
                 ASSUME_LIFETIMES,
                 ASSUME_VALIDITY,
                 ASSUME_VISIBILITY,
diff --git a/tests/ui/transmutability/issue-101739-2.stderr b/tests/ui/transmutability/issue-101739-2.stderr
index 526fcabe14e..b436ab0e2f9 100644
--- a/tests/ui/transmutability/issue-101739-2.stderr
+++ b/tests/ui/transmutability/issue-101739-2.stderr
@@ -11,13 +11,6 @@ LL | |                 ASSUME_VALIDITY,
 LL | |                 ASSUME_VISIBILITY,
    | |_________________________________- help: remove the unnecessary generic arguments
 
-error[E0308]: mismatched types
-  --> $DIR/issue-101739-2.rs:20:17
-   |
-LL |                 ASSUME_ALIGNMENT,
-   |                 ^^^^^^^^^^^^^^^^ expected `Assume`, found `bool`
-
-error: aborting due to 2 previous errors
+error: aborting due to 1 previous error
 
-Some errors have detailed explanations: E0107, E0308.
-For more information about an error, try `rustc --explain E0107`.
+For more information about this error, try `rustc --explain E0107`.
diff --git a/tests/ui/typeck/issue-114918/const-in-impl-fn-return-type.rs b/tests/ui/typeck/issue-114918/const-in-impl-fn-return-type.rs
index 92c1999e154..5eef2688721 100644
--- a/tests/ui/typeck/issue-114918/const-in-impl-fn-return-type.rs
+++ b/tests/ui/typeck/issue-114918/const-in-impl-fn-return-type.rs
@@ -6,7 +6,6 @@
 trait Trait {
     fn func<const N: u32>() -> [(); N];
     //~^ ERROR: the constant `N` is not of type `usize`
-    //~| ERROR: mismatched types
 }
 
 struct S {}
diff --git a/tests/ui/typeck/issue-114918/const-in-impl-fn-return-type.stderr b/tests/ui/typeck/issue-114918/const-in-impl-fn-return-type.stderr
index bb8025d47a1..8017e5446cc 100644
--- a/tests/ui/typeck/issue-114918/const-in-impl-fn-return-type.stderr
+++ b/tests/ui/typeck/issue-114918/const-in-impl-fn-return-type.stderr
@@ -1,5 +1,5 @@
 error[E0308]: mismatched types
-  --> $DIR/const-in-impl-fn-return-type.rs:16:39
+  --> $DIR/const-in-impl-fn-return-type.rs:15:39
    |
 LL |     fn func<const N: u32>() -> [(); { () }] {
    |                                       ^^ expected `usize`, found `()`
@@ -10,12 +10,6 @@ error: the constant `N` is not of type `usize`
 LL |     fn func<const N: u32>() -> [(); N];
    |                                ^^^^^^^ expected `usize`, found `u32`
 
-error[E0308]: mismatched types
-  --> $DIR/const-in-impl-fn-return-type.rs:7:37
-   |
-LL |     fn func<const N: u32>() -> [(); N];
-   |                                     ^ expected `usize`, found `u32`
-
-error: aborting due to 3 previous errors
+error: aborting due to 2 previous errors
 
 For more information about this error, try `rustc --explain E0308`.