Skip to content

Commit

Permalink
update help message
Browse files Browse the repository at this point in the history
  • Loading branch information
lcnr committed Jul 16, 2020
1 parent 6f5d8bf commit 0c511ab
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 13 deletions.
7 changes: 5 additions & 2 deletions src/librustc_resolve/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down
14 changes: 10 additions & 4 deletions src/librustc_resolve/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/const-generics/issues/issue-71381.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/const-generics/issues/issue-71611.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0c511ab

Please sign in to comment.