This commit introduces the following changes:

* Change error message for type param in a const expression when using
min_const_generics
* Change ParamInNonTrivialAnonConst to contain an extra bool used for
distinguishing whether the passed-in symbol is a type or a value.
This commit is contained in:
Hameer Abbasi 2020-09-14 23:39:43 +02:00
parent 356d8ad1a3
commit 7d5db239e7
9 changed files with 82 additions and 14 deletions

View file

@ -466,7 +466,7 @@ impl<'a> Resolver<'a> {
);
err
}
ResolutionError::ParamInNonTrivialAnonConst(name) => {
ResolutionError::ParamInNonTrivialAnonConst { name, is_type } => {
let mut err = self.session.struct_span_err(
span,
"generic parameters must not be used inside of non trivial constant values",
@ -478,9 +478,19 @@ impl<'a> Resolver<'a> {
name
),
);
err.help(
&format!("it is currently only allowed to use either `{0}` or `{{ {0} }}` as generic constants", name)
);
if is_type {
err.note(&format!(
"type parameters are currently not permitted in anonymous constants"
));
} else {
err.help(
&format!("it is currently only allowed to use either `{0}` or `{{ {0} }}` as generic constants",
name
)
);
}
err
}
ResolutionError::SelfInTyParamDefault => {