about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/test/ui/const-generics/defaults/auxiliary/const_defaulty.rs15
-rw-r--r--src/test/ui/const-generics/defaults/const-default.rs30
-rw-r--r--src/test/ui/const-generics/defaults/default-annotation.rs20
-rw-r--r--src/test/ui/const-generics/defaults/external.rs27
-rw-r--r--src/test/ui/const-generics/defaults/mismatch.rs23
-rw-r--r--src/test/ui/const-generics/defaults/mismatch.stderr52
-rw-r--r--src/test/ui/const-generics/defaults/pretty-printing-ast.rs13
-rw-r--r--src/test/ui/const-generics/defaults/pretty-printing-ast.stdout20
-rw-r--r--src/test/ui/const-generics/defaults/wrong-order.full.stderr2
-rw-r--r--src/test/ui/const-generics/defaults/wrong-order.min.stderr2
-rw-r--r--src/test/ui/const-generics/defaults/wrong-order.rs2
-rw-r--r--src/test/ui/const-generics/min_const_generics/const_default_first.rs9
-rw-r--r--src/test/ui/const-generics/min_const_generics/const_default_first.stderr8
-rw-r--r--src/test/ui/const-generics/min_const_generics/default_function_param.rs8
-rw-r--r--src/test/ui/const-generics/min_const_generics/default_function_param.stderr12
-rw-r--r--src/test/ui/const-generics/min_const_generics/type_and_const_defaults.rs27
-rw-r--r--src/test/ui/const-generics/params-in-ct-in-ty-param-lazy-norm.full.stderr2
-rw-r--r--src/test/ui/const-generics/params-in-ct-in-ty-param-lazy-norm.min.stderr2
-rw-r--r--src/test/ui/const-generics/params-in-ct-in-ty-param-lazy-norm.rs2
-rw-r--r--src/test/ui/error-codes/E0128.stderr4
-rw-r--r--src/test/ui/feature-gates/feature-gate-default_type_parameter_fallback.stderr4
-rw-r--r--src/test/ui/generics/generic-non-trailing-defaults.rs5
-rw-r--r--src/test/ui/generics/generic-non-trailing-defaults.stderr13
-rw-r--r--src/test/ui/generics/generic-type-params-forward-mention.rs2
-rw-r--r--src/test/ui/generics/generic-type-params-forward-mention.stderr4
-rw-r--r--src/test/ui/issues/issue-18183.stderr4
-rw-r--r--src/test/ui/issues/issue-26812.rs2
-rw-r--r--src/test/ui/issues/issue-26812.stderr4
-rw-r--r--src/tools/clippy/clippy_utils/src/ast_utils.rs8
29 files changed, 280 insertions, 46 deletions
diff --git a/src/test/ui/const-generics/defaults/auxiliary/const_defaulty.rs b/src/test/ui/const-generics/defaults/auxiliary/const_defaulty.rs
new file mode 100644
index 00000000000..769b6e952dc
--- /dev/null
+++ b/src/test/ui/const-generics/defaults/auxiliary/const_defaulty.rs
@@ -0,0 +1,15 @@
+#![feature(const_generics)]
+#![feature(const_generics_defaults)]
+#![allow(incomplete_features)]
+
+pub struct Defaulted<const N: usize=3>;
+impl Defaulted {
+    pub fn new() -> Self {
+        Defaulted
+    }
+}
+impl<const N: usize> Defaulted<N> {
+    pub fn value(&self) -> usize {
+        N
+    }
+}
diff --git a/src/test/ui/const-generics/defaults/const-default.rs b/src/test/ui/const-generics/defaults/const-default.rs
new file mode 100644
index 00000000000..150c70770ae
--- /dev/null
+++ b/src/test/ui/const-generics/defaults/const-default.rs
@@ -0,0 +1,30 @@
+// run-pass
+
+#![feature(const_generics)]
+#![feature(const_generics_defaults)]
+#![allow(incomplete_features)]
+
+
+pub struct ConstDefault<const N: usize = 3>;
+
+impl<const N: usize> ConstDefault<N> {
+    fn foo(self) -> usize {
+        N
+    }
+}
+
+impl ConstDefault {
+    fn new() -> Self {
+        ConstDefault
+    }
+
+    fn bar(self) {}
+}
+
+pub fn main() {
+    let s = ConstDefault::new();
+    assert_eq!(s.foo(), 3);
+
+    let w = ConstDefault::<3>;
+    w.bar();
+}
diff --git a/src/test/ui/const-generics/defaults/default-annotation.rs b/src/test/ui/const-generics/defaults/default-annotation.rs
new file mode 100644
index 00000000000..e6e8d732bee
--- /dev/null
+++ b/src/test/ui/const-generics/defaults/default-annotation.rs
@@ -0,0 +1,20 @@
+// run-pass
+#![feature(staged_api)]
+
+#![feature(const_generics)]
+#![feature(const_generics_defaults)]
+#![allow(incomplete_features)]
+
+#![stable(feature = "const_default_test", since="none")]
+
+
+#[unstable(feature = "const_default_stable", issue="none")]
+pub struct ConstDefaultUnstable<const N: usize = 3>;
+
+#[stable(feature = "const_default_unstable", since="none")]
+pub struct ConstDefaultStable<const N: usize = {
+  #[stable(feature = "const_default_unstable_val", since="none")]
+  3
+}>;
+
+fn main() {}
diff --git a/src/test/ui/const-generics/defaults/external.rs b/src/test/ui/const-generics/defaults/external.rs
new file mode 100644
index 00000000000..b39e69ab10b
--- /dev/null
+++ b/src/test/ui/const-generics/defaults/external.rs
@@ -0,0 +1,27 @@
+// aux-build:const_defaulty.rs
+// check-pass
+#![feature(const_generics_defaults)]
+#![allow(incomplete_features)]
+
+extern crate const_defaulty;
+use const_defaulty::Defaulted;
+
+struct Local<const N: usize=4>;
+impl Local {
+    fn new() -> Self {
+        Local
+    }
+}
+impl<const N: usize>Local<N> {
+    fn value(&self) -> usize {
+        N
+    }
+}
+
+fn main() {
+    let v = Defaulted::new();
+    assert_eq!(v.value(), 3);
+
+    let l = Local::new();
+    assert_eq!(l.value(), 4);
+}
diff --git a/src/test/ui/const-generics/defaults/mismatch.rs b/src/test/ui/const-generics/defaults/mismatch.rs
new file mode 100644
index 00000000000..bf578468bb6
--- /dev/null
+++ b/src/test/ui/const-generics/defaults/mismatch.rs
@@ -0,0 +1,23 @@
+#![feature(const_generics)]
+#![feature(const_generics_defaults)]
+#![allow(incomplete_features)]
+
+pub struct Example<const N: usize=13>;
+pub struct Example2<T=u32, const N: usize=13>(T);
+pub struct Example3<const N: usize=13, T=u32>(T);
+pub struct Example4<const N: usize=13, const M: usize=4>;
+
+fn main() {
+  let e: Example::<13> = ();
+  //~^ Error: mismatched types
+  let e: Example2::<u32, 13> = ();
+  //~^ Error: mismatched types
+  let e: Example3::<13, u32> = ();
+  //~^ Error: mismatched types
+  let e: Example3::<7> = ();
+  //~^ Error: mismatched types
+  // FIXME(const_generics_defaults): There should be a note for the error below, but it is
+  // missing.
+  let e: Example4::<7> = ();
+  //~^ Error: mismatched types
+}
diff --git a/src/test/ui/const-generics/defaults/mismatch.stderr b/src/test/ui/const-generics/defaults/mismatch.stderr
new file mode 100644
index 00000000000..c66eb4cd645
--- /dev/null
+++ b/src/test/ui/const-generics/defaults/mismatch.stderr
@@ -0,0 +1,52 @@
+error[E0308]: mismatched types
+  --> $DIR/mismatch.rs:11:26
+   |
+LL |   let e: Example::<13> = ();
+   |          -------------   ^^ expected struct `Example`, found `()`
+   |          |
+   |          expected due to this
+
+error[E0308]: mismatched types
+  --> $DIR/mismatch.rs:13:32
+   |
+LL |   let e: Example2::<u32, 13> = ();
+   |          -------------------   ^^ expected struct `Example2`, found `()`
+   |          |
+   |          expected due to this
+   |
+   = note: expected struct `Example2`
+           found unit type `()`
+
+error[E0308]: mismatched types
+  --> $DIR/mismatch.rs:15:32
+   |
+LL |   let e: Example3::<13, u32> = ();
+   |          -------------------   ^^ expected struct `Example3`, found `()`
+   |          |
+   |          expected due to this
+   |
+   = note: expected struct `Example3`
+           found unit type `()`
+
+error[E0308]: mismatched types
+  --> $DIR/mismatch.rs:17:26
+   |
+LL |   let e: Example3::<7> = ();
+   |          -------------   ^^ expected struct `Example3`, found `()`
+   |          |
+   |          expected due to this
+   |
+   = note: expected struct `Example3<7_usize>`
+           found unit type `()`
+
+error[E0308]: mismatched types
+  --> $DIR/mismatch.rs:21:26
+   |
+LL |   let e: Example4::<7> = ();
+   |          -------------   ^^ expected struct `Example4`, found `()`
+   |          |
+   |          expected due to this
+
+error: aborting due to 5 previous errors
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/const-generics/defaults/pretty-printing-ast.rs b/src/test/ui/const-generics/defaults/pretty-printing-ast.rs
new file mode 100644
index 00000000000..a25d4baca1a
--- /dev/null
+++ b/src/test/ui/const-generics/defaults/pretty-printing-ast.rs
@@ -0,0 +1,13 @@
+// Test the AST pretty printer correctly handles default values for const generics
+// check-pass
+// compile-flags: -Z unpretty=expanded
+
+#![crate_type = "lib"]
+#![feature(const_generics_defaults)]
+#![allow(incomplete_features)]
+
+trait Foo<const KIND: bool = true> {}
+
+fn foo<const SIZE: usize = 5>() {}
+
+struct Range<const FROM: usize = 0, const LEN: usize = 0, const TO: usize = {FROM + LEN}>;
diff --git a/src/test/ui/const-generics/defaults/pretty-printing-ast.stdout b/src/test/ui/const-generics/defaults/pretty-printing-ast.stdout
new file mode 100644
index 00000000000..f7a1d2ca4b2
--- /dev/null
+++ b/src/test/ui/const-generics/defaults/pretty-printing-ast.stdout
@@ -0,0 +1,20 @@
+#![feature(prelude_import)]
+#![no_std]
+// Test the AST pretty printer correctly handles default values for const generics
+// check-pass
+// compile-flags: -Z unpretty=expanded
+
+#![crate_type = "lib"]
+#![feature(const_generics_defaults)]
+#![allow(incomplete_features)]
+#[prelude_import]
+use ::std::prelude::rust_2015::*;
+#[macro_use]
+extern crate std;
+
+trait Foo<const KIND : bool = true> { }
+
+fn foo<const SIZE : usize = 5>() { }
+
+struct Range<const FROM : usize = 0, const LEN : usize = 0, const TO : usize =
+             { FROM + LEN }>;
diff --git a/src/test/ui/const-generics/defaults/wrong-order.full.stderr b/src/test/ui/const-generics/defaults/wrong-order.full.stderr
index 96deb4a8b5a..accc73134d8 100644
--- a/src/test/ui/const-generics/defaults/wrong-order.full.stderr
+++ b/src/test/ui/const-generics/defaults/wrong-order.full.stderr
@@ -1,4 +1,4 @@
-error: type parameters with a default must be trailing
+error: generic parameters with a default must be trailing
   --> $DIR/wrong-order.rs:4:10
    |
 LL | struct A<T = u32, const N: usize> {
diff --git a/src/test/ui/const-generics/defaults/wrong-order.min.stderr b/src/test/ui/const-generics/defaults/wrong-order.min.stderr
index b19da76f415..c8f1d471b24 100644
--- a/src/test/ui/const-generics/defaults/wrong-order.min.stderr
+++ b/src/test/ui/const-generics/defaults/wrong-order.min.stderr
@@ -1,4 +1,4 @@
-error: type parameters with a default must be trailing
+error: generic parameters with a default must be trailing
   --> $DIR/wrong-order.rs:4:10
    |
 LL | struct A<T = u32, const N: usize> {
diff --git a/src/test/ui/const-generics/defaults/wrong-order.rs b/src/test/ui/const-generics/defaults/wrong-order.rs
index 4f1c05011b0..5c2d9b8ad47 100644
--- a/src/test/ui/const-generics/defaults/wrong-order.rs
+++ b/src/test/ui/const-generics/defaults/wrong-order.rs
@@ -2,7 +2,7 @@
 #![cfg_attr(full, feature(const_generics))] //[full]~WARN the feature `const_generics` is incomplete
 
 struct A<T = u32, const N: usize> {
-    //~^ ERROR type parameters with a default must be trailing
+    //~^ ERROR generic parameters with a default must be trailing
     arg: T,
 }
 
diff --git a/src/test/ui/const-generics/min_const_generics/const_default_first.rs b/src/test/ui/const-generics/min_const_generics/const_default_first.rs
new file mode 100644
index 00000000000..ae82c85eb7e
--- /dev/null
+++ b/src/test/ui/const-generics/min_const_generics/const_default_first.rs
@@ -0,0 +1,9 @@
+#![crate_type = "lib"]
+#![feature(const_generics)]
+#![feature(const_generics_defaults)]
+#![allow(incomplete_features, dead_code)]
+
+struct Both<const N: usize=3, T> {
+//~^ ERROR: generic parameters with a default must be
+  v: T
+}
diff --git a/src/test/ui/const-generics/min_const_generics/const_default_first.stderr b/src/test/ui/const-generics/min_const_generics/const_default_first.stderr
new file mode 100644
index 00000000000..f7a2e484fc6
--- /dev/null
+++ b/src/test/ui/const-generics/min_const_generics/const_default_first.stderr
@@ -0,0 +1,8 @@
+error: generic parameters with a default must be trailing
+  --> $DIR/const_default_first.rs:6:19
+   |
+LL | struct Both<const N: usize=3, T> {
+   |                   ^
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/const-generics/min_const_generics/default_function_param.rs b/src/test/ui/const-generics/min_const_generics/default_function_param.rs
index 5b0a42a4556..ebdb5a65bc3 100644
--- a/src/test/ui/const-generics/min_const_generics/default_function_param.rs
+++ b/src/test/ui/const-generics/min_const_generics/default_function_param.rs
@@ -1,4 +1,6 @@
-fn foo<const SIZE: usize = 5>() {}
-//~^ ERROR default values for const generic parameters are experimental
+#![crate_type = "lib"]
+#![feature(const_generics_defaults)]
+#![allow(incomplete_features)]
 
-fn main() {}
+fn foo<const SIZE: usize = 5usize>() {}
+//~^ ERROR defaults for const parameters are
diff --git a/src/test/ui/const-generics/min_const_generics/default_function_param.stderr b/src/test/ui/const-generics/min_const_generics/default_function_param.stderr
index 31b5ad5123e..243ac0db5f5 100644
--- a/src/test/ui/const-generics/min_const_generics/default_function_param.stderr
+++ b/src/test/ui/const-generics/min_const_generics/default_function_param.stderr
@@ -1,12 +1,8 @@
-error[E0658]: default values for const generic parameters are experimental
-  --> $DIR/default_function_param.rs:1:26
+error: defaults for const parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions
+  --> $DIR/default_function_param.rs:5:14
    |
-LL | fn foo<const SIZE: usize = 5>() {}
-   |                          ^^^
-   |
-   = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
-   = help: add `#![feature(const_generics_defaults)]` to the crate attributes to enable
+LL | fn foo<const SIZE: usize = 5usize>() {}
+   |              ^^^^
 
 error: aborting due to previous error
 
-For more information about this error, try `rustc --explain E0658`.
diff --git a/src/test/ui/const-generics/min_const_generics/type_and_const_defaults.rs b/src/test/ui/const-generics/min_const_generics/type_and_const_defaults.rs
new file mode 100644
index 00000000000..435a63a5283
--- /dev/null
+++ b/src/test/ui/const-generics/min_const_generics/type_and_const_defaults.rs
@@ -0,0 +1,27 @@
+// run-pass
+#![feature(const_generics)]
+#![feature(const_generics_defaults)]
+#![allow(incomplete_features, dead_code)]
+
+struct Both<T=u32, const N: usize=3> {
+  arr: [T; N]
+}
+
+trait BothTrait<T=u32, const N: usize=3> {}
+
+enum BothEnum<T=u32, const N: usize=3> {
+  Dummy([T; N])
+}
+
+struct OppOrder<const N: usize=3, T=u32> {
+  arr: [T; N]
+}
+
+fn main() {
+  let _ = OppOrder::<3, u32> {
+    arr: [0,0,0],
+  };
+  let _ = Both::<u8, 1> {
+    arr: [0],
+  };
+}
diff --git a/src/test/ui/const-generics/params-in-ct-in-ty-param-lazy-norm.full.stderr b/src/test/ui/const-generics/params-in-ct-in-ty-param-lazy-norm.full.stderr
index debb272da36..c2b7b206653 100644
--- a/src/test/ui/const-generics/params-in-ct-in-ty-param-lazy-norm.full.stderr
+++ b/src/test/ui/const-generics/params-in-ct-in-ty-param-lazy-norm.full.stderr
@@ -1,4 +1,4 @@
-error: type parameters with a default must be trailing
+error: generic parameters with a default must be trailing
   --> $DIR/params-in-ct-in-ty-param-lazy-norm.rs:11:12
    |
 LL | struct Bar<T = [u8; N], const N: usize>(T);
diff --git a/src/test/ui/const-generics/params-in-ct-in-ty-param-lazy-norm.min.stderr b/src/test/ui/const-generics/params-in-ct-in-ty-param-lazy-norm.min.stderr
index 171efca1938..4a462c328bf 100644
--- a/src/test/ui/const-generics/params-in-ct-in-ty-param-lazy-norm.min.stderr
+++ b/src/test/ui/const-generics/params-in-ct-in-ty-param-lazy-norm.min.stderr
@@ -1,4 +1,4 @@
-error: type parameters with a default must be trailing
+error: generic parameters with a default must be trailing
   --> $DIR/params-in-ct-in-ty-param-lazy-norm.rs:11:12
    |
 LL | struct Bar<T = [u8; N], const N: usize>(T);
diff --git a/src/test/ui/const-generics/params-in-ct-in-ty-param-lazy-norm.rs b/src/test/ui/const-generics/params-in-ct-in-ty-param-lazy-norm.rs
index a85e2a2f2c4..c7be8bdaf9c 100644
--- a/src/test/ui/const-generics/params-in-ct-in-ty-param-lazy-norm.rs
+++ b/src/test/ui/const-generics/params-in-ct-in-ty-param-lazy-norm.rs
@@ -10,6 +10,6 @@ struct Foo<T, U = [u8; std::mem::size_of::<T>()]>(T, U);
 // FIXME(const_generics_defaults): We still don't know how to deal with type defaults.
 struct Bar<T = [u8; N], const N: usize>(T);
 //~^ ERROR constant values inside of type parameter defaults
-//~| ERROR type parameters with a default
+//~| ERROR generic parameters with a default
 
 fn main() {}
diff --git a/src/test/ui/error-codes/E0128.stderr b/src/test/ui/error-codes/E0128.stderr
index 253aa166bd3..eb66d46936a 100644
--- a/src/test/ui/error-codes/E0128.stderr
+++ b/src/test/ui/error-codes/E0128.stderr
@@ -1,8 +1,8 @@
-error[E0128]: type parameters with a default cannot use forward declared identifiers
+error[E0128]: generic parameters with a default cannot use forward declared identifiers
   --> $DIR/E0128.rs:1:14
    |
 LL | struct Foo<T=U, U=()> {
-   |              ^ defaulted type parameters cannot be forward declared
+   |              ^ defaulted generic parameters cannot be forward declared
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/feature-gates/feature-gate-default_type_parameter_fallback.stderr b/src/test/ui/feature-gates/feature-gate-default_type_parameter_fallback.stderr
index f13803b80f3..5cd38ebab37 100644
--- a/src/test/ui/feature-gates/feature-gate-default_type_parameter_fallback.stderr
+++ b/src/test/ui/feature-gates/feature-gate-default_type_parameter_fallback.stderr
@@ -1,4 +1,4 @@
-error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions.
+error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions
   --> $DIR/feature-gate-default_type_parameter_fallback.rs:3:8
    |
 LL | fn avg<T=i32>(_: T) {}
@@ -8,7 +8,7 @@ LL | fn avg<T=i32>(_: T) {}
    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
    = note: for more information, see issue #36887 <https://github.com/rust-lang/rust/issues/36887>
 
-error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions.
+error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions
   --> $DIR/feature-gate-default_type_parameter_fallback.rs:8:6
    |
 LL | impl<T=i32> S<T> {}
diff --git a/src/test/ui/generics/generic-non-trailing-defaults.rs b/src/test/ui/generics/generic-non-trailing-defaults.rs
index 8d9883dc7a9..cb2bb2832b7 100644
--- a/src/test/ui/generics/generic-non-trailing-defaults.rs
+++ b/src/test/ui/generics/generic-non-trailing-defaults.rs
@@ -1,10 +1,9 @@
 struct Heap;
 
 struct Vec<A = Heap, T>(A, T);
-//~^ ERROR type parameters with a default must be trailing
+//~^ ERROR generic parameters with a default must be trailing
 
 struct Foo<A, B = Vec<C>, C>(A, B, C);
-//~^ ERROR type parameters with a default must be trailing
-//~| ERROR type parameters with a default cannot use forward declared identifiers
+//~^ ERROR generic parameters with a default must be trailing
 
 fn main() {}
diff --git a/src/test/ui/generics/generic-non-trailing-defaults.stderr b/src/test/ui/generics/generic-non-trailing-defaults.stderr
index fb359f673a9..6d768617503 100644
--- a/src/test/ui/generics/generic-non-trailing-defaults.stderr
+++ b/src/test/ui/generics/generic-non-trailing-defaults.stderr
@@ -1,21 +1,14 @@
-error: type parameters with a default must be trailing
+error: generic parameters with a default must be trailing
   --> $DIR/generic-non-trailing-defaults.rs:3:12
    |
 LL | struct Vec<A = Heap, T>(A, T);
    |            ^
 
-error: type parameters with a default must be trailing
+error: generic parameters with a default must be trailing
   --> $DIR/generic-non-trailing-defaults.rs:6:15
    |
 LL | struct Foo<A, B = Vec<C>, C>(A, B, C);
    |               ^
 
-error[E0128]: type parameters with a default cannot use forward declared identifiers
-  --> $DIR/generic-non-trailing-defaults.rs:6:23
-   |
-LL | struct Foo<A, B = Vec<C>, C>(A, B, C);
-   |                       ^ defaulted type parameters cannot be forward declared
-
-error: aborting due to 3 previous errors
+error: aborting due to 2 previous errors
 
-For more information about this error, try `rustc --explain E0128`.
diff --git a/src/test/ui/generics/generic-type-params-forward-mention.rs b/src/test/ui/generics/generic-type-params-forward-mention.rs
index ac0cab20d78..000c47095d2 100644
--- a/src/test/ui/generics/generic-type-params-forward-mention.rs
+++ b/src/test/ui/generics/generic-type-params-forward-mention.rs
@@ -1,6 +1,6 @@
 // Ensure that we get an error and not an ICE for this problematic case.
 struct Foo<T = Option<U>, U = bool>(T, U);
-//~^ ERROR type parameters with a default cannot use forward declared identifiers
+//~^ ERROR generic parameters with a default cannot use forward declared identifiers
 fn main() {
     let x: Foo;
 }
diff --git a/src/test/ui/generics/generic-type-params-forward-mention.stderr b/src/test/ui/generics/generic-type-params-forward-mention.stderr
index 97389c337fc..fa661c274eb 100644
--- a/src/test/ui/generics/generic-type-params-forward-mention.stderr
+++ b/src/test/ui/generics/generic-type-params-forward-mention.stderr
@@ -1,8 +1,8 @@
-error[E0128]: type parameters with a default cannot use forward declared identifiers
+error[E0128]: generic parameters with a default cannot use forward declared identifiers
   --> $DIR/generic-type-params-forward-mention.rs:2:23
    |
 LL | struct Foo<T = Option<U>, U = bool>(T, U);
-   |                       ^ defaulted type parameters cannot be forward declared
+   |                       ^ defaulted generic parameters cannot be forward declared
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/issues/issue-18183.stderr b/src/test/ui/issues/issue-18183.stderr
index c8f8ac9296d..a7dc64708d8 100644
--- a/src/test/ui/issues/issue-18183.stderr
+++ b/src/test/ui/issues/issue-18183.stderr
@@ -1,8 +1,8 @@
-error[E0128]: type parameters with a default cannot use forward declared identifiers
+error[E0128]: generic parameters with a default cannot use forward declared identifiers
   --> $DIR/issue-18183.rs:1:20
    |
 LL | pub struct Foo<Bar=Bar>(Bar);
-   |                    ^^^ defaulted type parameters cannot be forward declared
+   |                    ^^^ defaulted generic parameters cannot be forward declared
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/issues/issue-26812.rs b/src/test/ui/issues/issue-26812.rs
index b2494a91a3f..3391ea4b350 100644
--- a/src/test/ui/issues/issue-26812.rs
+++ b/src/test/ui/issues/issue-26812.rs
@@ -1,6 +1,6 @@
 #![feature(default_type_parameter_fallback)]
 
 fn avg<T=T::Item>(_: T) {}
-//~^ ERROR type parameters with a default cannot use forward declared identifiers
+//~^ ERROR generic parameters with a default cannot use forward declared identifiers
 
 fn main() {}
diff --git a/src/test/ui/issues/issue-26812.stderr b/src/test/ui/issues/issue-26812.stderr
index 8d507a7ea01..fd1bbb9c567 100644
--- a/src/test/ui/issues/issue-26812.stderr
+++ b/src/test/ui/issues/issue-26812.stderr
@@ -1,8 +1,8 @@
-error[E0128]: type parameters with a default cannot use forward declared identifiers
+error[E0128]: generic parameters with a default cannot use forward declared identifiers
   --> $DIR/issue-26812.rs:3:10
    |
 LL | fn avg<T=T::Item>(_: T) {}
-   |          ^^^^^^^ defaulted type parameters cannot be forward declared
+   |          ^^^^^^^ defaulted generic parameters cannot be forward declared
 
 error: aborting due to previous error
 
diff --git a/src/tools/clippy/clippy_utils/src/ast_utils.rs b/src/tools/clippy/clippy_utils/src/ast_utils.rs
index ea9a910d1b9..e202b5061a6 100644
--- a/src/tools/clippy/clippy_utils/src/ast_utils.rs
+++ b/src/tools/clippy/clippy_utils/src/ast_utils.rs
@@ -408,6 +408,10 @@ pub fn eq_use_tree(l: &UseTree, r: &UseTree) -> bool {
     eq_path(&l.prefix, &r.prefix) && eq_use_tree_kind(&l.kind, &r.kind)
 }
 
+pub fn eq_anon_const(l: &AnonConst, r: &AnonConst) -> bool {
+  eq_expr(&l.value, &r.value)
+}
+
 pub fn eq_use_tree_kind(l: &UseTreeKind, r: &UseTreeKind) -> bool {
     use UseTreeKind::*;
     match (l, r) {
@@ -418,10 +422,6 @@ pub fn eq_use_tree_kind(l: &UseTreeKind, r: &UseTreeKind) -> bool {
     }
 }
 
-pub fn eq_anon_const(l: &AnonConst, r: &AnonConst) -> bool {
-    eq_expr(&l.value, &r.value)
-}
-
 pub fn eq_defaultness(l: Defaultness, r: Defaultness) -> bool {
     matches!(
         (l, r),