diff options
| author | Hameer Abbasi <einstein.edison@gmail.com> | 2020-09-14 23:39:43 +0200 |
|---|---|---|
| committer | Hameer Abbasi <einstein.edison@gmail.com> | 2020-09-15 10:27:19 +0200 |
| commit | 7d5db239e73067de3d35394d4c194dd4396c90f1 (patch) | |
| tree | b16c3d1806123a5f6c9b03c49ce90cc6d444742e /compiler/rustc_resolve/src/diagnostics.rs | |
| parent | 356d8ad1a310a2265e05d5c193d41704030d70d3 (diff) | |
| download | rust-7d5db239e73067de3d35394d4c194dd4396c90f1.tar.gz rust-7d5db239e73067de3d35394d4c194dd4396c90f1.zip | |
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.
Diffstat (limited to 'compiler/rustc_resolve/src/diagnostics.rs')
| -rw-r--r-- | compiler/rustc_resolve/src/diagnostics.rs | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/compiler/rustc_resolve/src/diagnostics.rs b/compiler/rustc_resolve/src/diagnostics.rs index b80da641491..5d66d90e2c0 100644 --- a/compiler/rustc_resolve/src/diagnostics.rs +++ b/compiler/rustc_resolve/src/diagnostics.rs @@ -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 => { |
