Rollup merge of #77825 - ethanboxx:min_const_generics_diagnostic, r=lcnr
`min_const_generics` diagnostics improvements As disscussed in [zulip/project-const-generics/non-trivial anonymous constant](https://rust-lang.zulipchat.com/#narrow/stream/260443-project-const-generics/topic/non-trivial.20anonymous.20constants). This is my first PR on the compiler. @lcnr is mentoring me on this PR. Related to #60551.
This commit is contained in:
commit
c44cc7e236
56 changed files with 185 additions and 192 deletions
|
@ -469,24 +469,17 @@ impl<'a> Resolver<'a> {
|
|||
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",
|
||||
);
|
||||
err.span_label(
|
||||
span,
|
||||
&format!(
|
||||
"non-trivial anonymous constants must not depend on the parameter `{}`",
|
||||
name
|
||||
),
|
||||
"generic parameters may not be used in const operations",
|
||||
);
|
||||
err.span_label(span, &format!("cannot perform const operation using `{}`", name));
|
||||
|
||||
if is_type {
|
||||
err.note("type parameters are currently not permitted in anonymous constants");
|
||||
err.note("type parameters may not be used in const expressions");
|
||||
} else {
|
||||
err.help(
|
||||
&format!("it is currently only allowed to use either `{0}` or `{{ {0} }}` as generic constants",
|
||||
name
|
||||
)
|
||||
);
|
||||
err.help(&format!(
|
||||
"const parameters may only be used as standalone arguments, i.e. `{}`",
|
||||
name
|
||||
));
|
||||
}
|
||||
|
||||
err
|
||||
|
|
|
@ -218,7 +218,7 @@ enum ResolutionError<'a> {
|
|||
ParamInTyOfConstParam(Symbol),
|
||||
/// constant values inside of type parameter defaults must not depend on generic parameters.
|
||||
ParamInAnonConstInTyDefault(Symbol),
|
||||
/// generic parameters must not be used inside of non-trivial constant values.
|
||||
/// generic parameters must not be used inside const evaluations.
|
||||
///
|
||||
/// This error is only emitted when using `min_const_generics`.
|
||||
ParamInNonTrivialAnonConst { name: Symbol, is_type: bool },
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue