about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/librustc_resolve/diagnostics.rs7
-rw-r--r--src/librustc_resolve/lib.rs14
-rw-r--r--src/test/ui/const-generics/const-param-type-depends-on-const-param.stderr4
-rw-r--r--src/test/ui/const-generics/const-param-type-depends-on-type-param-ungated.stderr2
-rw-r--r--src/test/ui/const-generics/const-param-type-depends-on-type-param.stderr2
-rw-r--r--src/test/ui/const-generics/issues/issue-71381.stderr4
-rw-r--r--src/test/ui/const-generics/issues/issue-71611.stderr2
7 files changed, 22 insertions, 13 deletions
diff --git a/src/librustc_resolve/diagnostics.rs b/src/librustc_resolve/diagnostics.rs
index c5ac7f7413a..575049c6bac 100644
--- a/src/librustc_resolve/diagnostics.rs
+++ b/src/librustc_resolve/diagnostics.rs
@@ -442,14 +442,17 @@ impl<'a> Resolver<'a> {
                 );
                 err
             }
-            ResolutionError::ParamInTyOfConstArg => {
+            ResolutionError::ParamInTyOfConstArg(name) => {
                 let mut err = struct_span_err!(
                     self.session,
                     span,
                     E0770,
                     "the type of const parameters must not depend on other generic parameters"
                 );
-                err.span_label(span, "const parameters must have a concrete type");
+                err.span_label(
+                    span,
+                    format!("the type must not depend on the parameter `{}`", name),
+                );
                 err
             }
             ResolutionError::SelfInTyParamDefault => {
diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs
index ba365e8f841..c3686ca4899 100644
--- a/src/librustc_resolve/lib.rs
+++ b/src/librustc_resolve/lib.rs
@@ -215,7 +215,7 @@ enum ResolutionError<'a> {
     /// Error E0128: type parameters with a default cannot use forward-declared identifiers.
     ForwardDeclaredTyParam, // FIXME(const_generics:defaults)
     /// ERROR E0770: the type of const parameters must not depend on other generic parameters.
-    ParamInTyOfConstArg,
+    ParamInTyOfConstArg(Symbol),
     /// Error E0735: type parameters with a default cannot use `Self`
     SelfInTyParamDefault,
     /// Error E0767: use of unreachable label
@@ -2484,7 +2484,7 @@ impl<'a> Resolver<'a> {
                         }
                         ConstParamTyRibKind => {
                             if record_used {
-                                self.report_error(span, ParamInTyOfConstArg);
+                                self.report_error(span, ParamInTyOfConstArg(rib_ident.name));
                             }
                             return Res::Err;
                         }
@@ -2513,7 +2513,10 @@ impl<'a> Resolver<'a> {
                         FnItemRibKind => HasGenericParams::Yes,
                         ConstParamTyRibKind => {
                             if record_used {
-                                self.report_error(span, ResolutionError::ParamInTyOfConstArg);
+                                self.report_error(
+                                    span,
+                                    ResolutionError::ParamInTyOfConstArg(rib_ident.name),
+                                );
                             }
                             return Res::Err;
                         }
@@ -2552,7 +2555,10 @@ impl<'a> Resolver<'a> {
                         FnItemRibKind => HasGenericParams::Yes,
                         ConstParamTyRibKind => {
                             if record_used {
-                                self.report_error(span, ResolutionError::ParamInTyOfConstArg);
+                                self.report_error(
+                                    span,
+                                    ResolutionError::ParamInTyOfConstArg(rib_ident.name),
+                                );
                             }
                             return Res::Err;
                         }
diff --git a/src/test/ui/const-generics/const-param-type-depends-on-const-param.stderr b/src/test/ui/const-generics/const-param-type-depends-on-const-param.stderr
index a06bdea1b3c..ece31b5fab2 100644
--- a/src/test/ui/const-generics/const-param-type-depends-on-const-param.stderr
+++ b/src/test/ui/const-generics/const-param-type-depends-on-const-param.stderr
@@ -2,13 +2,13 @@ error[E0770]: the type of const parameters must not depend on other generic para
   --> $DIR/const-param-type-depends-on-const-param.rs:9:52
    |
 LL | pub struct Dependent<const N: usize, const X: [u8; N]>([(); N]);
-   |                                                    ^ const parameters must have a concrete type
+   |                                                    ^ the type must not depend on the parameter `N`
 
 error[E0770]: the type of const parameters must not depend on other generic parameters
   --> $DIR/const-param-type-depends-on-const-param.rs:12:40
    |
 LL | pub struct SelfDependent<const N: [u8; N]>;
-   |                                        ^ const parameters must have a concrete type
+   |                                        ^ the type must not depend on the parameter `N`
 
 warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
   --> $DIR/const-param-type-depends-on-const-param.rs:1:12
diff --git a/src/test/ui/const-generics/const-param-type-depends-on-type-param-ungated.stderr b/src/test/ui/const-generics/const-param-type-depends-on-type-param-ungated.stderr
index a2182d9edaf..7a2ee689c33 100644
--- a/src/test/ui/const-generics/const-param-type-depends-on-type-param-ungated.stderr
+++ b/src/test/ui/const-generics/const-param-type-depends-on-type-param-ungated.stderr
@@ -2,7 +2,7 @@ error[E0770]: the type of const parameters must not depend on other generic para
   --> $DIR/const-param-type-depends-on-type-param-ungated.rs:3:22
    |
 LL | struct B<T, const N: T>(PhantomData<[T; N]>);
-   |                      ^ const parameters must have a concrete type
+   |                      ^ the type must not depend on the parameter `T`
 
 error[E0658]: const generics are unstable
   --> $DIR/const-param-type-depends-on-type-param-ungated.rs:3:19
diff --git a/src/test/ui/const-generics/const-param-type-depends-on-type-param.stderr b/src/test/ui/const-generics/const-param-type-depends-on-type-param.stderr
index 606bb4f4fe7..fa566b5536f 100644
--- a/src/test/ui/const-generics/const-param-type-depends-on-type-param.stderr
+++ b/src/test/ui/const-generics/const-param-type-depends-on-type-param.stderr
@@ -2,7 +2,7 @@ error[E0770]: the type of const parameters must not depend on other generic para
   --> $DIR/const-param-type-depends-on-type-param.rs:9:34
    |
 LL | pub struct Dependent<T, const X: T>([(); X]);
-   |                                  ^ const parameters must have a concrete type
+   |                                  ^ the type must not depend on the parameter `T`
 
 warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
   --> $DIR/const-param-type-depends-on-type-param.rs:1:12
diff --git a/src/test/ui/const-generics/issues/issue-71381.stderr b/src/test/ui/const-generics/issues/issue-71381.stderr
index 177a2cdf14c..fe6d5125223 100644
--- a/src/test/ui/const-generics/issues/issue-71381.stderr
+++ b/src/test/ui/const-generics/issues/issue-71381.stderr
@@ -2,13 +2,13 @@ error[E0770]: the type of const parameters must not depend on other generic para
   --> $DIR/issue-71381.rs:13:82
    |
 LL |     pub fn call_me<Args: Sized, const IDX: usize, const FN: unsafe extern "C" fn(Args)>(&self) {
-   |                                                                                  ^^^^ const parameters must have a concrete type
+   |                                                                                  ^^^^ the type must not depend on the parameter `Args`
 
 error[E0770]: the type of const parameters must not depend on other generic parameters
   --> $DIR/issue-71381.rs:22:40
    |
 LL |         const FN: unsafe extern "C" fn(Args),
-   |                                        ^^^^ const parameters must have a concrete type
+   |                                        ^^^^ the type must not depend on the parameter `Args`
 
 error: using function pointers as const generic parameters is forbidden
   --> $DIR/issue-71381.rs:13:61
diff --git a/src/test/ui/const-generics/issues/issue-71611.stderr b/src/test/ui/const-generics/issues/issue-71611.stderr
index fe8978b4298..a8363cdff78 100644
--- a/src/test/ui/const-generics/issues/issue-71611.stderr
+++ b/src/test/ui/const-generics/issues/issue-71611.stderr
@@ -2,7 +2,7 @@ error[E0770]: the type of const parameters must not depend on other generic para
   --> $DIR/issue-71611.rs:4:31
    |
 LL | fn func<A, const F: fn(inner: A)>(outer: A) {
-   |                               ^ const parameters must have a concrete type
+   |                               ^ the type must not depend on the parameter `A`
 
 error: using function pointers as const generic parameters is forbidden
   --> $DIR/issue-71611.rs:4:21