1
Fork 0

update help message

This commit is contained in:
Bastian Kauschke 2020-07-16 11:10:22 +02:00
parent 6f5d8bf5c8
commit 0c511ab5c7
7 changed files with 22 additions and 13 deletions

View file

@ -442,14 +442,17 @@ impl<'a> Resolver<'a> {
); );
err err
} }
ResolutionError::ParamInTyOfConstArg => { ResolutionError::ParamInTyOfConstArg(name) => {
let mut err = struct_span_err!( let mut err = struct_span_err!(
self.session, self.session,
span, span,
E0770, E0770,
"the type of const parameters must not depend on other generic parameters" "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 err
} }
ResolutionError::SelfInTyParamDefault => { ResolutionError::SelfInTyParamDefault => {

View file

@ -215,7 +215,7 @@ enum ResolutionError<'a> {
/// Error E0128: type parameters with a default cannot use forward-declared identifiers. /// Error E0128: type parameters with a default cannot use forward-declared identifiers.
ForwardDeclaredTyParam, // FIXME(const_generics:defaults) ForwardDeclaredTyParam, // FIXME(const_generics:defaults)
/// ERROR E0770: the type of const parameters must not depend on other generic parameters. /// 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` /// Error E0735: type parameters with a default cannot use `Self`
SelfInTyParamDefault, SelfInTyParamDefault,
/// Error E0767: use of unreachable label /// Error E0767: use of unreachable label
@ -2484,7 +2484,7 @@ impl<'a> Resolver<'a> {
} }
ConstParamTyRibKind => { ConstParamTyRibKind => {
if record_used { if record_used {
self.report_error(span, ParamInTyOfConstArg); self.report_error(span, ParamInTyOfConstArg(rib_ident.name));
} }
return Res::Err; return Res::Err;
} }
@ -2513,7 +2513,10 @@ impl<'a> Resolver<'a> {
FnItemRibKind => HasGenericParams::Yes, FnItemRibKind => HasGenericParams::Yes,
ConstParamTyRibKind => { ConstParamTyRibKind => {
if record_used { if record_used {
self.report_error(span, ResolutionError::ParamInTyOfConstArg); self.report_error(
span,
ResolutionError::ParamInTyOfConstArg(rib_ident.name),
);
} }
return Res::Err; return Res::Err;
} }
@ -2552,7 +2555,10 @@ impl<'a> Resolver<'a> {
FnItemRibKind => HasGenericParams::Yes, FnItemRibKind => HasGenericParams::Yes,
ConstParamTyRibKind => { ConstParamTyRibKind => {
if record_used { if record_used {
self.report_error(span, ResolutionError::ParamInTyOfConstArg); self.report_error(
span,
ResolutionError::ParamInTyOfConstArg(rib_ident.name),
);
} }
return Res::Err; return Res::Err;
} }

View file

@ -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 --> $DIR/const-param-type-depends-on-const-param.rs:9:52
| |
LL | pub struct Dependent<const N: usize, const X: [u8; N]>([(); N]); 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 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 --> $DIR/const-param-type-depends-on-const-param.rs:12:40
| |
LL | pub struct SelfDependent<const N: [u8; N]>; 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 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 --> $DIR/const-param-type-depends-on-const-param.rs:1:12

View file

@ -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 --> $DIR/const-param-type-depends-on-type-param-ungated.rs:3:22
| |
LL | struct B<T, const N: T>(PhantomData<[T; N]>); 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 error[E0658]: const generics are unstable
--> $DIR/const-param-type-depends-on-type-param-ungated.rs:3:19 --> $DIR/const-param-type-depends-on-type-param-ungated.rs:3:19

View file

@ -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 --> $DIR/const-param-type-depends-on-type-param.rs:9:34
| |
LL | pub struct Dependent<T, const X: T>([(); X]); 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 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 --> $DIR/const-param-type-depends-on-type-param.rs:1:12

View file

@ -2,13 +2,13 @@ error[E0770]: the type of const parameters must not depend on other generic para
--> $DIR/issue-71381.rs:13:82 --> $DIR/issue-71381.rs:13:82
| |
LL | pub fn call_me<Args: Sized, const IDX: usize, const FN: unsafe extern "C" fn(Args)>(&self) { 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 error[E0770]: the type of const parameters must not depend on other generic parameters
--> $DIR/issue-71381.rs:22:40 --> $DIR/issue-71381.rs:22:40
| |
LL | const FN: unsafe extern "C" fn(Args), 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 error: using function pointers as const generic parameters is forbidden
--> $DIR/issue-71381.rs:13:61 --> $DIR/issue-71381.rs:13:61

View file

@ -2,7 +2,7 @@ error[E0770]: the type of const parameters must not depend on other generic para
--> $DIR/issue-71611.rs:4:31 --> $DIR/issue-71611.rs:4:31
| |
LL | fn func<A, const F: fn(inner: A)>(outer: A) { 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 error: using function pointers as const generic parameters is forbidden
--> $DIR/issue-71611.rs:4:21 --> $DIR/issue-71611.rs:4:21